调试器内部原理与应用详解
1. 调试器基础代码与运行机制
以下是一段调试器相关的代码示例:
if(!commandLine.validArguments())
{
return(RETURN_ERROR);
}
Debugee debugee (
commandLine.getFileName(),
commandLine.getArgument()
);
DebugEventHandler handler;
handler.startDebugLoop(debugee.getProcessHandle());
return(RETURN_OK);
这段代码基本是Win32环境下与之前提到的16位调试API等效的实现。二者主要区别在于,Win32版本会将待调试程序作为子进程加载。
2. 使用Windows调试器
为了说明调试器的工作原理,构建了一个32位Windows控制台程序,代码如下:
#include<stdio.h>
int i;
int j;
void main()
{
// do stuff (create signature)
_asm{ nop }
_asm{ int 3 }
_asm{ nop }
_asm{ inc bx }
for(i = 0; i < 10; i++)
{
j = i;
}
fprintf(stdout, "j=%d\n", j)
超级会员免费看
订阅专栏 解锁全文
170万+

被折叠的 条评论
为什么被折叠?



