mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-29 15:23:02 +05:00
SHGetFolderPath on User Files - in SA
This commit is contained in:
parent
2d24b6fee5
commit
403df49335
3 changed files with 155 additions and 9 deletions
|
@ -205,6 +205,118 @@ inline T AddressByVersion(DWORD address10, DWORD address11, DWORD addressSteam)
|
|||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T AddressByVersion(DWORD address10, DWORD address11, DWORD addressSteam, DWORD addressNewsteamR2, DWORD addressNewsteamR2_LV)
|
||||
{
|
||||
signed char* bVer = GetVer();
|
||||
bool* bEuropean = GetEuropean();
|
||||
|
||||
if ( *bVer == -1 )
|
||||
{
|
||||
if ( *(DWORD*)DynBaseAddress(0x82457C) == 0x94BF )
|
||||
{
|
||||
// 1.0 US
|
||||
*bVer = 0;
|
||||
*bEuropean = false;
|
||||
}
|
||||
else if ( *(DWORD*)DynBaseAddress(0x8245BC) == 0x94BF )
|
||||
{
|
||||
// 1.0 EU
|
||||
*bVer = 0;
|
||||
*bEuropean = true;
|
||||
}
|
||||
else if ( *(DWORD*)DynBaseAddress(0x8252FC) == 0x94BF )
|
||||
{
|
||||
// 1.01 US
|
||||
*bVer = 1;
|
||||
*bEuropean = false;
|
||||
}
|
||||
else if ( *(DWORD*)DynBaseAddress(0x82533C) == 0x94BF )
|
||||
{
|
||||
// 1.01 EU
|
||||
*bVer = 1;
|
||||
*bEuropean = true;
|
||||
}
|
||||
else if (*(DWORD*)DynBaseAddress(0x85EC4A) == 0x94BF )
|
||||
{
|
||||
// 3.0
|
||||
*bVer = 2;
|
||||
*bEuropean = false;
|
||||
}
|
||||
|
||||
else if ( *(DWORD*)DynBaseAddress(0x858D21) == 0x3539F633 )
|
||||
{
|
||||
// newsteam r1
|
||||
*bVer = 3;
|
||||
*bEuropean = false;
|
||||
}
|
||||
else if ( *(DWORD*)DynBaseAddress(0x858D51) == 0x3539F633 )
|
||||
{
|
||||
// newsteam r2
|
||||
*bVer = 4;
|
||||
*bEuropean = false;
|
||||
}
|
||||
else if ( *(DWORD*)DynBaseAddress(0x858C61) == 0x3539F633 )
|
||||
{
|
||||
// newsteam r2 lv
|
||||
*bVer = 5;
|
||||
*bEuropean = false;
|
||||
}
|
||||
}
|
||||
|
||||
switch ( *bVer )
|
||||
{
|
||||
case 1:
|
||||
assert(address11);
|
||||
|
||||
// Safety measures - if null, return dummy var pointer to prevent a crash
|
||||
if ( !address11 )
|
||||
return (T)GetDummy();
|
||||
|
||||
// Adjust to US if needed
|
||||
if ( !(*bEuropean) && address11 > 0x746FA0 )
|
||||
{
|
||||
if ( address11 < 0x7BB240 )
|
||||
address11 -= 0x50;
|
||||
else
|
||||
address11 -= 0x40;
|
||||
}
|
||||
return (T)address11;
|
||||
case 2:
|
||||
assert(addressSteam);
|
||||
// Safety measures - if null, return dummy var pointer to prevent a crash
|
||||
if ( !addressSteam )
|
||||
return (T)GetDummy();
|
||||
|
||||
return (T)addressSteam;
|
||||
case 3:
|
||||
return (T)GetDummy();
|
||||
case 4:
|
||||
assert(addressNewsteamR2);
|
||||
if ( !addressNewsteamR2 )
|
||||
return (T)GetDummy();
|
||||
|
||||
return (T)DynBaseAddress(addressNewsteamR2);
|
||||
case 5:
|
||||
assert(addressNewsteamR2_LV);
|
||||
if ( !addressNewsteamR2_LV )
|
||||
return (T)GetDummy();
|
||||
|
||||
return (T)DynBaseAddress(addressNewsteamR2_LV);
|
||||
default:
|
||||
assert(address10);
|
||||
// Adjust to EU if needed
|
||||
if ( *bEuropean && address10 > 0x7466D0 )
|
||||
{
|
||||
if ( address10 < 0x7BA940 )
|
||||
address10 += 0x50;
|
||||
else
|
||||
address10 += 0x40;
|
||||
}
|
||||
return (T)address10;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T AddressByRegion_10(DWORD address10)
|
||||
{
|
||||
|
|
|
@ -67,7 +67,7 @@ RwCamera* RwCameraClear(RwCamera* camera, RwRGBA* colour, RwInt32 clearMode)
|
|||
|
||||
RwFrame* RwFrameForAllChildren(RwFrame* frame, RwFrameCallBack callBack, void* data)
|
||||
{
|
||||
for ( RwFrame* curFrame = frame->child; curFrame; curFrame = curFrame->next )
|
||||
for ( RwFrame* curFrame = frame->child; curFrame != nullptr; curFrame = curFrame->next )
|
||||
{
|
||||
if ( !callBack(curFrame, data) )
|
||||
break;
|
||||
|
@ -661,7 +661,32 @@ void DrawRect_HalfPixel_Steam(CRect& rect, const CRGBA& rgba)
|
|||
((void(*)(const CRect&, const CRGBA&))0x75CDA0)(rect, rgba);
|
||||
}
|
||||
|
||||
static IDirect3DVertexShader9* pNVCShader = nullptr;
|
||||
static char** const ppUserFilesDir = AddressByVersion<char**>(0x74503F, 0x74586F, 0x77EE50, 0x77902B, 0x778F1B);
|
||||
|
||||
char* GetMyDocumentsPath()
|
||||
{
|
||||
static char cUserFilesPath[MAX_PATH];
|
||||
|
||||
if ( cUserFilesPath[0] == '\0' )
|
||||
{
|
||||
char cTmpPath[MAX_PATH];
|
||||
|
||||
SHGetFolderPath(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, cUserFilesPath);
|
||||
PathAppend(cUserFilesPath, *ppUserFilesDir);
|
||||
CreateDirectory(cUserFilesPath, nullptr);
|
||||
|
||||
strcpy(cTmpPath, cUserFilesPath);
|
||||
PathAppend(cTmpPath, "Gallery");
|
||||
CreateDirectory(cTmpPath, nullptr);
|
||||
|
||||
strcpy(cTmpPath, cUserFilesPath);
|
||||
PathAppend(cTmpPath, "User Tracks");
|
||||
CreateDirectory(cTmpPath, nullptr);
|
||||
}
|
||||
return cUserFilesPath;
|
||||
}
|
||||
|
||||
static void* pNVCShader = nullptr;
|
||||
static bool bRenderNVC = false;
|
||||
static RpAtomic* pRenderedAtomic;
|
||||
|
||||
|
@ -2506,6 +2531,9 @@ void Patch_SA_10()
|
|||
Patch<BYTE>(AddressByRegion_10<DWORD>(0x74754A), 0xB8);
|
||||
Patch<DWORD>(AddressByRegion_10<DWORD>(0x74754B), 0x900);
|
||||
|
||||
// SHGetFolderPath on User Files
|
||||
InjectHook(0x744FB0, GetMyDocumentsPath, PATCH_JUMP);
|
||||
|
||||
// Fixed police scanner names
|
||||
char* pScannerNames = *(char**)0x4E72D4;
|
||||
strncpy(pScannerNames + (8*113), "WESTP", 8);
|
||||
|
@ -2750,6 +2778,9 @@ void Patch_SA_11()
|
|||
Patch<BYTE>(AddressByRegion_11<DWORD>(0x747E1A), 0xB8);
|
||||
Patch<DWORD>(AddressByRegion_11<DWORD>(0x747E1B), 0x900);
|
||||
|
||||
// SHGetFolderPath on User Files
|
||||
InjectHook(0x7457E0, GetMyDocumentsPath, PATCH_JUMP);
|
||||
|
||||
// Fixed police scanner names
|
||||
char* pScannerNames = *(char**)0x4E7714;
|
||||
strncpy(pScannerNames + (8*113), "WESTP", 8);
|
||||
|
@ -2973,6 +3004,9 @@ void Patch_SA_Steam()
|
|||
Patch<BYTE>(0x781456, 0xB8);
|
||||
Patch<DWORD>(0x781457, 0x900);
|
||||
|
||||
// SHGetFolderPath on User Files
|
||||
InjectHook(0x77EDC0, GetMyDocumentsPath, PATCH_JUMP);
|
||||
|
||||
// Fixed police scanner names
|
||||
char* pScannerNames = *(char**)0x4F2B83;
|
||||
strncpy(pScannerNames + (8*113), "WESTP", 8);
|
||||
|
@ -3123,6 +3157,9 @@ void Patch_SA_NewSteam_r2()
|
|||
Patch<BYTE>(0x77B46E, 0xB8);
|
||||
Patch<DWORD>(0x77B46F, 0x900);
|
||||
|
||||
// SHGetFolderPath on User Files
|
||||
InjectHook(0x778FA0, GetMyDocumentsPath, PATCH_JUMP);
|
||||
|
||||
// Proper aspect ratios
|
||||
static const float f43 = 4.0f/3.0f, f54 = 5.0f/4.0f, f169 = 16.0f/9.0f;
|
||||
Patch<const void*>(0x73424B, &f169);
|
||||
|
@ -3177,6 +3214,9 @@ void Patch_SA_NewSteam_r2_lv()
|
|||
Patch<BYTE>(0x77B35E, 0xB8);
|
||||
Patch<DWORD>(0x77B35F, 0x900);
|
||||
|
||||
// SHGetFolderPath on User Files
|
||||
InjectHook(0x778E90, GetMyDocumentsPath, PATCH_JUMP);
|
||||
|
||||
// Proper aspect ratios
|
||||
static const float f43 = 4.0f/3.0f, f54 = 5.0f/4.0f, f169 = 16.0f/9.0f;
|
||||
Patch<const void*>(0x73414B, &f169);
|
||||
|
|
|
@ -15,14 +15,8 @@
|
|||
#include <utility>
|
||||
#include <cassert>
|
||||
#include <tuple>
|
||||
|
||||
/*#include <windows.h>
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
#include <mmsystem.h>
|
||||
#include <Shlwapi.h>
|
||||
#include <tuple>
|
||||
#include <cassert>*/
|
||||
#include <ShlObj.h>
|
||||
|
||||
#define RwEngineInstance (*rwengine)
|
||||
|
||||
|
|
Loading…
Reference in a new issue