共用方式為


IDebugHostSymbols::CreateTypeSignature 方法 (dbgmodel.h)

CreateTypeSignature 方法會建立簽章,以透過包含模組和類型名稱來比對一組具體類型。 類型名稱簽章字串的格式專屬於正在偵錯的語言(以及偵錯主機)。 對於 C/C++,簽章字串相當於 NatVis 類型規格。 也就是說,簽章字串是範本自變數允許通配符(指定為*) 的類型名稱。

語法

HRESULT CreateTypeSignature(
  PCWSTR                  signatureSpecification,
  IDebugHostModule        *module,
  IDebugHostTypeSignature **typeSignature
);

參數

signatureSpecification

識別套用此簽章之類型的簽章字串。 此字串的格式專屬於所偵錯的語言。 針對 C/C++,這相當於 NatVis 類型規格。 這是範本自變數允許通配符的類型名稱(指定為 *)。

module

如果指定,則只有包含在指定模組內的型別符合簽章。 如果未指定,任何模組中的類型可能會符合簽章。

typeSignature

建立的類型簽章物件會在這裡傳回。

傳回值

此方法會傳回表示成功或失敗的 HRESULT。

言論

範例程式代碼

ComPtr<IDebugHost> spHost; /* get the host */

ComPtr<IDebugHostSymbols> spSym;
if (SUCCEEDED(spHost.As(&spSym)))
{
    // Create a type signature for MyTemplateType<*>
    ComPtr<IDebugHostTypeSignature> spSig1;
    if (SUCCEEDED(spSym->CreateTypeSignature(L"MyTemplateType<*>", 
                                             nullptr, 
                                             &spSig1)))
    {
        // spSig1 is a type signature which will match any concrete template 
        // type with a base name of MyTemplateType and *ANY* template arguments.
        // This is true regardless of the module in which the type is contained.
    }

    ComPtr<IDebugHostModule> spMyModule;
    if (SUCCEEDED(spSym->FindModuleByName(USE_CURRENT_HOST_CONTEXT, 
                                          L"MyModule.dll", 
                                          &spMyModule)))
    {
        // Create a type signature for MyTemplateType<*> within MyModule.dll.
        ComPtr<IDebugHostTypeSignature> spSig2;
        if (SUCCEEDED(spSym->CreateTypeSignature(L"MyTemplateType<*>", 
                                                 nullptr, 
                                                 &spSig2)))
        {
            // spSig2 is a type signature which will match any concrete 
            // template type with a base name of MyTemplateType and *ANY* 
            // template arguments that is within the particular MyModule.dll 
            // that's in the current UI context (e.g.: process) of the debugger.
            // This means if the host is debugging multiple processes
            // and you switch processes, a MyTemplateType<*> in an identically
            // named and versioned MyModule.dll will *NOT* match this signature.
        }
    }
}

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 介面

FindModuleByName

CreateTypeSignatureForModuleRange