NoteZ icon indicating copy to clipboard operation
NoteZ copied to clipboard

Detours 解析

Open jmpews opened this issue 6 years ago • 0 comments

Prologue

Detours, 微软开源的 Inlinehook Framework.

Somniloquy

Build

使用 nmake 编译, 编译前使用 Microsoft_Visual_Studio_2017\VC\Auxiliary\Build\vcvars32.bat 初始化下 x86 的环境变量, 之后直接切入到 src\, nmake 即可.

Key Function

DetourCreateProcessWithDllExW

创建进程并注入 detours.dll.

step by step: hook process

  1. 使用 CreateProcessA 函数, 并以 CREATE_SUSPENDED flag 打开进行文件创建进程
  2. 使用 DetourUpdateProcessWithDll 进行导入表注入.
  3. 使用 DetourCopyPayloadToProcess 函数保存数据至 .detour section

step by step: hook restore process

  1. DetourRestoreAfterWith :{ DetourFindPayloadEx -> DetourRestoreAfterWithEx }

jmpews avatar Mar 01 '18 08:03 jmpews