这个找地址比帝国时代简单 本来还要做个瞬移功能 MFC还不太熟练 算了
// An highlighted block
#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
void callMenu() {
cout << "**************************************" << endl;
cout << "**************************************" << endl;
cout << "******** " << "0 增加10000木材" << "**************" << endl;
cout << "******** " << "1 增加10000水银" << "**************" << endl;
cout << "******** " << "2 增加10000石头" << "**************" << endl;
cout << "******** " << "3 增加10000硫磺" << "**************" << endl;
cout << "******** " << "4 增加10000水晶" << "**************" << endl;
cout << "******** " << "5 增加10000宝石" << "**************" << endl;
cout << "******** " << "6 增加9999999金币" << "************" << endl;
cout << "******** " << "7 退出 " << "************" << endl;
cout << "**************************************" << endl;
cout << "**************************************" << endl;
}
void callCheat(int &key,int &baseKey, HANDLE &processH) {
// 设定起始偏移量表 木材 水银 石头 硫磺 水晶 宝石 金币
int woodPtrValue[7] = { 0x9c ,0xa0 ,0xa4 ,0xa8 ,0xac,0xb0 ,0xb4 };
string nameArr[7] = { "木材","水银","石头","硫磺","水晶","宝石","金币" };
int counter;
ReadProcessMemory(processH, (void*)(baseKey+ woodPtrValue[key]), &counter, sizeof(counter), NULL);
if (key == 6) {
counter += 9999999;
}
else {
counter += 10000;
}
WriteProcessMemory(processH, (void*)(baseKey + woodPtrValue[key]), &counter, sizeof(counter), NULL);
cout << nameArr[key] << "增加了"<< endl;
cout << "现在您有" << counter << nameArr[key] << endl;
system("pause");
system("cls");
callMenu();
}
int main() {
HWND gameHwnd = FindWindow(NULL, L"魔法门之英雄无敌III 3.1 Jul 18 2000 13:48:09");
DWORD processid;
::GetWindowThreadProcessId(gameHwnd, &processid);
//打开指定进程
HANDLE processH = ::OpenProcess(PROCESS_ALL_ACCESS, false, processid);
//读取指针
int nSize = 0;
int resourcesCSAdress = 0;
ReadProcessMemory(processH, (void*)0x0082b0bc, &resourcesCSAdress, sizeof(resourcesCSAdress), NULL);
callMenu();
while (true)
{
int key;
cout << "请输入想要的功能:" << endl;
cin >> key;
if (key == 7) {
break;
}
callCheat(key, resourcesCSAdress, processH);
}
system("pause");
return 0;
}