Skip to content

Instantly share code, notes, and snippets.

@un4ckn0wl3z
Created March 19, 2023 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save un4ckn0wl3z/18f68421a843163b3a80578adbb22d7b to your computer and use it in GitHub Desktop.
Save un4ckn0wl3z/18f68421a843163b3a80578adbb22d7b to your computer and use it in GitHub Desktop.
#include <iostream>
#include <Windows.h>
int main()
{
STARTUPINFO si;
si.cb = sizeof(si);
ZeroMemory(&si, sizeof(si));
PROCESS_INFORMATION pi;
ZeroMemory(&pi, sizeof(pi));
BOOL success = CreateProcess(
L"C:\\Windows\\System32\\notepad.exe",
NULL,
0,
0,
FALSE,
0,
NULL,
L"C:\\Windows\\System32",
&si,
&pi);
if (success)
{
printf("Process created with PID: %d.\n", pi.dwProcessId);
return 0;
}
else
{
printf("Failed to create process. Error code: %d.\n", GetLastError());
return 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment