CreateProcess Example (Basic)

#include <windows.h>
#incluse <stdio.h>

int main(void){    
STARTUPINFOW si = { 0 };
PROCESS_INFORMATION pi = { 0 };

    if (!CreateProcessW(
        L"C:\\Windows\\System32\\mspaint.exe",
        NULL,
        NULL,
        FALSE,
        NORMAL_PRIORITY_CLASS,
        NULL,
        NULL,
        &si;
        &pi;  
    )){
        printf("(-) failed to create process, error: %ld", GetLastError());
        return EXIT_FAILURE;
    }
    printf("(+) process started! pid: %ld", pi.dwProcessId);
    return EXIT_SUCCESS;    //same as return 0;
}    

Last updated