Esempio n. 1
0
search_result DIPENTRY DIPImpAddrSym( imp_image_handle *ii, imp_mod_handle im,
                        address addr, imp_sym_handle *is )
{
    search_result       sr;

    if( im == NO_MOD ) {
        if( ImpInterface.addr_mod( ii, addr, &is->im ) == SR_NONE ) return( SR_NONE );
    } else {
        is->im = im;
    }
    sr = LookupLclAddr( ii, addr, is );
    if( sr != SR_NONE ) return( sr );
    return( LookupGblAddr( ii, addr, is ) );
}
Esempio n. 2
0
size_t DIPIMPENTRY( SymName )( imp_image_handle *ii, imp_sym_handle *is,
                                location_context *lc,
                                symbol_name sn, char *buff, size_t buff_size )
{
    byte                *sp;
    byte                *ep;
    byte                curr;
    size_t              len;
    char                *mangled_name;
    location_list       ll;
    imp_sym_handle      gbl_is;

    switch( sn ) {
    case SN_EXPRESSION:
        sp = (byte *)is;
        ++is;
        len = 0;
        #define STUFF_IT( c )   if( (len+1) < buff_size ) *ep++ = (c); ++len
        ep = (byte *)buff;
        STUFF_IT( SH_ESCAPE );
        while( sp < (byte *)is ) {
            curr = *sp++;
            switch( curr ) {
            case SH_ESCAPE:
                curr = 1;
                STUFF_IT( SH_ESCAPE );
                break;
            case '\0':
                curr = 2;
                STUFF_IT( SH_ESCAPE );
                break;
            case '`':
                curr = 3;
                STUFF_IT( SH_ESCAPE );
                break;
            }
            STUFF_IT( curr );
        }
        if( buff_size > 0 )
            *ep++ = '\0';
        return( len );
    case SN_DEMANGLED:
        len = ImpInterface.SymName( ii, is, lc, SN_OBJECT, NULL, 0 );
        if( len == 0 )
            return( len );
        mangled_name = __alloca( len + 1 );
        ImpInterface.SymName( ii, is, lc, SN_OBJECT, mangled_name, len + 1 );
        if( !__is_mangled( mangled_name, len ) )
            return( 0 );
        return( __demangle_l( mangled_name, len, buff, buff_size ) );
    case SN_OBJECT:
        switch( is->type ) {
        case SH_LCL:
            if( Lcl2GblHdl( ii, is, &gbl_is ) != DS_OK )
                break;
            return( SymHdl2ObjGblName( ii, &gbl_is, buff, buff_size ) );
        case SH_MBR:
            if( ImpInterface.SymLocation( ii, is, lc, &ll ) != DS_OK )
                break;
            if( ll.num != 1 || ll.e[0].type != LT_ADDR )
                break;
            if( ImpInterface.AddrMod( ii, ll.e[0].u.addr, &gbl_is.im ) == SR_NONE )
                break;
            if( LookupGblAddr(ii,ll.e[0].u.addr,&gbl_is) != SR_EXACT )
                break;
            is = &gbl_is;
            /* fall through */
        case SH_GBL:
            return( SymHdl2ObjGblName( ii, is, buff, buff_size ) );
        }
        /* fall through */
    case SN_SOURCE:
        switch( is->type ) {
        case SH_GBL:
            return( SymHdl2GblName( ii, is, buff, buff_size ) );
        case SH_LCL:
            return( SymHdl2LclName( ii, is, buff, buff_size ) );
        case SH_MBR:
            return( SymHdl2MbrName( ii, is, buff, buff_size ) );
        case SH_TYP:
            return( SymHdl2TypName( ii, is, buff, buff_size ) );
        case SH_CST:
            return( SymHdl2CstName( ii, is, buff, buff_size ) );
        }
        break;
    }
    return( 0 );
}