From 6bdd02ffdd5979256cbc44ef61a7c8d5dcee93b6 Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 9 Apr 2017 18:21:07 +0200 Subject: [PATCH] Fully migrate on utf-16 strings where possible --- DDraw/DDraw.vcxproj | 2 +- DDraw/dllmain.cpp | 6 +-- SilentPatchIII/SilentPatchIII.cpp | 8 ++-- SilentPatchIII/SilentPatchIII.vcxproj | 4 +- SilentPatchSA/SilentPatchSA.cpp | 57 ++++++++++++++------------- SilentPatchSA/SilentPatchSA.vcxproj | 4 +- SilentPatchSA/versionmeta.props | 2 +- SilentPatchVC/SilentPatchVC.cpp | 8 ++-- SilentPatchVC/SilentPatchVC.vcxproj | 4 +- 9 files changed, 48 insertions(+), 47 deletions(-) diff --git a/DDraw/DDraw.vcxproj b/DDraw/DDraw.vcxproj index 342e77a..57b9d00 100644 --- a/DDraw/DDraw.vcxproj +++ b/DDraw/DDraw.vcxproj @@ -16,7 +16,7 @@ DynamicLibrary false true - MultiByte + Unicode v120_xp diff --git a/DDraw/dllmain.cpp b/DDraw/dllmain.cpp index d4ba221..1b250b1 100644 --- a/DDraw/dllmain.cpp +++ b/DDraw/dllmain.cpp @@ -34,10 +34,10 @@ char* GetMyDocumentsPath() if ( cUserFilesPath[0] == '\0' ) { - SHGetFolderPath(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, cUserFilesPath); - PathAppend(cUserFilesPath, *ppUserFilesDir); + SHGetFolderPathA(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, cUserFilesPath); + PathAppendA(cUserFilesPath, *ppUserFilesDir); - CreateDirectory(cUserFilesPath, nullptr); + CreateDirectoryA(cUserFilesPath, nullptr); } return cUserFilesPath; } diff --git a/SilentPatchIII/SilentPatchIII.cpp b/SilentPatchIII/SilentPatchIII.cpp index 0d809c2..8f0871a 100644 --- a/SilentPatchIII/SilentPatchIII.cpp +++ b/SilentPatchIII/SilentPatchIII.cpp @@ -280,9 +280,9 @@ char* GetMyDocumentsPath() if ( cUserFilesPath[0] == '\0' ) { - SHGetFolderPath(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, cUserFilesPath); - PathAppend(cUserFilesPath, *ppUserFilesDir); - CreateDirectory(cUserFilesPath, nullptr); + SHGetFolderPathA(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, cUserFilesPath); + PathAppendA(cUserFilesPath, *ppUserFilesDir); + CreateDirectoryA(cUserFilesPath, nullptr); } return cUserFilesPath; } @@ -821,7 +821,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) CTimer::Initialise(); HMODULE hDummyHandle; - GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR)&DllMain, &hDummyHandle); + GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)&DllMain, &hDummyHandle); } return TRUE; } \ No newline at end of file diff --git a/SilentPatchIII/SilentPatchIII.vcxproj b/SilentPatchIII/SilentPatchIII.vcxproj index c4d3a2f..9d8c091 100644 --- a/SilentPatchIII/SilentPatchIII.vcxproj +++ b/SilentPatchIII/SilentPatchIII.vcxproj @@ -42,14 +42,14 @@ DynamicLibrary true - MultiByte + Unicode v141_xp DynamicLibrary false true - MultiByte + Unicode v141_xp diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index 918ee06..c2c2c01 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -281,7 +281,6 @@ CLinkListSA& m_alphaList = **AddressByVersion(LoadResource(thisModule, resource)); gpMoonMask = CPNGFile::ReadFromMemory(pMoonMask, SizeofResource(thisModule, resource)); @@ -816,17 +817,17 @@ char* GetMyDocumentsPath() char cTmpPath[MAX_PATH]; - SHGetFolderPath(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, ppTempBufPtr); - PathAppend(ppTempBufPtr, *ppUserFilesDir); - CreateDirectory(ppTempBufPtr, nullptr); + SHGetFolderPathA(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, ppTempBufPtr); + PathAppendA(ppTempBufPtr, *ppUserFilesDir); + CreateDirectoryA(ppTempBufPtr, nullptr); - strcpy(cTmpPath, ppTempBufPtr); - PathAppend(cTmpPath, "Gallery"); - CreateDirectory(cTmpPath, nullptr); + strcpy_s(cTmpPath, ppTempBufPtr); + PathAppendA(cTmpPath, "Gallery"); + CreateDirectoryA(cTmpPath, nullptr); - strcpy(cTmpPath, ppTempBufPtr); - PathAppend(cTmpPath, "User Tracks"); - CreateDirectory(cTmpPath, nullptr); + strcpy_s(cTmpPath, ppTempBufPtr); + PathAppendA(cTmpPath, "User Tracks"); + CreateDirectoryA(cTmpPath, nullptr); } return ppTempBufPtr; } @@ -1134,7 +1135,7 @@ bool ShaderAttach() if ( InitialiseRenderWare() ) { HMODULE thisModule; - GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCSTR)ShaderAttach, &thisModule); + GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCWSTR)ShaderAttach, &thisModule); HRSRC resource = FindResource(thisModule, MAKEINTRESOURCE(IDR_NVCSHADER), RT_RCDATA); RwUInt32* shader = static_cast(LoadResource(thisModule, resource)); @@ -2149,9 +2150,9 @@ BOOL InjectDelayedPatches_10() GetModuleFileNameW(hDLLModule, wcModulePath, _countof(wcModulePath) - 3); // Minus max required space for extension PathRenameExtensionW(wcModulePath, L".ini"); - bool bHasImVehFt = GetModuleHandle("ImVehFt.asi") != nullptr; - bool bSAMP = GetModuleHandle("samp") != nullptr; - bool bSARender = GetModuleHandle("SARender.asi") != nullptr; + bool bHasImVehFt = GetModuleHandleW(L"ImVehFt.asi") != nullptr; + bool bSAMP = GetModuleHandleW(L"samp") != nullptr; + bool bSARender = GetModuleHandleW(L"SARender.asi") != nullptr; ReadRotorFixExceptions(wcModulePath); ReadDoubleRearWheels(wcModulePath); @@ -2328,7 +2329,7 @@ BOOL InjectDelayedPatches_10() } // SSE conflicts - if ( GetModuleHandle("shadows.asi") == nullptr ) + if ( GetModuleHandleW(L"shadows.asi") == nullptr ) { Patch(0x70665C, 0x52909090); InjectHook(0x706662, &CShadowCamera::Update); @@ -2344,7 +2345,7 @@ BOOL InjectDelayedPatches_10() // Adblocker #if DISABLE_FLA_DONATION_WINDOW - if ( GetModuleHandle("$fastman92limitAdjuster.asi") != nullptr ) + if ( GetModuleHandleW(L"$fastman92limitAdjuster.asi") != nullptr ) { if ( *(DWORD*)0x748736 != 0xE8186A53 ) { @@ -2372,9 +2373,9 @@ BOOL InjectDelayedPatches_11() GetModuleFileNameW(hDLLModule, wcModulePath, _countof(wcModulePath) - 3); // Minus max required space for extension PathRenameExtensionW(wcModulePath, L".ini"); - bool bHasImVehFt = GetModuleHandle("ImVehFt.asi") != nullptr; - bool bSAMP = GetModuleHandle("samp") != nullptr; - bool bSARender = GetModuleHandle("SARender.asi") != nullptr; + bool bHasImVehFt = GetModuleHandleW(L"ImVehFt.asi") != nullptr; + bool bSAMP = GetModuleHandleW(L"samp") != nullptr; + bool bSARender = GetModuleHandleW(L"SARender.asi") != nullptr; ReadRotorFixExceptions(wcModulePath); @@ -2559,7 +2560,7 @@ BOOL InjectDelayedPatches_11() } // SSE conflicts - if ( GetModuleHandle("shadows.asi") == nullptr ) + if ( GetModuleHandleW(L"shadows.asi") == nullptr ) { Patch(0x706E8C, 0x52909090); InjectHook(0x706E92, &CShadowCamera::Update); @@ -2591,9 +2592,9 @@ BOOL InjectDelayedPatches_Steam() GetModuleFileNameW(hDLLModule, wcModulePath, _countof(wcModulePath) - 3); // Minus max required space for extension PathRenameExtensionW(wcModulePath, L".ini"); - bool bHasImVehFt = GetModuleHandle("ImVehFt.asi") != nullptr; - bool bSAMP = GetModuleHandle("samp") != nullptr; - bool bSARender = GetModuleHandle("SARender.asi") != nullptr; + bool bHasImVehFt = GetModuleHandleW(L"ImVehFt.asi") != nullptr; + bool bSAMP = GetModuleHandleW(L"samp") != nullptr; + bool bSARender = GetModuleHandleW(L"SARender.asi") != nullptr; ReadRotorFixExceptions(wcModulePath); @@ -2765,7 +2766,7 @@ BOOL InjectDelayedPatches_Steam() } // SSE conflicts - if ( GetModuleHandle("shadows.asi") == nullptr ) + if ( GetModuleHandleW(L"shadows.asi") == nullptr ) { Patch(0x74A864, 0x52909090); InjectHook(0x74A86A, &CShadowCamera::Update); @@ -4515,7 +4516,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) ScopedUnprotect::Section Protect2( hGameHandle, ".rdata" ); if (*(DWORD*)DynBaseAddress(0x82457C) == 0x94BF || *(DWORD*)DynBaseAddress(0x8245BC) == 0x94BF) Patch_SA_10(); - else if (*(DWORD*)DynBaseAddress(0x8252FC) == 0x94BF || *(DWORD*)DynBaseAddress(0x82533C) == 0x94BF) Patch_SA_11(), MessageBox( nullptr, "You're using a 1.01 executable which is no longer supported by SilentPatch!\n\nI have no idea if anyone was still using it, so if you do - shoot me an e-mail!", "SilentPatch", MB_OK | MB_ICONWARNING ); + else if (*(DWORD*)DynBaseAddress(0x8252FC) == 0x94BF || *(DWORD*)DynBaseAddress(0x82533C) == 0x94BF) Patch_SA_11(), MessageBoxW( nullptr, L"You're using a 1.01 executable which is no longer supported by SilentPatch!\n\nI have no idea if anyone was still using it, so if you do - shoot me an e-mail!", L"SilentPatch", MB_OK | MB_ICONWARNING ); else if (*(DWORD*)DynBaseAddress(0x85EC4A) == 0x94BF) Patch_SA_Steam(); else { diff --git a/SilentPatchSA/SilentPatchSA.vcxproj b/SilentPatchSA/SilentPatchSA.vcxproj index 954df03..77912e0 100644 --- a/SilentPatchSA/SilentPatchSA.vcxproj +++ b/SilentPatchSA/SilentPatchSA.vcxproj @@ -20,14 +20,14 @@ DynamicLibrary true - MultiByte + Unicode v141_xp DynamicLibrary false true - MultiByte + Unicode v141_xp diff --git a/SilentPatchSA/versionmeta.props b/SilentPatchSA/versionmeta.props index 296f2e5..2766fd6 100644 --- a/SilentPatchSA/versionmeta.props +++ b/SilentPatchSA/versionmeta.props @@ -6,7 +6,7 @@ .asi SilentPatch for San Andreas 29 - 0 + 1 2014-2017 diff --git a/SilentPatchVC/SilentPatchVC.cpp b/SilentPatchVC/SilentPatchVC.cpp index 06919cf..5d70bf4 100644 --- a/SilentPatchVC/SilentPatchVC.cpp +++ b/SilentPatchVC/SilentPatchVC.cpp @@ -151,9 +151,9 @@ char* GetMyDocumentsPath() if ( cUserFilesPath[0] == '\0' ) { - SHGetFolderPath(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, cUserFilesPath); - PathAppend(cUserFilesPath, *ppUserFilesDir); - CreateDirectory(cUserFilesPath, nullptr); + SHGetFolderPathA(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, cUserFilesPath); + PathAppendA(cUserFilesPath, *ppUserFilesDir); + CreateDirectoryA(cUserFilesPath, nullptr); } return cUserFilesPath; } @@ -659,7 +659,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) CTimer::Initialise(); HMODULE hDummyHandle; - GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR)&DllMain, &hDummyHandle); + GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)&DllMain, &hDummyHandle); } return TRUE; } \ No newline at end of file diff --git a/SilentPatchVC/SilentPatchVC.vcxproj b/SilentPatchVC/SilentPatchVC.vcxproj index 0883720..8bdcf0e 100644 --- a/SilentPatchVC/SilentPatchVC.vcxproj +++ b/SilentPatchVC/SilentPatchVC.vcxproj @@ -20,14 +20,14 @@ DynamicLibrary true - MultiByte + Unicode v141_xp DynamicLibrary false true - MultiByte + Unicode v141_xp