FindModuleByName 方法将浏览给定的主机上下文,并找到具有指定名称的模块,并向其返回接口。 使用或不使用文件扩展名按名称搜索模块是合法的。
语法
HRESULT FindModuleByName(
IDebugHostContext *context,
PCWSTR moduleName,
IDebugHostModule **module
);
参数
context
此主机上下文将搜索与给定名称匹配的已加载模块。
moduleName
要搜索的模块的名称。 可以使用或不使用文件扩展名指定名称。
module
如果找到模块,则会在此处返回模块的接口。
返回值
此方法返回指示成功或失败的 HRESULT。
言论
示例代码
ComPtr<IDebugHost> spHost; /* get the host */
ComPtr<IDebugHostSymbols> spSym;
if (SUCCEEDED(spHost.As(&spSym)))
{
// Find the "notepad.exe" module in the current UI context (process)
// of the debug host:
ComPtr<IDebugHostModule> spModule;
if (SUCCEEDED(spSym->FindModuleByName(USE_CURRENT_HOST_CONTEXT,
L"notepad.exe",
&spModule)))
{
// spModule is the module "notepad.exe"
}
}
FindModuleByName、CreateTypeSignature 和 CreateTypeSignatureForModuleRange 中的符号模块匹配的差异
FindModuleByName 将允许传递的模块名称是模块的真实映像名称(例如 My Module.dll),或者可以在调试器引擎(例如:MyModule 或MyModule_<hex_base>)中引用它的名称)。
调用 CreateTypeSignatureForModuleRange 并传递名称/nullptr/nullptr 将创建与任何版本名称匹配的任何模块的签名。
传递给 CreateTypeSignature 函数的模块名称将仅接受模块的真实映像名称(例如:MyModule.dll)。
调用 FindModuleByName,然后使用该模块创建一个签名,该签名将仅匹配传递给它的模块的特定实例。 如果加载的模块有两个副本(例如:在 64 位 Windows 上运行的 32 位进程中的 ntdll),它只会匹配传递的特定实例。 如果卸载并重新加载了 DLL,该 DLL 也不会再匹配。 签名与调试器已知的模块的特定实例相关联。
要求
要求 | 价值 |
---|---|
标头 | dbgmodel.h |