From 0bbdacbfa3f2dd3d08b3437631f5967b34761c28 Mon Sep 17 00:00:00 2001 From: Yimura <24669514+Yimura@users.noreply.github.com> Date: Fri, 9 Dec 2022 20:55:25 +0100 Subject: [PATCH] feat(Protections): Constraint attachment crash (#673) --- src/hooking.cpp | 1 + src/hooking.hpp | 1 + .../protections/constraint_attachment_crash.cpp | 12 ++++++++++++ src/pointers.cpp | 5 +++++ src/pointers.hpp | 1 + 5 files changed, 20 insertions(+) create mode 100644 src/hooks/protections/constraint_attachment_crash.cpp diff --git a/src/hooking.cpp b/src/hooking.cpp index fafaa11e..c4c918c7 100644 --- a/src/hooking.cpp +++ b/src/hooking.cpp @@ -64,6 +64,7 @@ namespace big detour_hook_helper::add("FMFS", g_pointers->m_format_metric_for_sending); detour_hook_helper::add("IMCD", g_pointers->m_invalid_mods_crash_detour); + detour_hook_helper::add("CAC", g_pointers->m_constraint_attachment_crash); detour_hook_helper::add("UPAI", g_pointers->m_update_presence_attribute_int); detour_hook_helper::add("UPAS", g_pointers->m_update_presence_attribute_string); diff --git a/src/hooking.hpp b/src/hooking.hpp index 7bb8733c..47c1e63d 100644 --- a/src/hooking.hpp +++ b/src/hooking.hpp @@ -98,6 +98,7 @@ namespace big static bool write_player_game_state_data_node(rage::netObject* player, CPlayerGameStateDataNode* node); static void invalid_mods_crash_detour(int64_t a1, int64_t a2, int a3, char a4); + static std::int64_t constraint_attachment_crash(std::uintptr_t a1); static bool update_presence_attribute_int(void* presence_data, int profile_index, char* attr, std::uint64_t value); static bool update_presence_attribute_string(void* presence_data, int profile_index, char* attr, char* value); diff --git a/src/hooks/protections/constraint_attachment_crash.cpp b/src/hooks/protections/constraint_attachment_crash.cpp new file mode 100644 index 00000000..e9e7668f --- /dev/null +++ b/src/hooks/protections/constraint_attachment_crash.cpp @@ -0,0 +1,12 @@ +#include "hooking.hpp" + +namespace big +{ + std::int64_t hooks::constraint_attachment_crash(std::uintptr_t a1) + { + if (!*reinterpret_cast(a1 + 0x38)) + return 0; + + return g_hooking->get_original()(a1); + } +} \ No newline at end of file diff --git a/src/pointers.cpp b/src/pointers.cpp index 1a4f2a45..c5c68eeb 100644 --- a/src/pointers.cpp +++ b/src/pointers.cpp @@ -665,6 +665,11 @@ namespace big m_read_bitbuffer_gamer_handle = ptr.as(); }); + main_batch.add("CAC", "40 53 48 83 EC 20 48 8B D9 48 8B 49 38 48 8B 01", [this](memory::handle ptr) + { + m_constraint_attachment_crash = ptr.as(); + }); + auto mem_region = memory::module("GTA5.exe"); main_batch.run(mem_region); diff --git a/src/pointers.hpp b/src/pointers.hpp index b8c27ac4..37190b0e 100644 --- a/src/pointers.hpp +++ b/src/pointers.hpp @@ -148,6 +148,7 @@ namespace big const char* m_online_version; PVOID m_invalid_mods_crash_detour{}; + PVOID m_constraint_attachment_crash{}; int64_t** m_send_chat_ptr{}; functions::send_chat_message m_send_chat_message{};