feat(Hooking/Pointers): Added script event handler hook

This commit is contained in:
Yimura 2020-12-27 19:10:01 +01:00
parent 52ac638a90
commit 3d527ba68c
6 changed files with 24 additions and 3 deletions

View File

@ -12,5 +12,6 @@ namespace big::functions
using error_screen = void(char* entryHeader, char* entryLine1, int instructionalKey, char* entryLine2, BOOL p4, Any p5, Any* p6, Any* p7, BOOL background);
using increment_stat_event = bool(uint64_t net_event_struct, int64_t sender, int64_t a3);
using get_player_name = char*(Player player);
using sync_local_time_t = void(int h, int m);
using script_event_handler = bool(void* events, CNetGamePlayer* sourcePlayer, CNetGamePlayer* targetPlayer);
using sync_local_time = void(int h, int m);
}

View File

@ -40,7 +40,8 @@ namespace big
m_convert_thread_to_fiber_hook("ConvertThreadToFiber", memory::module("kernel32.dll").get_export("ConvertThreadToFiber").as<void*>(), &hooks::convert_thread_to_fiber),
m_error_screen_hook("Disable Warning/Error Screen", g_pointers->m_error_screen, &hooks::error_screen),
m_increment_stat_hook("Increment Stat Event", g_pointers->m_increment_stat_event, &hooks::increment_stat_event)
m_increment_stat_hook("Increment Stat Event", g_pointers->m_increment_stat_event, &hooks::increment_stat_event),
m_script_event_hook("Script Event Handler hook", g_pointers->m_script_event_handler, &hooks::script_event_handler)
{
m_swapchain_hook.hook(hooks::swapchain_present_index, &hooks::swapchain_present);
m_swapchain_hook.hook(hooks::swapchain_resizebuffers_index, &hooks::swapchain_resizebuffers);
@ -68,6 +69,7 @@ namespace big
// New hooks enable
m_error_screen_hook.enable();
m_increment_stat_hook.enable();
m_script_event_hook.enable();
m_enabled = true;
}
@ -86,6 +88,7 @@ namespace big
// New hooks disable
m_error_screen_hook.disable();
m_increment_stat_hook.disable();
m_script_event_hook.disable();
}
minhook_keepalive::minhook_keepalive()

View File

@ -24,6 +24,7 @@ namespace big
// New Hook Definitions
static void error_screen(char* entryHeader, char* entryLine1, int instructionalKey, char* entryLine2, BOOL p4, Any p5, Any* p6, Any* p7, BOOL background);
static bool increment_stat_event(uint64_t net_event_struct, int64_t sender, int64_t a3);
static bool script_event_handler(std::int64_t NetEventStruct, std::int64_t CNetGamePlayer);
};
struct minhook_keepalive
@ -56,6 +57,7 @@ namespace big
// New Detour Hook Definitions
detour_hook m_error_screen_hook;
detour_hook m_increment_stat_hook;
detour_hook m_script_event_hook;
};
inline hooking *g_hooking{};

View File

@ -0,0 +1,9 @@
#include "hooking.hpp"
namespace big
{
bool hooks::script_event_handler(std::int64_t NetEventStruct, std::int64_t CNetGamePlayer)
{
return g_hooking->m_script_event_hook.get_original<decltype(&script_event_handler)>()(NetEventStruct, CNetGamePlayer);
}
}

View File

@ -92,6 +92,11 @@ namespace big
{
m_increment_stat_event = ptr.as<decltype(m_increment_stat_event)>();
});
main_batch.add("Script Event Handler", "40 53 48 81 EC ? ? ? ? 44 8B 81 ? ? ? ? 4C 8B CA 41 8D 40 FF 3D ? ? ? ? 77 42", [this](memory::handle ptr)
{
m_script_event_handler = ptr.as<decltype(m_script_event_handler)>();
});
main_batch.run(memory::module(nullptr));

View File

@ -38,7 +38,8 @@ namespace big
functions::error_screen* m_error_screen{};
functions::get_player_name* m_get_player_name{};
functions::increment_stat_event* m_increment_stat_event{};
functions::sync_local_time_t* m_sync_local_time{};
functions::script_event_handler* m_script_event_handler{};
functions::sync_local_time* m_sync_local_time{};
};
inline pointers *g_pointers{};