From ac349ec844c7cf5460a04bd09210028918852fec Mon Sep 17 00:00:00 2001 From: Silent Date: Fri, 22 Apr 2016 21:42:10 +0200 Subject: [PATCH] Crash when entering advanced display options on a dual monitor machine - 1.0 --- SilentPatchSA/SilentPatchSA.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index fbad7eb..ad5a055 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -808,6 +808,20 @@ void MSAAText( char* buffer, const char*, DWORD level ) sprintf( buffer, "%ux", 1 << level ); } + +static RwInt32 numSavedVideoModes; +static RwInt32 (*orgGetNumVideoModes)(); +RwInt32 GetNumVideoModes_Store() +{ + return numSavedVideoModes = orgGetNumVideoModes(); +} + +RwInt32 GetNumVideoModes_Retrieve() +{ + return numSavedVideoModes; +} + + static void* (*orgMemMgrMalloc)(RwUInt32, RwUInt32); void* CollisionData_MallocAndInit( RwUInt32 size, RwUInt32 hint ) { @@ -2869,6 +2883,16 @@ void Patch_SA_10() InjectHook(0x40F81D, CollisionData_NewAndInit); + // Crash when entering advanced display options on a dual monitor machine after: + // - starting game on primary monitor in maximum resolution, exiting, + // starting again in maximum resolution on secondary monitor. + // Secondary monitor maximum resolution had to be greater than maximum resolution of primary monitor. + int pGetNumVideoModes = 0x745B1E; + orgGetNumVideoModes = (RwInt32(*)())(*(int*)(pGetNumVideoModes+1) + pGetNumVideoModes + 5); + InjectHook(0x745B1E, GetNumVideoModes_Store); + InjectHook(0x745A81, GetNumVideoModes_Retrieve); + + // Fixed police scanner names char* pScannerNames = *(char**)0x4E72D4; strcpy(pScannerNames + (8*113), "WESTP");