Skip to main content

Posts

Showing posts with the label Waiting to finish CreateProcess()

CreateProcess() - Waiting for CreateProcess to finish.

CreateProcess() :   Creates a new process and its primary thread. The new process runs in the security context of the calling process. If the calling process is impersonating another user, the new process uses the token for the calling process, not the impersonation token. To run the new process in the security context of the user represented by the impersonation token, use the CreateProcessAsUser or CreateProcessWithLogonW function. Primary focus of this post is going to be waiting for CreateProcess() to finish. I have seen in many situations developer wants to start a external binary and this task can be accomplished by using CreateProcess() API. What happens after starting this process ?  We will not have control over this newly running application/binary, that is expected however at times we want to wait till it completes it execution.  How do achieve that ? It is not rocket science it in fact is pretty simple.  // Create the process PROCESS_INFORMATION pi; ...