14
14
#include " SWRSToys.h"
15
15
16
16
#define CRenderer_Unknown1 ((void (__thiscall *)(int , int ))0x404AF0 )
17
- #define REAL_VERSION_STR " alpha 0.3 .1"
17
+ #define REAL_VERSION_STR " alpha 0.4 .1"
18
18
#ifdef _NOTEX
19
19
#define MOD_REAL_VERSION_STR REAL_VERSION_STR " no texture"
20
20
#else
@@ -101,7 +101,7 @@ LONG WINAPI UnhandledExFilter(PEXCEPTION_POINTERS ExPtr)
101
101
}
102
102
printf (" %S\n " , buf);
103
103
MessageBoxW (nullptr , buf, L" Fatal Error" , MB_ICONERROR);
104
- exit (ExPtr-> ExceptionRecord -> ExceptionCode ) ;
104
+ return EXCEPTION_CONTINUE_SEARCH ;
105
105
}
106
106
107
107
void loadAssets ()
@@ -111,7 +111,6 @@ void loadAssets()
111
111
loaded = true ;
112
112
SokuLib::FontDescription desc;
113
113
114
- SetUnhandledExceptionFilter (UnhandledExFilter);
115
114
puts (" Placed exception handler!" );
116
115
desc.r1 = 255 ;
117
116
desc.r2 = 255 ;
@@ -545,6 +544,13 @@ int __fastcall myTitleOnRender(SokuLib::Title *This)
545
544
return ret;
546
545
}
547
546
547
+ void trapDebugger (bool b)
548
+ {
549
+ if (!b)
550
+ return ;
551
+ DebugBreak ();
552
+ }
553
+
548
554
bool Hook (HMODULE this_module)
549
555
{
550
556
#ifdef _DEBUG
@@ -573,6 +579,13 @@ bool Hook(HMODULE this_module)
573
579
puts (" Loading settings file" );
574
580
loadSettings (gameHash, this_module);
575
581
puts (" Placing hooks" );
582
+ SetUnhandledExceptionFilter (UnhandledExFilter);
583
+ VirtualProtect ((PVOID)TEXT_SECTION_OFFSET, TEXT_SECTION_SIZE, PAGE_EXECUTE_WRITECOPY, &old);
584
+ *(char *)0x81FF00 = 0x90 ;
585
+ *(char *)0x81FF01 = 0x50 ;
586
+ *(char *)0x81FF04 = 0x90 ;
587
+ SokuLib::TamperNearCall (0x81FF05 , trapDebugger);
588
+ VirtualProtect ((PVOID)TEXT_SECTION_OFFSET, TEXT_SECTION_SIZE, old, &old);
576
589
VirtualProtect ((PVOID)RDATA_SECTION_OFFSET, RDATA_SECTION_SIZE, PAGE_EXECUTE_WRITECOPY, &old);
577
590
ogTitleOnProcess = SokuLib::TamperDword (&SokuLib::VTable_Title.onProcess , myTitleOnProcess);
578
591
ogTitleOnRender = SokuLib::TamperDword (&SokuLib::VTable_Title.onRender , myTitleOnRender);
0 commit comments