IDiaEnumSymbolsByAddr2

Enumerates by address the various symbols contained in the data source.

Syntax

IDiaEnumSymbolsByAddr2 : IDiaEnumSymbolsByAdd

Methods in Vtable Order

The following table shows the methods of IDiaEnumSymbolsByAddr2.

Method Description
IDiaEnumSymbolsByAddr2::symbolByAddrEx Positions the enumerator by performing a lookup by section and offset.
IDiaEnumSymbolsByAddr2::symbolByRVAEx Positions the enumerator by performing a lookup by relative virtual address (RVA).
IDiaEnumSymbolsByAddr2::symbolByVAEx Positions the enumerator by performing a lookup by virtual address (VA).
IDiaEnumSymbolsByAddr2::NextEx Retrieves the next symbols in order by address. Updates the enumerator position by number of elements fetched.
IDiaEnumSymbolsByAddr2::PrevEx Retrieves the previous symbols in order by address. Updates the enumerator position by number of elements fetched.

Remarks

This interface provides symbols grouped by address. To work with symbols grouped by type, for example SymTagUDT (user-defined type) or SymTagBaseClass, use the IDiaEnumSymbols interface.

Notes for callers

Obtain this interface by calling the IDiaSession::getSymbolsByAddr method and then calling IUnknown::QueryInterface with the riid parameter set to IID_IDiaEnumSymbolsByAddr2.

Example

This function displays the name and address of all symbols ordered by relative virtual address.

void ShowSymbolsByAddress(IDiaSession *pSession)
{
    CComPtr<IDiaEnumSymbolsByAddr> pEnumByAddr;
    if ( FAILED( psession->getSymbolsByAddr( &pEnumByAddr ) ) )
    {
        Fatal( "getSymbolsByAddr" );
    }
    CComPtr<IDiaEnumSymbolsByAddr2> pEnumByAddr2;
    if ( FAILED( pEnumByAddr->QueryInterface( IID_IDiaEnumSymbolsByAddr2, &pEnumByAddr2 ) ) )
    {
        Fatal( "getSymbolsByAddr" );
    }
    CComPtr<IDiaSymbol> pSym;
    if ( FAILED( pEnumByAddr2->symbolByAddrEx( FALSE, 1, 0, &pSym ) ) )
    {
        Fatal( "symbolByAddr" );
    }
    DWORD rvaLast = 0;
    if ( pSym->get_relativeVirtualAddress( &rvaLast ) == S_OK )
    {
        pSym = 0;
        if ( FAILED( pEnumByAddr2->symbolByRVAEx( FALSE, rvaLast, &pSym ) ) )
        {
            Fatal( "symbolByAddr" );
        }
        printf( "Symbols in order\n" );
        do
        {
            CDiaBSTR name;
            if ( pSym->get_name( &name ) != S_OK )
            {
                printf( "\t0x%08X (%ws) <no name>\n", rvaLast );
            }
            else
            {
                printf( "\t0x%08X %ws\n", rvaLast, name );
            }
            pSym = 0;
            celt = 0;
            if ( FAILED( hr = pEnumByAddr2->NextEx( FALSE, 1, &pSym, &celt ) ) )
            {
                break;
            }
        } while ( celt == 1 );
    }
}

Requirements

Header: Dia2.h

Library: diaguids.lib

DLL: msdia140.dll

See also