From c28110a338f9e7632a8abb14fcecf93aafb22fb9 Mon Sep 17 00:00:00 2001 From: maybegreat48 <96936658+maybegreat48@users.noreply.github.com> Date: Sun, 16 Apr 2023 22:27:02 +0000 Subject: [PATCH] Hotfix VM patch (#1253) --- src/byte_patch_manager.cpp | 20 +++++++++++++ src/gta_pointers.hpp | 7 +++++ src/pointers.cpp | 59 +++++++++++++++++++++++++------------- src/pointers.hpp | 2 -- 4 files changed, 66 insertions(+), 22 deletions(-) diff --git a/src/byte_patch_manager.cpp b/src/byte_patch_manager.cpp index 3c3a6ec2..2c7679b8 100644 --- a/src/byte_patch_manager.cpp +++ b/src/byte_patch_manager.cpp @@ -54,6 +54,26 @@ namespace big // Crash Trigger memory::byte_patch::make(g_pointers->m_gta.m_crash_trigger.add(4).as(), 0x00)->apply(); + + // Script VM patches + + memory::byte_patch::make(g_pointers->m_gta.m_script_vm_patch_1.add(2).as(), 0xc9310272)->apply(); + memory::byte_patch::make(g_pointers->m_gta.m_script_vm_patch_1.add(6).as(), 0x9090)->apply(); + + memory::byte_patch::make(g_pointers->m_gta.m_script_vm_patch_2.add(2).as(), 0xc9310272)->apply(); + memory::byte_patch::make(g_pointers->m_gta.m_script_vm_patch_2.add(6).as(), 0x9090)->apply(); + + memory::byte_patch::make(g_pointers->m_gta.m_script_vm_patch_3.add(2).as(), 0xd2310272)->apply(); + memory::byte_patch::make(g_pointers->m_gta.m_script_vm_patch_3.add(6).as(), 0x9090)->apply(); + + memory::byte_patch::make(g_pointers->m_gta.m_script_vm_patch_4.add(2).as(), 0xd2310272)->apply(); + memory::byte_patch::make(g_pointers->m_gta.m_script_vm_patch_4.add(6).as(), 0x9090)->apply(); + + memory::byte_patch::make(g_pointers->m_gta.m_script_vm_patch_5.add(2).as(), 0xd2310272)->apply(); + memory::byte_patch::make(g_pointers->m_gta.m_script_vm_patch_5.add(6).as(), 0x9090)->apply(); + + memory::byte_patch::make(g_pointers->m_gta.m_script_vm_patch_6.add(2).as(), 0xd2310272)->apply(); + memory::byte_patch::make(g_pointers->m_gta.m_script_vm_patch_6.add(6).as(), 0x9090)->apply(); } byte_patch_manager::byte_patch_manager() diff --git a/src/gta_pointers.hpp b/src/gta_pointers.hpp index a51c757e..be36452b 100644 --- a/src/gta_pointers.hpp +++ b/src/gta_pointers.hpp @@ -45,6 +45,13 @@ namespace big memory::handle m_crash_trigger; + memory::handle m_script_vm_patch_1; + memory::handle m_script_vm_patch_2; + memory::handle m_script_vm_patch_3; + memory::handle m_script_vm_patch_4; + memory::handle m_script_vm_patch_5; + memory::handle m_script_vm_patch_6; + eGameState* m_game_state{}; bool* m_is_session_started{}; diff --git a/src/pointers.cpp b/src/pointers.cpp index e0a3c764..c104dafe 100644 --- a/src/pointers.cpp +++ b/src/pointers.cpp @@ -1347,8 +1347,46 @@ namespace big { g_pointers->m_gta.m_crash_trigger = ptr; } + }, + // Script VM Patch 1 + { + "SVM1", + "3b 0a 0f 83 ? ? ? ? 48 ff c7", + [](memory::handle ptr) + { + g_pointers->m_gta.m_script_vm_patch_1 = ptr; + } + }, + // Script VM Patch 2 + { + "SVM2", + "3b 0a 0f 83 ? ? ? ? 49 03 fa", + [](memory::handle ptr) + { + g_pointers->m_gta.m_script_vm_patch_2 = ptr; + } + }, + // Script VM Patches 3 and 4 + { + "SVM3&4", + "3b 11 0f 83 ? ? ? ? 48 ff c7", + [](memory::handle ptr) + { + g_pointers->m_gta.m_script_vm_patch_3 = ptr; + g_pointers->m_gta.m_script_vm_patch_4 = ptr.add(0x1C); + } + }, + // Script VM Patches 5 and 6 + { + "SVM5&6", + "3b 11 0f 83 ? ? ? ? 49 03 fa", + [](memory::handle ptr) + { + g_pointers->m_gta.m_script_vm_patch_5 = ptr; + g_pointers->m_gta.m_script_vm_patch_6 = ptr.add(0x26); + } } - >(); + >(); // don't leave a trailing comma at the end // clang-format on @@ -1387,23 +1425,6 @@ namespace big return batch_and_hash; } - void pointers::freemode_thread_restorer_through_vm_patch(const memory::module& mem_region) - { - auto pat3 = mem_region.scan_all("3b 11 0f 83 ? ? ? ? 48 ff c7"); - for (auto& handle : pat3) - { - memory::byte_patch::make(handle.add(2).as(), 0xd2310272)->apply(); - memory::byte_patch::make(handle.add(6).as(), 0x9090)->apply(); - } - - auto pat4 = mem_region.scan_all("3b 11 0f 83 ? ? ? ? 49 03 fa"); - for (auto& handle : pat4) - { - memory::byte_patch::make(handle.add(2).as(), 0xd2310272)->apply(); - memory::byte_patch::make(handle.add(6).as(), 0x9090)->apply(); - } - } - void pointers::load_pointers_from_cache(const cache_file& cache_file, const uintptr_t pointer_to_cacheable_data_start, const memory::module& mem_region) { // fill pointers instance fields by reading the file data into it @@ -1468,8 +1489,6 @@ namespace big else LOG(WARNING) << "socialclub.dll module was not loaded within the time limit."; - freemode_thread_restorer_through_vm_patch(mem_region); - m_hwnd = FindWindowW(L"grcWindow", nullptr); if (!m_hwnd) diff --git a/src/pointers.hpp b/src/pointers.hpp index 09cfdb24..543a6522 100644 --- a/src/pointers.hpp +++ b/src/pointers.hpp @@ -111,8 +111,6 @@ namespace big } } - void freemode_thread_restorer_through_vm_patch(const memory::module& mem_region); - public: explicit pointers(); ~pointers();