-
Notifications
You must be signed in to change notification settings - Fork 0
/
createprocess.c
39 lines (34 loc) · 1.3 KB
/
createprocess.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdio.h>
#include <Windows.h>
int main(void) { // creating a process that start mspaint
// BOOL CreateProcessW(
// [in, optional] LPCWSTR lpApplicationName,
// [in, out, optional] LPWSTR lpCommandLine,
// [in, optional] LPSECURITY_ATTRIBUTES lpProcessAttributes,
// [in, optional] LPSECURITY_ATTRIBUTES lpThreadAttributes,
// [in] BOOL bInheritHandles,
// [in] DWORD dwCreationFlags,
// [in, optional] LPVOID lpEnvironment,
// [in, optional] LPCWSTR lpCurrentDirectory,
// [in] LPSTARTUPINFOW lpStartupInfo,
// [out] LPPROCESS_INFORMATION lpProcessInformation
// );
STARTUPINFO si = { 0 };
PROCESS_INFORMATION pi = { 0 };
if (!CreateProcessW(
L"C:\\Windows\\System32\\mspaint.exe",
NULL,
NULL,
NULL,
FALSE,
BELOW_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;
}