allow iohook and serial_hook to land on DLLs loaded after initialization

This commit is contained in:
Kevin Trocolli
2023-11-30 02:18:50 -05:00
parent f0e5f82028
commit 888d068d58
4 changed files with 17 additions and 6 deletions
+10 -5
View File
@@ -229,11 +229,7 @@ static void iohook_init(void)
/* Splice iohook into IAT entries referencing Win32 I/O APIs */
hook_table_apply(
NULL,
"kernel32.dll",
iohook_kernel32_syms,
_countof(iohook_kernel32_syms));
iohook_apply_hooks(NULL);
/* Here be dragons:
@@ -281,6 +277,15 @@ static void iohook_init(void)
LeaveCriticalSection(&iohook_lock);
}
void iohook_apply_hooks(HMODULE target)
{
hook_table_apply(
target,
"kernel32.dll",
iohook_kernel32_syms,
_countof(iohook_kernel32_syms));
}
// Deprecated
HANDLE iohook_open_dummy_fd(void)
{
+1
View File
@@ -48,3 +48,4 @@ __attribute__((deprecated("Use iohook_open_nul_fd instead")))
HRESULT iohook_open_nul_fd(HANDLE *fd);
HRESULT iohook_push_handler(iohook_fn_t fn);
HRESULT iohook_invoke_next(struct irp *irp);
void iohook_apply_hooks(HMODULE target);
+5 -1
View File
@@ -84,10 +84,14 @@ void serial_hook_init(void)
return;
}
hook_table_apply(NULL, "kernel32.dll", serial_syms, _countof(serial_syms));
serial_hook_apply_hooks(NULL);
serial_hook_initted = true;
}
void serial_hook_apply_hooks(HMODULE target) {
hook_table_apply(target, "kernel32.dll", serial_syms, _countof(serial_syms));
}
static BOOL WINAPI my_ClearCommError(
HANDLE fd,
uint32_t *errors,
+1
View File
@@ -1,3 +1,4 @@
#pragma once
void serial_hook_init(void);
void serial_hook_apply_hooks(HMODULE target);