共用方式為


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位進程中的ntdll),只會符合傳遞的特定實例。 如果卸除並重載該 DLL,它也不會再相符。 簽章會與調試程式所稱模組的特定實例相關聯。

要求

要求 價值
標頭 dbgmodel.h

另請參閱

IDebugHostSymbols 介面

CreateTypeSignature

CreateTypeSignatureForModuleRange