diff --git a/hooklib/path.c b/hooklib/path.c index 5b6b734..fd07729 100644 --- a/hooklib/path.c +++ b/hooklib/path.c @@ -97,10 +97,6 @@ static BOOL WINAPI hook_RemoveDirectoryA(const char *lpFileName); static BOOL WINAPI hook_RemoveDirectoryW(const wchar_t *lpFileName); -static BOOL WINAPI hook_PathFileExistsA(LPCSTR pszPath); - -static BOOL WINAPI hook_PathFileExistsW(LPCWSTR pszPath); - static BOOL WINAPI hook_MoveFileA( const char *lpExistingFileName, const char *lpNewFileName); @@ -217,6 +213,12 @@ static DWORD WINAPI hook_GetFullPathNameW( LPWSTR lpBuffer, LPWSTR *lpFilePart); +static BOOL WINAPI hook_PathFileExistsA(LPCSTR pszPath); + +static BOOL WINAPI hook_PathFileExistsW(LPCWSTR pszPath); + +static BOOL WINAPI hook_MakeSureDirectoryPathExists(LPCSTR DirPath); + /* Link pointers */ static BOOL (WINAPI *next_CreateDirectoryA)( @@ -297,10 +299,6 @@ static BOOL (WINAPI *next_RemoveDirectoryA)(const char *lpFileName); static BOOL (WINAPI *next_RemoveDirectoryW)(const wchar_t *lpFileName); -static BOOL (WINAPI *next_PathFileExistsA)(LPCSTR pszPath); - -static BOOL (WINAPI *next_PathFileExistsW)(LPCWSTR pszPath); - static BOOL (WINAPI *next_MoveFileA)( const char *lpExistingFileName, const char *lpNewFileName); @@ -429,6 +427,12 @@ static DWORD (WINAPI *next_GetFullPathNameW)( LPWSTR lpBuffer, LPWSTR *lpFilePart); +static BOOL (WINAPI *next_PathFileExistsA)(LPCSTR pszPath); + +static BOOL (WINAPI *next_PathFileExistsW)(LPCWSTR pszPath); + +static BOOL (WINAPI *next_MakeSureDirectoryPathExists)(LPCSTR DirPath); + /* Hook table */ static const struct hook_symbol path_hook_syms[] = { @@ -496,14 +500,6 @@ static const struct hook_symbol path_hook_syms[] = { .name = "RemoveDirectoryW", .patch = hook_RemoveDirectoryW, .link = (void **) &next_RemoveDirectoryW, - }, { - .name = "PathFileExistsA", - .patch = hook_PathFileExistsA, - .link = (void **) &next_PathFileExistsA, - }, { - .name = "PathFileExistsW", - .patch = hook_PathFileExistsW, - .link = (void **) &next_PathFileExistsW, }, { .name = "MoveFileA", .patch = hook_MoveFileA, @@ -587,6 +583,26 @@ static const struct hook_symbol path_hook_syms[] = { }, }; +static const struct hook_symbol path_hook_shlwapi_syms[] = { + { + .name = "PathFileExistsA", + .patch = hook_PathFileExistsA, + .link = (void **) &next_PathFileExistsA, + }, { + .name = "PathFileExistsW", + .patch = hook_PathFileExistsW, + .link = (void **) &next_PathFileExistsW, + } +}; + +static const struct hook_symbol path_hook_dbghelp_syms[] = { + { + .name = "MakeSureDirectoryPathExists", + .patch = hook_MakeSureDirectoryPathExists, + .link = (void **) &next_MakeSureDirectoryPathExists + } +}; + static bool path_hook_initted; static CRITICAL_SECTION path_hook_lock; static path_hook_t *path_hook_list; @@ -646,6 +662,18 @@ void path_hook_insert_hooks(HMODULE target) "kernel32.dll", path_hook_syms, _countof(path_hook_syms)); + + hook_table_apply( + target, + "kernel32.dll", + path_hook_shlwapi_syms, + _countof(path_hook_shlwapi_syms)); + + hook_table_apply( + target, + "imagehlp.dll", + path_hook_dbghelp_syms, + _countof(path_hook_dbghelp_syms)); } BOOL path_transform_a(char **out, const char *src) @@ -1087,6 +1115,7 @@ static DWORD WINAPI hook_GetFileAttributesA(const char *lpFileName) } result = next_GetFileAttributesA(trans ? trans : lpFileName); + free(trans); return result; @@ -1159,6 +1188,23 @@ static BOOL WINAPI hook_GetFileAttributesExW( return ok; } +static BOOL WINAPI hook_MakeSureDirectoryPathExists(LPCSTR DirPath) { + char *trans; + BOOL result; + + BOOL ok = path_transform_a(&trans, DirPath); + + if (!ok) { + return FALSE; + } + + result = next_MakeSureDirectoryPathExists(trans ? trans : DirPath); + + free(trans); + + return result; +} + static BOOL WINAPI hook_RemoveDirectoryA(const char *lpFileName) { char *trans; diff --git a/taikohook/amfw.c b/taikohook/amfw.c index 4ca4f88..a5cdca2 100644 --- a/taikohook/amfw.c +++ b/taikohook/amfw.c @@ -25,6 +25,7 @@ static const wchar_t *target_modules[] = { L"nbamUsbfinder.dll", + L"garmc.dll", L"bngrw.dll", }; @@ -164,7 +165,7 @@ static HMODULE WINAPI hook_LoadLibraryW(const wchar_t *name) setupapi_hook_insert_hooks(result); es3sec_insert_hooks(result); - serial_hook_apply_hooks(result); + // serial_hook_apply_hooks(result); iohook_apply_hooks(result); } }