Beispiel #1
0
static char *DoMadLongConv( char *buff, size_t buff_len, unsigned long value, mad_radix radix, int size )
{
    mad_radix           old_radix;
    mad_type_info       mti;

    old_radix = NewCurrRadix( radix );
    MADTypeInfoForHost( MTK_INTEGER, size, &mti );
    MADTypeToString( radix, &mti, &value, buff, &buff_len );
    NewCurrRadix( old_radix );
    return( buff + buff_len );
}
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
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 #4
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 #5
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 #6
0
static void InitChangeRegisterDialog(HWND hwnd,LPARAM lparam)
{
    RegModifyData   *data;
    char            *name;
    unsigned        len;
    mad_radix       radix;
    mad_type_info   mti;
    mad_type_info   cmp;
    char            s[255];
    RECT            p_rect;
    RECT            c_rect;
    HWND            field;
    int             i;
    unsigned        max_len;
    HDC             dc;
    TEXTMETRIC      tm;
    HWND            cancel;

    SetWindowLong( hwnd, DWL_USER, (LONG)lparam);
    data = (RegModifyData *)lparam;
    len = MADRegFullName( data->curr_info, ".", NULL, 0 );
    if( len > 0 ) {
        name = alloca( ( len + 1 ) * sizeof( char ) );
        MADRegFullName( data->curr_info, ".", name, len );
        SetWindowText( hwnd, name );
    } else {
        SetWindowText( hwnd, "" );
    }

    if( data->num_possible == 1 ) {
        field = GetDlgItem( hwnd, REG_EDIT_FIELD );
    } else {
        field = GetDlgItem( hwnd, CH_REG_COMBO_LIST );
    }
    SetMonoFont( field );
    GetChildPos( hwnd, field, &c_rect);
    dc = GetDC( field );
    GetTextMetrics( dc, &tm );
    MADTypeInfo( data->th, &mti );
    radix = MADTypePreferredRadix( data->th );

    if( data->num_possible == 1 ) {
        if( data->maxv == 0 ) {
            len = 255;
        } else {
            len = data->maxv;
        }
        MADTypeToString( radix, &mti, data->curr_value, s, &len );
        if( data->maxv == 0 ) {
            max_len = strlen( s );
        } else {
            max_len = data->maxv;
        }
        SetDlgItemText(hwnd,REG_EDIT_FIELD,s);
    } else {
        MADTypeInfo( data->curr_info->type, &cmp );
        max_len = 0;
        for( i = 0; i < data->num_possible; i++ ) {
            if( data->m_list[i].name == MAD_MSTR_NIL ) {
                len = sizeof( s );
                MADTypeToString( radix, &mti, data->m_list[i].data, s, &len );
            } else {
                MADCliString( data->m_list[i].name, s, sizeof( s ) );
            }
            if( max_len < strlen( s ) )
                max_len = strlen( s );
            SendDlgItemMessage( hwnd, CH_REG_COMBO_LIST, CB_ADDSTRING, 0, (LPARAM)s );
            if( memcmp( data->curr_value, data->m_list[i].data, cmp.b.bits / BITS_PER_BYTE ) == 0 ){
                SendDlgItemMessage( hwnd, CH_REG_COMBO_LIST, CB_SETCURSEL, (WPARAM)i, 0 );
            }
        }
        c_rect.bottom += SendMessage( field, CB_GETITEMHEIGHT, 0, 0 ) * (i + 1);
    }
    max_len *= tm.tmMaxCharWidth;
    if( max_len > c_rect.right ) {
        max_len -= max_len%2;
        GetWindowRect( hwnd, &p_rect );
        p_rect.right -= p_rect.left;
        p_rect.bottom -= p_rect.top;
        p_rect.left -= ( max_len - c_rect.right )/2;
        p_rect.right += ( max_len - c_rect.right );
        MoveWindow( hwnd, p_rect.left, p_rect.top, p_rect.right, p_rect.bottom, FALSE );
        cancel = GetDlgItem( hwnd, IDCANCEL );
        GetChildPos( hwnd, cancel, &p_rect );
        p_rect.left += ( max_len - c_rect.right );
        MoveWindow( cancel, p_rect.left, p_rect.top, p_rect.right, p_rect.bottom, FALSE );
        c_rect.right = max_len;
    }
    ReleaseDC( field, dc );
    MoveWindow( field, c_rect.left, c_rect.top, c_rect.right, c_rect.bottom, FALSE );
}