How can I write a simple debugger for Windows? I need to launch another program (do not attach to an already running one, but launch it yourself) then to let it run and to catch it at a certain address. Moreover, the breakpoint must be set via hardware debugging registers, not by just 0xCC. I did not find any source code for an example of such thing over the Internet, alas.

2 Answers 2


Not exactly an RE question but MSDN has an example of the main loop. I also found this tutorial:


  • I need to write a launcher for some program so that the program unpacks itself and then stops at its unpacked code. The fact is that I can't use 0xCC, it will be overwritten during the unpacking so I need to make a stop using HDR to stop on execution at a certain address. I saw the link to MSDN you mentioned, but it shows just a skeleton, no specifics. Thanks for the second link, it's more clear there. The question remains: how to use HDR? Am I have to modify their values via say SetThreadContext? I did not find any WinAPI for manipulating exactly the values ​​of hardware debug registers. Aug 14, 2022 at 5:20
  • And yes, the program I try to dig in is packed (protected) with Themida, so it's quite an RE question :-) I need Themida unpack its stuff first and then I get down to the program itself. Aug 14, 2022 at 5:27

I remember reading Grey Hat Python where they take you through writing your own debugger, maybe that would be a good start.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.