1 #include <stdio.h> 2 #include <windows.h> 3 #include <winuser.h> 4 5 int main() 6 { 7 int cur_value;//修改前的数值。 8 int m_value;//修改后的数值。 9 DWORD pid = 0; 10 DWORD baseAdress = 0x00951E68;//内存地址 11 HANDLE hd; 12 HWND hwd = FindWindow(NULL,"Demo"); 13 14 GetWindowThreadProcessId(hwd,&pid); 15 if (hwd==NULL) 16 { 17 printf("游戏没有运行!\n"); 18 } 19 else 20 { 21 printf("可以修改!\n"); 22 } 23 24 hd = OpenProcess(PROCESS_ALL_ACCESS,FALSE,pid); 25 26 ReadProcessMemory(hd,(LPCVOID)baseAdress,&cur_value,sizeof(cur_value),NULL); 27 28 printf("\n"); 29 printf("当前数值为:%d\n",cur_value); 30 printf("请输入数值:\n"); 31 scanf("%d",&m_value); 32 33 WriteProcessMemory(hd,(LPVOID)baseAdress,&m_value,sizeof(m_value),NULL); 34 35 CloseHandle(hd); 36 return 0; 37 }
时间: 2024-11-12 14:07:04