forked from ReClassNET/ReClass.NET
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWriteRemoteMemory.cpp
More file actions
40 lines (35 loc) · 949 Bytes
/
Copy pathWriteRemoteMemory.cpp
File metadata and controls
40 lines (35 loc) · 949 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
37
38
39
40
#include <windows.h>
#include "Program.h"
#include "NativeCore.hpp"
bool RC_CallConv WriteRemoteMemory(RC_Pointer handle, RC_Pointer address, RC_Pointer buffer, int offset, int size)
{
buffer = reinterpret_cast<RC_Pointer>(reinterpret_cast<uintptr_t>(buffer) + offset);
if (!UseKernal)
{
DWORD oldProtect;
if (VirtualProtectEx(handle, address, size, PAGE_EXECUTE_READWRITE, &oldProtect))
{
SIZE_T numberOfBytesWritten = 0;
if (WriteProcessMemory(handle, address, buffer, size, &numberOfBytesWritten))
{
VirtualProtectEx(handle, address, size, oldProtect, nullptr);
if (size == numberOfBytesWritten)
{
return true;
}
}
}
}
else if (ByPass != nullptr) // BypaPH Stuff
{
SIZE_T numberOfBytesWritten = 0;
if (ByPass->WVM(ByPass->m_hTarget, address, buffer, size, &numberOfBytesWritten) == STATUS_SUCCESS)
{
if (size == numberOfBytesWritten)
{
return true;
}
}
}
return false;
}