From 58263d0e96d11b48638d3cfcbceb010d91b6aa92 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Fri, 16 Feb 2024 22:20:59 +0800 Subject: [PATCH] [saco] Implement `UninstallFileSystemHooks()` * Updates `DllMain(...)` --- saco/filehooks.cpp | 16 ++++++++++++++++ saco/filehooks.h | 1 + saco/main.cpp | 3 +-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/saco/filehooks.cpp b/saco/filehooks.cpp index 124e4a8..b278db8 100644 --- a/saco/filehooks.cpp +++ b/saco/filehooks.cpp @@ -157,3 +157,19 @@ void InstallFileSystemHooks() //---------------------------------------------------------- +void UninstallFileSystemHooks() +{ + if(bFileHooksInstalled) { + DetourRemove((PBYTE)Real_CreateFileA,(PBYTE)Arch_CreateFileA); + DetourRemove((PBYTE)Real_ReadFile,(PBYTE)Arch_ReadFile); + DetourRemove((PBYTE)Real_GetFileSize,(PBYTE)Arch_GetFileSize); + DetourRemove((PBYTE)Real_SetFilePointer,(PBYTE)Arch_SetFilePointer); + DetourRemove((PBYTE)Real_CloseHandle,(PBYTE)Arch_CloseHandle); + DetourRemove((PBYTE)Real_GetFileType,(PBYTE)Arch_GetFileType); + DetourRemove((PBYTE)Real_ShowCursor,(PBYTE)Arch_ShowCursor); + bFileHooksInstalled = FALSE; + } +} + +//---------------------------------------------------------- + diff --git a/saco/filehooks.h b/saco/filehooks.h index 192ca74..7c638ec 100644 --- a/saco/filehooks.h +++ b/saco/filehooks.h @@ -3,6 +3,7 @@ void InstallShowCursorHook(); void InstallFileSystemHooks(); +void UninstallFileSystemHooks(); #define MAX_OPEN_ARCH_FILES 50 diff --git a/saco/main.cpp b/saco/main.cpp index dd14960..3f42a5d 100644 --- a/saco/main.cpp +++ b/saco/main.cpp @@ -62,7 +62,6 @@ void LaunchMonitor(PVOID v) BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { - // TODO: DllMain if(DLL_PROCESS_ATTACH==fdwReason) { hInstance = hinstDLL; @@ -97,7 +96,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) else if(DLL_PROCESS_DETACH==fdwReason) { if(tSettings.bDebug || tSettings.bPlayOnline) { - //sub_10062D90 + UninstallFileSystemHooks(); } }