植物大战僵尸1

#include <iostream>
#include <windows.h>
using namespace std;
HWND hand=NULL;
DWORD pid=0;
HANDLE hProcess=NULL;
DWORD BaseValue=0;
DWORD SunshineAddress;
bool startGame();//阳光
bool initSunshine();
int getSunshineValse();
void setSunshineValue(int value);
bool money();//金币
void noCoolDown();
int main(){
	system("title 植物大战僵尸");
	do{
		bool result=false;
		result=startGame();
		if(result==false){
			system("start C:\\Users\\Administrator\\Desktop\\植物大战僵尸1电脑版\\PlantsVsZombies.exe");
			Sleep(3*1000);
		}else{
			break;
		}
	}while(true);
	while(1){
	int a;
	system("color 0C");
	cout<<"植物大战僵尸辅助工具"<<endl;
	//Sleep(2000);
	cout<<"1.修改阳光"<<endl;
	//Sleep(2000);
	cout<<"2.修改金币"<<endl;
	cout<<"3.种植无冷却"<<endl<<"4.切换窗口不暂停"<<endl<<"5.跳过关卡"<<endl<<"6.秒杀全屏僵尸"<<endl<<
	"7.植物无敌"<<endl<<"8.关闭程序"<<endl;
		cin>>a;
		int b;
		switch(a){
			case 1:{
				initSunshine();
				getSunshineValse();
				cout<<"输入你要修改的阳光值";
				cin>>b;
				setSunshineValue(b);
				system("cls");
				break;
			}
			case 2:{
				money();
				system("cls");
				break;
			}
			case 3:{
			 	noCoolDown();
			 	system("cls");
				break;
			}
		}
	
	}

	return 0;
}
bool startGame(){
	hand=FindWindow("MainWindow","植物大战僵尸中文版");
	if(hand==NULL){
	cout<<"游戏未运行"<<endl;
	return false;
	}
	cout<<"窗口:"<<hand<<endl;
	GetWindowThreadProcessId(hand,&pid);
	if(pid==0){
	cout<<"未找到进程"<<endl;
	return false;
	}
	cout<<"进程:"<<pid<<endl;
	hProcess=OpenProcess(PROCESS_ALL_ACCESS,
	false,
	pid);
	if(hProcess==NULL){
		cout<<"无法打开进程"<<endl;
		return false;
	}
	DWORD BaseAddress=0x006A9EC0;
	bool Result=ReadProcessMemory(
		hProcess,
		(LPVOID)BaseAddress,
		&BaseValue,
		4,
		NULL);
	if(Result==false){
		cout<<"初始化基础地址失败"<<endl;
		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<<"初始化阳光地址失败"<<endl;
	return false;
	}
	SunshineAddress=_Value+0x5560;//二级偏移
	return true;
}
//获取阳光值
int getSunshineValse(){
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 money(){
	int JB=0;
	DWORD jinbiAddress=JB+0X28;
	int jinbi=0;
	bool Result=ReadProcessMemory(hProcess,
	(LPVOID)jinbiAddress,
	&jinbi,4,NULL);
	if(Result==false){
	cout<<"获取金币数据失败";
	return false;
	}
	cout<<"金币数据:"<<jinbi<<endl;
	cout<<"请输入要修改的值:"<<endl;
	int vzlue;
	cin>>vzlue;
	WriteProcessMemory(hProcess,(LPVOID)jinbiAddress,&vzlue,4,NULL);
}
void noCoolDown(){
	//无法冷却时间代码 
	DWORD base=0x00488e73;
	//打开进程 获取所以操作权限 
	DWORD pianyi=0x80;
	WriteProcessMemory(hProcess,(LPVOID)base,&pianyi,1,NULL); 
	cout<<"冷却已关闭"<<endl;;
}

  

posted @ 2023-12-17 09:24  fushuxuan1  阅读(45)  评论(0)    收藏  举报