Adapted for new Memory version

This commit is contained in:
Silent 2016-09-12 00:09:21 +02:00
parent e07c0b4d5c
commit b27ec3a264
5 changed files with 78 additions and 118 deletions

View File

@ -42,7 +42,7 @@
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers> <OmitFramePointers>true</OmitFramePointers>
<PreprocessorDefinitions>NDEBUG;_SIMPLE_MEMORY_ONLY;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling> <StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>..\SilentPatch;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\SilentPatch;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

View File

@ -8,6 +8,7 @@
#include <Shlwapi.h> #include <Shlwapi.h>
#include <ShlObj.h> #include <ShlObj.h>
#include <cstdint> #include <cstdint>
#define _MEMORY_NO_CRT
#include "MemoryMgr.h" #include "MemoryMgr.h"
extern "C" HRESULT WINAPI DirectDrawCreateEx(GUID FAR *lpGUID, LPVOID *lplpDD, REFIID iid, IUnknown FAR *pUnkOuter) extern "C" HRESULT WINAPI DirectDrawCreateEx(GUID FAR *lpGUID, LPVOID *lplpDD, REFIID iid, IUnknown FAR *pUnkOuter)

View File

@ -435,9 +435,8 @@ void Patch_III_10(const RECT& desktop)
InjectHook(0x46BADA, III_SensResetFix, PATCH_CALL); InjectHook(0x46BADA, III_SensResetFix, PATCH_CALL);
// (Hopefully) more precise frame limiter // (Hopefully) more precise frame limiter
int pAddress = 0x582EFD; ReadCall( 0x582EFD, RsEventHandler );
RsEventHandler = (void(*)(int,void*))(*(int*)(pAddress+1) + pAddress + 5); InjectHook(0x582EFD, NewFrameRender);
InjectHook(pAddress, NewFrameRender);
InjectHook(0x582EA4, GetTimeSinceLastFrame); InjectHook(0x582EA4, GetTimeSinceLastFrame);
// Default to desktop res // Default to desktop res
@ -458,8 +457,7 @@ void Patch_III_10(const RECT& desktop)
// Reinit CCarCtrl fields (firetruck and ambulance generation) // Reinit CCarCtrl fields (firetruck and ambulance generation)
int pCarCtrlReInit = 0x48C4FB; ReadCall( 0x48C4FB, orgCarCtrlReInit );
orgCarCtrlReInit = (void(*)())(*(int*)(pCarCtrlReInit+1) + pCarCtrlReInit + 5);
InjectHook(0x48C4FB, CarCtrlReInit_SilentPatch); InjectHook(0x48C4FB, CarCtrlReInit_SilentPatch);
@ -607,9 +605,8 @@ void Patch_III_11(const RECT& desktop)
Patch(0x581FB4, &pCustomWndProc); Patch(0x581FB4, &pCustomWndProc);
// (Hopefully) more precise frame limiter // (Hopefully) more precise frame limiter
int pAddress = 0x58323D; ReadCall( 0x58323D, RsEventHandler );
RsEventHandler = (void(*)(int,void*))(*(int*)(pAddress+1) + pAddress + 5); InjectHook(0x58323D, NewFrameRender);
InjectHook(pAddress, NewFrameRender);
InjectHook(0x5831E4, GetTimeSinceLastFrame); InjectHook(0x5831E4, GetTimeSinceLastFrame);
// Default to desktop res // Default to desktop res
@ -630,8 +627,7 @@ void Patch_III_11(const RECT& desktop)
// Reinit CCarCtrl fields (firetruck and ambulance generation) // Reinit CCarCtrl fields (firetruck and ambulance generation)
int pCarCtrlReInit = 0x48C5FB; ReadCall( 0x48C5FB, orgCarCtrlReInit );
orgCarCtrlReInit = (void(*)())(*(int*)(pCarCtrlReInit+1) + pCarCtrlReInit + 5);
InjectHook(0x48C5FB, CarCtrlReInit_SilentPatch); InjectHook(0x48C5FB, CarCtrlReInit_SilentPatch);
@ -765,9 +761,8 @@ void Patch_III_Steam(const RECT& desktop)
Patch(0x581EA4, &pCustomWndProc); Patch(0x581EA4, &pCustomWndProc);
// (Hopefully) more precise frame limiter // (Hopefully) more precise frame limiter
int pAddress = 0x58312D; ReadCall( 0x58312D, RsEventHandler );
RsEventHandler = (void(*)(int,void*))(*(int*)(pAddress+1) + pAddress + 5); InjectHook(0x58312D, NewFrameRender);
InjectHook(pAddress, NewFrameRender);
InjectHook(0x5830D4, GetTimeSinceLastFrame); InjectHook(0x5830D4, GetTimeSinceLastFrame);
// Default to desktop res // Default to desktop res
@ -788,8 +783,7 @@ void Patch_III_Steam(const RECT& desktop)
// Reinit CCarCtrl fields (firetruck and ambulance generation) // Reinit CCarCtrl fields (firetruck and ambulance generation)
int pCarCtrlReInit = 0x48C58B; ReadCall( 0x48C58B, orgCarCtrlReInit );
orgCarCtrlReInit = (void(*)())(*(int*)(pCarCtrlReInit+1) + pCarCtrlReInit + 5);
InjectHook(0x48C58B, CarCtrlReInit_SilentPatch); InjectHook(0x48C58B, CarCtrlReInit_SilentPatch);

View File

@ -939,7 +939,8 @@ void ShaderDetach()
// Function for 1.01 // Function for 1.01
BOOL Initialise3D(void* pParam) BOOL Initialise3D(void* pParam)
{ {
RwBool (*RsRwInitialize)(void*) = (RwBool(*)(void*))(*(int*)0x5BFB93 + 0x5BFB92 + 5); RwBool (*RsRwInitialize)(void*);
Memory::ReadCall( 0x5BFB92, RsRwInitialize);
if ( RsRwInitialize(pParam) ) if ( RsRwInitialize(pParam) )
return ShaderAttach(); return ShaderAttach();
return false; return false;
@ -1975,7 +1976,7 @@ BOOL InjectDelayedPatches_10()
if ( !bSAMP ) if ( !bSAMP )
{ {
DoSunAndMoon = (void(*)())(*(int*)0x53C137 + 0x53C136 + 5); ReadCall( 0x53C136, DoSunAndMoon );
InjectHook(0x53C136, SunAndMoonFarClip); InjectHook(0x53C136, SunAndMoonFarClip);
Patch<const void*>(0x6FC5AA, &fSunFarClip); Patch<const void*>(0x6FC5AA, &fSunFarClip);
} }
@ -2021,9 +2022,9 @@ BOOL InjectDelayedPatches_10()
{ {
// Shaders! // Shaders!
// plugin-sdk compatibility // plugin-sdk compatibility
InitialiseRenderWare = (bool(*)())(*(int*)0x5BF3A2 + 0x5BF3A1 + 5); ReadCall( 0x5BF3A1, InitialiseRenderWare );
ShutdownRenderWare = (void(*)())(*(int*)0x53D911 + 0x53D910 + 5); ReadCall( 0x53D910, ShutdownRenderWare );
sub_5DA6A0 = (void(*)(void*,void*,void*,void*))(*(int*)0x5D66F2 + 0x5D66F1 + 5); ReadCall( 0x5D66F1, sub_5DA6A0 );
InjectHook(0x5DA743, SetShader); InjectHook(0x5DA743, SetShader);
InjectHook(0x5D66F1, SetShader2); InjectHook(0x5D66F1, SetShader2);
@ -2065,8 +2066,8 @@ BOOL InjectDelayedPatches_10()
InjectHook(0x470B05, &CRunningScript::GetDay_GymGlitch, PATCH_CALL); InjectHook(0x470B05, &CRunningScript::GetDay_GymGlitch, PATCH_CALL);
// Basketball fix // Basketball fix
WipeLocalVariableMemoryForMissionScript = (void(*)())(*(int*)0x489A71 + 0x489A70 + 5); ReadCall( 0x489A70, WipeLocalVariableMemoryForMissionScript );
TheScriptsLoad = (void(*)())(*(int*)0x5D18F1 + 0x5D18F0 + 5); ReadCall( 0x5D18F0, TheScriptsLoad );
InjectHook(0x5D18F0, TheScriptsLoad_BasketballFix); InjectHook(0x5D18F0, TheScriptsLoad_BasketballFix);
// Fixed for Hoodlum // Fixed for Hoodlum
InjectHook(0x489A70, StartNewMission_SCMFixes); InjectHook(0x489A70, StartNewMission_SCMFixes);
@ -2203,7 +2204,7 @@ BOOL InjectDelayedPatches_11()
if ( !bSAMP ) if ( !bSAMP )
{ {
DoSunAndMoon = (void(*)())(*(int*)0x53C5D7 + 0x53C5D6 + 5); ReadCall( 0x53C5D6, DoSunAndMoon );
InjectHook(0x53C5D6, SunAndMoonFarClip); InjectHook(0x53C5D6, SunAndMoonFarClip);
Patch<const void*>(0x6FCDDA, &fSunFarClip); Patch<const void*>(0x6FCDDA, &fSunFarClip);
@ -2251,9 +2252,9 @@ BOOL InjectDelayedPatches_11()
// Shaders! // Shaders!
// plugin-sdk compatibility // plugin-sdk compatibility
// 1.01 needs to reverse Initialise3D // 1.01 needs to reverse Initialise3D
InitialiseRenderWare = (bool(*)())(*(int*)0x5BFB9F + 0x5BFB9E + 5); ReadCall( 0x5BFB9E, InitialiseRenderWare );
ShutdownRenderWare = (void(*)())(*(int*)0x53DDB1 + 0x53DDB0 + 5); ReadCall( 0x53DDB0, ShutdownRenderWare );
sub_5DA6A0 = (void(*)(void*,void*,void*,void*))(*(int*)0x5D6ED2 + 0x5D6ED1 + 5); ReadCall( 0x5D6ED1, sub_5DA6A0 );
InjectHook(0x5BFB70, Initialise3D, PATCH_JUMP); InjectHook(0x5BFB70, Initialise3D, PATCH_JUMP);
InjectHook(0x5D6ED1, SetShader2); InjectHook(0x5D6ED1, SetShader2);
@ -2309,8 +2310,8 @@ BOOL InjectDelayedPatches_11()
InjectHook(0x470B85, &CRunningScript::GetDay_GymGlitch, PATCH_CALL); InjectHook(0x470B85, &CRunningScript::GetDay_GymGlitch, PATCH_CALL);
// Basketball fix // Basketball fix
WipeLocalVariableMemoryForMissionScript = (void(*)())(*(int*)0x489AF1 + 0x489AF0 + 5); ReadCall( 0x489AF0, WipeLocalVariableMemoryForMissionScript );
TheScriptsLoad = (void(*)())(*(int*)0x5D20D1 + 0x5D20D0 + 5); ReadCall( 0x5D20D0, TheScriptsLoad );
InjectHook(0x5D20D0, TheScriptsLoad_BasketballFix); InjectHook(0x5D20D0, TheScriptsLoad_BasketballFix);
// Fixed for Hoodlum // Fixed for Hoodlum
InjectHook(0x489A70, StartNewMission_SCMFixes); InjectHook(0x489A70, StartNewMission_SCMFixes);
@ -2428,7 +2429,7 @@ BOOL InjectDelayedPatches_Steam()
if ( !bSAMP ) if ( !bSAMP )
{ {
DoSunAndMoon = (void(*)())(*(int*)0x54E0B7 + 0x54E0B6 + 5); ReadCall( 0x54E0B6, DoSunAndMoon );
InjectHook(0x54E0B6, SunAndMoonFarClip); InjectHook(0x54E0B6, SunAndMoonFarClip);
Patch<const void*>(0x734DEA, &fSunFarClip); Patch<const void*>(0x734DEA, &fSunFarClip);
@ -2475,9 +2476,9 @@ BOOL InjectDelayedPatches_Steam()
{ {
// Shaders! // Shaders!
// plugin-sdk compatibility // plugin-sdk compatibility
InitialiseRenderWare = (bool(*)())(*(int*)0x5DE5A2 + 0x5DE5A1 + 5); ReadCall( 0x5DE5A1, InitialiseRenderWare );
ShutdownRenderWare = (void(*)())(*(int*)0x550071 + 0x550070 + 5); ReadCall( 0x550070, ShutdownRenderWare );
sub_5DA6A0 = (void(*)(void*,void*,void*,void*))(*(int*)0x5F663F + 0x5F663E + 5); ReadCall( 0x5F663E, sub_5DA6A0 );
InjectHook(0x5F6EB3, SetShader); InjectHook(0x5F6EB3, SetShader);
InjectHook(0x5F2F02, SetShader2); InjectHook(0x5F2F02, SetShader2);
@ -2521,8 +2522,8 @@ BOOL InjectDelayedPatches_Steam()
InjectHook(0x476C2C, &CRunningScript::GetDay_GymGlitch, PATCH_CALL); InjectHook(0x476C2C, &CRunningScript::GetDay_GymGlitch, PATCH_CALL);
// Basketball fix // Basketball fix
WipeLocalVariableMemoryForMissionScript = (void(*)())(*(int*)0x4907AF + 0x4907AE + 5); ReadCall( 0x4907AE, WipeLocalVariableMemoryForMissionScript );
TheScriptsLoad = (void(*)())(*(int*)0x5EE018 + 0x5EE017 + 5); ReadCall( 0x5EE017, TheScriptsLoad );
InjectHook(0x5EE017, TheScriptsLoad_BasketballFix); InjectHook(0x5EE017, TheScriptsLoad_BasketballFix);
// Fixed for Hoodlum // Fixed for Hoodlum
InjectHook(0x4907AE, StartNewMission_SCMFixes); InjectHook(0x4907AE, StartNewMission_SCMFixes);
@ -2619,7 +2620,7 @@ void Patch_SA_10()
// IsAlreadyRunning needs to be read relatively late - the later, the better // IsAlreadyRunning needs to be read relatively late - the later, the better
int pIsAlreadyRunning = AddressByRegion_10<int>(0x74872D); int pIsAlreadyRunning = AddressByRegion_10<int>(0x74872D);
IsAlreadyRunning = (BOOL(*)())(*(int*)(pIsAlreadyRunning+1) + pIsAlreadyRunning + 5); ReadCall( pIsAlreadyRunning, IsAlreadyRunning );
InjectHook(pIsAlreadyRunning, InjectDelayedPatches_10); InjectHook(pIsAlreadyRunning, InjectDelayedPatches_10);
// Newsteam crash fix // Newsteam crash fix
@ -2628,7 +2629,7 @@ void Patch_SA_10()
// (Hopefully) more precise frame limiter // (Hopefully) more precise frame limiter
int pAddress = AddressByRegion_10<int>(0x748D9B); int pAddress = AddressByRegion_10<int>(0x748D9B);
RsEventHandler = (void(*)(int,void*))(*(int*)(pAddress+1) + pAddress + 5); ReadCall( pAddress, RsEventHandler );
InjectHook(pAddress, NewFrameRender); InjectHook(pAddress, NewFrameRender);
InjectHook(AddressByRegion_10<int>(0x748D1F), GetTimeSinceLastFrame); InjectHook(AddressByRegion_10<int>(0x748D1F), GetTimeSinceLastFrame);
@ -2927,19 +2928,16 @@ void Patch_SA_10()
Patch<BYTE>(AddressByRegion_10<BYTE*>(0x7F60C6), 0xEB); Patch<BYTE>(AddressByRegion_10<BYTE*>(0x7F60C6), 0xEB);
Patch<WORD>(AddressByRegion_10<BYTE*>(0x7F6683), 0xE990); Patch<WORD>(AddressByRegion_10<BYTE*>(0x7F6683), 0xE990);
int pGetMaxMultiSamplingLevels = 0x57D136; ReadCall( 0x57D136, orgGetMaxMultiSamplingLevels );
orgGetMaxMultiSamplingLevels = (RwUInt32(*)())(*(int*)(pGetMaxMultiSamplingLevels+1) + pGetMaxMultiSamplingLevels + 5);
InjectHook(0x57D136, GetMaxMultiSamplingLevels); InjectHook(0x57D136, GetMaxMultiSamplingLevels);
InjectHook(0x57D0EA, GetMaxMultiSamplingLevels); InjectHook(0x57D0EA, GetMaxMultiSamplingLevels);
int pChangeMultiSamplingLevels = 0x5744FD; ReadCall( 0x5744FD, orgChangeMultiSamplingLevels );
orgChangeMultiSamplingLevels = (void(*)(RwUInt32))(*(int*)(pChangeMultiSamplingLevels+1) + pChangeMultiSamplingLevels + 5);
InjectHook(0x5744FD, ChangeMultiSamplingLevels); InjectHook(0x5744FD, ChangeMultiSamplingLevels);
InjectHook(0x57D162, ChangeMultiSamplingLevels); InjectHook(0x57D162, ChangeMultiSamplingLevels);
InjectHook(0x57D2A6, ChangeMultiSamplingLevels); InjectHook(0x57D2A6, ChangeMultiSamplingLevels);
int pSetMultiSamplingLevels = 0x746350; ReadCall( 0x746350, orgSetMultiSamplingLevels );
orgSetMultiSamplingLevels = (void(*)(RwUInt32))(*(int*)(pSetMultiSamplingLevels+1) + pSetMultiSamplingLevels + 5);
InjectHook(0x746350, SetMultiSamplingLevels); InjectHook(0x746350, SetMultiSamplingLevels);
Nop(0x57A0FC, 1); Nop(0x57A0FC, 1);
@ -2960,7 +2958,7 @@ void Patch_SA_10()
pHoodlumCompat = 0x40F870; pHoodlumCompat = 0x40F870;
int pMemMgrMalloc = pHoodlumCompat + 0x63; int pMemMgrMalloc = pHoodlumCompat + 0x63;
orgMemMgrMalloc = (void*(*)(RwUInt32,RwUInt32))(*(int*)(pMemMgrMalloc+1) + pMemMgrMalloc + 5); ReadCall( pMemMgrMalloc, orgMemMgrMalloc );
InjectHook(pMemMgrMalloc, CollisionData_MallocAndInit); InjectHook(pMemMgrMalloc, CollisionData_MallocAndInit);
} }
{ {
@ -2977,7 +2975,7 @@ void Patch_SA_10()
} }
int pNewAlloc = pHoodlumCompat + 0xC; int pNewAlloc = pHoodlumCompat + 0xC;
orgNewAlloc = (void*(*)(size_t))(*(int*)(pNewAlloc+1) + pNewAlloc + 5); ReadCall( pNewAlloc, orgNewAlloc );
InjectHook(pHoodlumCompat + 0xC, CollisionData_NewAndInit); InjectHook(pHoodlumCompat + 0xC, CollisionData_NewAndInit);
InjectHook(pHoodlumCompat2 + 0xD, CollisionData_NewAndInit); InjectHook(pHoodlumCompat2 + 0xD, CollisionData_NewAndInit);
} }
@ -2988,15 +2986,13 @@ void Patch_SA_10()
// starting again in maximum resolution on secondary monitor. // starting again in maximum resolution on secondary monitor.
// Secondary monitor maximum resolution had to be greater than maximum resolution of primary monitor. // Secondary monitor maximum resolution had to be greater than maximum resolution of primary monitor.
// Not in 1.01 // Not in 1.01
int pGetNumVideoModes = 0x745B1E; ReadCall( 0x745B1E, orgGetNumVideoModes );
orgGetNumVideoModes = (RwInt32(*)())(*(int*)(pGetNumVideoModes+1) + pGetNumVideoModes + 5);
InjectHook(0x745B1E, GetNumVideoModes_Store); InjectHook(0x745B1E, GetNumVideoModes_Store);
InjectHook(0x745A81, GetNumVideoModes_Retrieve); InjectHook(0x745A81, GetNumVideoModes_Retrieve);
// Fixed escalators crash // Fixed escalators crash
int pUpdateEscalators = 0x7185B5; ReadCall( 0x7185B5, orgEscalatorsUpdate );
orgEscalatorsUpdate = (void(*)())(*(int*)(pUpdateEscalators+1) + pUpdateEscalators + 5);
InjectHook(0x7185B5, UpdateEscalators); InjectHook(0x7185B5, UpdateEscalators);
InjectHook(0x71791F, &CEscalator::SwitchOffNoRemove); InjectHook(0x71791F, &CEscalator::SwitchOffNoRemove);
@ -3037,12 +3033,12 @@ void Patch_SA_11()
// IsAlreadyRunning needs to be read relatively late - the later, the better // IsAlreadyRunning needs to be read relatively late - the later, the better
int pIsAlreadyRunning = AddressByRegion_11<int>(0x749000); int pIsAlreadyRunning = AddressByRegion_11<int>(0x749000);
IsAlreadyRunning = (BOOL(*)())(*(int*)(pIsAlreadyRunning+1) + pIsAlreadyRunning + 5); ReadCall( pIsAlreadyRunning, IsAlreadyRunning );
InjectHook(pIsAlreadyRunning, InjectDelayedPatches_11); InjectHook(pIsAlreadyRunning, InjectDelayedPatches_11);
// (Hopefully) more precise frame limiter // (Hopefully) more precise frame limiter
int pAddress = AddressByRegion_11<int>(0x7496A0); int pAddress = AddressByRegion_11<int>(0x7496A0);
RsEventHandler = (void(*)(int,void*))(*(int*)(pAddress+1) + pAddress + 5); ReadCall( pAddress, RsEventHandler );
InjectHook(pAddress, NewFrameRender); InjectHook(pAddress, NewFrameRender);
InjectHook(AddressByRegion_11<int>(0x749624), GetTimeSinceLastFrame); InjectHook(AddressByRegion_11<int>(0x749624), GetTimeSinceLastFrame);
@ -3328,19 +3324,16 @@ void Patch_SA_11()
Patch<BYTE>(AddressByRegion_11<BYTE*>(0x7F69C6), 0xEB); Patch<BYTE>(AddressByRegion_11<BYTE*>(0x7F69C6), 0xEB);
Patch<WORD>(AddressByRegion_11<BYTE*>(0x7F6F83), 0xE990); Patch<WORD>(AddressByRegion_11<BYTE*>(0x7F6F83), 0xE990);
int pGetMaxMultiSamplingLevels = 0x57D916; ReadCall( 0x57D916, orgGetMaxMultiSamplingLevels );
orgGetMaxMultiSamplingLevels = (RwUInt32(*)())(*(int*)(pGetMaxMultiSamplingLevels+1) + pGetMaxMultiSamplingLevels + 5);
InjectHook(0x57D916, GetMaxMultiSamplingLevels); InjectHook(0x57D916, GetMaxMultiSamplingLevels);
InjectHook(0x57D8CA, GetMaxMultiSamplingLevels); InjectHook(0x57D8CA, GetMaxMultiSamplingLevels);
int pChangeMultiSamplingLevels = 0x574A6D; ReadCall( 0x574A6D, orgChangeMultiSamplingLevels );
orgChangeMultiSamplingLevels = (void(*)(RwUInt32))(*(int*)(pChangeMultiSamplingLevels+1) + pChangeMultiSamplingLevels + 5);
InjectHook(0x574A6D, ChangeMultiSamplingLevels); InjectHook(0x574A6D, ChangeMultiSamplingLevels);
InjectHook(0x57D942, ChangeMultiSamplingLevels); InjectHook(0x57D942, ChangeMultiSamplingLevels);
InjectHook(0x57DA86, ChangeMultiSamplingLevels); InjectHook(0x57DA86, ChangeMultiSamplingLevels);
int pSetMultiSamplingLevels = 0x746BD0; ReadCall( 0x746BD0, orgSetMultiSamplingLevels );
orgSetMultiSamplingLevels = (void(*)(RwUInt32))(*(int*)(pSetMultiSamplingLevels+1) + pSetMultiSamplingLevels + 5);
InjectHook(0x746BD0, SetMultiSamplingLevels); InjectHook(0x746BD0, SetMultiSamplingLevels);
Nop(0x57A66C, 1); Nop(0x57A66C, 1);
@ -3380,13 +3373,12 @@ void Patch_SA_Steam()
ScopedUnprotect::Section Protect2( (HINSTANCE)0x400000, ".rdata" ); ScopedUnprotect::Section Protect2( (HINSTANCE)0x400000, ".rdata" );
// IsAlreadyRunning needs to be read relatively late - the later, the better // IsAlreadyRunning needs to be read relatively late - the later, the better
IsAlreadyRunning = (BOOL(*)())(*(int*)(0x7826ED+1) + 0x7826ED + 5); ReadCall( 0x7826ED, IsAlreadyRunning );
InjectHook(0x7826ED, InjectDelayedPatches_Steam); InjectHook(0x7826ED, InjectDelayedPatches_Steam);
// (Hopefully) more precise frame limiter // (Hopefully) more precise frame limiter
int pAddress = 0x782D25; ReadCall( 0x782D25, RsEventHandler );
RsEventHandler = (void(*)(int,void*))(*(int*)(pAddress+1) + pAddress + 5); InjectHook(0x782D25, NewFrameRender);
InjectHook(pAddress, NewFrameRender);
InjectHook(0x782CA8, GetTimeSinceLastFrame); InjectHook(0x782CA8, GetTimeSinceLastFrame);
// Set CAEDataStream to use an old structure // Set CAEDataStream to use an old structure
@ -3641,19 +3633,16 @@ void Patch_SA_Steam()
Patch<BYTE>(0x830086, 0xEB); Patch<BYTE>(0x830086, 0xEB);
Patch<WORD>(0x830643, 0xE990); Patch<WORD>(0x830643, 0xE990);
int pGetMaxMultiSamplingLevels = 0x592BCF; ReadCall( 0x592BCF, orgGetMaxMultiSamplingLevels );
orgGetMaxMultiSamplingLevels = (RwUInt32(*)())(*(int*)(pGetMaxMultiSamplingLevels+1) + pGetMaxMultiSamplingLevels + 5);
InjectHook(0x592BCF, GetMaxMultiSamplingLevels); InjectHook(0x592BCF, GetMaxMultiSamplingLevels);
InjectHook(0x592B81, GetMaxMultiSamplingLevels); InjectHook(0x592B81, GetMaxMultiSamplingLevels);
int pChangeMultiSamplingLevels = 0x5897CD; ReadCall( 0x5897CD, orgChangeMultiSamplingLevels );
orgChangeMultiSamplingLevels = (void(*)(RwUInt32))(*(int*)(pChangeMultiSamplingLevels+1) + pChangeMultiSamplingLevels + 5);
InjectHook(0x5897CD, ChangeMultiSamplingLevels); InjectHook(0x5897CD, ChangeMultiSamplingLevels);
InjectHook(0x592BFB, ChangeMultiSamplingLevels); InjectHook(0x592BFB, ChangeMultiSamplingLevels);
InjectHook(0x592D2E, ChangeMultiSamplingLevels); InjectHook(0x592D2E, ChangeMultiSamplingLevels);
int pSetMultiSamplingLevels = 0x780206; ReadCall( 0x780206, orgSetMultiSamplingLevels );
orgSetMultiSamplingLevels = (void(*)(RwUInt32))(*(int*)(pSetMultiSamplingLevels+1) + pSetMultiSamplingLevels + 5);
InjectHook(0x780206, SetMultiSamplingLevels); InjectHook(0x780206, SetMultiSamplingLevels);
Patch<WORD>(0x58F88C, 0xBA90); Patch<WORD>(0x58F88C, 0xBA90);
@ -3666,12 +3655,10 @@ void Patch_SA_Steam()
// Car explosion crash with multimonitor // Car explosion crash with multimonitor
// Unitialized collision data breaking stencil shadows // Unitialized collision data breaking stencil shadows
int pMemMgrMalloc = 0x41A216; ReadCall( 0x41A216, orgMemMgrMalloc );
orgMemMgrMalloc = (void*(*)(RwUInt32,RwUInt32))(*(int*)(pMemMgrMalloc+1) + pMemMgrMalloc + 5);
InjectHook(0x41A216, CollisionData_MallocAndInit); InjectHook(0x41A216, CollisionData_MallocAndInit);
int pNewAlloc = 0x41A07C; ReadCall( 0x41A07C, orgNewAlloc );
orgNewAlloc = (void*(*)(size_t))(*(int*)(pNewAlloc+1) + pNewAlloc + 5);
InjectHook(0x41A07C, CollisionData_NewAndInit); InjectHook(0x41A07C, CollisionData_NewAndInit);
InjectHook(0x41A159, CollisionData_NewAndInit); InjectHook(0x41A159, CollisionData_NewAndInit);
@ -3681,15 +3668,13 @@ void Patch_SA_Steam()
// starting again in maximum resolution on secondary monitor. // starting again in maximum resolution on secondary monitor.
// Secondary monitor maximum resolution had to be greater than maximum resolution of primary monitor. // Secondary monitor maximum resolution had to be greater than maximum resolution of primary monitor.
// Not in 1.01 // Not in 1.01
int pGetNumVideoModes = 0x77F99E; ReadCall( 0x77F99E, orgGetNumVideoModes );
orgGetNumVideoModes = (RwInt32(*)())(*(int*)(pGetNumVideoModes+1) + pGetNumVideoModes + 5);
InjectHook(0x77F99E, GetNumVideoModes_Store); InjectHook(0x77F99E, GetNumVideoModes_Store);
InjectHook(0x77F901, GetNumVideoModes_Retrieve); InjectHook(0x77F901, GetNumVideoModes_Retrieve);
// Fixed escalators crash // Fixed escalators crash
int pUpdateEscalators = 0x739975; ReadCall( 0x739975, orgEscalatorsUpdate );
orgEscalatorsUpdate = (void(*)())(*(int*)(pUpdateEscalators+1) + pUpdateEscalators + 5);
InjectHook(0x739975, UpdateEscalators); InjectHook(0x739975, UpdateEscalators);
InjectHook(0x738BBD, &CEscalator::SwitchOffNoRemove); InjectHook(0x738BBD, &CEscalator::SwitchOffNoRemove);
@ -3827,8 +3812,7 @@ void Patch_SA_NewSteam_r2()
ScopedUnprotect::Section Protect2( GetModuleHandle( nullptr ), ".rdata" ); ScopedUnprotect::Section Protect2( GetModuleHandle( nullptr ), ".rdata" );
// (Hopefully) more precise frame limiter // (Hopefully) more precise frame limiter
int pAddress = DynBaseAddress(0x77D55F); ReadCall( DynBaseAddress(0x77D55F), RsEventHandler );
RsEventHandler = (void(*)(int,void*))(*(int*)(pAddress+1) + pAddress + 5);
InjectHook(0x77D55F, NewFrameRender); InjectHook(0x77D55F, NewFrameRender);
InjectHook(0x77D4E8, GetTimeSinceLastFrame); InjectHook(0x77D4E8, GetTimeSinceLastFrame);
@ -3930,19 +3914,16 @@ void Patch_SA_NewSteam_r2()
Patch<BYTE>(0x82A916, 0xEB); Patch<BYTE>(0x82A916, 0xEB);
Patch<WORD>(0x82AED3, 0xE990); Patch<WORD>(0x82AED3, 0xE990);
int pGetMaxMultiSamplingLevels = DynBaseAddress(0x590F8B); ReadCall( DynBaseAddress(0x590F8B), orgGetMaxMultiSamplingLevels );
orgGetMaxMultiSamplingLevels = (RwUInt32(*)())(*(int*)(pGetMaxMultiSamplingLevels+1) + pGetMaxMultiSamplingLevels + 5);
InjectHook(0x590F8B, GetMaxMultiSamplingLevels); InjectHook(0x590F8B, GetMaxMultiSamplingLevels);
InjectHook(0x590F36, GetMaxMultiSamplingLevels); InjectHook(0x590F36, GetMaxMultiSamplingLevels);
int pChangeMultiSamplingLevels = DynBaseAddress(0x5881C0); ReadCall( DynBaseAddress(0x5881C0), orgChangeMultiSamplingLevels );
orgChangeMultiSamplingLevels = (void(*)(RwUInt32))(*(int*)(pChangeMultiSamplingLevels+1) + pChangeMultiSamplingLevels + 5);
InjectHook(0x5881C0, ChangeMultiSamplingLevels); InjectHook(0x5881C0, ChangeMultiSamplingLevels);
InjectHook(0x590FBB, ChangeMultiSamplingLevels); InjectHook(0x590FBB, ChangeMultiSamplingLevels);
InjectHook(0x591111, ChangeMultiSamplingLevels); InjectHook(0x591111, ChangeMultiSamplingLevels);
int pSetMultiSamplingLevels = DynBaseAddress(0x77A40D); ReadCall( DynBaseAddress(0x77A40D), orgSetMultiSamplingLevels );
orgSetMultiSamplingLevels = (void(*)(RwUInt32))(*(int*)(pSetMultiSamplingLevels+1) + pSetMultiSamplingLevels + 5);
InjectHook(0x77A40D, SetMultiSamplingLevels); InjectHook(0x77A40D, SetMultiSamplingLevels);
Patch<WORD>(0x58DDEF, 0xBA90); Patch<WORD>(0x58DDEF, 0xBA90);
@ -3955,12 +3936,10 @@ void Patch_SA_NewSteam_r2()
// Car explosion crash with multimonitor // Car explosion crash with multimonitor
// Unitialized collision data breaking stencil shadows // Unitialized collision data breaking stencil shadows
int pMemMgrMalloc = DynBaseAddress(0x41A661); ReadCall( DynBaseAddress(0x41A661), orgMemMgrMalloc );
orgMemMgrMalloc = (void*(*)(RwUInt32,RwUInt32))(*(int*)(pMemMgrMalloc+1) + pMemMgrMalloc + 5);
InjectHook(0x41A661, CollisionData_MallocAndInit); InjectHook(0x41A661, CollisionData_MallocAndInit);
int pNewAlloc = DynBaseAddress(0x41A4CC); ReadCall( DynBaseAddress(0x41A4CC), orgNewAlloc );
orgNewAlloc = (void*(*)(size_t))(*(int*)(pNewAlloc+1) + pNewAlloc + 5);
InjectHook(0x41A4CC, CollisionData_NewAndInit); InjectHook(0x41A4CC, CollisionData_NewAndInit);
InjectHook(0x41A5A9, CollisionData_NewAndInit); InjectHook(0x41A5A9, CollisionData_NewAndInit);
@ -3970,8 +3949,7 @@ void Patch_SA_NewSteam_r2()
// starting again in maximum resolution on secondary monitor. // starting again in maximum resolution on secondary monitor.
// Secondary monitor maximum resolution had to be greater than maximum resolution of primary monitor. // Secondary monitor maximum resolution had to be greater than maximum resolution of primary monitor.
// Not in 1.01 // Not in 1.01
int pGetNumVideoModes = DynBaseAddress(0x779B71); ReadCall( DynBaseAddress(0x779B71), orgGetNumVideoModes );
orgGetNumVideoModes = (RwInt32(*)())(*(int*)(pGetNumVideoModes+1) + pGetNumVideoModes + 5);
InjectHook(0x779B71, GetNumVideoModes_Store); InjectHook(0x779B71, GetNumVideoModes_Store);
InjectHook(0x779AD1, GetNumVideoModes_Retrieve); InjectHook(0x779AD1, GetNumVideoModes_Retrieve);
@ -4023,8 +4001,7 @@ void Patch_SA_NewSteam_r2_lv()
ScopedUnprotect::Section Protect2( GetModuleHandle( nullptr ), ".rdata" ); ScopedUnprotect::Section Protect2( GetModuleHandle( nullptr ), ".rdata" );
// (Hopefully) more precise frame limiter // (Hopefully) more precise frame limiter
int pAddress = DynBaseAddress(0x77D44F); ReadCall( DynBaseAddress(0x77D44F), RsEventHandler );
RsEventHandler = (void(*)(int,void*))(*(int*)(pAddress+1) + pAddress + 5);
InjectHook(0x77D44F, NewFrameRender); InjectHook(0x77D44F, NewFrameRender);
InjectHook(0x77D3D8, GetTimeSinceLastFrame); InjectHook(0x77D3D8, GetTimeSinceLastFrame);
@ -4126,19 +4103,16 @@ void Patch_SA_NewSteam_r2_lv()
Patch<BYTE>(0x82A7E6, 0xEB); Patch<BYTE>(0x82A7E6, 0xEB);
Patch<WORD>(0x82ADA3, 0xE990); Patch<WORD>(0x82ADA3, 0xE990);
int pGetMaxMultiSamplingLevels = DynBaseAddress(0x590ECB); ReadCall( DynBaseAddress(0x590ECB), orgGetMaxMultiSamplingLevels );
orgGetMaxMultiSamplingLevels = (RwUInt32(*)())(*(int*)(pGetMaxMultiSamplingLevels+1) + pGetMaxMultiSamplingLevels + 5);
InjectHook(0x590ECB, GetMaxMultiSamplingLevels); InjectHook(0x590ECB, GetMaxMultiSamplingLevels);
InjectHook(0x590E76, GetMaxMultiSamplingLevels); InjectHook(0x590E76, GetMaxMultiSamplingLevels);
int pChangeMultiSamplingLevels = DynBaseAddress(0x588100); ReadCall( DynBaseAddress(0x588100), orgChangeMultiSamplingLevels );
orgChangeMultiSamplingLevels = (void(*)(RwUInt32))(*(int*)(pChangeMultiSamplingLevels+1) + pChangeMultiSamplingLevels + 5);
InjectHook(0x588100, ChangeMultiSamplingLevels); InjectHook(0x588100, ChangeMultiSamplingLevels);
InjectHook(0x590EFB, ChangeMultiSamplingLevels); InjectHook(0x590EFB, ChangeMultiSamplingLevels);
InjectHook(0x591051, ChangeMultiSamplingLevels); InjectHook(0x591051, ChangeMultiSamplingLevels);
int pSetMultiSamplingLevels = DynBaseAddress(0x77A2FD); ReadCall( DynBaseAddress(0x77A2FD), orgSetMultiSamplingLevels );
orgSetMultiSamplingLevels = (void(*)(RwUInt32))(*(int*)(pSetMultiSamplingLevels+1) + pSetMultiSamplingLevels + 5);
InjectHook(0x77A2FD, SetMultiSamplingLevels); InjectHook(0x77A2FD, SetMultiSamplingLevels);
Patch<WORD>(0x58DD2F, 0xBA90); Patch<WORD>(0x58DD2F, 0xBA90);
@ -4151,12 +4125,10 @@ void Patch_SA_NewSteam_r2_lv()
// Car explosion crash with multimonitor // Car explosion crash with multimonitor
// Unitialized collision data breaking stencil shadows // Unitialized collision data breaking stencil shadows
int pMemMgrMalloc = DynBaseAddress(0x41A661); ReadCall( DynBaseAddress(0x41A661), orgMemMgrMalloc );
orgMemMgrMalloc = (void*(*)(RwUInt32,RwUInt32))(*(int*)(pMemMgrMalloc+1) + pMemMgrMalloc + 5);
InjectHook(0x41A661, CollisionData_MallocAndInit); InjectHook(0x41A661, CollisionData_MallocAndInit);
int pNewAlloc = DynBaseAddress(0x41A4CC); ReadCall( DynBaseAddress(0x41A4CC), orgNewAlloc );
orgNewAlloc = (void*(*)(size_t))(*(int*)(pNewAlloc+1) + pNewAlloc + 5);
InjectHook(0x41A4CC, CollisionData_NewAndInit); InjectHook(0x41A4CC, CollisionData_NewAndInit);
InjectHook(0x41A5A9, CollisionData_NewAndInit); InjectHook(0x41A5A9, CollisionData_NewAndInit);
@ -4166,8 +4138,7 @@ void Patch_SA_NewSteam_r2_lv()
// starting again in maximum resolution on secondary monitor. // starting again in maximum resolution on secondary monitor.
// Secondary monitor maximum resolution had to be greater than maximum resolution of primary monitor. // Secondary monitor maximum resolution had to be greater than maximum resolution of primary monitor.
// Not in 1.01 // Not in 1.01
int pGetNumVideoModes = DynBaseAddress(0x779A61); ReadCall( DynBaseAddress(0x779A61), orgGetNumVideoModes );
orgGetNumVideoModes = (RwInt32(*)())(*(int*)(pGetNumVideoModes+1) + pGetNumVideoModes + 5);
InjectHook(0x779A61, GetNumVideoModes_Store); InjectHook(0x779A61, GetNumVideoModes_Store);
InjectHook(0x7799C1, GetNumVideoModes_Retrieve); InjectHook(0x7799C1, GetNumVideoModes_Retrieve);

View File

@ -254,9 +254,8 @@ void Patch_VC_10(const RECT& desktop)
Patch<DWORD>(0x601740, 0xC3C030); Patch<DWORD>(0x601740, 0xC3C030);
// (Hopefully) more precise frame limiter // (Hopefully) more precise frame limiter
int pAddress = 0x6004A2; ReadCall( 0x6004A2, RsEventHandler );
RsEventHandler = (void(*)(int,void*))(*(int*)(pAddress+1) + pAddress + 5); InjectHook(0x6004A2, NewFrameRender);
InjectHook(pAddress, NewFrameRender);
InjectHook(0x600449, GetTimeSinceLastFrame); InjectHook(0x600449, GetTimeSinceLastFrame);
// Default to desktop res // Default to desktop res
@ -320,8 +319,7 @@ void Patch_VC_10(const RECT& desktop)
// Reinit CCarCtrl fields (firetruck and ambulance generation) // Reinit CCarCtrl fields (firetruck and ambulance generation)
int pCarCtrlReInit = 0x4A489B; ReadCall( 0x4A489B, orgCarCtrlReInit );
orgCarCtrlReInit = (void(*)())(*(int*)(pCarCtrlReInit+1) + pCarCtrlReInit + 5);
InjectHook(0x4A489B, CarCtrlReInit_SilentPatch); InjectHook(0x4A489B, CarCtrlReInit_SilentPatch);
@ -405,9 +403,8 @@ void Patch_VC_11(const RECT& desktop)
Patch<DWORD>(0x601770, 0xC3C030); Patch<DWORD>(0x601770, 0xC3C030);
// (Hopefully) more precise frame limiter // (Hopefully) more precise frame limiter
int pAddress = 0x6004C2; ReadCall( 0x6004C2, RsEventHandler );
RsEventHandler = (void(*)(int,void*))(*(int*)(pAddress+1) + pAddress + 5); InjectHook(0x6004C2, NewFrameRender);
InjectHook(pAddress, NewFrameRender);
InjectHook(0x600469, GetTimeSinceLastFrame); InjectHook(0x600469, GetTimeSinceLastFrame);
// Default to desktop res // Default to desktop res
@ -471,8 +468,7 @@ void Patch_VC_11(const RECT& desktop)
// Reinit CCarCtrl fields (firetruck and ambulance generation) // Reinit CCarCtrl fields (firetruck and ambulance generation)
int pCarCtrlReInit = 0x4A48BB; ReadCall( 0x4A48BB, orgCarCtrlReInit );
orgCarCtrlReInit = (void(*)())(*(int*)(pCarCtrlReInit+1) + pCarCtrlReInit + 5);
InjectHook(0x4A48BB, CarCtrlReInit_SilentPatch); InjectHook(0x4A48BB, CarCtrlReInit_SilentPatch);
@ -547,9 +543,8 @@ void Patch_VC_Steam(const RECT& desktop)
Patch<DWORD>(0x6013B0, 0xC3C030); Patch<DWORD>(0x6013B0, 0xC3C030);
// (Hopefully) more precise frame limiter // (Hopefully) more precise frame limiter
int pAddress = 0x600102; ReadCall( 0x600102, RsEventHandler );
RsEventHandler = (void(*)(int,void*))(*(int*)(pAddress+1) + pAddress + 5); InjectHook(0x600102, NewFrameRender);
InjectHook(pAddress, NewFrameRender);
InjectHook(0x6000A9, GetTimeSinceLastFrame); InjectHook(0x6000A9, GetTimeSinceLastFrame);
// Default to desktop res // Default to desktop res
@ -612,8 +607,7 @@ void Patch_VC_Steam(const RECT& desktop)
// Reinit CCarCtrl fields (firetruck and ambulance generation) // Reinit CCarCtrl fields (firetruck and ambulance generation)
int pCarCtrlReInit = 0x4A475B; ReadCall( 0x4A475B, orgCarCtrlReInit );
orgCarCtrlReInit = (void(*)())(*(int*)(pCarCtrlReInit+1) + pCarCtrlReInit + 5);
InjectHook(0x4A475B, CarCtrlReInit_SilentPatch); InjectHook(0x4A475B, CarCtrlReInit_SilentPatch);