From cd0fa0f044397c7d0ff7d8ff1365c77437b21885 Mon Sep 17 00:00:00 2001 From: Silent Date: Fri, 22 Aug 2014 00:10:23 +0200 Subject: [PATCH] Working on 1.01 support --- SAFix/AudioHardwareSA.cpp | 2 +- SAFix/GeneralSA.cpp | 12 +++++------ SAFix/ModelInfoSA.cpp | 12 +++++------ SAFix/PNGFile.cpp | 2 +- SAFix/PedSA.cpp | 10 ++++----- SAFix/ScriptSA.cpp | 2 +- SAFix/SilentPatchSA.cpp | 8 +++++++- SAFix/TimerSA.cpp | 2 +- SAFix/VehicleSA.cpp | 4 ++-- SilentPatch/MemoryMgr.h | 43 +++++++++++++++++++++++++++++++++++---- 10 files changed, 69 insertions(+), 28 deletions(-) diff --git a/SAFix/AudioHardwareSA.cpp b/SAFix/AudioHardwareSA.cpp index af96c7b..1d244d1 100644 --- a/SAFix/AudioHardwareSA.cpp +++ b/SAFix/AudioHardwareSA.cpp @@ -5,7 +5,7 @@ // { EAXJMP(0x4DC340); } //WRAPPER HRESULT STDMETHODCALLTYPE CAEDataStream::Stat(STATSTG* pStatstg, DWORD grfStatFlag) { EAXJMP(0x4DC3A0); } -static void* CAEDataStream__Initialise = AddressByVersion(0x4DC2B0, 0, 0x4E7550); +static void* CAEDataStream__Initialise = AddressByVersion(0x4DC2B0, 0x4DC7A0, 0x4E7550); WRAPPER bool CAEDataStream::Initialise() { VARJMP(CAEDataStream__Initialise); } unsigned int CAEStreamingDecoder::nMallocRefCount = 0; diff --git a/SAFix/GeneralSA.cpp b/SAFix/GeneralSA.cpp index 1189df8..cb4bcd0 100644 --- a/SAFix/GeneralSA.cpp +++ b/SAFix/GeneralSA.cpp @@ -4,18 +4,18 @@ #include "PedSA.h" // Wrappers -static void* EntityRender = AddressByVersion(0x534310, 0, 0x545B30); +static void* EntityRender = AddressByVersion(0x534310, 0x5347B0, 0x545B30); WRAPPER void CEntity::Render() { VARJMP(EntityRender); } -static void* varInvertRaster = AddressByVersion(0x705660, 0, 0x7497A0); +static void* varInvertRaster = AddressByVersion(0x705660, 0x705E90, 0x7497A0); WRAPPER void CShadowCamera::InvertRaster() { VARJMP(varInvertRaster); } -CWeaponInfo* (*CWeaponInfo::GetWeaponInfo)(eWeaponType, signed char) = AddressByVersion(0x743C60, 0, 0x77D940); +CWeaponInfo* (*CWeaponInfo::GetWeaponInfo)(eWeaponType, signed char) = AddressByVersion(0x743C60, 0x744490, 0x77D940); -static RwTexture*& ms_pRemapTexture = **AddressByVersion(0x59F1BD, 0, 0x5B811D); -static unsigned char* ms_currentCol = *AddressByVersion(0x4C84C8, 0, 0x4D2DC8); +static RwTexture*& ms_pRemapTexture = **AddressByVersion(0x59F1BD, 0x6D6E53, 0x5B811D); +static unsigned char* ms_currentCol = *AddressByVersion(0x4C84C8, 0x4C86C8, 0x4D2DC8); -auto SetEditableMaterialsCB = AddressByVersion(0x4C83E0, 0, 0x4D2CE0); +auto SetEditableMaterialsCB = AddressByVersion(0x4C83E0, 0x4C8460, 0x4D2CE0); static void SetVehicleColour(unsigned char primaryColour, unsigned char secondaryColour, unsigned char tertiaryColour, unsigned char quaternaryColour) { diff --git a/SAFix/ModelInfoSA.cpp b/SAFix/ModelInfoSA.cpp index f0edf5d..6c46460 100644 --- a/SAFix/ModelInfoSA.cpp +++ b/SAFix/ModelInfoSA.cpp @@ -1,15 +1,15 @@ #include "StdAfxSA.h" #include "ModelInfoSA.h" -static void* BaseModelInfoShutdown = AddressByVersion(0x4C4D50, 0, 0x4CF590); +static void* BaseModelInfoShutdown = AddressByVersion(0x4C4D50, 0x4C4DD0, 0x4CF590); WRAPPER void CBaseModelInfo::Shutdown() { VARJMP(BaseModelInfoShutdown); } -RwTexture* (*CCustomCarPlateMgr::CreatePlateTexture)(const char* pText, signed char nDesign) = AddressByVersion(0x6FDEA0, 0, 0x736AC0); -bool (*CCustomCarPlateMgr::GeneratePlateText)(char* pBuf, int nLen) = AddressByVersion(0x6FD5B0, 0, 0x7360F0); -signed char (*CCustomCarPlateMgr::GetMapRegionPlateDesign)() = AddressByVersion(0x6FD7A0, 0, 0x7363E0); -void (*CCustomCarPlateMgr::SetupMaterialPlatebackTexture)(RpMaterial* pMaterial, signed char nDesign) = AddressByVersion(0x6FDE50, 0, 0x736A80); +RwTexture* (*CCustomCarPlateMgr::CreatePlateTexture)(const char* pText, signed char nDesign) = AddressByVersion(0x6FDEA0, 0x6FE6D0, 0x736AC0); +bool (*CCustomCarPlateMgr::GeneratePlateText)(char* pBuf, int nLen) = AddressByVersion(0x6FD5B0, 0x6FDDE0, 0x7360F0); +signed char (*CCustomCarPlateMgr::GetMapRegionPlateDesign)() = AddressByVersion(0x6FD7A0, 0x6FDFD0, 0x7363E0); +void (*CCustomCarPlateMgr::SetupMaterialPlatebackTexture)(RpMaterial* pMaterial, signed char nDesign) = AddressByVersion(0x6FDE50, 0x6FE680, 0x736A80); -CBaseModelInfo** const ms_modelInfoPtrs = *AddressByVersion(0x509CB1, 0, 0x403DB7); +CBaseModelInfo** const ms_modelInfoPtrs = *AddressByVersion(0x509CB1, 0x4C0C96, 0x403DB7); void CVehicleModelInfo::Shutdown() { diff --git a/SAFix/PNGFile.cpp b/SAFix/PNGFile.cpp index bbe7db2..a5506db 100644 --- a/SAFix/PNGFile.cpp +++ b/SAFix/PNGFile.cpp @@ -24,7 +24,7 @@ RwTexture* CPNGFile::ReadFromFile(const char* pFileName) RwTexture* CPNGFile::ReadFromMemory(const void* pMemory, unsigned int nLen) { - static BYTE* pMem = AddressByVersion(0x7CF9CA, 0, 0x80998A); + static BYTE* pMem = AddressByVersion(0x7CF9CA, 0x7D02CA, 0x80998A); RwTexture* pTexture = nullptr; MemoryVP::Patch(pMem, rwSTREAMMEMORY); diff --git a/SAFix/PedSA.cpp b/SAFix/PedSA.cpp index 6e62313..070033b 100644 --- a/SAFix/PedSA.cpp +++ b/SAFix/PedSA.cpp @@ -1,17 +1,17 @@ #include "StdAfxSA.h" #include "PedSA.h" -static void* varGetWeaponSkill = AddressByVersion(0x5E6580, 0, 0x6039F0); +static void* varGetWeaponSkill = AddressByVersion(0x5E6580, 0x5E6DA0, 0x6039F0); WRAPPER unsigned char CPed::GetWeaponSkill() { VARJMP(varGetWeaponSkill); } -static void* varResetGunFlashAlpha = AddressByVersion(0x5DF4E0, 0, 0x5FC210); +static void* varResetGunFlashAlpha = AddressByVersion(0x5DF4E0, 0x5DFD00, 0x5FC210); WRAPPER void CPed::ResetGunFlashAlpha() { VARJMP(varResetGunFlashAlpha); } -static void* varSetGunFlashAlpha = AddressByVersion(0x5DF400, 0, 0x5FC120); +static void* varSetGunFlashAlpha = AddressByVersion(0x5DF400, 0x5DFC20, 0x5FC120); WRAPPER void CPed::SetGunFlashAlpha(bool bSecondWeapon) { WRAPARG(bSecondWeapon); VARJMP(varSetGunFlashAlpha); } -static void* varGetTaskJetPack = AddressByVersion(0x601110, 0, 0x620E70); +static void* varGetTaskJetPack = AddressByVersion(0x601110, 0x601930, 0x620E70); WRAPPER CTaskSimpleJetPack* CPedIntelligence::GetTaskJetPack() const { VARJMP(varGetTaskJetPack); } -static void* varRenderJetPack = AddressByVersion(0x67F6A0, 0, 0x6AB110); +static void* varRenderJetPack = AddressByVersion(0x67F6A0, 0x67FEC0, 0x6AB110); WRAPPER void CTaskSimpleJetPack::RenderJetPack(CPed* pPed) { WRAPARG(pPed); VARJMP(varRenderJetPack); } static RwObject* GetFirstObjectCallback(RwObject* pObject, void* pData) diff --git a/SAFix/ScriptSA.cpp b/SAFix/ScriptSA.cpp index dff2502..f30fcf0 100644 --- a/SAFix/ScriptSA.cpp +++ b/SAFix/ScriptSA.cpp @@ -1,7 +1,7 @@ #include "StdAfxSA.h" #include "ScriptSA.h" -static int* StatTypesInt = *AddressByVersion(0x55C0D8, 0, 0x574F24); +static int* StatTypesInt = *AddressByVersion(0x55C0D8, 0x55C578, 0x574F24); std::pair* CRunningScript::GetDay_GymGlitch() { diff --git a/SAFix/SilentPatchSA.cpp b/SAFix/SilentPatchSA.cpp index a62bb98..1bfc531 100644 --- a/SAFix/SilentPatchSA.cpp +++ b/SAFix/SilentPatchSA.cpp @@ -1911,6 +1911,12 @@ __forceinline void Patch_SA_10() strncpy(pScannerNames + (8*134), "????", 8); } +__forceinline void Patch_SA_11() +{ + using namespace MemoryVP; + +} + __forceinline void Patch_SA_Steam() { using namespace MemoryVP; @@ -2085,7 +2091,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) hDLLModule = hinstDLL; if (*(DWORD*)0x82457C == 0x94BF || *(DWORD*)0x8245BC == 0x94BF) Patch_SA_10(); - //else if (*(DWORD*)0x8252FC == 0x94BF || *(DWORD*)0x82533C == 0x94BF) Patch_SA_11(); + else if (*(DWORD*)0x8252FC == 0x94BF || *(DWORD*)0x82533C == 0x94BF) Patch_SA_11(); else if (*(DWORD*)0x85EC4A == 0x94BF) Patch_SA_Steam(); else return FALSE; } diff --git a/SAFix/TimerSA.cpp b/SAFix/TimerSA.cpp index 8c45fdd..6f2615f 100644 --- a/SAFix/TimerSA.cpp +++ b/SAFix/TimerSA.cpp @@ -1,4 +1,4 @@ #include "StdAfxSA.h" #include "TimerSA.h" -int& CTimer::m_snTimeInMilliseconds = **AddressByVersion(0x4242D1, 0, 0x406FA1); \ No newline at end of file +int& CTimer::m_snTimeInMilliseconds = **AddressByVersion(0x4242D1, 0x53F6A1, 0x406FA1); \ No newline at end of file diff --git a/SAFix/VehicleSA.cpp b/SAFix/VehicleSA.cpp index e8456f6..bcb33ff 100644 --- a/SAFix/VehicleSA.cpp +++ b/SAFix/VehicleSA.cpp @@ -3,9 +3,9 @@ #include "VehicleSA.h" #include "TimerSA.h" -static void* varVehicleRender = AddressByVersion(0x6D0E60, 0, 0x70C0B0); +static void* varVehicleRender = AddressByVersion(0x6D0E60, 0x6D1680, 0x70C0B0); WRAPPER void CVehicle::Render() { VARJMP(varVehicleRender); } -static void* varIsLawEnforcementVehicle = AddressByVersion(0x6D2370, 0, 0x70D8C0); +static void* varIsLawEnforcementVehicle = AddressByVersion(0x6D2370, 0x6D2BA0, 0x70D8C0); WRAPPER bool CVehicle::IsLawEnforcementVehicle() { VARJMP(varIsLawEnforcementVehicle); } static RwObject* GetCurrentAtomicObjectCB(RwObject* pObject, void* data) diff --git a/SilentPatch/MemoryMgr.h b/SilentPatch/MemoryMgr.h index a5166d9..15dd68d 100644 --- a/SilentPatch/MemoryMgr.h +++ b/SilentPatch/MemoryMgr.h @@ -80,13 +80,13 @@ inline T AddressByVersion(DWORD address10, DWORD address11, DWORD addressSteam) if ( !address11 ) return (T)GetDummy(); - // Adjust to EU if needed - if ( *bEuropean && address11 > 0x746FA0 ) + // Adjust to US if needed + if ( !(*bEuropean) && address11 > 0x746FA0 ) { if ( address11 < 0x7BB240 ) - address11 += 0x50; + address11 -= 0x50; else - address11 += 0x40; + address11 -= 0x40; } return (T)address11; case 2: @@ -145,6 +145,41 @@ inline T AddressByRegion_10(DWORD address10) return (T)address10; } +template +inline T AddressByRegion_11(DWORD address11) +{ + bool* bEuropean = GetEuropean(); + signed char* bVer = GetVer(); + + if ( *bVer == -1 ) + { + if ( *(DWORD*)0x8252FC == 0x94BF ) + { + *bVer = 1; + *bEuropean = false; + } + else if ( *(DWORD*)0x82533C == 0x94BF ) + { + *bVer = 1; + *bEuropean = true; + } + else + { + assert(!"AddressByRegion_11 on non-1.01 EXE!"); + } + } + + // Adjust to US if needed + if ( !(*bEuropean) && address11 > 0x746FA0 ) + { + if ( address11 < 0x7BB240 ) + address11 -= 0x50; + else + address11 -= 0x40; + } + return (T)address11; +} + namespace Memory { template