-
Notifications
You must be signed in to change notification settings - Fork 7
/
ps.c
34 lines (28 loc) · 758 Bytes
/
ps.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
#include <stdio.h>
#include <tlhelp32.h>
#include <windows.h>
#include "../../src/psxecute.h"
int start()
{
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSnapshot == INVALID_HANDLE_VALUE)
{
PSX_PRINT("Error creating snapshot\n");
return 1;
}
PROCESSENTRY32 pe32;
pe32.dwSize = sizeof(PROCESSENTRY32);
if (!Process32First(hSnapshot, &pe32))
{
PSX_PRINT("Error getting first process\n");
CloseHandle(hSnapshot);
return 1;
}
PSX_PRINT("Running processes:\n");
do
{
PSX_PRINTF_2("%i\t%s\n", (void*)pe32.th32ProcessID, (void*)pe32.szExeFile);
} while (Process32Next(hSnapshot, &pe32));
CloseHandle(hSnapshot);
return 0;
}