如何读取特定地址的进程内存?
How to read process memory at a specific address?
我想从已知的内存位置开始从进程的内存中读取 64 个字节。为此,我编写了以下C++
代码:
#include <iostream>
#include <Windows.h>
#include <iomanip>
using namespace std;
int main() {
LPCVOID Address = (LPCVOID)0x0000029FC0C41FF0; // the memory address where I want to read from
byte buffer[64];
HANDLE hProcess = OpenProcess(PROCESS_VM_READ, 0, 13868); // the process ID of the process
ReadProcessMemory(hProcess, Address, &buffer, sizeof(buffer), 0);
const int siz_ar = sizeof(buffer) / sizeof(int); // the rest is trying to display the bytes read on stdout
for (int i = 0; i < siz_ar; ++i)
cout << hex << setfill('0') << setw(2) << buffer[i] << " ";
cout << endl;
}
它不起作用,并在控制台输出中产生以下奇怪的字符串:
0╠ 0╠ 0╠ 0╠ 0╠ 0╠ 0╠ 0╠
如何更正此程序以从特定进程(由进程 ID 指定(的特定内存地址读取原始字节?
您的byte
可能是char
的别名。如果将char
传递给std::cout
,它将打印为字符,而不是数字。首先转换为非字符类型,如unsigned int
。
然后你会注意到它只输出0xCC
,这是未初始化内存的常见标记(在某些代码页中╠
(。对您的呼叫进行错误检查,以找出为什么buffer
永远不会被填满。
相关文章:
- 如何读取特定地址的进程内存?
- 两个不同的进程,在同一地址上有 2 个 std::atomic 变量?
- C++如何使用读取进程内存查找进程内存中使用的最后一个(偏移量 - 地址)
- 使用 ReadProcessMemory 从进程读取相对于基址的地址
- 如何使用 C# 在 Windows 中获取另一个进程库地址
- 写入进程内存没有错误,它不会写入正确的地址
- 内存中进程的实际起始地址/W32调试API
- 为什么 GetProcessImageFileName 返回 null 而不是进程的地址
- 从注入进程的 DLL 调用函数并更改指针函数的地址
- 如何从wow64进程中检索特定内核对象的64位地址
- 从进程读取地址
- 如何在C++中获取进程的起始地址/基地址
- 进程如何访问不属于其虚拟地址空间的内存映射 IO 地址?
- 从另一个进程中查找变量的地址
- 获取C++中的另一个进程变量值(或内存地址)
- 以何种形式,可以通过管道将空指针发送到不同进程地址空间中的另一个进程
- 更新进程地址空间中的HTML内容
- 如何判断共享库在进程地址空间中的加载位置
- 一个IP地址和一个端口号可以一起唯一地标识一个进程ID吗
- 从另一个进程获取 win32 线程的起始地址