#include <iostream> #include <windows.h> using namespace std; HWND hand=NULL; DWORD pid=0; HANDLE hProcess=NULL; DWORD BaseValue=0; DWORD SunshineAddress; bool startGame();//阳光 bool initSunshine(); int getSunshineValse(); void setSunshineValue(int value); bool money();//金币 int main(){ while(1){ int a; cout<<"植物大战僵尸辅助工具"<<endl<<"1.修改阳光"<<endl<<"2.修改金币"<<endl<< "3.种植无冷却"<<endl<<"4.切换窗口不暂停"<<endl<<"5.跳过关卡"<<endl<<"6.秒杀全屏僵尸"<<endl<< "7.植物无敌"<<endl<<"8.关闭程序"<<endl; bool result=false; result=startGame(); if(result==false){ return 0; } cin>>a; int b; switch(a){ case 1:{ initSunshine(); getSunshineValse(); cout<<"输入你要修改的阳光值"; cin>>b; setSunshineValue(b); break; } case 2:{ money(); break; } } } return 0; } bool startGame(){ hand=FindWindow("MainWindow","植物大战僵尸中文版"); if(hand==NULL){ cout<<"游戏未运行"<<endl; return false; } cout<<"窗口:"<<hand<<endl; GetWindowThreadProcessId(hand,&pid); if(pid==0){ cout<<"未找到进程"<<endl; return false; } cout<<"进程:"<<pid<<endl; hProcess=OpenProcess(PROCESS_ALL_ACCESS, false, pid); if(hProcess==NULL){ cout<<"无法打开进程"<<endl; return false; } DWORD BaseAddress=0x006A9EC0; bool Result=ReadProcessMemory( hProcess, (LPVOID)BaseAddress, &BaseValue, 4, NULL); if(Result==false){ cout<<"初始化基础地址失败"<<endl; return false; } return true; } //初始化阳光地址--寻找真实的阳光地址 bool initSunshine(){ DWORD _Address=BaseValue+0x768;//一级偏移 DWORD _Value=0; bool Result=ReadProcessMemory( hProcess,//读取哪一个进程 (LPVOID)_Address,//内存地址是多少 &_Value,//读取数据放哪 4,//数据存储长度 NULL);//实际读取的长度 if(Result==false){ cout<<"初始化阳光地址失败"<<endl; return false; } SunshineAddress=_Value+0x5560;//二级偏移 return true; } //获取阳光值 int getSunshineValse(){ DWORD value=0;//阳光内存变量的真正名称 bool Result=ReadProcessMemory( hProcess, (LPVOID)SunshineAddress, &value, 4, NULL); if(Result==false){ cout<<"获取阳光数据失败"; return 0; } cout<<"阳光:"<<value<<endl; return (int)value; } //设置阳光值 void setSunshineValue(int value){ WriteProcessMemory(hProcess,(LPVOID)SunshineAddress,&value,4,NULL); } bool money(){ int JB=0; DWORD jinbiAddress=JB+0X28; int jinbi=0; bool Result=ReadProcessMemory(hProcess, (LPVOID)jinbiAddress, &jinbi,4,NULL); if(Result==false){ cout<<"获取金币数据失败"; return false; } cout<<"金币数据:"<<jinbi<<endl; cout<<"请输入要修改的值:"<<endl; int vzlue; cin>>vzlue; WriteProcessMemory(hProcess,(LPVOID)jinbiAddress,&vzlue,4,NULL); }
标签:NULL,僵尸,int,大战,bool,hand,DWORD,2.0,cout From: https://www.cnblogs.com/w6826301/p/17922694.html