#include <iostream> #include <windows.h> using namespace std; /*声明变量 */ HWND hand=NULL; //游戏窗口 DWORD pid=0;//游戏进程ID HANDLE hProcess=NULL;//进程对象 DWORD BaseValue=0;//游戏数据存放的基础值 DWORD SunshineAddress; DWORD ZombiesAddress; bool startGame(){ hand=FindWindow("MainWindow","植物大战僵尸中文版"); cout<<hand<<endl; if(hand==NULL){ cout<<"游戏没有运行"; return false; } cout<<"窗口"<<hand<<endl; GetWindowThreadProcessId(hand,&pid); if(pid==0){ cout<<"无法找到植物大战僵尸进程"; return false; } cout<<"进程:"<<pid<<endl; hProcess=OpenProcess(PROCESS_ALL_ACCESS,false,pid); if(hProcess==NULL){ cout<<"无法打开进程"<<endl; return false; } cout<<"打开进程:"<<hProcess<<endl; DWORD BaseAddress=0x006A9EC0; bool Result=ReadProcessMemory(hProcess,(LPVOID)BaseAddress,&BaseValue,4,NULL); if(Result==false){ cout<<"初始化基础地址失败"; 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<<"初始化阳光地址失败"; return false; } SunshineAddress=_Value+0x5560;//二级偏移地址 return true; } //获取阳光值 int getSunshineValue(){ 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); } //无冷却 void noCoolDown(){ cout<<"无冷却"<<endl; DWORD base=0x00488e73; DWORD pianyi=0x80; WriteProcessMemory(hProcess,(LPVOID)base,&pianyi,1,NULL); } void zanting(){ cout<<"无暂停"<<endl; DWORD base=0x4502C0; DWORD pianyi=0xC3; WriteProcessMemory(hProcess,(LPVOID)base,&pianyi,1,NULL); } bool initZombies(){ DWORD _Address=BaseValue+0x768;//一级偏移地址 DWORD _Value=0; bool Result=ReadProcessMemory(hProcess,(LPVOID)_Address,&_Value,4,NULL); if(Result==false){ cout<<"初始化僵尸地址失败"; return false; } ZombiesAddress=_Value+0x90; Result=ReadProcessMemory(hProcess,(LPVOID)ZombiesAddress,&_Value,4,NULL); if(Result==false){ cout<<"僵尸二次偏移失败"; return false; } ZombiesAddress=_Value; cout<<"僵尸地址:"<<ZombiesAddress<<endl; return true; } bool killZombies(){ for(int i=-100;i<100;i++){ DWORD _address=ZombiesAddress+0x28+i*0x15c;//一级偏移地址 DWORD _Value=0; bool Result=ReadProcessMemory(hProcess,(LPVOID)_address,&_Value,4,NULL); if(Result==false){ cout<<"僵尸血量获取失败"; continue; } int value=3; if(_Value<100){ WriteProcessMemory(hProcess,(LPVOID)_address,&value,4,NULL); }else{ cout<<"疑似僵尸血量"<<_Value<<endl; } } return true; } int main(){ system("color 1A"); system("title 植物大战僵外挂"); bool Result=false; do{ Result=startGame(); if(Result==false){ system("start C:\\Users\\Administrator\\Desktop\\植物大战僵尸1电脑版\\PlantsVsZombies.exe"); Sleep(3000); }else{ break; } }while(1); Result=initSunshine(); if(Result==false){ return false; } int a; int sun_zhi; noCoolDown(); zanting(); while(1){ cin>>a; switch(a){ case 1: cout<<"请输入充值阳光的数目:"; initSunshine(); getSunshineValue(); cin>>sun_zhi; setSunshineValue(sun_zhi); case 2: killZombies(); break; } } return 0; }
标签:case,include,cout,3123,DWORD,NULL From: https://www.cnblogs.com/boyeyuan/p/17924082.html