Jump to content
Tuts 4 You

Dr7 Setting


Recommended Posts

I have been looking into setting hardware breakpoints, I googled the hell out of it, anyway, every site I go to says set dr7 to 101, which although it works, it isnt very helpful, I was wondering if anyone could explain how to set the dr7 right especially when there is more then 1 hardware breakpoint and where to put the settings for type (access, write, execute) for each breakpoint. Thank you for you time.

Link to comment

Found a pretty good source in C++ which doesnt seem to edit DR7 just hardcoded but somehow calculates it.

I dont have a clue about that myself so I couldnt tell you why it is done which way.


Especially look at that piece of code:

SetBits(cxt.Dr7, 16 + (m_index*4), 2, when);
SetBits(cxt.Dr7, 18 + (m_index*4), 2, len);
SetBits(cxt.Dr7, m_index*2, 1, 1);

where 'when' decides whether its hwbp on write (3) or read (1).

Not sure about execute, should be either 2 or 0 :D

Look at breakpoint.h for the implementation of SetBits :)

Link to comment

Well, that was confusing as hell, but I think I got it, I guess you have to place 32 bits of info into 1 dword and reset the regflag. For instance if you just want to set all for breakpoints to execute on execution, you set dr7 to 257. Still a little confused. Thanks for the Intel manual and example.

Edited by What
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...