forked from Hay1tsme/bananatools
hooklib: add debugger trap defuser (thanks PockyWitch!)
This commit is contained in:
parent
e4d6b02199
commit
5055d20172
@ -12,6 +12,7 @@
|
|||||||
#include "hook/process.h"
|
#include "hook/process.h"
|
||||||
|
|
||||||
#include "hooklib/serial.h"
|
#include "hooklib/serial.h"
|
||||||
|
#include "hooklib/debug.h"
|
||||||
|
|
||||||
#include "platform/platform.h"
|
#include "platform/platform.h"
|
||||||
#include "gfxhook/gfx.h"
|
#include "gfxhook/gfx.h"
|
||||||
@ -70,6 +71,8 @@ static DWORD CALLBACK ferrum_pre_startup(void)
|
|||||||
ExitProcess(EXIT_FAILURE);
|
ExitProcess(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug_hook_init();
|
||||||
|
|
||||||
gfx_hook_init(&ferrum_hook_cfg.gfx);
|
gfx_hook_init(&ferrum_hook_cfg.gfx);
|
||||||
gfx_d3d11_hook_init(&ferrum_hook_cfg.gfx, ferrum_hook_mod);
|
gfx_d3d11_hook_init(&ferrum_hook_cfg.gfx, ferrum_hook_mod);
|
||||||
gfx_dxgi_hook_init(&ferrum_hook_cfg.gfx, ferrum_hook_mod);
|
gfx_dxgi_hook_init(&ferrum_hook_cfg.gfx, ferrum_hook_mod);
|
||||||
|
48
hooklib/debug.c
Normal file
48
hooklib/debug.c
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#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;
|
||||||
|
}
|
4
hooklib/debug.h
Normal file
4
hooklib/debug.h
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
void debug_hook_init();
|
@ -9,6 +9,8 @@ hooklib_lib = static_library(
|
|||||||
sources : [
|
sources : [
|
||||||
'config.c',
|
'config.c',
|
||||||
'config.h',
|
'config.h',
|
||||||
|
'debug.c',
|
||||||
|
'debug.h',
|
||||||
'dll.c',
|
'dll.c',
|
||||||
'dll.h',
|
'dll.h',
|
||||||
'dns.c',
|
'dns.c',
|
||||||
|
Loading…
Reference in New Issue
Block a user