Tuesday, February 11, 2014

Launch Program in Debugger Automatically

Sometimes I have the requirement to launch an application automatically (and always) in debugger. For example, if we have a pair of master and slave programs. The master program will start the slave program and we want to debug the slave program.

On Windows, there is a simple way to do that. Basically, we just need to add a string value Debugger=PathToYourDebugger.exe to registry under the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\YourProgram.exe. Here, PathToYourDebugger.exe is the full path to your debugger and YourProgram.exe is the full path to your program.

After that, every time you start YourProgram.exe, the debugger will be launched.

The commands below can make it even easier.

To enable automatically-debugger-launching for a program

REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\YourProgram.exe"  /f /t REG_SZ /v debugger /d "PathToYourDebugger.exe"

To disable automatically-debugger-launching for a program

REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\YourProgram.exe" /f

No comments:

Post a Comment