通过DMA搜索字符串 - DmaFindString
函数简介
通过 DMA 搜索指定范围内的字符串。支持多种字符串编码格式。(高级版功能,普通版无法使用)
接口名称
DmaFindString
DLL调用
OLA_STRING_RETURN OLA_CALL_TYPE DmaFindString(int64_t instance, int64_t deviceId, int32_t pid, OLA_STRING_INPUT addr_range, OLA_STRING_INPUT string_value, int32_t type);
参数定义:
instance(长整型数): OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。deviceId(长整型数): 设备IDpid(整型数): 进程 PIDaddr_range(字符串): 地址范围string_value(字符串): 要搜索的字符串type(整型数): 字符串类型
示例:
// 搜索 ASCII 字符串
const char* results = DmaFindString(instance, deviceId, 1234, "0x400000-0x500000", "Hello", 0);
if (results != NULL && strlen(results) > 0) {
printf("搜索结果: %s\n", results);
FreeStringPtr(instance, results);
}
// 搜索 Unicode 字符串
const char* results2 = DmaFindString(instance, deviceId, 1234, "0x400000-0x500000", "World", 1);
if (results2 != NULL && strlen(results2) > 0) {
printf("搜索结果: %s\n", results2);
FreeStringPtr(instance, results2);
}
// 搜索 UTF8 字符串
const char* results3 = DmaFindString(instance, deviceId, 1234, "0x400000-0x500000", "你好", 2);
if (results3 != NULL && strlen(results3) > 0) {
printf("搜索结果: %s\n", results3);
FreeStringPtr(instance, results3);
}
返回值
字符串:
返回二进制字符串的指针,数据格式为 addr1|addr2|addr3...|addrn
示例:123456|ff001122|dc12366
注意: 返回的字符串指针需要调用 FreeStringPtr 接口释放内存
参数说明
type(字符串类型):
- 0: Ascii 字符串
- 1: Unicode 字符串
- 2: UTF8 字符串
string_value(搜索字符串):
- 要搜索的字符串内容
- 必须与指定的字符串类型匹配
应用场景
- 搜索文本内容
- 字符串定位
- 内存分析
相关接口
- DmaFindStringEx - 高级搜索选项
- DmaFindData - 搜索二进制数据
