-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathread_addr.c
64 lines (53 loc) · 1.44 KB
/
read_addr.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* @file read_addr.c
* @author Lucas Vieira ([email protected])
* @brief Demonstração de uso da libhack para ler um valor da memória de outro programa
* @date 2020-08-18
*
* @copyright Copyright (c) 2020
*
*/
#include "../../init.h"
#include "../../process.h"
int main()
{
struct libhack_handle *hack = NULL;
int value;
DWORD baseAddr;
/*
Initialize library always
*/
hack = libhack_init("calculator.exe");
if(!hack)
{
printf("Failed to initialize libhack\n");
return 0;
}
/*
We won't be able to perform any operations in a process
unless it is opened
*/
if(!libhack_open_process(hack))
{
printf("We failed to open process\n");
return 0;
}
/*
Here we get the base address of process
Many of values can be obtained by using a offset from
a process base address
*/
baseAddr = libhack_get_base_addr(hack);
printf("Base address of %s: %#x\n", hack->process_name, baseAddr);
/*
Here we are reading the memory at address with a offset
0x4c from process base address
*/
value = libhack_read_int_from_addr(hack, baseAddr + 0x4c);
printf("Value readed from address %#x: %d\n", baseAddr + 0x4c, value);
/*
Cleanup resources used by library
*/
libhack_free(hack);
return 0;
}