读取指定地址的数据 - ReadDataToBin
函数简介
读取指定地址的数据,地址支持CE数据格式,返回数据指针。
接口名称
ReadDataToBin
DLL调用
long ReadDataToBin(long instance, long hwnd, string addr, int len);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| hwnd | 长整数型 | 窗口句柄 |
| addr | 字符串 | 地址,支持CE数据格式,格式示例见下方。 |
| len | 整数型 | 长度 |
CE地址格式示例
<Game.exe>+1234 // 模块基址+偏移
<Game.exe>+1234+8+4 // 多级偏移(非指针)
[<Game.exe>+1234]+8+4 // 一级指针+偏移
[[<Game.exe>+1234]+8]+4 // 二级指针+偏移
[[[<module>+offset1]+offset2]+offset3] // 三级指针
[0x12345678]+10 // 直接地址+偏移
示例
C++
long instance = CreateCOLAPlugInterFace();
// hwnd 为目标窗口句柄
// 读取16字节数据到本地缓冲区,地址使用CE格式
long dataPtr = ReadDataToBin(instance, hwnd, "模块名+0x1A2B3C", 16);
if (dataPtr != 0) {
unsigned char* buf = (unsigned char*)dataPtr;
// 直接操作二进制数据
printf("第一个字节: 0x%02X\n", buf[0]);
FreeMemoryPtr(dataPtr);
}
Python
# 待补充
返回值
读取到的数据指针,返回0表示读取失败。
注意事项
- 返回的内存地址需调用 FreeMemoryPtr 释放内存。
