Fixed widescreen patch for 1.0, 3.0 and newsteam

This commit is contained in:
Silent 2014-11-08 12:36:14 +01:00
parent 260d6a2339
commit 24800b17e2
2 changed files with 27 additions and 18 deletions

View file

@ -2328,7 +2328,8 @@ void Patch_SA_10()
#endif
// Unlocked widescreen resolutions
Patch<DWORD>(0x745B71, 0x9090687D);
//Patch<DWORD>(0x745B71, 0x9090687D);
Patch<DWORD>(0x745B81, 0x9090587D);
Patch<DWORD>(0x74596C, 0x9090127D);
Nop(0x745970, 2);
Nop(0x745B75, 2);
@ -2797,7 +2798,8 @@ void Patch_SA_Steam()
Patch<const void*>(0x734DF0, &dSunMult);
// Unlocked widescreen resolutions
Patch<WORD>(0x77F9F0, 0x6E7d);
//Patch<WORD>(0x77F9F0, 0x6E7D);
Patch<WORD>(0x77F9FC, 0x627D);
Patch<DWORD>(0x77F80B, 0x9090127D);
Nop(0x77F80F, 2);
Nop(0x77F880, 2);
@ -2957,7 +2959,8 @@ void Patch_SA_NewSteam()
Patch<BYTE>(0x53EC4A, 6);
// Unlocked widescreen resolutions
Patch<WORD>(0x779BAD, 0x607D);
//Patch<WORD>(0x779BAD, 0x607D);
Patch<WORD>(0x779BB8, 0x557D);
// TODO: Do the rest
// Disable re-initialization of DirectInput mouse device by the game
@ -2988,11 +2991,11 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
hDLLModule = hinstDLL;
if ( *(DWORD*)(GetModule()+0x458D21) == 0x3539F633) Patch_SA_NewSteam();
if (*(DWORD*)DynBaseAddress(0x82457C) == 0x94BF || *(DWORD*)DynBaseAddress(0x8245BC) == 0x94BF) Patch_SA_10();
else if (*(DWORD*)DynBaseAddress(0x8252FC) == 0x94BF || *(DWORD*)DynBaseAddress(0x82533C) == 0x94BF) Patch_SA_11();
else if (*(DWORD*)DynBaseAddress(0x85EC4A) == 0x94BF) Patch_SA_Steam();
else if (*(DWORD*)0x82457C == 0x94BF || *(DWORD*)0x8245BC == 0x94BF) Patch_SA_10();
else if (*(DWORD*)0x8252FC == 0x94BF || *(DWORD*)0x82533C == 0x94BF) Patch_SA_11();
else if (*(DWORD*)0x85EC4A == 0x94BF) Patch_SA_Steam();
else if ( *(DWORD*)DynBaseAddress(0x858D21) == 0x3539F633) Patch_SA_NewSteam();
else return FALSE;
}

View file

@ -41,6 +41,12 @@ inline ptrdiff_t GetModule()
return (ptrdiff_t)hModule;
}
template<typename AT>
inline AT DynBaseAddress(AT address)
{
return GetModule() - 0x400000 + address;
}
#if defined SILENTPATCH_III_VER
// This function initially detects III version then chooses the address basing on game version
@ -110,33 +116,33 @@ inline T AddressByVersion(DWORD address10, DWORD address11, DWORD addressSteam)
if ( *bVer == -1 )
{
if ( *(DWORD*)(GetModule()+0x458D21) == 0x3539F633 )
if ( *(DWORD*)DynBaseAddress(0x858D21) == 0x3539F633 )
{
*bVer = 3;
*bEuropean = false;
}
else if ( *(DWORD*)0x82457C == 0x94BF )
else if ( *(DWORD*)DynBaseAddress(0x82457C) == 0x94BF )
{
*bVer = 0;
*bEuropean = false;
}
else if ( *(DWORD*)0x8245BC == 0x94BF )
else if ( *(DWORD*)DynBaseAddress(0x8245BC) == 0x94BF )
{
*bVer = 0;
*bEuropean = true;
}
else if ( *(DWORD*)0x8252FC == 0x94BF )
else if ( *(DWORD*)DynBaseAddress(0x8252FC) == 0x94BF )
{
*bVer = 1;
*bEuropean = false;
}
else if ( *(DWORD*)0x82533C == 0x94BF )
else if ( *(DWORD*)DynBaseAddress(0x82533C) == 0x94BF )
{
*bVer = 1;
*bEuropean = true;
}
else if (*(DWORD*)0x85EC4A == 0x94BF )
else if (*(DWORD*)DynBaseAddress(0x85EC4A) == 0x94BF )
{
*bVer = 2;
*bEuropean = false;
@ -288,7 +294,7 @@ namespace Memory
break;
}
*(DWORD*)((DWORD)address + 1) = dwHook - (DWORD)address - 5;
*(ptrdiff_t*)((DWORD)address + 1) = dwHook - (DWORD)address - 5;
}
};
@ -337,7 +343,7 @@ namespace MemoryVP
mov dwHook, eax
}
*(DWORD*)((DWORD)address + 1) = (DWORD)dwHook - (DWORD)address - 5;
*(ptrdiff_t*)((DWORD)address + 1) = (DWORD)dwHook - (DWORD)address - 5;
if ( nType == PATCH_NOTHING )
VirtualProtect((void*)((DWORD)address + 1), 4, dwProtect[0], &dwProtect[1]);
else
@ -349,19 +355,19 @@ namespace MemoryVP
template<typename T, typename AT>
inline void Patch(AT address, T value)
{
MemoryVP::Patch(GetModule() - 0x400000 + address, value);
MemoryVP::Patch(DynBaseAddress(address), value);
}
template<typename AT>
inline void Nop(AT address, unsigned int nCount)
{
MemoryVP::Nop(GetModule() - 0x400000 + address, nCount);
MemoryVP::Nop(DynBaseAddress(address), nCount);
}
template<typename AT, typename HT>
inline void InjectHook(AT address, HT hook, unsigned int nType=PATCH_NOTHING)
{
MemoryVP::InjectHook(GetModule() - 0x400000 + address, hook, nType);
MemoryVP::InjectHook(DynBaseAddress(address), hook, nType);
}
};
};