Compartir a través de


IDiaSegment

Maps data from the section number to segments of address space.

IDiaSegment : IUnknown

Methods in Vtable Order

The following table shows the methods of IDiaSegment.

Method

Description

IDiaSegment::get_frame

Retrieves the segment number.

IDiaSegment::get_offset

Retrieves the offset in segments where the section begins.

IDiaSegment::get_length

Retrieves the number of bytes in the segment.

IDiaSegment::get_read

Retrieves a flag that indicates whether the segment can be read.

IDiaSegment::get_write

Retrieves a flag that indicates whether the segment can be modified.

IDiaSegment::get_execute

Retrieves a flag that indicates whether the segment is executable.

IDiaSegment::get_addressSection

Retrieves the section number that maps to this segment.

IDiaSegment::get_relativeVirtualAddress

Retrieves the relative virtual address (RVA) of the beginning of the section.

IDiaSegment::get_virtualAddress

Retrieves the virtual address (VA) of the beginning of the section.

Remarks

Because the DIA SDK already performs translations from the section offset to relative virtual addresses, most applications will not make use of the information in the segment map.

Notes for Callers

Obtain this interface by calling the IDiaEnumSegments::Item or IDiaEnumSegments::Next methods. See the example for details.

Example

This function displays the address of all segments in a table and the nearest symbol.

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 ] );
                }
            }
        }
    }
}

Requirements

Header: Dia2.h

Library: diaguids.lib

DLL: msdia80.dll

See Also

Reference

IDiaEnumSegments::Item

IDiaEnumSegments::Next

Other Resources

Interfaces (Debug Interface Access SDK)