获取模块导出函数地址 - DmaGetProcAddress
函数简介
获取指定模块中导出函数的地址。(高级版功能,普通版无法使用)
接口名称
DmaGetProcAddress
DLL调用
int64_t OLA_CALL_TYPE DmaGetProcAddress(int64_t instance, int64_t deviceId, int32_t pid, OLA_STRING_INPUT moduleName, OLA_STRING_INPUT functionName);
参数定义:
instance(长整型数): OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。deviceId(长整型数): 设备IDpid(整型数): 进程 PIDmoduleName(字符串): 模块名functionName(字符串): 函数名
示例:
// 获取 kernel32.dll 中 CreateFileA 函数的地址
int64_t funcAddr = DmaGetProcAddress(instance, deviceId, 1234, "kernel32.dll", "CreateFileA");
if (funcAddr > 0) {
printf("CreateFileA 地址: 0x%llx\n", funcAddr);
}
// 获取自定义 DLL 中的函数地址
int64_t customFuncAddr = DmaGetProcAddress(instance, deviceId, 1234, "mylib.dll", "MyFunction");
if (customFuncAddr > 0) {
printf("MyFunction 地址: 0x%llx\n", customFuncAddr);
}
// 获取主模块中的函数地址
int64_t mainFuncAddr = DmaGetProcAddress(instance, deviceId, 1234, "", "main");
if (mainFuncAddr > 0) {
printf("main 函数地址: 0x%llx\n", mainFuncAddr);
}
返回值
长整型数:
- 成功: 返回函数地址 (>0)
- 失败: 返回 0
参数说明
moduleName(模块名):
- 空字符串
""表示主模块 - 其他值表示具体的 DLL 模块名
- 模块名不区分大小写
functionName(函数名):
- 导出函数的名称
- 必须是模块中实际导出的函数
- 函数名区分大小写
应用场景
- 获取 API 函数地址
- 动态函数调用
- 函数 Hook 和拦截
- 模块分析
相关接口
- DmaGetModuleBase - 获取模块基址
- DmaGetModuleSize - 获取模块大小
