-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemory.h
More file actions
32 lines (26 loc) · 754 Bytes
/
Copy pathmemory.h
File metadata and controls
32 lines (26 loc) · 754 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
#pragma once
#include <windows.h>
#include <tlhelp32.h>
#include <string>
#include <vector>
class Memory {
private:
DWORD processId = 0;
HANDLE processHandle = nullptr;
public:
Memory() = default;
~Memory();
bool Init(const wchar_t* windowName);
template <typename T>
T Read(uintptr_t address) {
T value{};
ReadProcessMemory(processHandle, (LPCVOID)address, &value, sizeof(T), nullptr);
return value;
}
template <typename T>
bool Write(uintptr_t address, T value) {
return WriteProcessMemory(processHandle, (LPVOID)address, &value, sizeof(T), nullptr);
}
uintptr_t ReadPointer(uintptr_t baseAddress, const std::vector<unsigned int>& offsets);
void Close();
};