Get a Win32 program to request a debugger at startup?

We have a C ++ Win32 application that appears using Qt QProcess (certainly the shell for CreateProcess ()), a secondary โ€œsubordinateโ€ program.

Unfortunately, when debugging a system using Visual Studio 2008, the debugger does not automatically join the spawned process.

I know that it is possible to programmatically start a debugger breakpoint using __debugbreak (), but is it possible for a subordinate program to select the "Select a program to debug" window immediately upon startup, since at the moment we must participate in the race manually bind to a new process ?

+3
source share
2 answers

Use Image File Execution Options . You can specify the Visual Studio debugger as the default debugger for attaching to the process.

If you use command line debuggers , you can use ntsd -ochild processes to automatically debug.

+4
source

Another neat trick I learned from Jeffrey Richterโ€™s book "Windows Application Programming"

  • Create a DLL with DebugBreak () in DLLMain () inside the DLL_PROCESS_ATTACH case
  • Add the path to your new DLL in the registry (this is a comma-separated list):
HKEY_LOCAL_MACHINE \ Software \ Microsoft \ Windows NT \ CurrentVersion \ Windows \ AppInit_DLLs

DLL, . DLLmain, .

. , "GetModuleBasename" .

+2

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


All Articles