feat(Protection): Improve Sound Crash Protection (#767)

Closes #762
This commit is contained in:
Aure7138 2022-12-30 09:45:04 +08:00 committed by GitHub
parent bd7bc362e3
commit 055bb3e939
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,21 @@
EXTERN g_sound_overload_ret_addr: DQ
.CODE
sound_overload_detour PROC
movzx eax, r8w
lea rdx, [rcx + rcx * 2]
cmp rdx, 190
jle label_1
mov rdx, 0
jmp label_2
label_1:
inc ecx
cmp r8w, [rbx + 28]
label_2:
push 0
mov r11, g_sound_overload_ret_addr
mov [rsp], r11
ret
sound_overload_detour ENDP
END

View File

@ -5,6 +5,9 @@
#include "security/RageSecurity.hpp" #include "security/RageSecurity.hpp"
#include "hooking.hpp" #include "hooking.hpp"
extern "C" void sound_overload_detour();
std::uint64_t g_sound_overload_ret_addr;
namespace big namespace big
{ {
pointers::pointers() pointers::pointers()
@ -762,6 +765,15 @@ namespace big
m_chat_gamer_info = ptr.add(1).rip().add(6).rip().as<rage::rlGamerInfo*>(); m_chat_gamer_info = ptr.add(1).rip().add(6).rip().as<rage::rlGamerInfo*>();
}); });
// Sound Overload Detour
main_batch.add("SOD", "66 45 3B C1 74 38", [this](memory::handle ptr)
{
g_sound_overload_ret_addr = ptr.add(13 + 15).as<decltype(g_sound_overload_ret_addr)>();
std::vector<byte> bytes = { 0xFF,0x25,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90 }; // far jump opcode + a nop opcode
*(void**)(bytes.data() + 6) = sound_overload_detour;
memory::byte_patch::make(ptr.add(13).as<void*>(), bytes)->apply();
});
auto mem_region = memory::module("GTA5.exe"); auto mem_region = memory::module("GTA5.exe");
main_batch.run(mem_region); main_batch.run(mem_region);

View File

@ -22,6 +22,8 @@ namespace rage
class rlGamerInfo; class rlGamerInfo;
} }
extern "C" std::uint64_t g_sound_overload_ret_addr;
namespace big namespace big
{ {
class pointers class pointers