From a3d915f3b7ddbe5dc83dbcb909e6523387a873e7 Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Wed, 24 Aug 2022 08:44:01 +0600 Subject: [PATCH] Add crash reporting in log --- src/dllmain.cpp | 10 ++++++++++ src/utils/d3dhook.cpp | 10 +++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/dllmain.cpp b/src/dllmain.cpp index 4643d1c..8d05f63 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -2,8 +2,18 @@ #include "utils/updater.h" #include "utils/rpc.h" +LONG WINAPI CrashHandler(PEXCEPTION_POINTERS pExceptionInfo) +{ + Log::Print(""); + Log::Print("Game crashed. Unhandled exception at {} (0x{:x})", + pExceptionInfo->ExceptionRecord->ExceptionAddress, pExceptionInfo->ExceptionRecord->ExceptionCode); + return EXCEPTION_CONTINUE_SEARCH; +} + void MenuThread(void* param) { + // SetUnhandledExceptionFilter can get replaced by other dlls + AddVectoredExceptionHandler(0, CrashHandler); while (true) { FontMgr::Process(); diff --git a/src/utils/d3dhook.cpp b/src/utils/d3dhook.cpp index c2dd15d..a2efdaf 100644 --- a/src/utils/d3dhook.cpp +++ b/src/utils/d3dhook.cpp @@ -228,9 +228,8 @@ void D3dHook::ProcessMouse() patch::Nop(BY_GAME(0x541DD7, 0x4AB6CA, 0x49272F), 5); // don't call CPad::UpdateMouse() #ifdef GTASA // Fix bug with radio switching - patch::SetUChar(0x4EB731, 0xEB); - patch::SetUChar(0x4EB75A, 0xEB); - + patch::SetUInt(0x4EB731, 0xEB); // jz -> jmp, skip mouse checks + patch::SetUChar(0x4EB75A, 0xEB); // jz -> jmp, skip mouse checks #endif } else @@ -239,8 +238,8 @@ void D3dHook::ProcessMouse() patch::SetUChar(BY_GAME(0x6194A0, 0x6020A0, 0x580D20), BY_GAME(0xE9, 0x53, 0x53)); #ifdef GTASA patch::SetRaw(0x541DD7, (char*)"\xE8\xE4\xD5\xFF\xFF", 5); - patch::SetUChar(0x4EB731, 0x74); - patch::SetUChar(0x4EB75A, 0x74); + patch::SetUChar(0x4EB731, 0x74); // jz + patch::SetUChar(0x4EB75A, 0x74); // jz #elif GTAVC patch::SetRaw(0x4AB6CA, (char*)"\xE8\x51\x21\x00\x00", 5); #else @@ -248,6 +247,7 @@ void D3dHook::ProcessMouse() #endif } + // Need to update pads before resting values CPad::UpdatePads(); CPad::NewMouseControllerState.x = 0; CPad::NewMouseControllerState.y = 0;