Quick Break Keys with the UserDebuggerHotKey
At times, you need a way to get into the debugger as fast as possible. If you're debugging a console-based application, pressing Ctrl+C or Ctrl+Break will cause a special exception, dbg_control_c. The dbg_control_c exception will pop you right into the debugger and allow you to start debugging.
A nice feature of Windows operating systems is that you can also pop into the debugger at any time for your GUI-based applications. When running under a debugger, by default, pressing the F12 key forces a call to DebugBreak nearly the instant the key is pressed. An interesting aspect of the F12 key processing is that even if you're using F12 as an accelerator or otherwise processing the keyboard messages for F12, you'll still break into the debugger.
The quick break key defaults to F12 but, if you like, you can specify which key to use. The UserDebuggerHotKey value is the numeric vk_* value you use to make the key the debugger hot key. For example, if you want to use the Scroll Lock key to break into the debugger, set the UserDebuggerHotKey value to 0x91. After you set a new value, you must reboot the computer for the change to take effect. A wonderful joke to play on your coworkers is to change the UserDebuggerHotKey to 0x45 (the letter E) so that every time they press the E key, the key breaks into the debugger. However, I take no responsibility if your coworkers gang up on you and make your life miserable.
Post a comment