-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmem.cpp
More file actions
32 lines (24 loc) · 707 Bytes
/
mem.cpp
File metadata and controls
32 lines (24 loc) · 707 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
#include "pch.h"
#include "mem.h"
void mem::Patch(BYTE* dst, BYTE* src, unsigned int size) {
DWORD oldPro;
VirtualProtect(dst, size, PAGE_EXECUTE_READWRITE, &oldPro);
memcpy(dst, src, size);
VirtualProtect(dst, size, oldPro, &oldPro);
}
void mem::Nop(BYTE* dst, unsigned int size) {
DWORD oldPro;
VirtualProtect(dst, size, PAGE_EXECUTE_READWRITE, &oldPro);
memset(dst, 0x90, size);
VirtualProtect(dst, size, oldPro, &oldPro);
}
uintptr_t mem::offset(uintptr_t ptr, std::vector<unsigned int> offset)
{
intptr_t addr = ptr;
//for (unsigned int i = 0; i < offset.size(); ++i) {
for (auto o : offset){
addr = *(uintptr_t*)addr;
addr += o;
}
return addr;
}