IDebugHostSymbols::FindModuleByName 方法 (dbgmodel.h)

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 並傳遞 name/nullptr/nullptr 將會建立簽章,以符合任何版本名稱的任何模組。

傳遞至 CreateTypeSignature 函式的模組名稱只會接受模組的實際映像名稱 (,例如:MyModule.dll) 。

呼叫 FindModuleByName,然後使用該模組建立 CreateTypeSignature 會建立簽章,只符合傳遞至該模組的特定模組實例。 如果模組有兩個復本載入 (例如:在64位 Windows) 上執行的32位進程中,只會符合傳遞的特定實例。 如果卸除並重載該 DLL,它也不會再相符。 簽章會與調試程式稱為模組的特定實例相關聯。

規格需求

需求
標頭 dbgmodel.h

另請參閱

IDebugHostSymbols 介面

CreateTypeSignature

CreateTypeSignatureForModuleRange