How to combat one of the hardware breakpoint debugging registers

Source: Internet
Author: User

Author: Lenus

1. Preface

When I entered the ollydbg door, I was full of questions about various breakpoints in ollydbg. I used to understand the differences between normal breakpoints, memory breakpoints, and hardware breakpoints, why are they sometimes unable to mix them? What are their principles? after learning the articles of their predecessors, they finally understood something. I hope this article will help you with the principle and usage of hardware breakpoints.

2. Text
I. Principle of hardware breakpoint

In registers, there are some registers for debugging. People call them debugging registers, which have a total of eight names respectively from the Dr0-Dr7. Therefore, we also call the debugging register Drx.

For the four Debug Registers of the Dr0-Dr3, their role is to store the interrupt address, for example: 401000
For Dr4 and Dr5 registers, we generally do not use them and keep them.
For Dr6, the two registers of Dr7 are used to record the properties of the address you disconnected in the Dr0-Dr3, for example, whether the 401000 is read or written by hardware or executed; whether it is a byte, a pair of words, or a pair of words.

Okay. you may understand something here.

1. Why is there only four hardware breakpoints in OD?
2. Why are there byte, word, and dword in the hardware breakpoint?
3. Why are there read, write, and execution points for the hardware breakpoint?

Ii. Differences between F4, F8, F7, and F2

In the help of ollydbug, I only mentioned how to use F7 and F8, and did not explain their implementation principles.

Now let's do an experiment.

Experiment 1 (Principles of F4)

1. Find a program, load the OD, and construct an endless loop.

Like this:

00400154> 90 nop // EP stops here
00400155 90 nop
00400156 90 nop
00400157 90 nop
00400158 ^ eb fa jmp short day 2 International. <ModuleEntryPoint> // construct an endless loop
0040015A 61 popad
0040015B 94 xchg eax, esp

2. Press F4 on the line 0040015A. The program runs continuously due to the endless loop.

3. In the debugger window, right-click to view the debugging register.

The result is displayed in Drx:

DR0 0040015A // address
DR1 00000000
DR2 00000000
DR3 00000000
DR6 FFFF0FF0 // breakpoint attribute
DR7 00000401

Experiment 2 (F8 Principles)

1. Find a program, load OD, and construct an endless loop of sub-programs.

Just like this

00400154 t> E8 0100D03F call 4010015A // EP, stop here
00400159 90 nop
0040015A 90 nop
0040015B 90 nop
0040015C 90 nop // The F2 breakpoint here
0040015D C3 retn // return

2. Press F8. Due to INT3 breakpoint, the program is interrupted at 0040015C.

3. In the debugger window, right-click to view the debugging register.

The result is displayed in Drx:

DR0 00400159 // return address of call
DR1 00000000
DR2 00000000
DR3 00000000
DR6 FFFF4FF1 // breakpoint attribute
DR7 00000401

Experiment 3 (F7 Principles)

1. Find a program and load the OD

2. Double-click the T sign in the window of the debugger to change TF from 0 to 1.

3. Run F9

The result program is disconnected from the following line.

Experiment 4 (Principles of F2)

1. Use notepad of 98 to load OD and construct an endless loop.

004010CC N> 90 nop // EP, which is quite here
004010CD 90 nop
004010CE ^ eb fc jmp short NOTEPAD. <ModuleEntryPoint> // endless loop
004010D0 90 nop // press F2 here, normal breakpoint
004010D1 90 nop

2. Press F9 and the program runs continuously due to an endless loop.

3. Use LordPE (do not use ollydump) to dump the program.

4. Reload OD

Let's see what it looks like.

004010CC d> $ Content $ nbsp; 90 nop
004010CD. 90 nop
004010CE. ^ eb fc jmp short dumped. <ModuleEntryPoint>
004010D0 CC int3 // CC is changed here
004010D1 90 nop


3. Summary

From experiment 1 and Experiment 2, we can clearly see that F4 directly puts the address of this row into drx, and F8 puts the address of the next row into drx, they all use debugging registers. From the third part of the experiment, we know that for F7, it is likely to use the method of setting TF to one, that is, when we press F7, OD sets TF to one. For F2, the first byte is changed to CC. Although it is not shown to me, it is a CC. When we press F2, OD is not running yet, just record this representation. When it runs, it modifies all the marked bytes, even though the original code is displayed. Of course, when it is paused

Related Article

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: 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.