#include <stdio.h>
#include <windows.h>
#include <winuser.h>
int main()
{
int cur_value;//修改前的数值。
int m_value;//修改后的数值。
DWORD pid = ;
DWORD baseAdress = 0x00951E68;//内存地址
HANDLE hd;
HWND hwd = FindWindow(NULL,"Demo");
GetWindowThreadProcessId(hwd,&pid);
if (hwd==NULL)
{
printf("游戏没有运行!\n");
}
else
{
printf("可以修改!\n");
}
hd = OpenProcess(PROCESS_ALL_ACCESS,FALSE,pid);
ReadProcessMemory(hd,(LPCVOID)baseAdress,&cur_value,sizeof(cur_value),NULL);
printf("\n");
printf("当前数值为:%d\n",cur_value);
printf("请输入数值:\n");
scanf("%d",&m_value);
WriteProcessMemory(hd,(LPVOID)baseAdress,&m_value,sizeof(m_value),NULL);
CloseHandle(hd);
return ;
}