KeepingUpWithDetours
samples
1 |
|
functions
basic
DetourTransactionBegin/创建hook任务
DetourUpdateThread/刷新线程
DetourAttach/DetourDetach/可以执行多次,hook/unhook多个API
1
2
3
4LONG DetourAttach(
_Inout_ PVOID * ppPointer, //Pointer to the target pointer to which the detour will be attached.
_In_ PVOID pDetour //Pointer to the detour function.
);DetourTransactionCommit/提交hook任务
DetourCreateProcessWithDlls/创建进程并加载特定dll
DetourRestoreAfterWith/创建新线程后修复内存中import table
comply
Detour-master目录下执行
1
nmake -f ./MakeFile
notes
添加头文件和静态库,与源代码放在同一文件夹下
1
2#include "detours.h"
#pragma comment(lib,"detours.lib")使用static类型,防止影响其他程序
1
2
3
4
5static int (WINAPI *OldMessageBox)(
HWND hWnd,
LPCSTR lpText,
LPCSTR lpCaption,
UINT uType) = MessageBox;用来替换的函数原型与原函数一致
1
2
3
4
5
6
7
8int WINAPI NewMessageBox(
HWND hWnd,
LPCSTR lpText,
LPCSTR lpCaption,
UINT uType)
{
return 0;
}- 要在Release模式下进行调试
references
- Detours官方文档:
- Detours样例: