How to start a process and then pause it immediately?

I would like to know if there is any command or tool that can be used to start the process and then pause it immediately.

I need this function so that I have time to connect a debugger to it. I tried the visual studio / debugexe function, but the program behavior seemed to be changed. So I need to find another way to attach it and debug it.

Thanks.

+5
source share
3 answers

You can use CreateProcess () with the CREATE_SUSPENDED flag. This will start the process with the suspension of the main thread. Then you call ResumeThread () after joining.

+5
source
0

You can also add a call.

System.Diagnostics.Debugger.Break();

in code. It pauses the program and then asks you to select the debugger that you want to use. Then you can connect to the executable instance of Visual Studio. If you are already using a debugger, it just breaks as if it hit a breakpoint.

0
source

All Articles