IDebugHostSymbols::EnumerateModules 方法 (dbgmodel.h)
EnumerateModules 方法创建一个枚举器,用于枚举特定主机上下文中可用的每个模块。 该主机上下文可能封装进程上下文,或者它可能封装类似于 Windows 内核的内容。
语法
HRESULT EnumerateModules(
IDebugHostContext *context,
IDebugHostSymbolEnumerator **moduleEnum
);
参数
context
要枚举每个已加载模块的主机上下文。
moduleEnum
将枚举加载到给定上下文中的每个模块的枚举器将在此处返回。
返回值
此方法返回指示成功或失败的 HRESULT。
言论
示例代码
ComPtr<IDebugHost> spHost; /* get the host */
ComPtr<IDebugHostSymbols> spSym;
if (SUCCEEDED(spHost.As(&spSym)))
{
// Enumerate all modules in the current UI context (process) of the debug host:
ComPtr<IDebugHostSymbolEnumerator> spEnum;
if (SUCCEEDED(spSym->EnumerateModules(USE_CURRENT_HOST_CONTEXT, &spEnum)))
{
HRESULT hr = S_OK;
while (SUCCEEDED(hr))
{
ComPtr<IDebugHostSymbol> spModSym;
hr = spEnum->GetNext(&spModSym);
if (SUCCEEDED(hr))
{
ComPtr<IDebugHostModule> spModule;
if (SUCCEEDED(spModSym.As(&spModule))) /* should always succeed */
{
// spModule is one of the modules in the current
// UI context (process) of the debug host
}
}
}
// hr == E_BOUNDS : hit the end of the enumerator
// hr == E_ABORT : a user interrupt was requested /
// propagate upwards immediately
}
}
要求
要求 | 价值 |
---|---|
标头 | dbgmodel.h |