// PlantvsWG.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "windows.h"
#include "stdio.h"
#include "stdlib.h"
//[[[6a9ec0]+768]+5560]
DWORD plantAddress=0x006a9ec0;
DWORD Fisrtoffset=0x768;
DWORD secondoffset=0x5560;
DWORD Fisrt;
DWORD second;
DWORD reasult;
HWND hd;
DWORD processid;
DWORD Threadid;
HANDLE planthd;
LPVOID BaseAddr;
char Gamecaption[]="植物大战僵尸中文版";
char newGamecaption[]="title 植物大战僵尸中文版无限阳光修改器by:lyf";
char color[]={"color 4e"};
DWORD buffsize;
DWORD size;
int modifile=0;
void changgetitleAndwndcolor(char *string)
{
system(string);
}
int main(int argc, char* argv[])
{
changgetitleAndwndcolor(newGamecaption);
changgetitleAndwndcolor(color);
hd=FindWindow(NULL,Gamecaption);
if (hd==NULL)
{
return false;
}
//printf("%x",hd);
Threadid = GetWindowThreadProcessId(hd,&processid); //获取进程ID
if (Threadid==NULL)
{
return false;
}
planthd=OpenProcess(PROCESS_ALL_ACCESS,NULL,processid); //打开进程
if (planthd==NULL)
{
return false;
}
// BaseAddr =VirtualAlloc(NULL,buffsize,MEM_COMMIT||MEM_RESERVE,PAGE_EXECUTE_READWRITE);
/* if (BaseAddr==NULL)
{
return false;
GetLastError();
}*/
printf("基址%p\n",plantAddress);
ReadProcessMemory(planthd,(LPCVOID )plantAddress,&Fisrt,0x4,&size);
printf("一级偏移%p\n",Fisrt);
ReadProcessMemory(planthd,(LPCVOID)(Fisrt+Fisrtoffset),&second,0x4,&size);
printf("二级偏移%p\n",second);
ReadProcessMemory(planthd,(LPCVOID)(second+secondoffset),&reasult,0x4,&size);
LPVOID buffnew=LPVOID(second+secondoffset);
printf("当前阳光%d\n",reasult);
printf("请输入你想要获取的阳光\n");
while (1)
{
scanf("%d",&modifile);
WriteProcessMemory(planthd,buffnew,&modifile,sizeof(DWORD),&size);
}
CloseHandle(planthd);
system("pause");
return 0;
}
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课