diff --git a/ferrumhook/dllmain.c b/ferrumhook/dllmain.c index 53bf094..9e54b27 100644 --- a/ferrumhook/dllmain.c +++ b/ferrumhook/dllmain.c @@ -12,6 +12,7 @@ #include "hook/process.h" #include "hooklib/serial.h" +#include "hooklib/debug.h" #include "platform/platform.h" #include "gfxhook/gfx.h" @@ -70,6 +71,8 @@ static DWORD CALLBACK ferrum_pre_startup(void) ExitProcess(EXIT_FAILURE); } + debug_hook_init(); + gfx_hook_init(&ferrum_hook_cfg.gfx); gfx_d3d11_hook_init(&ferrum_hook_cfg.gfx, ferrum_hook_mod); gfx_dxgi_hook_init(&ferrum_hook_cfg.gfx, ferrum_hook_mod); diff --git a/hooklib/debug.c b/hooklib/debug.c new file mode 100644 index 0000000..6f2c0eb --- /dev/null +++ b/hooklib/debug.c @@ -0,0 +1,48 @@ +#include + +#include +#include +#include + +#include "hook/com-proxy.h" +#include "hook/table.h" + +#include "hooklib/config.h" +#include "hooklib/dll.h" +#include "hooklib/debug.h" + +#include "util/dprintf.h" + +/* API hooks */ + +static BOOL WINAPI hook_IsDebuggerPresent(); + +static BOOL (WINAPI *next_IsDebuggerPresent)(); + +/* Link pointers */ + +static bool debug_hook_initted; + +static const struct hook_symbol debug_hooks[] = { + { .name = "IsDebuggerPresent", + .patch = hook_IsDebuggerPresent, + .link = (void **) &next_IsDebuggerPresent }, +}; + +void debug_hook_init() +{ + if (debug_hook_initted) { + return; + } + + debug_hook_initted = true; + + hook_table_apply(NULL, "kernel32.dll", debug_hooks, _countof(debug_hooks)); + dprintf("debug: hook enabled.\n"); +} + +BOOL WINAPI hook_IsDebuggerPresent() +{ + dprintf("debug: IsDebuggerPresent hooked.\n"); + return false; +} diff --git a/hooklib/debug.h b/hooklib/debug.h new file mode 100644 index 0000000..2e220d5 --- /dev/null +++ b/hooklib/debug.h @@ -0,0 +1,4 @@ +#pragma once +#include + +void debug_hook_init(); \ No newline at end of file diff --git a/hooklib/meson.build b/hooklib/meson.build index ce1c96e..47c4cab 100644 --- a/hooklib/meson.build +++ b/hooklib/meson.build @@ -9,6 +9,8 @@ hooklib_lib = static_library( sources : [ 'config.c', 'config.h', + 'debug.c', + 'debug.h', 'dll.c', 'dll.h', 'dns.c',