读取或修改进程某一地址的数据

本文演示了如何使用Windows API函数FindWindow, GetWindowThreadProcessId, OpenProcess, ReadProcessMemory和WriteProcessMemory来定位并操作QQ游戏-连连看角色版的进程内存,实现了对游戏中特定地址的数据读取和修改。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 
  
HWND hWnd = ::FindWindow(NULL, TEXT( " QQ游戏 - 连连看角色版 " ));
if (hWnd != NULL) {
DWORD pid;
GetWindowThreadProcessId(hWnd,
& pid);
HANDLE hProcess
= OpenProcess(PROCESS_ALL_ACCESS, false , pid);
if (hProcess != NULL) {
int num;
SIZE_T cnt;
if (ReadProcessMemory(hProcess, (LPCVOID) 0x112f78 , (LPVOID) & num, 4 , & cnt)) {
if ( 4 == cnt) {
// 读取数据成功
}
}
}
}
 
  
HWND hWnd = ::FindWindow(NULL, TEXT( " QQ游戏 - 连连看角色版 " ));
if (hWnd != NULL) {
DWORD pid;
GetWindowThreadProcessId(hWnd,
& pid);
HANDLE hProcess
= OpenProcess(PROCESS_ALL_ACCESS, false , pid);
if (hProcess != NULL) {
int num = 0 ;
SIZE_T cnt;
if (WriteProcessMemory(hProcess, (LPVOID) 0x1163b0 , & num, 4 , & cnt)) {
if ( 4 == cnt) {
MessageBox(TEXT(
" GOOD! " ));
}
}
}
}

转载于:https://www.cnblogs.com/pen-ink/archive/2011/02/03/1948941.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值