Log in

View Full Version : OllyDbg v1.10 And Hardware Breakpoints


walied
February 7th, 2012, 18:16
While playing with OllyDbg v1.10, i came across a weird behavior of OllyDbg v1.10, which was fixed in the latest version. The problem lies in the way OllyDbg sets hardware breakpoints.

At 0x4D8D70, there is an array of four structures of type, t_hardbpoint.
http://3.bp.blogspot.com/-jDHuerF5XGI/TzCC0Pmk6yI/AAAAAAAAAUU/aqXl2mjbJ-c/s1600/Untitled.png

Each structure in this array holds information about each hardware breakpoint. Information includes hardware breakpoint address, type, and size. When you manually set a hardware breakpoint, this structure is filled, but the breakpoint is not immediately activated.

On the other hand, when an EXCEPTION_SINGLE_STEP or EXCEPTION_BREAKPOINT is received, information in the structures at 0x4D8D70 is copied to DR0 through DR3 overwriting old values in them, if there are any. The point here is that if you programmatically set a hardware breakpoint, single stepping will be enough to cause debug registers to be cleared.
http://1.bp.blogspot.com/-5fIwPjAJXgQ/TzCf-_gXJ_I/AAAAAAAAAUc/6g0nPFwNPSw/s1600/Untitled.png
N.B. IDA pro and OllyDbg v2.0 behave normally with this scenario.

An executable demonstrating how to use this strange behavior to detect OllyDbg v1.10 can be found here.
http://ollytlscatch.googlecode.com/files/demo_hwbp.exe

Original topic here.
http://waleedassar.blogspot.com/2012/02/ollydbg-v110-and-hardware-breakpoints.html