获取模块基址 - DmaGetModuleBase
函数简介
获取指定进程中模块的基址。空字符串表示主模块。(高级版功能,普通版无法使用)
接口名称
DmaGetModuleBase
DLL调用
int64_t OLA_CALL_TYPE DmaGetModuleBase(int64_t instance, int64_t deviceId, int32_t pid, OLA_STRING_INPUT moduleName);
参数定义:
instance(长整型数): OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。deviceId(长整型数): 设备IDpid(整型数): 进程 PIDmoduleName(字符串): 模块名,空字符串表示主模块
示例:
// 获取主模块基址
int64_t mainModuleBase = DmaGetModuleBase(instance, deviceId, 1234, "");
if (mainModuleBase > 0) {
printf("主模块基址: 0x%llx\n", mainModuleBase);
}
// 获取指定模块基址
int64_t dllBase = DmaGetModuleBase(instance, deviceId, 1234, "kernel32.dll");
if (dllBase > 0) {
printf("kernel32.dll 基址: 0x%llx\n", dllBase);
}
// 获取自定义 DLL 基址
int64_t customDllBase = DmaGetModuleBase(instance, deviceId, 1234, "mylib.dll");
if (customDllBase > 0) {
printf("mylib.dll 基址: 0x%llx\n", customDllBase);
}
返回值
长整型数:
- 成功: 返回模块基址 (>0)
- 失败: 返回 0
参数说明
moduleName(模块名):
- 空字符串
""表示主模块(EXE 文件) - 其他值表示具体的 DLL 模块名
- 模块名不区分大小写
应用场景
- 获取模块在内存中的加载地址
- 进行相对地址计算
- 模块分析和调试
相关接口
- DmaGetModuleSize - 获取模块大小
- DmaGetProcAddress - 获取模块导出函数地址
