#include <iostream> #include <windows.h> using namespace std; HWND hand=NULL; DWORD pid=0; HANDLE hProcess=NULL; DWORD BaseValue=0; bool startGame(); int main(int argc, char** argv) { bool Result=false; Result=startGame(); if(Result==false){ return 0; } return 0; } 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; }
标签:false,僵尸,0.1,大战,bool,Result,startGame From: https://www.cnblogs.com/w6826301/p/17904120.html