How can I debug a process (1.exe) under another process (2.exe)?

1.exe does not give me time to run the IDE and attach 1.exe to the debugger to break into it.

+3
source share
6 answers

I would suggest using the same approach as for NT services in this case. They will also start and usually do not give you enough time to attach a debugger for startup procedures.

Details are described here: http://www.debuginfo.com/articles/debugstartup.html

In short, you add a registry entry for the second exe:

HKLM \ Software \ Microsoft \ Windows NT \ CurrentVersion \ Image File Execution Options \ 2.exe Debugger = "C: \ Progs \ MSVS \ Common7 \ ide \ devenv.exe / debugexe" (REG_SZ)

c:\progrs\msms\ .

, .

+6

, 1.exe( ), , , . (getch(), , .)

.

0

- :

#ifdef DEBUG
Thread.Sleep(10000);
#endif
0

1.exe? CreateProcess(), , , .

0

If you want to consider a debugger other than Visual Studio, WinDBG can automatically debug child processes (native code only).

0
source

You did not indicate which language you are using. But if you use C # or VB.NET, you can add Debug.Break () or Stop to trigger a request to attach the debugger to the process.

Or, as mentioned above, just use something like Console.Readline () or MessageBox.Show () to pause the process until you can connect a debugger to it.

0
source

Source: https://habr.com/ru/post/1696988/


All Articles