|
#include "stdafx.h"
RWmem::RWmem()
{
hwnd = FindWindowA(0, "League of Legends (TM) Client");//获取窗口句柄
DWORD pid = NULL;
GetWindowThreadProcessId(hwnd, &pid);获取线程ID
process = OpenProcess(/*PROCESS_ALL_ACCESS*/ PROCESS_VM_WRITE | PROCESS_VM_OPERATION | PROCESS_VM_READ, FALSE, pid);//获取线程ID
RetRead = ReadProcessMemory(process, (LPVOID)Address, &(buffer0), sizeof(buffer0), NULL);//读取未修改时候的代码
if (!RetRead)
{
printf("ReadErro\n");
}
else
{
printf("FF加载成功\n");
}
Binit = true;
}
RWmem::~RWmem()
{
}
bool RWmem::WriteMemory()
{
if (this == NULL)
return false;
if (!RetRead)
return false;
if (!process)
return false;
if (!RetRead)
return false;
if (!Binit)
return false;
RetWrite = WriteProcessMemory(process, (LPVOID)Address, &(buffer1), sizeof(buffer1), NULL);//修改内存过掉检测
if (!RetWrite)
{
printf("writeErro\n");
return false;
}
auto a = GetLastError();
return true;
}
bool RWmem::RestorMemory()
{
if (this == NULL)
return false;
if (!RetWrite)
return false;
if (!RetRead)
return false;
RetRestore = WriteProcessMemory(process, (LPVOID)Address, &(buffer0), sizeof(buffer0), NULL);//还原内存
if (!RetRestore)
{
printf("RestoreErro\n");
return false;
}
return true;
}
|
|