|
本帖最后由 黑夜的力量 于 2013-1-25 13:49 编辑
#include<stdio.h>
#include<Windows.h>
#include<TlHelp32.h>
#include<stdlib.h>
DWORD pid;
void *p=0x000FE944;//基址
int t;
int main(void)
{
pid=FindGameWindow("PlantsVsZombies.exe");//调用找游戏窗口
WriteSunCount(t);//写入阳光数量
return(0);
}
int FindGameWindow(const char*ProcessName)//找游戏窗口---相当于E的子程序
{
PROCESSENTRY32 stProcess;
HWND hProcessShot;
hProcessShot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);//获得所有进程信息
stProcess.dwSize=sizeof(PROCESSENTRY32);
Process32First(hProcessShot,&stProcess);
do
if(!strcmp(ProcessName,stProcess.szExeFile))
{
return stProcess.th32ProcessID;
}
while(Process32Next(hProcessShot,&stProcess));
CloseHandle(hProcessShot);
return FALSE;
}
int WriteSunCount()//写入阳光数量--相当于E的子程序
{
LPVOID lpBuffer;
HANDLE hProcess;
DWORD nSize;
hProcess=OpenProcess(PROCESS_ALL_ACCESS,FALSE, pid);
//打开进程
ReadProcessMemory(hProcess,p,&lpBuffer,sizeof(DWORD),0);
//读取内存数据
ReadProcessMemory(hProcess,lpBuffer+0x868,&lpBuffer,sizeof(DWORD),0);
ReadProcessMemory(hProcess,lpBuffer+0x5578,&p,sizeof(DWORD),0);
while(1)
{
scanf("%d",&t);
if(t<0)
{
break;
}
Sleep(1000);
WriteProcessMemory(hProcess,lpBuffer+0x5578,&t,sizeof(DWORD),0);
//修改内存数据
}
CloseHandle(hProcess);
return FALSE;
}
没什么技术含量.纯属水贴. |
|