feat(Hooking): Added hooks for report_cash_spawn & report_cheating

This commit is contained in:
Yimura 2021-07-24 14:49:31 +02:00
parent bce48acb36
commit 055dc25fc3
7 changed files with 72 additions and 36 deletions

View File

@ -35,4 +35,8 @@ namespace big::functions
// Received Event Signatures END
using spectate_player = bool(bool toggle, Ped player);
// Net Event Handlers
using report_cash_spawn = bool(__int64 creport_cash_spawn_event, CNetGamePlayer* source_player);
using report_cheating = void(__int64 a1, unsigned int a2, unsigned int a3, unsigned int a4);
}

View File

@ -54,7 +54,12 @@ namespace big
m_error_screen_hook("ES", g_pointers->m_error_screen, &hooks::disable_error_screen),
// Received Event
m_received_event_hook("RE", g_pointers->m_received_event, &hooks::received_event)
m_received_event_hook("RE", g_pointers->m_received_event, &hooks::received_event),
// Report Cash Spawn Event
m_report_cash_spawn_event_hook("RCSE", g_pointers->m_report_cash_spawn, &hooks::report_cash_spawn_handler),
// Report Cheating Hook
m_report_cheating_hook("RC", g_pointers->m_report_cheating, &hooks::report_cheating_handler)
{
m_swapchain_hook.hook(hooks::swapchain_present_index, &hooks::swapchain_present);
m_swapchain_hook.hook(hooks::swapchain_resizebuffers_index, &hooks::swapchain_resizebuffers);
@ -88,6 +93,9 @@ namespace big
m_received_event_hook.enable();
m_report_cash_spawn_event_hook.enable();
m_report_cheating_hook.enable();
m_enabled = true;
}
@ -95,6 +103,9 @@ namespace big
{
m_enabled = false;
m_report_cheating_hook.disable();
m_report_cash_spawn_event_hook.disable();
m_received_event_hook.disable();
m_error_screen_hook.disable();

View File

@ -40,6 +40,9 @@ namespace big
int64_t bit_buffer_size,
int64_t bit_buffer
);
static bool report_cash_spawn_handler(__int64 creport_cash_spawn_event, CNetGamePlayer* source_player);
static void report_cheating_handler(__int64 a1, unsigned int a2, unsigned int a3, unsigned int a4);
};
struct minhook_keepalive
@ -77,6 +80,9 @@ namespace big
detour_hook m_increment_stat_hook;
detour_hook m_received_event_hook;
detour_hook m_report_cash_spawn_event_hook;
detour_hook m_report_cheating_hook;
};
inline hooking *g_hooking{};

View File

@ -0,0 +1,19 @@
#include "hooking.hpp"
#include "natives.hpp"
namespace big
{
bool hooks::report_cash_spawn_handler(__int64 creport_cash_spawn_event, CNetGamePlayer* source_player)
{
if (source_player->player_id == PLAYER::PLAYER_ID())
{
LOG(INFO) << "Blocked self report for spawning modded cash";
return false;
}
LOG(INFO) << "Reported " << source_player->get_name() << " for spawning modded cash.";
return g_hooking->m_report_cash_spawn_event_hook.get_original<decltype(&hooks::report_cash_spawn_handler)>()(creport_cash_spawn_event, source_player);
}
}

View File

@ -0,0 +1,15 @@
#include "hooking.hpp"
#include "util/notify.hpp"
namespace big
{
void hooks::report_cheating_handler(__int64 a1, unsigned int a2, unsigned int a3, unsigned int a4)
{
LOG(INFO) << "Caught game trying to report self.";
notify::above_map("Game tried to snitch.");
return;
//return g_hooking->m_report_cheating_hook.get_original<decltype(&hooks::report_cheating_handler)>()(a1, a2, a3, a4);
}
}

View File

@ -90,36 +90,6 @@ namespace big
m_native_return = ptr.add(0).as<PVOID>();
});
// Event Registry
main_batch.add("ER", "48 83 EC 28 E8 ? ? ? ? 48 8B 0D ? ? ? ? 4C 8D 0D ? ? ? ? 4C 8D 05 ? ? ? ? BA 03", [this](memory::handle ptr)
{
m_event_register = ptr.as<char*>();
if (m_event_register)
{
const char* pattern = "\x4C\x8D\x05";
for (int i = 0, x = 0, found = 0, matches = 0; found < event_count; i++)
{
if (m_event_register[i] == pattern[x])
{
if (++matches == 3)
{
m_event_ptr.push_back((void*)(reinterpret_cast<uint64_t>(m_event_register + i - x) + *reinterpret_cast<int*>(m_event_register + i + 1) + 7));
found++;
x = matches = 0;
}
x++;
continue;
}
x = matches = 0;
}
}
});
// Incompatible Version Fix
main_batch.add("IVF", "48 89 5C 24 ? 55 56 57 41 54 41 55 41 56 41 57 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 33 FF 48 8B DA", [this](memory::handle ptr)
{
@ -197,6 +167,18 @@ namespace big
{
m_spectate_player = ptr.as<decltype(m_spectate_player)>();
});
// Report Cash Spawn Handler
main_batch.add("RCSH", "40 53 48 83 EC 20 48 8B D9 48 85 D2 74 29", [this](memory::handle ptr)
{
m_report_cash_spawn = ptr.as<decltype(m_report_cash_spawn)>();
});
// Report Myself Handler
main_batch.add("RMH", "E8 ? ? ? ? 41 8B 47 0C 39 43 20", [this](memory::handle ptr)
{
m_report_cheating = ptr.as<decltype(m_report_cheating)>();
});
main_batch.run(memory::module(nullptr));

View File

@ -36,11 +36,6 @@ namespace big
PVOID m_model_spawn_bypass;
PVOID m_native_return;
static const int event_count = 87;
std::vector<PVOID> m_event_ptr;
unsigned char m_event_restore[event_count];
char* m_event_register;
functions::error_screen* m_error_screen{};
functions::gta_thread_tick* m_gta_thread_tick{};
@ -58,6 +53,10 @@ namespace big
// Received Event Signatures END
functions::spectate_player* m_spectate_player{};
// Net Event Handlers
functions::report_cash_spawn* m_report_cash_spawn{};
functions::report_cheating* m_report_cheating{};
};
inline pointers *g_pointers{};