I have an application in C++ developed in VS2010. This application has an ability to restart itself when needed (some changes that requires it to reboot). Now there's some bug that occurs only under certain circumstances on the beginning of the new instance after the restart. The problem is that I can't find out what it is, because the new instance does not have the debugger attached (VS debug mode ends with the initial instance closing). Any idea how to automatically attach a debugger to the new instance?
Thank you
I "discovered" how this is done after getting infected with some malware that used the same technique to wrap all calls to anti-virus products to redirect them to it's own executable!
Summarising the steps described here, it just involves some registry editing. FWIW, tools like DebugDiag
also used to use this method to trap an application launch and activate the debugger:
To setup an application to launch the debugger automatically
Start the Registry Editor (regedit).
In the Registry Editor, open the HKEY_LOCAL_MACHINE
folder.
Navigate to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\image file execution options
.
In the Image File Execution Options folder, locate the name of the application you want to debug, such as myapp.exe. If you cannot find the application you want to debug:
a. Right-click the Image File Execution Options folder, and on the shortcut menu, click New Key.
b. Right-click the new key, and on the shortcut menu, click Rename.
c. Edit the key name to the name of your application; myapp.exe, in this example.
Right-click the myapp.exe folder, and on the shortcut menu, click New String Value.
Right-click the new string value, and on the shortcut menu, click Rename.
Change the name to debugger
.
Right-click the new string value, and on the shortcut menu, click Modify.
The Edit String dialog box appears.
In the Value data box, type vsjitdebugger.exe.
Click OK.
From the Registry menu, click Exit.
The directory containing vsjitdebugger.exe must be in your system path. See the above link for the full instructions.
Now, use any method to start your application. Visual Studio will start and load the application in the debugger.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With