-
Notifications
You must be signed in to change notification settings - Fork 2
/
pid.c
47 lines (39 loc) · 925 Bytes
/
pid.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
40
41
42
43
44
45
46
47
/**
* @file read_addr.c
* @author Lucas Vieira ([email protected])
* @brief Demonstração de uso para obter o pid de um processo
* @date 2020-08-18
*
* @copyright Copyright (c) 2020
*
*/
#include "../../init.h"
#include "../../process.h"
int main()
{
struct libhack_handle *hack = NULL;
DWORD pid;
const char *process = "explorer.exe";
/*
Initialize library always
*/
hack = libhack_init(process);
if(!hack)
{
printf("Failed to initialize libhack\n");
return 0;
}
/*
We get the pid of process
*/
pid = libhack_get_process_id(hack);
if(pid)
printf("PID of %s is %lu\n", process, pid);
else
printf("We failed to get process ID: %lu\n", GetLastError());
/*
Cleanup resources used by library
*/
libhack_free(hack);
return 0;
}