Skip to content

Instantly share code, notes, and snippets.

@iljavs
Last active July 16, 2020 21:28
Show Gist options
  • Save iljavs/d0a7d34cb207156fedc72f6add9a2723 to your computer and use it in GitHub Desktop.
Save iljavs/d0a7d34cb207156fedc72f6add9a2723 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <windows.h>
int main(){
STARTUPINFOW su;
PROCESS_INFORMATION pi;
memset(&su, 0x00, sizeof(su));
memset(&pi, 0x00, sizeof(pi));
su.cb = sizeof(su);
int r = CreateProcessW(L"c:\\windows\\system32\\mspaint.exe", NULL, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &su, &pi);
if (r) {
printf("CreateProcess() worked\n");
DWORD r = WaitForSingleObject(pi.hProcess, 10000);
if (r == WAIT_OBJECT_0) {
printf("process closed\n");
}
else {
printf("Process is still running\n");
}
}
else {
DWORD e = GetLastError();
printf("CreateProcess() failed :(, error: 0x%x \n", e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment