From eba692ff37148614369e848448fd650624e205a8 Mon Sep 17 00:00:00 2001 From: Yimura Date: Fri, 21 Jan 2022 23:11:37 +0100 Subject: [PATCH] feat(Hooking): Added GTA Thread start hook --- BigBaseV2/src/hooking.cpp | 7 +++++-- BigBaseV2/src/hooking.hpp | 6 +++--- BigBaseV2/src/hooks/gta_thread_start.cpp | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 BigBaseV2/src/hooks/gta_thread_start.cpp diff --git a/BigBaseV2/src/hooking.cpp b/BigBaseV2/src/hooking.cpp index ebea5e6f..51520f45 100644 --- a/BigBaseV2/src/hooking.cpp +++ b/BigBaseV2/src/hooking.cpp @@ -8,7 +8,6 @@ #include "hooking.hpp" #include "memory/module.hpp" #include "natives.hpp" -#include "native_hooks/native_hooks.hpp" #include "pointers.hpp" #include "renderer.hpp" #include "script_mgr.hpp" @@ -47,7 +46,9 @@ namespace big m_scripted_game_event_hook("SGEH", g_pointers->m_scripted_game_event, &hooks::scripted_game_event), // Send NET Info to Lobby - m_send_net_info_to_lobby("SNITL", g_pointers->m_send_net_info_to_lobby, &hooks::send_net_info_to_lobby) + m_send_net_info_to_lobby("SNITL", g_pointers->m_send_net_info_to_lobby, &hooks::send_net_info_to_lobby), + + m_gta_thread_start_hook("GTS", g_pointers->m_gta_thread_start, &hooks::gta_thread_start) { m_swapchain_hook.hook(hooks::swapchain_present_index, &hooks::swapchain_present); m_swapchain_hook.hook(hooks::swapchain_resizebuffers_index, &hooks::swapchain_resizebuffers); @@ -72,6 +73,7 @@ namespace big m_run_script_threads_hook.enable(); m_convert_thread_to_fiber_hook.enable(); + m_gta_thread_start_hook.enable(); m_gta_thread_kill_hook.enable(); m_gta_thread_tick_hook.enable(); @@ -104,6 +106,7 @@ namespace big m_gta_thread_tick_hook.disable(); m_gta_thread_kill_hook.disable(); + m_gta_thread_start_hook.disable(); m_convert_thread_to_fiber_hook.disable(); m_run_script_threads_hook.disable(); diff --git a/BigBaseV2/src/hooking.hpp b/BigBaseV2/src/hooking.hpp index 5fa5f6e2..46bff2db 100644 --- a/BigBaseV2/src/hooking.hpp +++ b/BigBaseV2/src/hooking.hpp @@ -36,6 +36,7 @@ namespace big Any p9 ); + static GtaThread* gta_thread_start(unsigned int** a1, unsigned int a2); static rage::eThreadState gta_thread_tick(GtaThread* a1, unsigned int a2); static rage::eThreadState gta_thread_kill(GtaThread* thread); @@ -73,14 +74,12 @@ namespace big void enable(); void disable(); - std::list m_native_hooks; - std::unordered_map m_natives; private: bool m_enabled{}; minhook_keepalive m_minhook_keepalive; vmt_hook m_swapchain_hook; - WNDPROC m_og_wndproc; + WNDPROC m_og_wndproc = nullptr; detour_hook m_set_cursor_pos_hook; detour_hook m_run_script_threads_hook; @@ -88,6 +87,7 @@ namespace big detour_hook m_error_screen_hook; + detour_hook m_gta_thread_start_hook; detour_hook m_gta_thread_tick_hook; detour_hook m_gta_thread_kill_hook; diff --git a/BigBaseV2/src/hooks/gta_thread_start.cpp b/BigBaseV2/src/hooks/gta_thread_start.cpp new file mode 100644 index 00000000..289f682a --- /dev/null +++ b/BigBaseV2/src/hooks/gta_thread_start.cpp @@ -0,0 +1,15 @@ +#include "hooking.hpp" +#include "native_hooks/native_hooks.hpp" + +namespace big +{ + GtaThread* hooks::gta_thread_start(unsigned int** a1, unsigned int a2) + { + GtaThread* new_thread = g_hooking->m_gta_thread_start_hook.get_original()(a1, a2); + + if (new_thread != nullptr) + g_native_hooks->check_for_thread(new_thread); + + return new_thread; + } +} \ No newline at end of file