Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to launch debugger automatically to debug 32 bit applications on Windows 7 64 bit?

I'm trying to have Windows automatically start the debugger when an application is launched (as described in msdn) however I'm getting the following error:

The Visual Studio Just-In-Time Debugger was not notified that the application correctly started

A quick search found this person with the same problem where the suggestion was:

If you are running Vista or Win7 you need to run vsjitdebugger as an administrator or you will get that error.

I went to C:\Windows\System32\ and in the compatibility tab of vsjitdebugger.exe's properties I checked the Run this program as an administrator check box. Now I'm getting the following message

The requested operation requires elevation

Followed by

Can't open this item
It might have been moved, renamed, or deleted. Do you want to remove this item?

I'm not sure if the fact that this is a 32 bit application on a 64 bit OS is relevant.

like image 289
Motti Avatar asked Jul 13 '11 10:07

Motti


People also ask

How do I start Windows debugger?

On the File menu, choose Open Executable. In the Open Executable dialog box, navigate to C:\MyApp\x64\Debug. For File name, enter MyApp.exe. Select Open.

How do I set up remote debugging?

Set up the remote debugger. On the remote computer, find and start the Remote Debugger from the Start menu. If you don't have administrative permissions on the remote computer, right-click the Remote Debugger app and select Run as administrator. Otherwise, just start it normally.


2 Answers

You should run your application as an administrator (don't setup vsjitdebugger.exe to run as administrator). Then you will be prompted with the security warning and after that normal list with debuggers to choose from. In my case I had to run as an administrator program which runs debugged program.

like image 140
Denis Kruchkov Avatar answered Nov 16 '22 03:11

Denis Kruchkov


So after looking around for the solution to this problem I found the answer here. The issue for me was that the debugger registry hives weren't set properly. This is prolly due to missing the Auto entry, though I'm not positive. I didn't have this issue before I upgraded to Windows 10. The registry entries need to be:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug]
"Auto"="1"
"Debugger"="\"C:\\WINDOWS\\system32\\vsjitdebugger.exe\" -p %ld -e %ld"
"UserDebuggerHotKey"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug]
"Auto"="1"
"Debugger"="\"C:\\WINDOWS\\system32\\vsjitdebugger.exe\" -p %ld -e %ld"
"UserDebuggerHotKey"=dword:00000000

To disable JIT debugging use:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug]
"Auto"="1"
"Debugger"=-
"UserDebuggerHotKey"=-

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug]
"Auto"="1"
"Debugger"=-
"UserDebuggerHotKey"=-

Just a FYI, I wrote a simple cmd script to enable/disable on a per executable name basis. I'm posting it here for you convenience:

@echo off
if %1.==. goto help
if %1==/internal goto apply
if %1==/d (
        %0 /internal %2 -
) else (
        %0 /internal %1 "vsjitdebugger.exe"
)
goto help

:apply
shift
 >%temp%\output.reg     echo Windows Registry Editor Version 5.00
>>%temp%\output.reg     echo+
if %2 == - (
  : Delete registry key
        >>%temp%\output.reg     echo [-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\%~1]
) else (
  : Add registry key
        >>%temp%\output.reg     echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\%~1]
        >>%temp%\output.reg     echo "debugger"=%2
)
:In case you want to see what it is importing, uncomment the following 3 lines
:echo %temp%\output.reg
:echo --------------------
:type %temp%\output.reg
regedit /s %temp%\output.reg
del %temp%\output.reg
goto :eof

:help
echo %0 [/d] ^<executable.exe^>
echo.
echo Allows you to attach a debugger as soon as the process executes anywhere in the
echo system. If /d switch is provided, then delete the registry key to stop this
echo behaviour.

Because of the use of %0, you can name it whatever you want (with an .cmd or .bat extension) and it will still work as expected.

like image 34
Adrian Avatar answered Nov 16 '22 03:11

Adrian