49 lines
932 B
C
49 lines
932 B
C
|
#include <windows.h>
|
||
|
|
||
|
#include <assert.h>
|
||
|
#include <stdbool.h>
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
#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;
|
||
|
}
|