关于c语言的问题调用api的问题 5
一个小游戏进程为:game,exe现在想游戏内存中写数据,以前用e语言直接用模块:写内存整数型就可以了。我查了一下要用到一个api:WriteProcessMemory,...
一个小游戏 进程为:game,exe 现在想游戏内存中写数据,以前用e语言直接用模块:写内存整数型就可以了。我查了一下 要用到一个api:WriteProcessMemory,请问一下如何用c语言实现这样的功能啊? 最好有源代码给我参考下 谢谢了
展开
展开全部
需要VC下编译
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
cout << "Loading..."<< endl;
int address = 0x3458CBC0;
int address2 = 0x3458CBC4;
int value = 20;
DWORD pid;
HWND hwnd = FindWindowA(NULL,"some window");
GetWindowThreadProcessId(hwnd,&pid);
HANDLE phandle;
cout << "Found Proccess ID:" << pid << endl;
phandle = OpenProcess(0x1F0FFF,0,pid);
cout << "Loaded Successfully."<< endl ;
ReadProcessMemory(phandle,(LPVOID)address,&value,4,0);
cout << "Readed Value:" << value << endl;
ReadProcessMemory(phandle,(LPVOID)address2,&value,4,0);
cout << "Readed Value:" << value << endl;
address = 0x3458CBC0;
address2 = 0x3458CBC4;
value = 20;
WriteProcessMemory(phandle,(LPVOID)address,&value,4,0);
WriteProcessMemory(phandle,(LPVOID)address2,&value,4,0);
cin.get();
return 0;
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询