refactor(Metrics): filter out "bad" metrics and allow normal ones to be sent (#2453)
This commit is contained in:
parent
b365d7d16e
commit
c01043cfb1
36
src/gta/json_serializer.hpp
Normal file
36
src/gta/json_serializer.hpp
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace rage
|
||||||
|
{
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
class json_serializer
|
||||||
|
{
|
||||||
|
uint32_t unk0; // 0x00
|
||||||
|
uint32_t unk1; // 0x00
|
||||||
|
char* buffer; // 0x08
|
||||||
|
uint32_t curlen; // 0x10
|
||||||
|
uint32_t maxlen; // 0x14
|
||||||
|
uint32_t unk4; // 0x18
|
||||||
|
uint8_t flags; // 0x1C
|
||||||
|
|
||||||
|
public:
|
||||||
|
json_serializer(char* _buffer, uint32_t _length) :
|
||||||
|
buffer(_buffer),
|
||||||
|
maxlen(_length)
|
||||||
|
{
|
||||||
|
unk0
|
||||||
|
= 0;
|
||||||
|
unk1 = 0;
|
||||||
|
curlen = 0;
|
||||||
|
unk4 = 1;
|
||||||
|
flags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline char* get_string() const
|
||||||
|
{
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
static_assert(sizeof(json_serializer) == 0x1D); // size is actually 0x20
|
||||||
|
#pragma pack(pop)
|
||||||
|
}
|
@ -5,6 +5,7 @@
|
|||||||
#include "gta/enums.hpp"
|
#include "gta/enums.hpp"
|
||||||
#include "gta/fwddec.hpp"
|
#include "gta/fwddec.hpp"
|
||||||
#include "gta/script_thread.hpp"
|
#include "gta/script_thread.hpp"
|
||||||
|
#include "gta/json_serializer.hpp"
|
||||||
#include "vmt_hook.hpp"
|
#include "vmt_hook.hpp"
|
||||||
#include "vtable_hook.hpp"
|
#include "vtable_hook.hpp"
|
||||||
#include "call_hook.hpp"
|
#include "call_hook.hpp"
|
||||||
@ -128,7 +129,8 @@ namespace big
|
|||||||
|
|
||||||
static int nt_query_virtual_memory(void* _this, HANDLE handle, PVOID base_addr, int info_class, MEMORY_BASIC_INFORMATION* info, int size, size_t* return_len);
|
static int nt_query_virtual_memory(void* _this, HANDLE handle, PVOID base_addr, int info_class, MEMORY_BASIC_INFORMATION* info, int size, size_t* return_len);
|
||||||
static int queue_dependency(void* a1, int a2, void* dependency);
|
static int queue_dependency(void* a1, int a2, void* dependency);
|
||||||
static bool prepare_metric_for_sending(rage::datBitBuffer* bit_buffer, int unk, int time, rage::rlMetric* metric);
|
|
||||||
|
static bool prepare_metric_for_sending(rage::json_serializer* bit_buffer, int unk, int time, rage::rlMetric* metric);
|
||||||
static bool http_start_request(void* request, const char* uri);
|
static bool http_start_request(void* request, const char* uri);
|
||||||
|
|
||||||
static bool received_array_update(rage::netArrayHandlerBase* array, CNetGamePlayer* sender, rage::datBitBuffer* buffer, int size, int16_t cycle);
|
static bool received_array_update(rage::netArrayHandlerBase* array, CNetGamePlayer* sender, rage::datBitBuffer* buffer, int size, int16_t cycle);
|
||||||
|
@ -3,50 +3,64 @@
|
|||||||
|
|
||||||
namespace big
|
namespace big
|
||||||
{
|
{
|
||||||
#pragma pack(push, 1)
|
const auto bad_metrics = std::unordered_set<std::string>({
|
||||||
class json_serializer
|
"REPORTER",
|
||||||
{
|
"REPORT_INVALIDMODEL",
|
||||||
uint32_t unk0; // 0x00
|
"MEM_NEW",
|
||||||
uint32_t unk1; // 0x00
|
"DEBUGGER_ATTACH",
|
||||||
char* buffer; // 0x08
|
"DIG",
|
||||||
uint32_t curlen;// 0x10
|
"XP_LOSS",
|
||||||
uint32_t maxlen;// 0x14
|
"AWARD_XP",
|
||||||
uint32_t unk4; // 0x18
|
"CF",
|
||||||
uint8_t flags; // 0x1C
|
"CC",
|
||||||
|
"CNR",
|
||||||
|
"SCRIPT",
|
||||||
|
"CHEAT",
|
||||||
|
"AUX_DEUX",
|
||||||
|
"WEATHER",
|
||||||
|
"HARDWARE_OS",
|
||||||
|
"HARDWARE_GPU",
|
||||||
|
"HARDWARE_MOBO",
|
||||||
|
"HARDWARE_MEM",
|
||||||
|
"HARDWARE_CPU",
|
||||||
|
"PCSETTINGS",
|
||||||
|
"CASH_CREATED",
|
||||||
|
"DR_PS",
|
||||||
|
"UVC",
|
||||||
|
"W_L",
|
||||||
|
"ESVCS",
|
||||||
|
"IDLEKICK",
|
||||||
|
"GSCB",
|
||||||
|
"GSINV",
|
||||||
|
"GSCW",
|
||||||
|
"GSINT",
|
||||||
|
"EARN",
|
||||||
|
"GARAGE_TAMPER",
|
||||||
|
"LAST_VEH",
|
||||||
|
"FAIL_SERV",
|
||||||
|
"CCF_UPDATE",
|
||||||
|
"CODE_CRC",
|
||||||
|
"COLLECTIBLE",
|
||||||
|
"FIRST_VEH",
|
||||||
|
});
|
||||||
|
|
||||||
public:
|
bool hooks::prepare_metric_for_sending(rage::json_serializer* serializer, int unk, int time, rage::rlMetric* metric)
|
||||||
json_serializer(char* _buffer, uint32_t _length) :
|
|
||||||
buffer(_buffer),
|
|
||||||
maxlen(_length)
|
|
||||||
{
|
{
|
||||||
unk0
|
const auto ret = g_hooking->get_original<prepare_metric_for_sending>()(serializer, unk, time, metric);
|
||||||
= 0;
|
|
||||||
unk1 = 0;
|
|
||||||
curlen = 0;
|
|
||||||
unk4 = 1;
|
|
||||||
flags = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline char* get_string() const
|
const auto is_bad_metric = bad_metrics.contains(metric->get_name());
|
||||||
|
if (is_bad_metric)
|
||||||
{
|
{
|
||||||
return buffer;
|
LOG(WARNING) << "BAD METRIC: " << metric->get_name() << "; DATA: " << serializer->get_string();
|
||||||
}
|
|
||||||
};
|
|
||||||
static_assert(sizeof(json_serializer) == 0x1D);// size is actually 0x20
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
bool hooks::prepare_metric_for_sending(rage::datBitBuffer* bit_buffer, int unk, int time, rage::rlMetric* metric)
|
|
||||||
{
|
|
||||||
if (g.debug.logs.metric_logs)
|
|
||||||
{
|
|
||||||
char buffer[256]{};
|
|
||||||
json_serializer serializer(buffer, sizeof(buffer));
|
|
||||||
|
|
||||||
metric->serialize(&serializer);
|
|
||||||
|
|
||||||
LOG(INFO) << "METRIC: " << metric->get_name() << "; DATA: " << serializer.get_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_bad_metric && g.debug.logs.metric_logs)
|
||||||
|
{
|
||||||
|
LOG(INFO) << "METRIC: " << metric->get_name() << "; DATA: " << serializer->get_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user