From ef818f03da5e68f3fc9f208f5f148f7909c21421 Mon Sep 17 00:00:00 2001 From: Yimura Date: Thu, 20 May 2021 15:49:36 +0200 Subject: [PATCH] feat(Hooks): Added error screen hook --- BigBaseV2/src/function_types.hpp | 2 ++ BigBaseV2/src/hooking.cpp | 8 ++++++- BigBaseV2/src/hooking.hpp | 4 ++++ BigBaseV2/src/hooks/disable_error_screen.cpp | 23 ++++++++++++++++++++ BigBaseV2/src/pointers.cpp | 5 +++++ BigBaseV2/src/pointers.hpp | 2 ++ 6 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 BigBaseV2/src/hooks/disable_error_screen.cpp diff --git a/BigBaseV2/src/function_types.hpp b/BigBaseV2/src/function_types.hpp index 4062b761..880fe131 100644 --- a/BigBaseV2/src/function_types.hpp +++ b/BigBaseV2/src/function_types.hpp @@ -9,6 +9,8 @@ namespace big::functions using get_native_handler_t = rage::scrNativeHandler(*)(rage::scrNativeRegistrationTable*, rage::scrNativeHash); using fix_vectors_t = void(*)(rage::scrNativeCallContext*); + using error_screen = void(char* entryHeader, char* entryLine1, int instructionalKey, char* entryLine2, BOOL p4, Any p5, Any* p6, Any* p7, BOOL background); + using gta_thread_tick = __int64(GtaThread* a1, unsigned int a2); using gta_thread_kill = __int64(GtaThread* a1); diff --git a/BigBaseV2/src/hooking.cpp b/BigBaseV2/src/hooking.cpp index c9226308..c21addcb 100644 --- a/BigBaseV2/src/hooking.cpp +++ b/BigBaseV2/src/hooking.cpp @@ -42,7 +42,9 @@ namespace big m_gta_thread_tick_hook("GTA Thread Tick", g_pointers->m_gta_thread_tick, &hooks::gta_thread_tick), m_gta_thread_kill_hook("GTA Thread Kill", g_pointers->m_gta_thread_kill, &hooks::gta_thread_kill), - 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_error_screen_hook("Error Screen", g_pointers->m_error_screen, &hooks::disable_error_screen) { m_swapchain_hook.hook(hooks::swapchain_present_index, &hooks::swapchain_present); m_swapchain_hook.hook(hooks::swapchain_resizebuffers_index, &hooks::swapchain_resizebuffers); @@ -72,6 +74,8 @@ namespace big m_increment_stat_hook.enable(); + m_error_screen_hook.enable(); + m_enabled = true; } @@ -79,6 +83,8 @@ namespace big { m_enabled = false; + m_error_screen_hook.disable(); + m_increment_stat_hook.disable(); m_gta_thread_tick_hook.disable(); diff --git a/BigBaseV2/src/hooking.hpp b/BigBaseV2/src/hooking.hpp index a5f0fca9..c3595e4d 100644 --- a/BigBaseV2/src/hooking.hpp +++ b/BigBaseV2/src/hooking.hpp @@ -22,6 +22,8 @@ namespace big static LRESULT wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); static BOOL set_cursor_pos(int x, int y); + static void disable_error_screen(char* entryHeader, char* entryLine1, int instructionalKey, char* entryLine2, BOOL p4, Any p5, Any* p6, Any* p7, BOOL background); + static rage::eThreadState gta_thread_tick(GtaThread* a1, unsigned int a2); static rage::eThreadState gta_thread_kill(GtaThread* thread); @@ -55,6 +57,8 @@ namespace big detour_hook m_run_script_threads_hook; detour_hook m_convert_thread_to_fiber_hook; + detour_hook m_error_screen_hook; + detour_hook m_gta_thread_tick_hook; detour_hook m_gta_thread_kill_hook; diff --git a/BigBaseV2/src/hooks/disable_error_screen.cpp b/BigBaseV2/src/hooks/disable_error_screen.cpp new file mode 100644 index 00000000..799b4a64 --- /dev/null +++ b/BigBaseV2/src/hooks/disable_error_screen.cpp @@ -0,0 +1,23 @@ +#include "gta/joaat.hpp" +#include "hooking.hpp" +#include "natives.hpp" + +namespace big +{ + void hooks::disable_error_screen( + char* entryHeader, + char* entryLine1, + int instructionalKey, + char* entryLine2, + BOOL p4, + Any p5, + Any* p6, + Any* p7, + BOOL background + ) + { + if (SCRIPT::GET_HASH_OF_THIS_SCRIPT_NAME() != RAGE_JOAAT("shop_controller")) + return g_hooking->m_error_screen_hook.get_original()(entryHeader, entryLine1, instructionalKey, entryLine2, p4, p5, p6, p7, background); + return; + } +} \ No newline at end of file diff --git a/BigBaseV2/src/pointers.cpp b/BigBaseV2/src/pointers.cpp index be391f05..5167cd76 100644 --- a/BigBaseV2/src/pointers.cpp +++ b/BigBaseV2/src/pointers.cpp @@ -127,6 +127,11 @@ namespace big { m_increment_stat_event = ptr.as(); }); + + main_batch.add("Error Screen", "48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 41 56 41 57 48 83 EC 60 4C 8B F2 48 8B 94 24 ? ? ? ? 33 DB", [this](memory::handle ptr) + { + m_error_screen = ptr.as(); + }); main_batch.run(memory::module(nullptr)); diff --git a/BigBaseV2/src/pointers.hpp b/BigBaseV2/src/pointers.hpp index 71369b7b..1d331a7e 100644 --- a/BigBaseV2/src/pointers.hpp +++ b/BigBaseV2/src/pointers.hpp @@ -41,6 +41,8 @@ namespace big 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{}; functions::gta_thread_kill* m_gta_thread_kill{};