-
Notifications
You must be signed in to change notification settings - Fork 0
/
HebroHelper.h
54 lines (42 loc) · 984 Bytes
/
HebroHelper.h
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once
#ifndef HEBROHELPER
#define HEBROHELPER
#include <iostream>
#include <Windows.h>
#include <string>
#include <TlHelp32.h>
//int getPID(const char* procname)
int getPID(const char* process)
{
process = "explorer.exe";
HANDLE hSnapshot;
PROCESSENTRY32 pe;
int pid = 0;
BOOL hResult;
//get all processes
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (INVALID_HANDLE_VALUE == hSnapshot)
{
//printf("Couldn't create a Snapshot of running Processes. Maybe your AV is blocking it\n");
return 0;
}
//int
pe.dwSize = sizeof(PROCESSENTRY32);
//info about first process
hResult = Process32First(hSnapshot, &pe);
//retrieve info
while (hResult)
{
if (strcmp(process, pe.szExeFile) == 0)
{
pid = pe.th32ProcessID;
break;
}
hResult = Process32Next(hSnapshot, &pe);
}
CloseHandle(hSnapshot);
//std::cout << pid;
return pid;
//destroy handle
};
#endif