Increased safety of INI path query

This commit is contained in:
Silent 2017-03-18 01:43:51 +01:00
parent 91d14c80b7
commit 8254c1da58

View file

@ -1985,14 +1985,8 @@ BOOL InjectDelayedPatches_10()
// Obtain a path to the ASI // Obtain a path to the ASI
wchar_t wcModulePath[MAX_PATH]; wchar_t wcModulePath[MAX_PATH];
GetModuleFileNameW(hDLLModule, wcModulePath, _countof(wcModulePath) - 3); // Minus max required space for extension
GetModuleFileNameW(hDLLModule, wcModulePath, MAX_PATH); PathRenameExtensionW(wcModulePath, L".ini");
// ASI -> INI
size_t nLen = wcslen(wcModulePath);
wcModulePath[nLen-1] = L'i';
wcModulePath[nLen-2] = L'n';
wcModulePath[nLen-3] = L'i';
bool bHasImVehFt = GetModuleHandle("ImVehFt.asi") != nullptr; bool bHasImVehFt = GetModuleHandle("ImVehFt.asi") != nullptr;
bool bSAMP = GetModuleHandle("samp") != nullptr; bool bSAMP = GetModuleHandle("samp") != nullptr;
@ -2213,14 +2207,8 @@ BOOL InjectDelayedPatches_11()
// Obtain a path to the ASI // Obtain a path to the ASI
wchar_t wcModulePath[MAX_PATH]; wchar_t wcModulePath[MAX_PATH];
GetModuleFileNameW(hDLLModule, wcModulePath, _countof(wcModulePath) - 3); // Minus max required space for extension
GetModuleFileNameW(hDLLModule, wcModulePath, MAX_PATH); PathRenameExtensionW(wcModulePath, L".ini");
// ASI -> INI
size_t nLen = wcslen(wcModulePath);
wcModulePath[nLen-1] = L'i';
wcModulePath[nLen-2] = L'n';
wcModulePath[nLen-3] = L'i';
bool bHasImVehFt = GetModuleHandle("ImVehFt.asi") != nullptr; bool bHasImVehFt = GetModuleHandle("ImVehFt.asi") != nullptr;
bool bSAMP = GetModuleHandle("samp") != nullptr; bool bSAMP = GetModuleHandle("samp") != nullptr;
@ -2438,14 +2426,8 @@ BOOL InjectDelayedPatches_Steam()
// Obtain a path to the ASI // Obtain a path to the ASI
wchar_t wcModulePath[MAX_PATH]; wchar_t wcModulePath[MAX_PATH];
GetModuleFileNameW(hDLLModule, wcModulePath, _countof(wcModulePath) - 3); // Minus max required space for extension
GetModuleFileNameW(hDLLModule, wcModulePath, MAX_PATH); PathRenameExtensionW(wcModulePath, L".ini");
// ASI -> INI
size_t nLen = wcslen(wcModulePath);
wcModulePath[nLen-1] = L'i';
wcModulePath[nLen-2] = L'n';
wcModulePath[nLen-3] = L'i';
bool bHasImVehFt = GetModuleHandle("ImVehFt.asi") != nullptr; bool bHasImVehFt = GetModuleHandle("ImVehFt.asi") != nullptr;
bool bSAMP = GetModuleHandle("samp") != nullptr; bool bSAMP = GetModuleHandle("samp") != nullptr;