feat(Protections): Block Indecent Exposure crash. (#683)

This commit is contained in:
Reece Watson 2022-12-10 19:28:56 -05:00 committed by GitHub
parent ae6704beea
commit 031067a668
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 0 deletions

View File

@ -65,6 +65,7 @@ namespace big
detour_hook_helper::add<hooks::invalid_mods_crash_detour>("IMCD", g_pointers->m_invalid_mods_crash_detour);
detour_hook_helper::add<hooks::constraint_attachment_crash>("CAC", g_pointers->m_constraint_attachment_crash);
detour_hook_helper::add<hooks::invalid_decal>("IDC", g_pointers->m_invalid_decal_crash);
detour_hook_helper::add<hooks::update_presence_attribute_int>("UPAI", g_pointers->m_update_presence_attribute_int);
detour_hook_helper::add<hooks::update_presence_attribute_string>("UPAS", g_pointers->m_update_presence_attribute_string);

View File

@ -99,6 +99,7 @@ namespace big
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 uint64_t invalid_decal(uintptr_t a1, int a2);
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);

View File

@ -0,0 +1,16 @@
#include "hooking.hpp"
namespace big
{
uint64_t hooks::invalid_decal(uintptr_t a1, int a2)
{
if (a1 && a2 == 2)
//*(*(*(a1 + 0x48) + 0x30) + 0x2C8)
if (const auto ptr = *reinterpret_cast<uintptr_t*>((a1 + 0x48)); ptr)
if (const auto ptr2 = *reinterpret_cast<uintptr_t*>((ptr + 0x30)); ptr2)
if (*reinterpret_cast<uintptr_t*>(ptr2 + 0x2C8) == 0)
return 0;
return g_hooking->get_original<hooks::invalid_decal>()(a1, a2);
}
}

View File

@ -665,11 +665,18 @@ namespace big
m_read_bitbuffer_gamer_handle = ptr.as<PVOID>();
});
// Constraint Attachment Crash
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<PVOID>();
});
// Invalid Decal Crash
main_batch.add("IDC", "E8 ? ? ? ? 8B 9C 24 B8 00 00 00 4C 8B AC 24 A8 00 00 00", [this](memory::handle ptr)
{
m_invalid_decal_crash = ptr.add(1).rip().as<PVOID>();
});
auto mem_region = memory::module("GTA5.exe");
main_batch.run(mem_region);

View File

@ -149,6 +149,7 @@ namespace big
PVOID m_invalid_mods_crash_detour{};
PVOID m_constraint_attachment_crash{};
PVOID m_invalid_decal_crash{};
int64_t** m_send_chat_ptr{};
functions::send_chat_message m_send_chat_message{};