mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-11-22 05:22:32 +01:00
Re-added fallback code if SHGetFolderPathA fails (like in stock code, falls back to "data" directory)
This commit is contained in:
parent
dfb46efa88
commit
63ba94e547
@ -30,21 +30,6 @@ extern "C" HRESULT WINAPI DirectDrawCreateEx(GUID FAR *lpGUID, LPVOID *lplpDD, R
|
||||
|
||||
char** ppUserFilesDir;
|
||||
|
||||
char* GetMyDocumentsPath()
|
||||
{
|
||||
static char cUserFilesPath[MAX_PATH];
|
||||
|
||||
if ( cUserFilesPath[0] == '\0' )
|
||||
{
|
||||
SHGetFolderPathA(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, cUserFilesPath);
|
||||
PathAppendA(cUserFilesPath, *ppUserFilesDir);
|
||||
|
||||
CreateDirectoryA(cUserFilesPath, nullptr);
|
||||
}
|
||||
return cUserFilesPath;
|
||||
}
|
||||
|
||||
|
||||
void InjectHooks()
|
||||
{
|
||||
static char aNoDesktopMode[64];
|
||||
|
@ -16,9 +16,15 @@ namespace Common {
|
||||
|
||||
if ( cUserFilesPath[0] == '\0' )
|
||||
{
|
||||
SHGetFolderPathA(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, cUserFilesPath);
|
||||
PathAppendA(cUserFilesPath, *ppUserFilesDir);
|
||||
CreateDirectoryA(cUserFilesPath, nullptr);
|
||||
if ( SHGetFolderPathA(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, cUserFilesPath) == S_OK )
|
||||
{
|
||||
PathAppendA(cUserFilesPath, *ppUserFilesDir);
|
||||
CreateDirectoryA(cUserFilesPath, nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy_s(cUserFilesPath, "data");
|
||||
}
|
||||
}
|
||||
return cUserFilesPath;
|
||||
}
|
||||
|
@ -716,11 +716,17 @@ char* GetMyDocumentsPathSA()
|
||||
static bool initPath = [&] () {
|
||||
char** const ppUserFilesDir = AddressByVersion<char**>(0x74503F, 0x74586F, 0x77EE50, 0x77902B, 0x778F1B);
|
||||
|
||||
char cTmpPath[MAX_PATH];
|
||||
if ( SHGetFolderPathA(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, ppTempBufPtr) == S_OK )
|
||||
{
|
||||
PathAppendA(ppTempBufPtr, *ppUserFilesDir);
|
||||
CreateDirectoryA(ppTempBufPtr, nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy_s(ppTempBufPtr, MAX_PATH, "data");
|
||||
}
|
||||
|
||||
SHGetFolderPathA(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, ppTempBufPtr);
|
||||
PathAppendA(ppTempBufPtr, *ppUserFilesDir);
|
||||
CreateDirectoryA(ppTempBufPtr, nullptr);
|
||||
char cTmpPath[MAX_PATH];
|
||||
|
||||
strcpy_s(cTmpPath, ppTempBufPtr);
|
||||
PathAppendA(cTmpPath, "Gallery");
|
||||
|
Loading…
Reference in New Issue
Block a user