From a602f91c8b0d154dacd78d4702a551ea90462953 Mon Sep 17 00:00:00 2001 From: Sucklead Date: Tue, 23 Feb 2021 19:02:26 +0000 Subject: [PATCH] Don't mess with checks for save games --- HookDll/HookDll.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/HookDll/HookDll.cpp b/HookDll/HookDll.cpp index 02ca7da..86feb73 100644 --- a/HookDll/HookDll.cpp +++ b/HookDll/HookDll.cpp @@ -100,17 +100,28 @@ FINDFIRSTFILE fpFindFirstFile = NULL; // } HANDLE WINAPI DetourFindFirstFile(LPCTSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData) { + HANDLE fileHandle = NULL; + // we should always patch the find first file calls // we can redirect to mods when the files are actually opened - LPCTSTR basePath = "..\\"; - int total_length = strlen(basePath) + strlen(lpFileName) + 1; - char* lpInstallFileName = (char*)malloc(total_length); + // BUT only if it's a relative path request otherwise we need to just let it through + // otherwise save file scans are broken + if (StartsWith(lpFileName, "..")) + { + LPCTSTR basePath = "..\\"; + int total_length = strlen(basePath) + strlen(lpFileName) + 1; + char* lpInstallFileName = (char*)malloc(total_length); - strcpy(lpInstallFileName, basePath); - strcat(lpInstallFileName, lpFileName); - HANDLE fileHandle = fpFindFirstFile(lpInstallFileName, lpFindFileData); + strcpy(lpInstallFileName, basePath); + strcat(lpInstallFileName, lpFileName); + fileHandle = fpFindFirstFile(lpInstallFileName, lpFindFileData); - free(lpInstallFileName); + free(lpInstallFileName); + } + else + { + fileHandle = fpFindFirstFile(lpFileName, lpFindFileData); + } return fileHandle; }