Implementation of the Simple Debugger (iii)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.