Ste*_*eve 6 c++ assembly detours
我通过它们的函数偏移在外部进程中挂钩函数.这对于我到目前为止挂钩的函数效果很好 - 但是我发现了一个"debugLog(char ...)"函数,它仍然存在于二进制文件中但没有进行任何打印 - 它看起来像这样
debugMessage proc near ;
xor eax, eax ; Logical Exclusive OR
retn ; Return Near from Procedure
debugMessage endp
Run Code Online (Sandbox Code Playgroud)
它被称为这样
push offset debugString ; "This is a debug message"...
call debugMessage ; Call Procedure
Run Code Online (Sandbox Code Playgroud)
现在调试消息显然已被禁用,我想挂钩到这个,因为我能够简单地挂钩到二进制文件中的类似func(char ..).
这是代码:
typedef void (__stdcall* DebugLog)(const char*);
DebugLog Real_DebugLog = (DebugLog)(0xCAFEBABE);
extern "C"
{
static void __stdcall Hook_DebugLog(const char*);
}
void __stdcall Hook_DebugLog(const char* text) {
MessageBox(NULL, text, "MyDebugLog", MB_OK);
return Real_DebugLog(text);
}
// in dll main attach..
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)Real_DebugLog, (PVOID)Hook_DebugLog);
Run Code Online (Sandbox Code Playgroud)
类似的方法适用于我到目前为止已经连接到这个二进制文件的所有其他函数.我还确保使用调试器调用debugMessage.
任何想法为什么这个钩子根本不起作用?也许是因为函数可能有var args?我已经尝试过使用const char*,...).
该函数可能太小而无法挂钩。Detours 必须覆盖一部分挂钩函数以将调用重定向到其他地方,但该日志存根中可能没有足够的空间供 Detours 编写针对您的替换的 JMP 指令。
| 归档时间: |
|
| 查看次数: |
1148 次 |
| 最近记录: |