Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Hardware breakpoint question.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Culinary
Newbie cheater
Reputation: 0

Joined: 24 Mar 2011
Posts: 15

PostPosted: Wed May 11, 2011 6:04 pm    Post subject: Hardware breakpoint question. Reply with quote

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 Smile
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25833
Location: The netherlands

PostPosted: Wed May 11, 2011 6:42 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Culinary
Newbie cheater
Reputation: 0

Joined: 24 Mar 2011
Posts: 15

PostPosted: Wed May 11, 2011 6:59 pm    Post subject: Reply with quote

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 Smile


-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 Smile
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25833
Location: The netherlands

PostPosted: Wed May 11, 2011 7:22 pm    Post subject: Reply with quote

http://www.intel.com/Assets/PDF/manual/253668.pdf

chapter 16

_________________
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
View user's profile Send private message MSN Messenger
Culinary
Newbie cheater
Reputation: 0

Joined: 24 Mar 2011
Posts: 15

PostPosted: Wed May 11, 2011 8:19 pm    Post subject: Reply with quote

very helpful, thanks again Cool
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites