 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
iPromise Grandmaster Cheater
Reputation: -1
Joined: 27 Jun 2009 Posts: 529 Location: Canada
|
Posted: Fri May 25, 2012 9:33 pm Post subject: Hardware Breakpoints |
|
|
I understand that the DR0 - DR3 registers are the registers where you set the address for your breakpoint. I can't seem to understand how the Dr7 register works though. I do know that they are the conditions set for the breakpoint but what i'm doing doesn't work.
| Code: |
// Create our variable
CONTEXT c;
// Obtain thread information
c.ContextFlags = CONTEXT_DEBUG_REGISTERS;
GetThreadContext ( GetCurrentThread (), &c );
// Adjust breakpoint
c.Dr0 = dwAddr;
c.Dr7 = ( 3 << 16 ); // 11b for data read/write
// Set breakpoint
SetThreadContext ( GetCurrentThread (), &c );
|
Dr0 is the address i'm setting for my breakpoint, and Dr7 is the conditions for the breakpoint. What am I missing?
|
|
| Back to top |
|
 |
Innovation Grandmaster Cheater
Reputation: 12
Joined: 14 Aug 2008 Posts: 617
|
Posted: Fri May 25, 2012 10:08 pm Post subject: |
|
|
You need to set the debug registers in every thread in the process (excluding the one in which you're doing this). Also, you should use SuspendThread and ResumeThread respectively before and after messing with the registers to ensure you don't accidentally screw up the context as the thread is still running. See this for an example.
To correctly use DR0 in your case, you should set the 0th, 16th, and 17th bits and unset the 1st, 18th, and 19th bits of DR7 (assuming you only want a breakpoint for one byte).
| Code: | c.Dr7 |= 0x00030001; // 1 | (3 << 16)
c.Dr7 &= 0xFFF3FFFD; // ~((1 << 1) | (3 << 18)) |
See this for more information.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|