#include <iostream> #include <windows.h> using namespace std; DWORD YG1=0; HANDLE hProcess=NULL; DWORD address1 =0x006A9EC0;//第一个房间门的编号 DWORD address2; int vzlue=0; bool p1(){ DWORD yangguangAddress=YG1+0x5560; int zZyGZ=0; bool Result=ReadProcessMemory( hProcess, (LPVOID)yangguangAddress, &zZyGZ, 4, NULL ); if(!Result){ cout<<"获取阳光数据失败"; return false; } cout<<"阳光数据:"<<zZyGZ<<endl; cout<<"请输入要修改的值:"<<endl; cin>>vzlue; WriteProcessMemory(hProcess,(LPVOID)yangguangAddress,&vzlue,4,NULL); } int JB1=0; bool p2(){ DWORD jinbiAddress=JB1+0x82c; int jinbi=0; bool Result=ReadProcessMemory(hProcess,(LPVOID)jinbiAddress,&jinbi,4,NULL); if(!Result){ cout<<"获取金币数据失败"; return false; } cout<<"金币数据:"<<jinbi<<endl; cout<<"请输入要修改的值:"<<endl; cin>>vzlue; WriteProcessMemory(hProcess,(LPVOID)jinbiAddress,&vzlue,4,NULL); } void p3(){ int a=0; WriteProcessMemory(hProcess,(LPVOID)0x50,&a,4,NULL); } int main(int argc, char** argv) { DWORD pid=0; HWND hand=FindWindow("MainWindow","植物大战僵尸中文版"); if(hand==NULL){ cout<<"没有打开植物大战僵尸"; return 0; } GetWindowThreadProcessId(hand,&pid); //注入进程 hProcess=OpenProcess(PROCESS_ALL_ACCESS,false,pid); if(hProcess==NULL){ cout<<"无法打开进程"; return false; } cout<<"注入进程成功!"<<endl; //去拿房间钥匙 bool Result=ReadProcessMemory( hProcess,//游戏句柄 (LPVOID)address1,//要打开房间门的编号 &address2, 4, NULL ); if(!Result){ cout<<"无法打开植物大战僵尸游戏的第一扇门"; return false; } //拿到钥匙后,继续打开第二扇门 DWORD YangGuang1=address2+0x768;//计算出第二个门的位置 DWORD JinBi1=address2+0x82c; Result=ReadProcessMemory(hProcess,(LPVOID)YangGuang1,&YG1,4,NULL); Result=ReadProcessMemory(hProcess,(LPVOID)JinBi1,&JB1,4,NULL); if(!Result){ cout<<"无法打开第二扇门"; return false; } //菜单 int a; while(1){ cout<<"植物大战僵尸辅助工具"<<endl<<"1.修改阳光"<<endl<<"2.修改金币"<<endl<<"3.种植无冷却"<<endl<<"4.切换窗口不暂停"<<endl<<"5.跳过关卡"<<endl<<"6.秒杀全屏僵尸"<<endl<<"7.植物无敌"<<endl<<"8.关闭程序"<<endl; cin>>a; switch(a){ case 1: if(p1()==false){ break; } break; case 2: if(p2()==false){ break; } break; case 3: p3(); break; case 4: break; case 5: break; case 6: break; case 7: break; case 8: return 1; break; } } return 0; }
标签:case,僵尸,int,植物,大战,break,DWORD,NULL,hProcess From: https://www.cnblogs.com/wangyueshuo/p/16746722.html