-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmemory.h
56 lines (48 loc) · 1.46 KB
/
memory.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
55
56
#pragma once
#include <Windows.h>
#include <TlHelp32.h>
#include <vector>
struct ModuleStruct
{
DWORD64 addr;
DWORD size;
};
extern DWORD g_dwProcessId;
extern HANDLE g_hProcess;
extern ModuleStruct moduleStruct;
extern DWORD64 LocalScriptsPTR;
DWORD getProcessId(LPCWSTR processName);
ModuleStruct getModuleStruct(DWORD processId, LPCWSTR moduleName);
DWORD64 patternScan(DWORD64 base, DWORD len, char* sig, char* mask);
template<typename T> T re(DWORD64 address)
{
T ret;
ReadProcessMemory(g_hProcess, (void*)address, &ret, sizeof(T), 0);
return ret;
};
template<typename T> void wr(DWORD64 address, T value)
{
T ret = value;
WriteProcessMemory(g_hProcess, (void*)address, &ret, sizeof(T), 0);
};
template<typename T> T res(DWORD64 address, std::vector<int> offsets)
{
T ret;
for (unsigned int i = 0; i < offsets.size(); ++i)
{
ReadProcessMemory(g_hProcess, (void*)address, &address, sizeof(address), 0);
address = address + offsets[i];
}
ReadProcessMemory(g_hProcess, (void*)address, &ret, sizeof(T), 0);
return ret;
};
template<typename T> void wrs(DWORD64 address, std::vector<int> offsets, T value)
{
T ret = value;
for (unsigned int i = 0; i < offsets.size(); ++i)
{
ReadProcessMemory(g_hProcess, (void*)address, &address, sizeof(address), 0);
address = address + offsets[i];
}
WriteProcessMemory(g_hProcess, (void*)address, &ret, sizeof(T), 0);
};