通过DMA读取指定地址的数据Addr - DmaReadDataAddr
函数简介
通过 DMA 读取指定地址的二进制数据。使用直接地址而不是 CE 格式。(高级版功能,普通版无法使用)
接口名称
DmaReadDataAddr
DLL调用
OLA_STRING_RETURN OLA_CALL_TYPE DmaReadDataAddr(int64_t instance, int64_t deviceId, int32_t pid, int64_t addr, int32_t len);
参数定义:
instance(长整型数): OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。deviceId(长整型数): 设备IDpid(整型数): 进程 PIDaddr(长整型数): 直接内存地址len(整型数): 读取长度(字节)
示例:
// 读取 16 字节数据
const char* data = DmaReadDataAddr(instance, deviceId, 1234, 0x400000, 16);
if (data != NULL) {
printf("读取数据: %s\n", data);
FreeStringPtr(instance, data);
}
// 读取 4 字节数据
const char* data2 = DmaReadDataAddr(instance, deviceId, 1234, 0x400010, 4);
if (data2 != NULL) {
printf("读取数据: %s\n", data2);
FreeStringPtr(instance, data2);
}
返回值
字符串:
返回二进制字符串的指针,数据格式为十六进制表示,每个字节以空格相隔
示例:12 34 56 78 ab cd ef
注意: 返回的字符串指针需要调用 FreeStringPtr 接口释放内存
参数说明
addr(地址):
- 直接的十六进制地址
- 例如:
0x400000
len(长度):
- 要读取的字节数
- 通常为 1、2、4、8 等
应用场景
- 读取内存中的二进制数据
- 数据分析
- 内存转储
相关接口
- DmaReadData - CE 格式地址读取
- DmaReadInt - 读取整数
- DmaReadString - 读取字符串
