代码改变世界

The simple debugger

2004-07-12 16:03  atempcode  阅读(580)  评论(0编辑  收藏  举报
This is the p-code of a simple debugger on Windows.

1. the debugger create a process with the dwCreationFlags set to DEBUG_ONLY_THIS_PROCESS.
2. After the target started, the debugger enter into a loop. It receives debugging message by WaitForDebugEvents, after handles the events, it calls ContinueDebugEvent to go on.

void main(void)
{
    CreateProcess(, DEBUG_ONLY_THIS_PROCESS, );
    
while (1 == WaitForDebugEvent())
    {
        
if (EXIT_PROCESS)
        {
            
break;
        }
        ContinueDebugEvent();
    }
}