Beispiel #1
0
mad_status MADCLIENTRY( AddrToString )( address a, mad_type_handle th,
                            mad_label_kind lk, char *buff, unsigned buff_len )
{
    mad_type_info       mti;
    addr_ptr            item;
    mad_type_info       host;

    MADTypeInfo( th, &mti );
    MADTypeInfoForHost( MTK_ADDRESS, sizeof( address ), &host );
    MADTypeConvert( &host, &a, &mti, &item, 0 );
    MADTypeToString( 16, &mti, &item, buff, &buff_len );
    return( MS_OK );
}
Beispiel #2
0
char *AddrTypeToString( address *a, mad_type_handle th, char *buff, size_t buff_len )
{
    mad_type_info       mti;
    item_mach           item;
    mad_type_info       host;

    MADTypeInfo( th, &mti );
    MADTypeInfoForHost( MTK_ADDRESS, sizeof( address ), &host );
    AddrFix( a );
    MADTypeConvert( &host, a, &mti, &item, 0 );
    MADTypeToString( 16, &mti, &item, buff, &buff_len );
    return( buff + buff_len );
}
Beispiel #3
0
static void SetIp( HWND hwnd, address *addr ) {
    mad_type_info   host;
    mad_type_info   mti;
    void            *item;
    char            buf[BUF_SIZE];
    unsigned        max;

    max = BUF_SIZE - 1;
    MADTypeInfoForHost( MTK_ADDRESS, sizeof( address ), &host );
    MADTypeInfo( MADTypeDefault( MTK_ADDRESS, MAF_FULL, NULL, addr ), &mti );
    item = alloca( ( mti.b.bits / BITS_PER_BYTE ) + 1);
    MADTypeConvert( &host, addr, &mti, item, 0 );
    MADTypeToString( 16, &mti, item, &max, buf );
    SetDlgItemText( hwnd, INT_CS_IP, buf );
}
Beispiel #4
0
static void logStack( ExceptDlgInfo *info ) {
    unsigned_16     *data;
    int             i;
    int             j;
    address         sp;
    DWORD           linecnt;
    DWORD           bytesread;
    mad_type_info   host;
    mad_type_info   mti;
    void            *item;
    char            buff[BUF_SIZE];
    unsigned        buff_len;
    unsigned        word_size;

#define MIN_SIZE    sizeof( unsigned_16 )

    MADRegSpecialGet( MSR_SP, info->regs, &( sp.mach ) );
    MADTypeInfoForHost( MTK_ADDRESS, sizeof( address ), &host );
    MADTypeInfo( MADTypeDefault( MTK_ADDRESS, MAF_FULL, NULL, &sp ), &mti );
    item = alloca( BITS2BYTES( mti.b.bits ) + 1 );
#ifdef __AXP__
    word_size = 8;
#else
    word_size = 4;
#endif
    data = alloca( word_size * 4 );
    logPrintf( STR_STACK_DATA );
    for( linecnt=0; linecnt < 20; linecnt ++ ) {
        bytesread = MADCliReadMem( sp, word_size * 4, data );
        MADTypeConvert( &host, &sp, &mti, item, 0 );
        buff_len = sizeof( buff );
        MADTypeToString( 16, &mti, item, buff, &buff_len );
        logStrPrintf( "%s - ", buff );
        for( i = 0; i < bytesread / MIN_SIZE; i += word_size / MIN_SIZE ) {
            for( j = word_size / MIN_SIZE - 1; j >= 0; j-- ) {
                logStrPrintf( "%04hX", data[i+j]);
            }
            logStrPrintf( " " );
            MADAddrAdd( &sp, word_size, MAF_FULL );
        }
        logStrPrintf( "\n" );
    }
}
Beispiel #5
0
void ToItemMAD( stack_entry *entry, item_mach *tmp, mad_type_info *mti )
{
    unsigned            bytes;
    mad_type_info       src;

    bytes = mti->b.bits / BITS_PER_BYTE;
    switch( mti->b.kind ) {
    case MTK_INTEGER:
        ConvertTo( entry, TK_INTEGER, TM_UNSIGNED, bytes );
        MADTypeInfoForHost( MTK_INTEGER, sizeof( entry->v.uint ), &src );
        break;
    case MTK_ADDRESS:
        if( mti->a.seg.bits == 0 ) {
            ConvertTo( entry, TK_ADDRESS, TM_NEAR, bytes );
            MADTypeInfoForHost( MTK_ADDRESS, sizeof( entry->v.addr.mach.offset ), &src );
        } else {
            ConvertTo( entry, TK_ADDRESS, TM_FAR, bytes );
            MADTypeInfoForHost( MTK_ADDRESS, sizeof( entry->v.addr.mach ), &src );
        }
        break;
    case MTK_FLOAT:
        ConvertTo( entry, TK_REAL, TM_NONE, bytes );
        MADTypeInfoForHost( MTK_FLOAT, sizeof( entry->v.real ), &src );
        break;
    case MTK_XMM:
        //MAD: nyi
        ToItem( entry, tmp );
        return;
    case MTK_CUSTOM:
        //MAD: nyi
        ToItem( entry, tmp );
        return;
    }
    if( MADTypeConvert( &src, &entry->v, mti, tmp, 0 ) != MS_OK ) {
        ToItem( entry, tmp );
    }
}
Beispiel #6
0
static void CheckForRegisterChange( HWND hwnd )
{
    RegModifyData   *data;
    mad_type_info   mti_target;
    mad_type_info   mti_host;
    int             size;
    char            *s;
    char            *endptr;
    void            *test;
    addr_seg        seg;
    InputUnion      in;

    data = ( RegModifyData * )GetWindowLong( hwnd, DWL_USER );
    MADTypeInfo( data->curr_info->type, &mti_target );
    if( data->num_possible == 1 ) {
        size = SendDlgItemMessage( hwnd, REG_EDIT_FIELD, WM_GETTEXTLENGTH, 0, 0 ) + 1 ;
        s = alloca( size );
        GetDlgItemText( hwnd, REG_EDIT_FIELD, s, 255 );
        test = alloca( mti_target.b.bits / BITS_PER_BYTE );
        memset( &seg, 0, sizeof( seg ) );
        errno = 0;
        size = 0;
        switch ( mti_target.b.kind ) {
        case MTK_INTEGER:
            if( !StrToU64( s, &( in.i ), ( mti_target.i.nr != MNR_UNSIGNED ) ) ) {
                MessageBox( hwnd, "Unrecognized input.", "Error",MB_OK | MB_ICONEXCLAMATION ) ;
                return;
            }
            size = sizeof( unsigned_64 );
            break;
        case MTK_FLOAT:
            in.d = strtod( s, &endptr );
            if( errno == ERANGE ) {
                MessageBox( hwnd, "Value out of range.", "Error",MB_OK | MB_ICONEXCLAMATION ) ;
                return;
            }
            if( *endptr != '\0' ) {
                MessageBox( hwnd, "Unrecognized input.", "Error",MB_OK | MB_ICONEXCLAMATION ) ;
                return;
            }
            size = sizeof( in.d );
            break;
        default:
            EndDialog( hwnd, 0 );
            break;
        }
        MADTypeInfoForHost( mti_target.b.kind, size, &mti_host );
        MADTypeConvert( &mti_host, &in, &mti_target, test, seg );
        if( memcmp( data->curr_value, test, mti_target.b.bits / BITS_PER_BYTE ) == 0 ) {
            EndDialog( hwnd, 0 );
        } else {
            memcpy( data->curr_value, test, mti_target.b.bits / BITS_PER_BYTE );
            EndDialog( hwnd, 1 );
        }
    } else {
        int i = (int)SendDlgItemMessage( hwnd, CH_REG_COMBO_LIST, CB_GETCURSEL, 0, 0L );
        if( memcmp( data->curr_value, data->m_list[i].data, mti_target.b.bits / BITS_PER_BYTE ) == 0 ) {
            EndDialog( hwnd, 0 );
        } else {
            memcpy( data->curr_value, data->m_list[i].data, mti_target.b.bits / BITS_PER_BYTE );
            EndDialog( hwnd, 1 );
        }
    }
}
Beispiel #7
0
void ToItem( stack_entry *entry, item_mach *tmp )
{
    unsigned            size;
    mad_type_info       src_type;
    mad_type_info       dst_type;

    if( entry->info.size > sizeof( *tmp ) ) {
        Error( ERR_NONE, LIT( ERR_TYPE_CONVERSION ) );
    }
    //NYI: use MAD routines for all conversions
    size = entry->info.size;
    switch( entry->info.kind ) {
    case TK_BOOL:
    case TK_ENUM:
    case TK_CHAR:
    case TK_INTEGER:
        MADTypeInfo( MADTypeForDIPType( &entry->info ), &dst_type );
        if( (entry->info.modifier & TM_MOD_MASK) == TM_SIGNED ) {
            MADTypeInfoForHost( MTK_INTEGER, -(int)sizeof( entry->v.sint ), &src_type );
        } else {
            MADTypeInfoForHost( MTK_INTEGER, sizeof( entry->v.sint ), &src_type );
        }
        MADTypeConvert( &src_type, &entry->v.uint, &dst_type, tmp, 0 );
        return;
    case TK_REAL:
        MADTypeInfo( MADTypeForDIPType( &entry->info ), &dst_type );
        MADTypeInfoForHost( MTK_FLOAT, sizeof( entry->v.real ), &src_type );
        MADTypeConvert( &src_type, &entry->v.real, &dst_type, tmp, 0 );
        return;
    case TK_COMPLEX:
        switch( size ) {
        case 8:
            tmp->sc.re = LDToD( &entry->v.cmplx.re );
            tmp->sc.im = LDToD( &entry->v.cmplx.im );
            return;
        case 16:
            tmp->lc.re = LDToD( &entry->v.cmplx.re );
            tmp->lc.im = LDToD( &entry->v.cmplx.im );
            return;
        case 20:
            tmp->xc = entry->v.cmplx;
            return;
        }
        break;
    case TK_POINTER:
    case TK_ADDRESS:
        switch( entry->info.modifier & TM_MOD_MASK ) {
        case TM_NEAR:
            switch( size ) {
            case 2:
                tmp->so = entry->v.addr.mach.offset;
                return;
            case 4:
                tmp->lo = entry->v.addr.mach.offset;
                return;
            case 8:
                tmp->qo.u._32[I64LO32] = entry->v.addr.mach.offset;
                tmp->qo.u._32[I64HI32] = 0;
            }
            break;
        case TM_FAR:
        case TM_HUGE:
            switch( size ) {
            case 4:
                ConvAddr48ToAddr32( entry->v.addr.mach, tmp->sa );
                return;
            case 6:
                tmp->la = entry->v.addr.mach;
                return;
            }
            break;
        }
        break;
    }
    Error( ERR_NONE, LIT( ERR_TYPE_CONVERSION ) );
}
Beispiel #8
0
void FromItem( item_mach *tmp, stack_entry *entry )
{
    unsigned            size;
    mad_type_info       src_type;
    mad_type_info       dst_type;
    type_info           ti;

    if( entry->info.size > sizeof( *tmp ) ) {
        Error( ERR_NONE, LIT( ERR_TYPE_CONVERSION ) );
    }
    size = entry->info.size;
    switch( entry->info.kind ) {
    case TK_BOOL:
    case TK_ENUM:
    case TK_CHAR:
    case TK_INTEGER:
        MADTypeInfo( MADTypeForDIPType( &entry->info ), &src_type );
        if( (entry->info.modifier & TM_MOD_MASK) == TM_SIGNED ) {
            MADTypeInfoForHost( MTK_INTEGER, -(int)sizeof( entry->v.sint ), &dst_type );
        } else {
            MADTypeInfoForHost( MTK_INTEGER, sizeof( entry->v.sint ), &dst_type );
        }
        MADTypeConvert( &src_type, tmp, &dst_type, &entry->v.uint, 0 );
        return;
    case TK_REAL:
        MADTypeInfo( MADTypeForDIPType( &entry->info ), &src_type );
        MADTypeInfoForHost( MTK_FLOAT, sizeof( entry->v.real ), &dst_type );
        MADTypeConvert( &src_type, tmp, &dst_type, &entry->v.real, 0 );
        return;
    case TK_COMPLEX:
        ti.kind = TK_REAL;
        ti.size = entry->info.size / 2;
        ti.modifier = entry->info.modifier;
        MADTypeInfo( MADTypeForDIPType( &ti ), &src_type );
        MADTypeInfoForHost( MTK_FLOAT, sizeof( entry->v.cmplx.re ), &dst_type );
        MADTypeConvert( &src_type, tmp, &dst_type, &entry->v.cmplx.re, 0 );
        MADTypeConvert( &src_type, (unsigned_8 *)tmp + ti.size, &dst_type, &entry->v.cmplx.im, 0 );
        return;
    case TK_POINTER:
    case TK_ADDRESS:
        //NYI: use MAD conversion routines....
        switch( entry->info.modifier & TM_MOD_MASK ) {
        case TM_NEAR:
            switch( size ) {
            case 2:
                entry->v.addr.mach.offset = tmp->so;
                return;
            case 8:
                //NYI: 64 bit offsets
                entry->info.size = 4;
            case 4:
                entry->v.addr.mach.offset = tmp->lo;
                return;
            }
            break;
        case TM_FAR:
        case TM_HUGE:
            switch( size ) {
            case 4:
                entry->v.addr.sect_id = 0;
                entry->v.addr.indirect = FALSE;
                ConvAddr32ToAddr48( tmp->sa, entry->v.addr.mach );
                return;
            case 6:
                entry->v.addr.sect_id = 0;
                entry->v.addr.indirect = FALSE;
                entry->v.addr.mach = tmp->la;
                return;
            case sizeof( address ):
                /* it's an internal address symbol */
                entry->v.addr = tmp->xa;
                entry->info.size = 6;
                return;
            }
            break;
        }
        break;
    }
    Error( ERR_NONE, LIT( ERR_TYPE_CONVERSION ) );
}