| View previous topic :: View next topic |
| Author |
Message |
Culinary Newbie cheater
Reputation: 0
Joined: 24 Mar 2011 Posts: 15
|
Posted: Wed May 11, 2011 6:04 pm Post subject: Hardware breakpoint question. |
|
|
Hi there, after using Cheat Engine for awhile I had become rather interested in debugging api and started writing my own tools for fun. I understand software breakpointing, I have done it many times (0xCC at the instruction, catching exception_breakpoint with the debugger etc) but I am wondering how hardware breakpoints are used.
Maybe I am just blind but I couldnt seem to find much documentation, I understand that DR registers need to be set to the address you want to break on, and that dr7 contains the flags for what is happening (read/write etc)
Also, is it done by using DebugBreakProcess to freeze the entire program and then using SetThreadContext? I remember reading that you need to use SuspendThread first, but that seems crazy if you were to just suspend one thread whilst the other continue. Unless going from SuspendThread and then SetThreadContext is fast enough that it wouldnt matter?
Ive never encountered that because I have only done software bps, and the entire program is already halted before you call ContinueDebugEvent.
This probably sounds like a ramble, but can someone point me in the right direction or link me some good documentation on this?
Thanks
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25833 Location: The netherlands
|
Posted: Wed May 11, 2011 6:42 pm Post subject: |
|
|
To set a debug register it's normal to suspend each thread, then call getthreadcontext to fetch the debug register state and then setthreadcontext after making the adjustments, and then resumethread (suspending for debug registers isn't really required as it works without, but it helps with debugging)
also, it's fast enough and it doesn't matter even if it was slow, each debug register is thread specific, so you can set a breakpoint in one thread and all the other threads can just run if they like
and DebugBreakProcess isn't used at all
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Culinary Newbie cheater
Reputation: 0
Joined: 24 Mar 2011 Posts: 15
|
Posted: Wed May 11, 2011 6:59 pm Post subject: |
|
|
thanks for the reply, and also thanks for keeping cheat engine free, its a great learning tool!
so would this make sense then?
0xdeadbeef can be our example
-obtain all thread handles
-suspend all threads
-set a hardware bp for 0xdeadbeef using setthreadcontext on all threads
-sit back and wait?
also, where can I find info on how to use dr0-dr7 properly?
thanks again Dark Byte, i appreciate the help
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25833 Location: The netherlands
|
|
| Back to top |
|
 |
Culinary Newbie cheater
Reputation: 0
Joined: 24 Mar 2011 Posts: 15
|
Posted: Wed May 11, 2011 8:19 pm Post subject: |
|
|
very helpful, thanks again
|
|
| Back to top |
|
 |
|