共用方式為


IDiaSegment

將資料從區段編號對應至位址空間的區段。

語法

IDiaSegment : IUnknown

依照 Vtable 順序的方法

下表顯示 IDiaSegment 方法。

方法 描述
IDiaSegment::get_frame 擷取區段編號。
IDiaSegment::get_offset 擷取區段開始處區段中的位移。
IDiaSegment::get_length 擷取區段中的位元組數目。
IDiaSegment::get_read 擷取旗標,指出是否可以讀取區段。
IDiaSegment::get_write 擷取旗標,指出是否可以修改區段。
IDiaSegment::get_execute 擷取旗標,指出該區段是否為可執行檔。
IDiaSegment::get_addressSection 擷取對應至此區段的區段編號。
IDiaSegment::get_relativeVirtualAddress 擷取區段開頭的相對虛擬位址 (RVA)。
IDiaSegment::get_virtualAddress 擷取區段開頭的虛擬位址 (VA)。

備註

因為偵錯介面存取 (DIA) SDK 已經從區段位移到相對虛擬位址執行翻譯,因此大部分的應用程式都不會使用區段對應中的資訊。

呼叫端注意事項

呼叫 IDiaEnumSegments::ItemIDiaEnumSegments::Next 方法來取得此介面。 如需詳細資料,請參閱範例。

範例

此函式會顯示資料表中所有區段的位址和最接近的符號。

void ShowSegments(IDiaTable *pTable, IDiaSession *pSession)
{
    CComPtr<IDiaEnumSegments> pSegments;
    if ( SUCCEEDED( pTable->QueryInterface(
                                _uuidof( IDiaEnumSegments ),
                               (void**)&pSegments )
                  )
       )
    {
        CComPtr<IDiaSegment> pSegment;
        while ( SUCCEEDED( hr = pSegments->Next( 1, &pSegment, &celt ) ) &&
                celt == 1 )
        {
            DWORD rva;
            DWORD seg;

            pSegment->get_addressSection( &seg );
            if ( pSegment->get_relativeVirtualAddress( &rva ) == S_OK )
            {
                printf( "Segment %i addr: 0x%.8X\n", seg, rva );
                pSegment = NULL;

                CComPtr<IDiaSymbol> pSym;
                if ( psession->findSymbolByRVA( rva, SymTagNull, &pSym ) == S_OK )
                {
                    CDiaBSTR name;
                    DWORD    tag;

                    pSym->get_symTag( &tag );
                    pSym->get_name( &name );
                    printf( "\tClosest symbol: %ws (%ws)\n",
                            name != NULL ? name : L"",
                            szTags[ tag ] );
                }
            }
        }
    }
}

需求

標頭: Dia2.h

程式庫: diaguids.lib

DLL: msdia80.dll

另請參閱