From 533683e595c072c41a9a1633bf569c710e978974 Mon Sep 17 00:00:00 2001 From: Matt Bilker Date: Fri, 14 Feb 2020 07:25:46 +0000 Subject: [PATCH] hooklib/path.c: add function to hook apply path hooks to another module --- hooklib/path.c | 8 +++++++- hooklib/path.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hooklib/path.c b/hooklib/path.c index 864d2e2..0d86183 100644 --- a/hooklib/path.c +++ b/hooklib/path.c @@ -252,8 +252,13 @@ static void path_hook_init(void) path_hook_initted = true; InitializeCriticalSection(&path_hook_lock); + path_hook_insert_hooks(NULL); +} + +void path_hook_insert_hooks(HMODULE target) +{ hook_table_apply( - NULL, + target, "kernel32.dll", path_hook_syms, _countof(path_hook_syms)); @@ -668,6 +673,7 @@ static DWORD WINAPI hook_GetFileAttributesW(const wchar_t *lpFileName) } result = next_GetFileAttributesW(trans ? trans : lpFileName); + free(trans); return result; diff --git a/hooklib/path.h b/hooklib/path.h index ccbd77a..3a58bb7 100644 --- a/hooklib/path.h +++ b/hooklib/path.h @@ -11,6 +11,7 @@ typedef HRESULT (*path_hook_t)( size_t *count); HRESULT path_hook_push(path_hook_t hook); +void path_hook_insert_hooks(HMODULE target); int path_compare_w(const wchar_t *string1, const wchar_t *string2, size_t count); static inline bool path_is_separator_w(wchar_t c)