rc-chuah

CreateProcess2

Mar 18th, 2022 (edited)
782
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.88 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <windows.h>
  3.  
  4. int main() {
  5.     STARTUPINFO si;
  6.     PROCESS_INFORMATION pi;
  7.     ZeroMemory(&si, sizeof(si));
  8.     si.cb = sizeof(si);
  9.     ZeroMemory(&pi, sizeof(pi));
  10.     // Start the child process.
  11.     if (!CreateProcessA("C:\\Windows\\System32\\bcdedit.exe", "C:\\Windows\\System32\\bcdedit.exe /enum", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
  12.     {
  13.         if (!CreateProcessA("C:\\Windows\\Sysnative\\bcdedit.exe", "C:\\Windows\\Sysnative\\bcdedit.exe /enum", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
  14.         {
  15.             puts("Error: CreateProcess Failed!");
  16.         }
  17.     }
  18.     // Wait until child process exits.
  19.     WaitForSingleObject(pi.hProcess, INFINITE);
  20.     // Close process and thread handles.
  21.     CloseHandle(pi.hProcess);
  22.     CloseHandle(pi.hThread);
  23.     printf("Press Enter To Continue ... ");
  24.     (void)getchar();
  25.     return 0;
  26. }
Add Comment
Please, Sign In to add comment