'How to debug a C application that is called by another process and ends very quickly in Visual Studio?

I can't attach to the C application process because it ends only milliseconds after being called. And the caller is an exe that I don't have the source code.



Solution 1:[1]

It's an annoying method but you can set a bbreakpoint in your sub-program, use CreateProcess (or one of its variants) to start the program with CREATE_SUSPENDED in the dwCreationFlags argument. Next attach to the suspended process, and finally resume the suspended program's main thread using the Debug -> Windows -> Threads window. The breakpont is necessary because otherwise the program will simply run to completion once the thread is resumed.

Or use trace debugging (although if it's not a console program you'll probably need to write to a log file).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SoronelHaetir