mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-28 23:03:01 +05:00
III version of User Files fix
This commit is contained in:
parent
785ad0d3ad
commit
2d24b6fee5
6 changed files with 78 additions and 19 deletions
|
@ -170,21 +170,23 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||||
using namespace MemoryVP;
|
using namespace MemoryVP;
|
||||||
DisableThreadLibraryCalls(hinstDLL);
|
DisableThreadLibraryCalls(hinstDLL);
|
||||||
|
|
||||||
// TODO: Offset by a byte, or 5
|
if (*(DWORD*)0x5C1E75 == 0xB85548EC)
|
||||||
if (*(DWORD*)0x5C1E70 == 0x53E58955)
|
|
||||||
{
|
{
|
||||||
// III 1.0
|
// III 1.0
|
||||||
|
ppUserFilesDir = (char**)0x580C16;
|
||||||
|
InjectHook(0x580BB0, GetMyDocumentsPath, PATCH_JUMP);
|
||||||
}
|
}
|
||||||
else if (*(DWORD*)0x5C2130 == 0x53E58955)
|
else if (*(DWORD*)0x5C2135 == 0xB85548EC)
|
||||||
{
|
{
|
||||||
// III 1.1
|
// III 1.1
|
||||||
|
ppUserFilesDir = (char**)0x580F66;
|
||||||
|
InjectHook(0x580F00, GetMyDocumentsPath, PATCH_JUMP);
|
||||||
}
|
}
|
||||||
else if (*(DWORD*)0x5C6FD0 == 0x53E58955)
|
else if (*(DWORD*)0x5C6FD5 == 0xB85548EC)
|
||||||
{
|
{
|
||||||
// III Steam
|
// III Steam
|
||||||
|
ppUserFilesDir = (char**)0x580E66;
|
||||||
|
InjectHook(0x580E00, GetMyDocumentsPath, PATCH_JUMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (*(DWORD*)0x667BF5 == 0xB85548EC)
|
else if (*(DWORD*)0x667BF5 == 0xB85548EC)
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
#include <mmsystem.h>
|
#include <mmsystem.h>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <ShlObj.h>
|
||||||
|
#include <Shlwapi.h>
|
||||||
|
|
||||||
#include "MemoryMgr.h"
|
#include "MemoryMgr.h"
|
||||||
|
|
||||||
|
|
|
@ -219,6 +219,21 @@ void __declspec(naked) SubtitlesShadowFix()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char** const ppUserFilesDir = AddressByVersion<char**>(0x580C16, 0x580F66, 0x580E66);
|
||||||
|
|
||||||
|
char* GetMyDocumentsPath()
|
||||||
|
{
|
||||||
|
static char cUserFilesPath[MAX_PATH];
|
||||||
|
|
||||||
|
if ( cUserFilesPath[0] == '\0' )
|
||||||
|
{
|
||||||
|
SHGetFolderPath(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, cUserFilesPath);
|
||||||
|
PathAppend(cUserFilesPath, *ppUserFilesDir);
|
||||||
|
CreateDirectory(cUserFilesPath, nullptr);
|
||||||
|
}
|
||||||
|
return cUserFilesPath;
|
||||||
|
}
|
||||||
|
|
||||||
static char aNoDesktopMode[64];
|
static char aNoDesktopMode[64];
|
||||||
|
|
||||||
void Patch_III_10(const RECT& desktop)
|
void Patch_III_10(const RECT& desktop)
|
||||||
|
@ -347,6 +362,9 @@ void Patch_III_10(const RECT& desktop)
|
||||||
// No DirectPlay dependency
|
// No DirectPlay dependency
|
||||||
Patch<BYTE>(0x5812D6, 0xB8);
|
Patch<BYTE>(0x5812D6, 0xB8);
|
||||||
Patch<DWORD>(0x5812D7, 0x900);
|
Patch<DWORD>(0x5812D7, 0x900);
|
||||||
|
|
||||||
|
// SHGetFolderPath on User Files
|
||||||
|
InjectHook(0x580BB0, GetMyDocumentsPath, PATCH_JUMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Patch_III_11(const RECT& desktop)
|
void Patch_III_11(const RECT& desktop)
|
||||||
|
@ -469,6 +487,9 @@ void Patch_III_11(const RECT& desktop)
|
||||||
// No DirectPlay dependency
|
// No DirectPlay dependency
|
||||||
Patch<BYTE>(0x581620, 0xB8);
|
Patch<BYTE>(0x581620, 0xB8);
|
||||||
Patch<DWORD>(0x581621, 0x900);
|
Patch<DWORD>(0x581621, 0x900);
|
||||||
|
|
||||||
|
// SHGetFolderPath on User Files
|
||||||
|
InjectHook(0x580E00, GetMyDocumentsPath, PATCH_JUMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Patch_III_Steam(const RECT& desktop)
|
void Patch_III_Steam(const RECT& desktop)
|
||||||
|
@ -587,6 +608,9 @@ void Patch_III_Steam(const RECT& desktop)
|
||||||
// No DirectPlay dependency
|
// No DirectPlay dependency
|
||||||
Patch<BYTE>(0x581520, 0xB8);
|
Patch<BYTE>(0x581520, 0xB8);
|
||||||
Patch<DWORD>(0x581521, 0x900);
|
Patch<DWORD>(0x581521, 0x900);
|
||||||
|
|
||||||
|
// SHGetFolderPath on User Files
|
||||||
|
InjectHook(0x580E00, GetMyDocumentsPath, PATCH_JUMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||||
|
@ -600,9 +624,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||||
GetWindowRect(GetDesktopWindow(), &desktop);
|
GetWindowRect(GetDesktopWindow(), &desktop);
|
||||||
sprintf(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom);
|
sprintf(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom);
|
||||||
|
|
||||||
if (*(DWORD*)0x5C1E70 == 0x53E58955) Patch_III_10(desktop);
|
if (*(DWORD*)0x5C1E75 == 0xB85548EC) Patch_III_10(desktop);
|
||||||
else if (*(DWORD*)0x5C2130 == 0x53E58955) Patch_III_11(desktop);
|
else if (*(DWORD*)0x5C2135 == 0xB85548EC) Patch_III_11(desktop);
|
||||||
else if (*(DWORD*)0x5C6FD0 == 0x53E58955) Patch_III_Steam(desktop);
|
else if (*(DWORD*)0x5C6FD5 == 0xB85548EC) Patch_III_Steam(desktop);
|
||||||
else return FALSE;
|
else return FALSE;
|
||||||
|
|
||||||
CTimer::Initialise();
|
CTimer::Initialise();
|
||||||
|
|
|
@ -75,12 +75,11 @@
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<MinimumRequiredVersion>5.0</MinimumRequiredVersion>
|
<MinimumRequiredVersion>5.0</MinimumRequiredVersion>
|
||||||
<EntryPointSymbol>
|
<EntryPointSymbol>
|
||||||
</EntryPointSymbol>
|
</EntryPointSymbol>
|
||||||
<AdditionalDependencies>Winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>Winmm.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>copy /y "$(TargetPath)" "D:\gry\Steam\steamapps\common\Grand Theft Auto 3\SilentPatchIII.asi"</Command>
|
<Command>copy /y "$(TargetPath)" "D:\gry\Steam\steamapps\common\Grand Theft Auto 3\SilentPatchIII.asi"</Command>
|
||||||
|
@ -106,12 +105,11 @@
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<MinimumRequiredVersion>5.0</MinimumRequiredVersion>
|
<MinimumRequiredVersion>5.0</MinimumRequiredVersion>
|
||||||
<EntryPointSymbol>
|
<EntryPointSymbol>
|
||||||
</EntryPointSymbol>
|
</EntryPointSymbol>
|
||||||
<AdditionalDependencies>Winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>Winmm.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>copy /y "$(TargetPath)" "D:\gry\Steam\steamapps\common\Grand Theft Auto 3\SilentPatchIII.asi"</Command>
|
<Command>copy /y "$(TargetPath)" "D:\gry\Steam\steamapps\common\Grand Theft Auto 3\SilentPatchIII.asi"</Command>
|
||||||
|
|
|
@ -106,6 +106,21 @@ void __declspec(naked) SubtitlesShadowFix()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char** const ppUserFilesDir = AddressByVersion<char**>(0x6022AA, 0x60228A, 0x601ECA);
|
||||||
|
|
||||||
|
char* GetMyDocumentsPath()
|
||||||
|
{
|
||||||
|
static char cUserFilesPath[MAX_PATH];
|
||||||
|
|
||||||
|
if ( cUserFilesPath[0] == '\0' )
|
||||||
|
{
|
||||||
|
SHGetFolderPath(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, cUserFilesPath);
|
||||||
|
PathAppend(cUserFilesPath, *ppUserFilesDir);
|
||||||
|
CreateDirectory(cUserFilesPath, nullptr);
|
||||||
|
}
|
||||||
|
return cUserFilesPath;
|
||||||
|
}
|
||||||
|
|
||||||
static char aNoDesktopMode[64];
|
static char aNoDesktopMode[64];
|
||||||
|
|
||||||
void Patch_VC_10(const RECT& desktop)
|
void Patch_VC_10(const RECT& desktop)
|
||||||
|
@ -180,6 +195,12 @@ void Patch_VC_10(const RECT& desktop)
|
||||||
// No DirectPlay dependency
|
// No DirectPlay dependency
|
||||||
Patch<BYTE>(0x601CA0, 0xB8);
|
Patch<BYTE>(0x601CA0, 0xB8);
|
||||||
Patch<DWORD>(0x601CA1, 0x900);
|
Patch<DWORD>(0x601CA1, 0x900);
|
||||||
|
|
||||||
|
// SHGetFolderPath on User Files
|
||||||
|
InjectHook(0x602240, GetMyDocumentsPath, PATCH_JUMP);
|
||||||
|
|
||||||
|
InjectHook(0x601A40, GetMyDocumentsPath, PATCH_CALL);
|
||||||
|
InjectHook(0x601A45, 0x601B2F, PATCH_JUMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Patch_VC_11(const RECT& desktop)
|
void Patch_VC_11(const RECT& desktop)
|
||||||
|
@ -254,6 +275,12 @@ void Patch_VC_11(const RECT& desktop)
|
||||||
// No DirectPlay dependency
|
// No DirectPlay dependency
|
||||||
Patch<BYTE>(0x601CD0, 0xB8);
|
Patch<BYTE>(0x601CD0, 0xB8);
|
||||||
Patch<DWORD>(0x601CD1, 0x900);
|
Patch<DWORD>(0x601CD1, 0x900);
|
||||||
|
|
||||||
|
// SHGetFolderPath on User Files
|
||||||
|
InjectHook(0x602220, GetMyDocumentsPath, PATCH_JUMP);
|
||||||
|
|
||||||
|
InjectHook(0x601A70, GetMyDocumentsPath, PATCH_CALL);
|
||||||
|
InjectHook(0x601A75, 0x601B5F, PATCH_JUMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Patch_VC_Steam(const RECT& desktop)
|
void Patch_VC_Steam(const RECT& desktop)
|
||||||
|
@ -328,6 +355,12 @@ void Patch_VC_Steam(const RECT& desktop)
|
||||||
// No DirectPlay dependency
|
// No DirectPlay dependency
|
||||||
Patch<BYTE>(0x601910, 0xB8);
|
Patch<BYTE>(0x601910, 0xB8);
|
||||||
Patch<DWORD>(0x601911, 0x900);
|
Patch<DWORD>(0x601911, 0x900);
|
||||||
|
|
||||||
|
// SHGetFolderPath on User Files
|
||||||
|
InjectHook(0x601E60, GetMyDocumentsPath, PATCH_JUMP);
|
||||||
|
|
||||||
|
InjectHook(0x6016B0, GetMyDocumentsPath, PATCH_CALL);
|
||||||
|
InjectHook(0x6016B5, 0x60179F, PATCH_JUMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||||
|
@ -341,9 +374,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||||
GetWindowRect(GetDesktopWindow(), &desktop);
|
GetWindowRect(GetDesktopWindow(), &desktop);
|
||||||
sprintf(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom);
|
sprintf(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom);
|
||||||
|
|
||||||
if(*(DWORD*)0x667BF0 == 0x53E58955) Patch_VC_10(desktop);
|
if(*(DWORD*)0x667BF5 == 0xB85548EC) Patch_VC_10(desktop);
|
||||||
else if(*(DWORD*)0x667C40 == 0x53E58955) Patch_VC_11(desktop);
|
else if(*(DWORD*)0x667C45 == 0xB85548EC) Patch_VC_11(desktop);
|
||||||
else if (*(DWORD*)0x666BA0 == 0x53E58955) Patch_VC_Steam(desktop);
|
else if (*(DWORD*)0x666BA5 == 0xB85548EC) Patch_VC_Steam(desktop);
|
||||||
else return FALSE;
|
else return FALSE;
|
||||||
|
|
||||||
CTimer::Initialise();
|
CTimer::Initialise();
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<MinimumRequiredVersion>5.0</MinimumRequiredVersion>
|
<MinimumRequiredVersion>5.0</MinimumRequiredVersion>
|
||||||
<AdditionalDependencies>Winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>Winmm.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>copy /y "$(TargetPath)" "D:\gry\Steam\steamapps\common\Grand Theft Auto Vice City\SilentPatchVC.asi"</Command>
|
<Command>copy /y "$(TargetPath)" "D:\gry\Steam\steamapps\common\Grand Theft Auto Vice City\SilentPatchVC.asi"</Command>
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<MinimumRequiredVersion>5.0</MinimumRequiredVersion>
|
<MinimumRequiredVersion>5.0</MinimumRequiredVersion>
|
||||||
<AdditionalDependencies>Winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>Winmm.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>copy /y "$(TargetPath)" "D:\gry\Steam\steamapps\common\Grand Theft Auto Vice City\SilentPatchVC.asi"</Command>
|
<Command>copy /y "$(TargetPath)" "D:\gry\Steam\steamapps\common\Grand Theft Auto Vice City\SilentPatchVC.asi"</Command>
|
||||||
|
|
Loading…
Reference in a new issue