46 lines
1007 B
C
46 lines
1007 B
C
#include <windows.h>
|
|
#include <stdio.h>
|
|
|
|
int main() {
|
|
|
|
STARTUPINFOW proc_start_info = { 0 };
|
|
PROCESS_INFORMATION proc_info = { 0 };
|
|
|
|
if (!CreateProcessW(
|
|
L"C:\\Windows\\system32\\notepad.exe",
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
FALSE,
|
|
BELOW_NORMAL_PRIORITY_CLASS,
|
|
NULL,
|
|
NULL,
|
|
&proc_start_info,
|
|
&proc_info
|
|
)) {
|
|
printf("Failed to create process: %ld\n", GetLastError());
|
|
return -1;
|
|
}
|
|
|
|
printf("Process started, pid: %ld, tid: %ld\n", proc_info.dwProcessId, proc_info.dwThreadId);
|
|
|
|
|
|
HANDLE h = OpenProcess(
|
|
PROCESS_QUERY_LIMITED_INFORMATION,
|
|
FALSE,
|
|
7132
|
|
);
|
|
if (h == NULL) {
|
|
printf("Failed to open process: ");
|
|
DWORD err = GetLastError();
|
|
if (err == ERROR_ACCESS_DENIED) {
|
|
printf("ERROR_ACCESS_DENIED");
|
|
} else {
|
|
printf("%ld", GetLastError());
|
|
}
|
|
printf("\n");
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
} |