读
#include <iostream>
#include <Windows.h>
using namespace std;
int main(){
HWND hwnd = FindWindowA("MainWindow", "植物大战僵尸中文版");
cout << hwnd<<endl;
DWORD pid, tid;
tid=GetWindowThreadProcessId(hwnd, &pid);
cout << pid<<endl;
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
unsigned int 返回值=0;
ReadProcessMemory(handle, (LPCVOID)0x401004, &返回值, 4, 0);
printf("%X", 返回值);
}
写
#include <iostream>
#include <Windows.h>
extern "C" UINT32 __stdcall mycall();
using namespace std;
unsigned int R4(UINT_PTR 数据地址) {
HWND hwnd = FindWindowA("MainWindow", "植物大战僵尸中文版");
DWORD pid, tid;
tid = GetWindowThreadProcessId(hwnd, &pid);
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
unsigned int 返回值 = 0;
ReadProcessMemory(handle, (LPCVOID)数据地址, &返回值, 4, 0);
CloseHandle(handle);
return 返回值;
}
int main(){
cout << mycall() << endl;
//printf("%X", R4(0x6A9EC0));
printf("%d", R4(R4(R4(0x6A9EC0) + 0x00000768) + 0x00005560));
UINT_PTR 阳光地址 = R4(R4(0x6A9EC0) + 0x00000768) + 0x00005560;
HWND hwnd = FindWindowA("MainWindow", "植物大战僵尸中文版");
DWORD pid, tid;
tid = GetWindowThreadProcessId(hwnd, &pid);
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
int 新阳光值 = 1000;
WriteProcessMemory(handle, (LPVOID)阳光地址, &新阳光值, 4, NULL);
}