植物大战僵尸0.1

发布时间 2023-12-15 20:05:19作者: 爱吃泡面的皮卡
#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;
}