rc-chuah

CreateProcess3

Mar 18th, 2022 (edited)
790
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.89 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <windows.h>
  3.  
  4. int main() {
  5.     STARTUPINFOW 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 (!CreateProcessW(L"C:\\Windows\\System32\\bcdedit.exe", L"C:\\Windows\\System32\\bcdedit.exe /enum", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
  12.     {
  13.         if (!CreateProcessW(L"C:\\Windows\\Sysnative\\bcdedit.exe", L"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