mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-28 23:03:01 +05: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
3 changed files with 19 additions and 22 deletions
|
@ -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,10 +16,16 @@ namespace Common {
|
|||
|
||||
if ( cUserFilesPath[0] == '\0' )
|
||||
{
|
||||
SHGetFolderPathA(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, cUserFilesPath);
|
||||
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];
|
||||
|
||||
SHGetFolderPathA(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, ppTempBufPtr);
|
||||
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");
|
||||
}
|
||||
|
||||
char cTmpPath[MAX_PATH];
|
||||
|
||||
strcpy_s(cTmpPath, ppTempBufPtr);
|
||||
PathAppendA(cTmpPath, "Gallery");
|
||||
|
|
Loading…
Reference in a new issue