// 获取窗口句柄 HWND hFindWnd = ::FindWindow(NULL, “[窗口标题]”);
// 获取窗口进程ID DWORD dwThreadProcessId = 0; GetWindowThreadProcessId(hFindWnd, &dwThreadProcessId);
// 打开指定进程 HANDLE hAndle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwThreadProcessId);
// 读取进程中的数据 int ReadData = 0; // 读取的数据 DWORD dwReadByteNumber = 0; // 读取到的实际数据大小 ReadProcessMemory(hAndle, (LPVOID)0x00000000, (LPVOID)&ReadData, 4, &dwReadByteNumber);
// 写入数据到进程中 int WriteData = 0; // 需要写入的数据 DWORD dwWriteByteNumber = 0; // 写入的实际数据大小 WriteProcessMemory(hAndle, (LPVOID)0x00000000, (LPVOID)&WriteData, 4, &dwWriteByteNumber);
// 特殊的写入,代码区 byte acode[6]={0x90,0x90,0x90,0x90,0x90,0x90}; int WriteData = 0; // 需要写入的数据 DWORD dwWriteByteNumber = 0; // 写入的实际数据大小 WriteProcessMemory(hAndle, (LPVOID)0x00000000, (LPVOID)acode, 6, &dwWriteByteNumber);