feat(ErrorScreen): Removed detour hook as it's "detected"

This commit is contained in:
Yimura 2022-05-13 18:45:32 +02:00
parent 286960ac18
commit ad690f242b
8 changed files with 43 additions and 78 deletions

View File

@ -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();

View File

@ -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;

View File

@ -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<int*>() = 0;
// we still return to prevent our original call from rendering a single frame
return;
}
return g_hooking->m_error_screen_hook.get_original<decltype(&hooks::set_warning_message_with_header)>()(
entryHeader,
entryLine1,
instructionalKey,
entryLine2,
p4,
p5,
showBackground,
p7,
p8,
p9
);
}
}

View File

@ -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)

View File

@ -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<const char*>(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<int*>() = 0;
return;
}
HUD::SET_WARNING_MESSAGE_WITH_HEADER(
src->get_arg<const char*>(0),
src->get_arg<const char*>(1),
src->get_arg<int>(2),
src->get_arg<const char*>(3),
src->get_arg<BOOL>(4),
src->get_arg<Any>(5),
src->get_arg<Any*>(6),
src->get_arg<Any*>(7),
src->get_arg<BOOL>(8),
src->get_arg<Any>(9)
);
}
}
}

View File

@ -119,12 +119,6 @@ namespace big
m_increment_stat_event = ptr.as<decltype(m_increment_stat_event)>();
});
// 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<decltype(m_error_screen)>();
});
// 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)
{

View File

@ -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{};

View File

@ -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", [] {