#include <iostream>
#include <windows.h>
using namespace std;
//声明变量
HWND hand = NULL;
DWORD pid = 0;
HANDLE hProcess = NULL;
DWORD BaseValue = 0;
DWORD SunshineAddress = 0;
DWORD MoneyshineAddress = 0;
DWORD ZombiesAddress = 0;
DWORD SunAddress = 0;
DWORD A = 0;
void a();
void chushihua();
bool startGame();
bool initSunshine();
int getSunshineValue();
void setSunshineValue(int value);
bool initMoneyshine();
int getMoneyshineValue();
void setMoneyshineValue(int value);
void initCDshine();
void noCoolDown();
bool initZombies();
bool killZombues();
bool initSun();
bool Sun();
bool b();
int main(){
system("title 植物大战僵尸外挂程序");
system("color 0B");
do{
bool Result = false;
Result = startGame();
if(Result==false){
system("start C:/Users/Administrator/Desktop/植物大战僵尸1电脑版/PlantsVsZombies.exe");
Sleep(3000);
}else{
break;
}
}while(true);
int n;
while(1){
system("cls");
chushihua();
int zhi;
cin>>n;
switch(n){
case 1:
initSunshine();
getSunshineValue();
cout<<"请输入你要修改的阳光值:";
cin>>zhi;
setSunshineValue(zhi);
cout<<"修改成功"<<endl;
break;
case 2:
initMoneyshine();
getMoneyshineValue();
cout<<"请输入你要修改的金币值:";
cin>>zhi;
setMoneyshineValue(zhi);
cout<<"修改成功"<<endl;
break;
case 3:
noCoolDown();
break;
case 4:
if(initZombies()){
if(killZombues()){
cout<<"秒杀成功"<<endl;
}
}
break;
case 5:
if(initSun()){
if(Sun()){
cout<<"生产成功"<<endl;
}
}
break;
case 6:
if(b){
cout<<"成功"<<endl;
}
break;
case 7:
a();
break;
case 8:
system("pause");
return 0;
}
system("pause");
}
return 0;
}
//免暂停
void a(){
//免暂停时间代码
DWORD BASE = 0x4502C0;
//打开进程
DWORD pianyi = 0xC3;
WriteProcessMemory(hProcess,(LPVOID)BASE,&pianyi,4,NULL);
}
//重叠种植
bool b(){
DWORD _Address = BaseValue+0x768;//一级偏移地址
DWORD _Value = 0;
bool Result = ReadProcessMemory(hProcess,(LPVOID)_Address,&_Value,4,NULL);
if(!Result){
cout<<"初始化地址失败"<<endl;
return false;
}
SunAddress = _Value+0xac;//二级偏移地址
Result = ReadProcessMemory(hProcess,(LPVOID)SunAddress,&_Value,4,NULL);
if(!Result){
cout<<"二次偏移失败"<<endl;
return false;
}
SunAddress = _Value;//地址
for(int i = -100;i<100;i++){
DWORD _address = SunAddress+0x40+i*0x14c;
DWORD _Value = 0;
bool Result = ReadProcessMemory(hProcess,(LPVOID)_address,&_Value,4,NULL);
if(!Result){
cout<<"获取失败"<<endl;
continue;
}
int value = 10000;
WriteProcessMemory(hProcess,(LPVOID)_address,&value,4,NULL);
}
return true;
}
void chushihua(){
cout<<"植物大战僵尸外挂程序"<<endl
<<"****1.修改阳光值****"<<endl
<<"****2.修改金币值****"<<endl
<<"****3.种植无冷却****"<<endl
<<"****4.秒杀僵尸******"<<endl
<<"****5.生产阳光******"<<endl
<<"****6.重叠种植******"<<endl
<<"****7.程序免暂停****"<<endl
<<"****8.关闭此外挂****"<<endl;
}
bool startGame(){
//查找电脑是否运行了植物大战僵尸
hand = FindWindow("MainWindow","植物大战僵尸中文版");
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<<"无法打开进程";
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);
}
//寻找真实的金币地址
bool initMoneyshine(){
DWORD _address = BaseValue+0x82c;//一级偏移地址
DWORD _value = 0;
bool Result = ReadProcessMemory(hProcess,(LPVOID)_address,&_value,4,NULL);
if(Result==false){
cout<<"初始化金币地址失败";
return false;
}
MoneyshineAddress = _value+0xac;//二级偏移地址
return true;
}
//获取金币值
int getMoneyshineValue(){
//金币存变量的真正名称
DWORD Vvalue = 0;
bool Result = ReadProcessMemory(hProcess,(LPVOID)MoneyshineAddress,&Vvalue,4,NULL);
if(Result==false){
cout<<"获取金币数据失败";
return 0;
}
cout<<"当前金币值:"<<Vvalue<<endl;
return (int)Vvalue;
}
//修改金币值
void setMoneyshineValue(int value){
WriteProcessMemory(hProcess,(LPVOID)MoneyshineAddress,&value,4,NULL);
}
void noCoolDown(){
//无冷却时间代码
DWORD base = 0x00488e73;
//打开进程
DWORD PIANYI = 0x80;
WriteProcessMemory(hProcess,(LPVOID)base,&PIANYI,1,NULL);
cout<<"种植无冷却"<<endl;
}
bool initZombies(){
DWORD _Address = BaseValue+0x768;//一级偏移地址
DWORD _Value = 0;
bool Result = ReadProcessMemory(hProcess,(LPVOID)_Address,&_Value,4,NULL);
if(!Result){
cout<<"初始化僵尸地址失败"<<endl;
return false;
}
ZombiesAddress = _Value+0x90;//二级偏移地址
Result = ReadProcessMemory(hProcess,(LPVOID)ZombiesAddress,&_Value,4,NULL);
if(!Result){
cout<<"僵尸二次偏移失败"<<endl;
return false;
}
ZombiesAddress = _Value;//僵尸地址
return true;
}
bool killZombues(){
for(int i = 0;i<50;i++){
DWORD _address = ZombiesAddress+0x28+i*0x15c;
DWORD _Value = 0;
bool Result = ReadProcessMemory(hProcess,(LPVOID)_address,&_Value,4,NULL);
if(!Result){
cout<<"僵尸血量获取失败"<<endl;
continue;
}
int value = 3;
if(_Value<100){
WriteProcessMemory(hProcess,(LPVOID)_address,&value,4,NULL);
}
}
return true;
}
bool initSun(){
DWORD _Address = BaseValue+0x768;//一级偏移地址
DWORD _Value = 0;
bool Result = ReadProcessMemory(hProcess,(LPVOID)_Address,&_Value,4,NULL);
if(!Result){
cout<<"初始化地址失败"<<endl;
return false;
}
SunAddress = _Value+0xac;//二级偏移地址
Result = ReadProcessMemory(hProcess,(LPVOID)SunAddress,&_Value,4,NULL);
if(!Result){
cout<<"二次偏移失败"<<endl;
return false;
}
SunAddress = _Value;//地址
return true;
}
bool Sun(){
for(int i = 0;i<50;i++){
DWORD _address = SunAddress+0x58+i*0x14c;
DWORD _Value = 0;
bool Result = ReadProcessMemory(hProcess,(LPVOID)_address,&_Value,4,NULL);
if(!Result){
cout<<"获取失败"<<endl;
continue;
}
int value = 0;
WriteProcessMemory(hProcess,(LPVOID)_address,&value,4,NULL);
}
return true;
}