-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasicMemoryInterface.cpp
More file actions
55 lines (42 loc) · 1.34 KB
/
BasicMemoryInterface.cpp
File metadata and controls
55 lines (42 loc) · 1.34 KB
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
#ifdef MEMORY_INTERFACE_BASIC
#include "BasicMemoryInterface.h"
#include <Windows.h>
#include <Psapi.h>
#include "Utils.h"
#define PRIMITIVES_ONLY 1
#include "Global.hpp"
BasicMemoryInterface::~BasicMemoryInterface() {
if (this->handle) {
CloseHandle(this->handle);
}
}
bool BasicMemoryInterface::UpdateProcessId(const wchar_t* processName) {
if (this->pid && this->handle) {
return true;
}
this->pid = Utils::GetProcessIdByName(processName);
if (this->handle) {
CloseHandle(this->handle);
this->handle = nullptr;
}
if (this->pid) {
this->handle = OpenProcess(PROCESS_ALL_ACCESS, false, this->pid);
}
return this->pid && this->handle;
}
uintptr_t BasicMemoryInterface::GetModuleBase() {
return 0x7FFCB7020000;
}
bool BasicMemoryInterface::ReadRaw(uintptr_t address, void* pBuffer, unsigned long size) {
if (!this->pid || !this->handle || address < MINIMUM_ADDRESS_SIZE) {
return false;
}
return ReadProcessMemory(this->handle, (LPCVOID)address, pBuffer, size, nullptr);
}
bool BasicMemoryInterface::WriteRaw(uintptr_t address, void* pBuffer, unsigned long size) {
if (!this->pid || !this->handle || address < MINIMUM_ADDRESS_SIZE) {
return false;
}
return WriteProcessMemory(this->handle, (LPVOID)address, pBuffer, size, nullptr);
}
#endif