-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmem.cpp
More file actions
36 lines (27 loc) · 724 Bytes
/
mem.cpp
File metadata and controls
36 lines (27 loc) · 724 Bytes
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
#include "framework.h"
#include "mem.h"
#include "proc.h"
uintptr_t MEM::FindDMAAddyIn(uintptr_t addr, std::vector<unsigned int> offsets)
{
uintptr_t cAddr = addr;
for (unsigned int i = 0; i < offsets.size(); i++)
{
cAddr = *(uintptr_t*)cAddr;
// Check if memory is writable (not ?? in cheatengine)
if (IsBadReadPtr((uintptr_t*)cAddr, sizeof(cAddr)))
return 0;
cAddr += offsets[i];
}
return cAddr;
}
uintptr_t MEM::FindDMAAddyEx(HANDLE hProc, uintptr_t ptr, std::vector<unsigned int> offsets)
{
uintptr_t addr = ptr;
for (unsigned int i = 0; i < offsets.size(); ++i)
{
ReadProcessMemory(hProc, (BYTE*)addr, &addr, sizeof(addr), 0);
addr += offsets[i];
}
return addr;
}
MEM* mem = new MEM();