diff --git a/BigBaseV2/src/core/globals.hpp b/BigBaseV2/src/core/globals.hpp index 22664e69..74492a4d 100644 --- a/BigBaseV2/src/core/globals.hpp +++ b/BigBaseV2/src/core/globals.hpp @@ -116,8 +116,6 @@ namespace big bool vehicle_kick = true; }; - bool freemode_terminated = false; - script_events script_events{}; }; diff --git a/BigBaseV2/src/hooking.cpp b/BigBaseV2/src/hooking.cpp index 36b48556..c9f5a0a5 100644 --- a/BigBaseV2/src/hooking.cpp +++ b/BigBaseV2/src/hooking.cpp @@ -29,8 +29,6 @@ namespace big // GTA Thead Start m_gta_thread_start_hook("GTS", g_pointers->m_gta_thread_start, &hooks::gta_thread_start), - // GTA Thread Tick - m_gta_thread_tick_hook("GTT", g_pointers->m_gta_thread_tick, &hooks::gta_thread_tick), // GTA Thread Kill m_gta_thread_kill_hook("GTK", g_pointers->m_gta_thread_kill, &hooks::gta_thread_kill), @@ -84,7 +82,6 @@ namespace big m_gta_thread_start_hook.enable(); m_gta_thread_kill_hook.enable(); - m_gta_thread_tick_hook.enable(); m_network_player_mgr_shutdown_hook.enable(); @@ -119,7 +116,6 @@ namespace big m_network_player_mgr_shutdown_hook.disable(); - m_gta_thread_tick_hook.disable(); m_gta_thread_kill_hook.disable(); m_gta_thread_start_hook.disable(); diff --git a/BigBaseV2/src/hooking.hpp b/BigBaseV2/src/hooking.hpp index a5671ea5..f1e04432 100644 --- a/BigBaseV2/src/hooking.hpp +++ b/BigBaseV2/src/hooking.hpp @@ -24,7 +24,6 @@ namespace big static BOOL set_cursor_pos(int x, int y); 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); static void network_player_mgr_shutdown(CNetworkPlayerMgr* _this); @@ -83,7 +82,6 @@ namespace big detour_hook m_convert_thread_to_fiber_hook; detour_hook m_gta_thread_start_hook; - detour_hook m_gta_thread_tick_hook; detour_hook m_gta_thread_kill_hook; detour_hook m_network_player_mgr_shutdown_hook; diff --git a/BigBaseV2/src/hooks/gta_thread_kill.cpp b/BigBaseV2/src/hooks/gta_thread_kill.cpp index 77cc4a55..015eb133 100644 --- a/BigBaseV2/src/hooks/gta_thread_kill.cpp +++ b/BigBaseV2/src/hooks/gta_thread_kill.cpp @@ -5,7 +5,7 @@ namespace big { rage::eThreadState hooks::gta_thread_kill(GtaThread* thread) { - rage::eThreadState result = g_hooking->m_gta_thread_kill_hook.get_original()(thread); + const auto result = g_hooking->m_gta_thread_kill_hook.get_original()(thread); if (g->notifications.gta_thread_kill.log) LOG(INFO) << "Script Thread '" << thread->m_name << "' terminated."; @@ -14,9 +14,6 @@ namespace big g_native_hooks->do_cleanup_for_thread(thread); - if (thread->m_script_hash == RAGE_JOAAT("freemode")) - g->protections.freemode_terminated = !(result == rage::eThreadState::running); - return result; } } \ No newline at end of file diff --git a/BigBaseV2/src/hooks/gta_thread_tick.cpp b/BigBaseV2/src/hooks/gta_thread_tick.cpp deleted file mode 100644 index df04a963..00000000 --- a/BigBaseV2/src/hooks/gta_thread_tick.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "hooking.hpp" -#include "gta/script_thread.hpp" - -namespace big -{ - static char struct_backup[sizeof(GtaThread)]; - static char stack_buffer[0xFFFF]; - - rage::eThreadState hooks::gta_thread_tick(GtaThread* thread, unsigned int a2) - { - rage::eThreadState state = thread->m_context.m_state; - - if (thread->m_script_hash == RAGE_JOAAT("freemode") && state == rage::eThreadState::running && !g->protections.freemode_terminated) - { - memcpy(struct_backup, (void*)thread, sizeof(GtaThread)); - if (thread->m_stack) - memcpy(stack_buffer, thread->m_stack, thread->m_context.m_stack_size); - } - - rage::eThreadState result = g_hooking->m_gta_thread_tick_hook.get_original()(thread, a2); - - if (thread->m_script_hash == RAGE_JOAAT("freemode")) - { - if (result == rage::eThreadState::killed && state == rage::eThreadState::running && !g->protections.freemode_terminated) - { - LOG(INFO) << "Freemode script crashed, attempting recovery..."; - - result = rage::eThreadState::running; - - memcpy(thread, struct_backup, sizeof(GtaThread)); - if (thread->m_stack) - memcpy(thread->m_stack, stack_buffer, thread->m_context.m_stack_size); - } - - if (g->protections.freemode_terminated) g->protections.freemode_terminated = !(result == rage::eThreadState::running); - } - - return result; - } -} \ No newline at end of file diff --git a/BigBaseV2/src/pointers.cpp b/BigBaseV2/src/pointers.cpp index adab8155..86fff265 100644 --- a/BigBaseV2/src/pointers.cpp +++ b/BigBaseV2/src/pointers.cpp @@ -101,13 +101,7 @@ namespace big m_gta_thread_start = ptr.as(); }); - // Thread Thick - main_batch.add("TT", "48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC 20 80 B9 ? ? ? ? ? 8B FA 48 8B D9 74 05", [this](memory::handle ptr) - { - m_gta_thread_tick = ptr.as(); - }); - - // Thread Kill + // GTA Thread Kill main_batch.add("TK", "48 89 5C 24 ? 57 48 83 EC 20 48 83 B9 ? ? ? ? ? 48 8B D9 74 14", [this](memory::handle ptr) { m_gta_thread_kill = ptr.as(); @@ -240,8 +234,38 @@ namespace big { m_network_group_override = ptr.as(); }); - - main_batch.run(memory::module(nullptr)); + + auto mem_region = memory::module(nullptr); + main_batch.run(mem_region); + + /** + * Freemode thread restorer through VM patch + */ + if (auto pat1 = mem_region.scan("3b 0a 0f 83 ? ? ? ? 48 ff c7")) + { + *pat1.add(2).as() = 0xc9310272; + *pat1.add(6).as() = 0x9090; + } + + if (auto pat2 = mem_region.scan("3b 0a 0f 83 ? ? ? ? 49 03 fa")) + { + *pat2.add(2).as() = 0xc9310272; + *pat2.add(6).as() = 0x9090; + } + + auto pat3 = mem_region.scan_all("3b 11 0f 83 ? ? ? ? 48 ff c7"); + for (auto& handle : pat3) + { + *handle.add(2).as() = 0xd2310272; + *handle.add(6).as() = 0x9090; + } + + auto pat4 = mem_region.scan_all("3b 11 0f 83 ? ? ? ? 49 03 fa"); + for (auto& handle : pat4) + { + *handle.add(2).as() = 0xd2310272; + *handle.add(6).as() = 0x9090; + } m_hwnd = FindWindowW(L"grcWindow", nullptr); if (!m_hwnd) diff --git a/BigBaseV2/src/pointers.hpp b/BigBaseV2/src/pointers.hpp index b6e5c5bb..e684dcf7 100644 --- a/BigBaseV2/src/pointers.hpp +++ b/BigBaseV2/src/pointers.hpp @@ -56,7 +56,6 @@ namespace big functions::get_screen_coords_for_world_coords* m_get_screen_coords_for_world_coords{}; PVOID m_gta_thread_start{}; - PVOID m_gta_thread_tick{}; PVOID m_gta_thread_kill{}; PVOID m_network_player_mgr_shutdown;