feat(Metric): Reimplementing metrics (#778)

This commit is contained in:
Bugisoft 2022-12-30 11:49:39 +01:00 committed by GitHub
parent 5909af7fd2
commit d6e64f6838
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 57 additions and 1 deletions

View File

@ -3,7 +3,7 @@ include(FetchContent)
FetchContent_Declare(
gtav_classes
GIT_REPOSITORY https://github.com/Yimura/GTAV-Classes.git
GIT_TAG 5ab30af647d7e64404d76ea6168e7f78f5e365af
GIT_TAG 985d0dcc4042ffb24dcb18c34ad5f42b10232510
GIT_PROGRESS TRUE
CONFIGURE_COMMAND ""
BUILD_COMMAND ""

View File

@ -99,6 +99,7 @@ namespace big
detour_hook_helper::add<hooks::read_bitbuffer_gamer_handle>("RBGH", g_pointers->m_read_bitbuffer_gamer_handle);
detour_hook_helper::add<hooks::queue_dependency>("QD", g_pointers->m_queue_dependency);
detour_hook_helper::add<hooks::prepare_metric_for_sending>("PMFS", g_pointers->m_prepare_metric_for_sending);
g_hooking = this;
}

View File

@ -33,6 +33,7 @@ namespace rage
class rlGamerHandle;
class netConnectionManager;
class datBitBuffer;
class rlMetric;
namespace netConnection
{
@ -136,6 +137,7 @@ 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 void queue_dependency(void* dependency);
static void prepare_metric_for_sending(rage::datBitBuffer* bit_buffer, int unk, int time, rage::rlMetric* metric);
};
class minhook_keepalive

View File

@ -0,0 +1,46 @@
#include "hooking.hpp"
#include "rage/rlMetric.hpp"
namespace big
{
#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)
void hooks::prepare_metric_for_sending(rage::datBitBuffer* bit_buffer, int unk, int time, rage::rlMetric* metric)
{
char buffer[256]{};
json_serializer serializer(buffer, sizeof(buffer));
metric->serialize(&serializer);
LOG(INFO) << "METRIC: " << metric->get_name() << "; DATA: " << serializer.get_string();
}
}

View File

@ -774,6 +774,12 @@ namespace big
memory::byte_patch::make(ptr.add(13).as<void*>(), bytes)->apply();
});
// Metric
main_batch.add("PMFS", "48 8B C4 48 89 58 08 48 89 68 10 48 89 70 18 48 89 78 20 41 56 48 83 EC 30 49 8B E8 4C 8D 40 EC 49 8B F1 48 8B D9 40 32 FF E8", [this](memory::handle ptr)
{
m_prepare_metric_for_sending = ptr.as<PVOID>();
});
auto mem_region = memory::module("GTA5.exe");
main_batch.run(mem_region);

View File

@ -201,6 +201,7 @@ namespace big
memory::byte_patch* m_broadcast_patch;
rage::atSingleton<rage::RageSecurity>* m_security;
PVOID m_prepare_metric_for_sending;
PVOID m_queue_dependency;
PVOID m_interval_check_func;