Single-Step implementation
Is the previously set TF flag bit
Set TF flag bit void Settrapflag () {Context context = {0}; Getdebuggeecontext (&context); context. EFlags |= 0x100; Setdebuggeecontext (&context);}
Step out is to set a breakpoint at the address of the Ebp+4
BOOL moveout () {//Get EBPContext context = {0}; Getdebuggeecontext (&Context); //get the return address saved at Ebp+4size_t addr =0; if(! ReadDebuggeeMemory (CONTEXT.EBP +4,sizeof(addr), (LPVOID) &addr)) { returnFALSE; } //set A one-time breakpointSetccbreakpointat (addr,softtype_once); returnTRUE;}
Step over is to get the next instruction length, the next command under the breakpoint
step Over, get the EIP next instruction length, over this command breakpoint, so that will not enter the call inside bool Moveover () { CONTEXT = {0}; Getdebuggeecontext (&Context); = Getcoodelen (CONTEXT.EIP) + Context.eip; Setccbreakpointat (addr,softtype_once); return TRUE;}
Then about the previous hardware breakpoint problem, found that set 1 bytes of breakpoint can be broken down, but when the breakpoint recovery, set TF recovery will not function properly
There is a problem.
This debugger also dragged for a long time did not get, feel put down for a long time will not get, even not in, footsteps not steadfast, when can down-to-earth.
Link Http://pan.baidu.com/s/1qXYKjxU
Implementation of the Simple Debugger (iii)