From ad690f242ba5040a8e7484bc83420394921c83d7 Mon Sep 17 00:00:00 2001 From: Yimura Date: Fri, 13 May 2022 18:45:32 +0200 Subject: [PATCH] feat(ErrorScreen): Removed detour hook as it's "detected" --- BigBaseV2/src/hooking.cpp | 7 --- BigBaseV2/src/hooking.hpp | 15 ------ BigBaseV2/src/hooks/disable_error_screen.cpp | 48 ------------------- BigBaseV2/src/native_hooks/native_hooks.hpp | 2 + .../src/native_hooks/shop_controller.hpp | 37 ++++++++++++++ BigBaseV2/src/pointers.cpp | 6 --- BigBaseV2/src/pointers.hpp | 2 - BigBaseV2/src/views/players/view_player.cpp | 4 ++ 8 files changed, 43 insertions(+), 78 deletions(-) delete mode 100644 BigBaseV2/src/hooks/disable_error_screen.cpp create mode 100644 BigBaseV2/src/native_hooks/shop_controller.hpp diff --git a/BigBaseV2/src/hooking.cpp b/BigBaseV2/src/hooking.cpp index 86dc38c0..36b48556 100644 --- a/BigBaseV2/src/hooking.cpp +++ b/BigBaseV2/src/hooking.cpp @@ -48,9 +48,6 @@ namespace big // Is DLC Present m_is_dlc_present_hook("IDP", g_pointers->m_is_dlc_present, &hooks::is_dlc_present), - // Error Screen - m_error_screen_hook("ES", g_pointers->m_error_screen, &hooks::set_warning_message_with_header), - // Received Event m_received_event_hook("RE", g_pointers->m_received_event, &hooks::received_event), @@ -98,8 +95,6 @@ namespace big m_increment_stat_hook.enable(); - m_error_screen_hook.enable(); - m_received_event_hook.enable(); m_send_net_info_to_lobby.enable(); @@ -115,8 +110,6 @@ namespace big m_received_event_hook.disable(); - m_error_screen_hook.disable(); - m_increment_stat_hook.disable(); m_player_has_joined_hook.disable(); diff --git a/BigBaseV2/src/hooking.hpp b/BigBaseV2/src/hooking.hpp index 46902d2e..a5671ea5 100644 --- a/BigBaseV2/src/hooking.hpp +++ b/BigBaseV2/src/hooking.hpp @@ -23,19 +23,6 @@ namespace big static LRESULT wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); static BOOL set_cursor_pos(int x, int y); - static void set_warning_message_with_header( - const char* entryHeader, - const char* entryLine1, - int instructionalKey, - const char* entryLine2, - bool p4, - Any p5, - Any* showBackground, - Any* p7, - bool p8, - 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); @@ -95,8 +82,6 @@ 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_start_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 deleted file mode 100644 index f10c7500..00000000 --- a/BigBaseV2/src/hooks/disable_error_screen.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "gta/joaat.hpp" -#include "hooking.hpp" -#include "natives.hpp" -#include "script_global.hpp" - -namespace big -{ - void hooks::set_warning_message_with_header( - const char* entryHeader, - const char* entryLine1, - int instructionalKey, - const char* entryLine2, - bool p4, - Any p5, - Any* showBackground, - Any* p7, - bool p8, - Any p9 - ) - { - if (SCRIPT::GET_HASH_OF_THIS_SCRIPT_NAME() == RAGE_JOAAT("shop_controller") && strcmp(entryLine1, "CTALERT_F_2") == 0) - { - if (g->notifications.transaction_rate_limit.log) - LOG(WARNING) << "Received transaction rate limit"; - if (g->notifications.transaction_rate_limit.notify) - g_notification_service->push_warning("Transaction Rate Limit", "You're receiving transaction rate limits, whatever you're doing do it less."); - - // dismisses popup instead of killing it silently - *script_global(4529830).as() = 0; - - // we still return to prevent our original call from rendering a single frame - return; - } - - return g_hooking->m_error_screen_hook.get_original()( - entryHeader, - entryLine1, - instructionalKey, - entryLine2, - p4, - p5, - showBackground, - p7, - p8, - p9 - ); - } -} \ No newline at end of file diff --git a/BigBaseV2/src/native_hooks/native_hooks.hpp b/BigBaseV2/src/native_hooks/native_hooks.hpp index a1b9228c..3ff0d57a 100644 --- a/BigBaseV2/src/native_hooks/native_hooks.hpp +++ b/BigBaseV2/src/native_hooks/native_hooks.hpp @@ -4,6 +4,7 @@ #include "gta/script_thread.hpp" #include "native_hooks/carmod_shop.hpp" #include "native_hooks/freemode.hpp" +#include "native_hooks/shop_controller.hpp" #include "script_hook.hpp" namespace big @@ -27,6 +28,7 @@ namespace big add_native_detour(RAGE_JOAAT("carmod_shop"), 0x34E710FF01247C5A, carmod_shop::SET_VEHICLE_LIGHTS); add_native_detour(RAGE_JOAAT("carmod_shop"), 0x767FBC2AC802EF3D, carmod_shop::STAT_GET_INT); add_native_detour(RAGE_JOAAT("freemode"), 0x95914459A87EBA28, freemode::NETWORK_BAIL); + add_native_detour(RAGE_JOAAT("shop_controller"), 0xDC38CC1E35B6A5D7, shop_controller::SET_WARNING_MESSAGE_WITH_HEADER); for (const auto& native_detours_for_script : m_native_registrations) if (const GtaThread* thread = gta_util::find_script_thread(native_detours_for_script.first); thread != nullptr && thread->m_context.m_state == rage::eThreadState::running) diff --git a/BigBaseV2/src/native_hooks/shop_controller.hpp b/BigBaseV2/src/native_hooks/shop_controller.hpp new file mode 100644 index 00000000..41b2b3e9 --- /dev/null +++ b/BigBaseV2/src/native_hooks/shop_controller.hpp @@ -0,0 +1,37 @@ +#pragma once +#include "native_hooks.hpp" +#include "script_global.hpp" + +namespace big +{ + namespace shop_controller + { + inline void SET_WARNING_MESSAGE_WITH_HEADER(rage::scrNativeCallContext* src) + { + if (auto entry_line = src->get_arg(1); !strcmp(entry_line, "CTALERT_F_2")) + { + if (g->notifications.transaction_rate_limit.log) + LOG(WARNING) << "Received transaction rate limit"; + if (g->notifications.transaction_rate_limit.notify) + g_notification_service->push_warning("Transaction Rate Limit", "You're receiving transaction rate limits, whatever you're doing do it less."); + + *script_global(4529830).as() = 0; + + return; + } + + HUD::SET_WARNING_MESSAGE_WITH_HEADER( + src->get_arg(0), + src->get_arg(1), + src->get_arg(2), + src->get_arg(3), + src->get_arg(4), + src->get_arg(5), + src->get_arg(6), + src->get_arg(7), + src->get_arg(8), + src->get_arg(9) + ); + } + } +} \ No newline at end of file diff --git a/BigBaseV2/src/pointers.cpp b/BigBaseV2/src/pointers.cpp index 5933f4d1..cfa29ba3 100644 --- a/BigBaseV2/src/pointers.cpp +++ b/BigBaseV2/src/pointers.cpp @@ -119,12 +119,6 @@ namespace big m_increment_stat_event = ptr.as(); }); - // Error Screen Hook - main_batch.add("ESH", "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(); - }); - // Trigger Script Event main_batch.add("TSE", "48 8B C4 48 89 58 08 48 89 68 10 48 89 70 18 48 89 78 20 41 56 48 81 EC ? ? ? ? 45 8B F0 41 8B F9", [this](memory::handle ptr) { diff --git a/BigBaseV2/src/pointers.hpp b/BigBaseV2/src/pointers.hpp index 49bec22a..b5bd3365 100644 --- a/BigBaseV2/src/pointers.hpp +++ b/BigBaseV2/src/pointers.hpp @@ -50,8 +50,6 @@ namespace big PVOID m_is_dlc_present; PVOID m_network_group_override; - PVOID m_error_screen{}; - FriendRegistry* m_friend_registry{}; functions::get_screen_coords_for_world_coords* m_get_screen_coords_for_world_coords{}; diff --git a/BigBaseV2/src/views/players/view_player.cpp b/BigBaseV2/src/views/players/view_player.cpp index 6f83a542..e1d341b1 100644 --- a/BigBaseV2/src/views/players/view_player.cpp +++ b/BigBaseV2/src/views/players/view_player.cpp @@ -17,6 +17,10 @@ namespace big if (g_player_service->get_selected()->is_valid()) { + if (ImGui::Button("Desync")) + { + gta_util::get_network_player_mgr()->RemovePlayer(g_player_service->get_selected()->get_net_game_player()); + } if (ImGui::TreeNode("Misc")) { components::button("Steal Outfit", [] {