通过DMA搜索字符串Ex - DmaFindStringEx
函数简介
通过 DMA 搜索指定范围内的字符串,支持自定义步长和多线程选项。(高级版功能,普通版无法使用)
接口名称
DmaFindStringEx
DLL调用
OLA_STRING_RETURN OLA_CALL_TYPE DmaFindStringEx(int64_t instance, int64_t deviceId, int32_t pid, OLA_STRING_INPUT addr_range, OLA_STRING_INPUT string_value, int32_t type, int32_t step, int32_t multi_thread, int32_t mode);
参数定义:
instance(长整型数): OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。deviceId(长整型数): 设备IDpid(整型数): 进程 PIDaddr_range(字符串): 地址范围string_value(字符串): 要搜索的字符串type(整型数): 字符串类型step(整型数): 步长multi_thread(整型数): 是否开启多线程mode(整型数): 搜索模式
示例:
// 使用步长为 1 的单线程搜索 ASCII 字符串
const char* results = DmaFindStringEx(instance, deviceId, 1234, "0x400000-0x500000", "Hello", 0, 1, 0, 0);
if (results != NULL && strlen(results) > 0) {
printf("搜索结果: %s\n", results);
FreeStringPtr(instance, results);
}
// 使用步长为 2 的多线程搜索 Unicode 字符串
const char* results2 = DmaFindStringEx(instance, deviceId, 1234, "0x400000-0x500000", "World", 1, 2, 1, 0);
if (results2 != NULL && strlen(results2) > 0) {
printf("搜索结果: %s\n", results2);
FreeStringPtr(instance, results2);
}
返回值
字符串:
返回二进制字符串的指针,数据格式为 addr1|addr2|addr3...|addrn
示例:123456|ff001122|dc12366
注意: 返回的字符串指针需要调用 FreeStringPtr 接口释放内存
参数说明
type(字符串类型):
- 0: Ascii 字符串
- 1: Unicode 字符串
- 2: UTF8 字符串
step(步长):
- 1: 逐字节搜索(最精确,最慢)
- 2: 每 2 字节搜索一次
- 更大的步长搜索更快但可能遗漏结果
multi_thread(多线程):
- 0: 单线程搜索
- 1: 多线程搜索(更快)
mode(搜索模式):
- 0: 全部
- 1: 可写
- 2: 不可写
- 4: 可执行
- 8: 不可执行
- 16: 写时复制
- 32: 不写时复制
应用场景
- 自定义搜索参数
- 平衡搜索速度和准确性
- 大范围内存搜索
相关接口
- DmaFindString - 基础搜索
- DmaFindData - 搜索二进制数据
