Exemple #1
0
/*
 * Dump the Resource Directory.
 */
static void dmp_res_dir( void )
/*****************************/
{
    resource_dir_header     res_head;
    resource_dir_entry      res_dir;
    unsigned_16             count, i;

    Wdputslc( "\n" );
    Wdputslc( "80000000H = name rva,        else integer id\n" );
    Wdputslc( "80000000H = sudirectory rva, else data entry rva\n" );
    Wdputslc( "  #id ents    #name ents    name rva/id    data/subdir rva\n" );
    Wdputslc( "    ====         ====         ========        ========\n" );
    Wlseek( Res_off );
    for( ;; ) {
        Wread( &res_head, sizeof( resource_dir_header ) );
        count = res_head.num_name_entries + res_head.num_id_entries;
        if( count == 0 ) break;
        Wdputs( "    " );
        Puthex( res_head.num_id_entries, 4 );
        Wdputs( "         " );
        Puthex( res_head.num_name_entries, 4 );
        Wdputs( "         " );
        for( i = 0; i < count; i++ ) {
            Wread( &res_dir, sizeof( resource_dir_entry ) );
            if( i != 0 ) {
                Wdputs( "                              " );
            }
            Puthex( res_dir.id_name, 8 );
            Wdputs( "        " );
            Puthex( res_dir.entry_rva, 8 );
            Wdputslc( "\n" );
        }
    }
}
Exemple #2
0
/*
 * Dump the Resource Data.
 */
static void dmp_res_data( void )
/******************************/
{
    resource_entry          res_data;
    unsigned_16             i;

    Wdputslc( "\n" );
    Wdputslc( "       data rva     data size    codepage     reserved\n" );
    Wdputslc( "       ========     ========     ========     ========\n" );
    Wlseek( Data_off );
    for( i = 0; ; i++ ) {
        Wread( &res_data, sizeof( resource_entry ) );
        if( res_data.rsvd != 0 ) break;
        Putdecl( i, 3 );
        Wdputs( ":   " );
        Puthex( res_data.data_rva, 8 );
        Wdputs( "     " );
        Puthex( res_data.size, 8 );
        Wdputs( "     " );
        Puthex( res_data.code_page, 8 );
        Wdputs( "     " );
        Puthex( res_data.rsvd, 8 );
        Wdputslc( "\n" );
    }
}
Exemple #3
0
/*
 * dump_hll_sstModules - dump HLL sstModules at 'offset' from 'base'
 */
static void dump_hll_sstModules( unsigned_32 base, unsigned_32 offset )
/*********************************************************************/
{
    hll_module          mod;
    hll_seginfo         seg;
    bool                first = TRUE;

    Wlseek( base + offset );
    Wdputs( "==== sstModules at offset " );
    Puthex( offset, 8 );
    Wdputslc( "\n" );
    Wread( &mod, offsetof( hll_module, name_len ) );
    Dump_header( &mod, hll_sstModules_msg );
    hll_level = mod.Version >> 8;
    Wdputs( "  module name: \"" );
    dump_name( 0 );
    Wdputslc( "\"\n" );
    if( mod.cSeg ) {
        while( --mod.cSeg ) {
            if( !first ) {
                Wdputslc( "    ====\n" );
            }
            Wread( &seg, sizeof( seg ) );
            Dump_header( &seg, hll_seg_msg );
            first = FALSE;
        }
    }
    Wdputslc( "\n" );
}
Exemple #4
0
/*
 * Dmp_hll_head - dump IBM HLL or MS CodeView debugging information
 */
bool Dmp_hll_head( void )
/**********************/
{
    off_t           end_off;
    off_t           dbg_off;
    hll_trailer     trailer;

    end_off = lseek( Handle, 0, SEEK_END );
    Wlseek( end_off - sizeof( trailer ) );
    Wread( &trailer, sizeof( trailer ) );
    dbg_off = end_off - trailer.offset;
    if( memcmp( trailer.sig, HLL_NB04, HLL_SIG_SIZE ) == 0 ) {
        Banner( "HLL NB04 debugging information" );
        Wdputs( "debugging information base  = " );
        Puthex( dbg_off, 8 );
        Wdputslc( "H\n" );
        Wdputs( "subsection directory offset = " );
        Puthex( trailer.offset, 8 );
        Wdputslc( "H\n\n" );
        dump_hll( dbg_off );
        return( 1 );
    } else if( memcmp( trailer.sig, HLL_NB02, HLL_SIG_SIZE ) == 0 ) {
        Banner( "CodeView NB02 debugging information" );
        Wdputs( "debugging information base  = " );
        Puthex( dbg_off, 8 );
        Wdputslc( "H\n" );
        Wdputs( "subsection directory offset = " );
        Puthex( trailer.offset, 8 );
        Wdputslc( "H\n\n" );
        dump_cv( dbg_off );
        return( 1 );
    }
    return( 0 );
} /* Dmp_hll_head */
Exemple #5
0
/*
 * dump_hll_sstPublics - dump HLL sstPublics at 'offset'
 * from 'base 'containing 'size' bytes
 */
static void dump_hll_sstPublics( unsigned_32 base, unsigned_32 offset,
                                 unsigned_32 size )
/********************************************************************/
{
    hll_public_32       pub32;
    unsigned_32         read = 0;
    unsigned_8          name_len;
    char                name[256];

    Wlseek( base + offset );
    Wdputs( "==== sstPublics at offset " );
    Puthex( offset, 8 );
    Wdputslc( "\n" );
    while( read < size ) {
        Wread( &pub32, sizeof( pub32 ) );
        name_len = pub32.name_len;
        Dump_header( &pub32, hll_sstPublics_msg );
        read += sizeof( pub32 );
        Wread( name, name_len );
        name[name_len] = '\0';
        Wdputs( "  symbol name: \"" );
        Wdputs( name );
        read += name_len;
        Wdputslc( "\"\n" );
    }
    Wdputslc( "\n" );
}
Exemple #6
0
/*
 * dump_cv_sstModules - dump CV sstModules at 'offset' from 'base'
 */
static void dump_cv_sstModules( unsigned_32 base, unsigned_32 offset )
/********************************************************************/
{
    cv3_module_16       mod;
    cv3_seginfo_16      seg;
    bool                first = TRUE;

    Wlseek( base + offset );
    Wdputs( "==== sstModules at offset " );
    Puthex( offset, 8 );
    Wdputslc( "\n" );
    Wread( &mod, offsetof( cv3_module_16, name_len ) );
    Dump_header( &mod, cv_sstModules_msg );
    Wdputs( "  module name: \"" );
    dump_name( 0 );
    Wdputslc( "\"\n" );
    if( mod.cSeg ) {
        while( --mod.cSeg ) {
            if( !first ) {
                Wdputslc( "    ====\n" );
            }
            Wread( &seg, sizeof( seg ) );
            Dump_header( &seg, cv_seg_msg );
            first = FALSE;
        }
    }
    Wdputslc( "\n" );
}
Exemple #7
0
/*
 * Dump public entry (export) table.
 */
static void dmp_public_entry( void )
/**********************************/
{
    unsigned_32     i;
    unsigned_8      len;
    char            *name;
    unsigned_32     addr;

    if( Nlm_head.numberOfPublics == 0 ) {
        return;
    }
    Wdputslc( "\n" );
    Wlseek( Nlm_head.publicsOffset );
    Banner( "Public Entry (Export) Table" );
    Wdputslc( "80000000H = symbol is in code\n" );
    Wdputslc( "      Address         Name\n" );
    Wdputslc( "      =======         ====\n" );
    for( i = 0; i < Nlm_head.numberOfPublics; i++ ) {
        Wread( &len, sizeof( unsigned_8 ) );
        name = Wmalloc( len );
        Wread( name, len );
        name[len] = '\0';
        Wread( &addr, sizeof( unsigned_32 ) );
        Wdputs( "      " );
        Puthex( addr, 8 );
        Wdputs( "        " );
        Wdputs( name );
        Wdputslc( "\n" );
    }
}
Exemple #8
0
/*
 * desc_array - dump info
 */
static void desc_array( unsigned_8 *ptr, bool is386 )
/***************************************************/
{
    addr32_ptr  *p32;
    addr48_ptr  *p48;

    Wdputs( "          scalar type 1 = " );
    scalar_type( ptr[0] );
    Wdputs( "  scalar type 2 = " );
    scalar_type( ptr[1] );
    ptr += 2;
    Wdputslc( "\n          addr = " );
    if( is386 ) {
        p48 = (addr48_ptr *)ptr;
        ptr += sizeof(addr48_ptr);
        Puthex( p48->segment, 4 );
        Wdputc( ':' );
        Puthex( p48->offset, 8 );
    } else {
        p32 = (addr32_ptr *)ptr;
        ptr += sizeof(addr32_ptr);
        Puthex( p32->segment, 4 );
        Wdputc( ':' );
        Puthex( p32->offset, 4 );
    }
    base_type_index( ptr );

} /* desc_array */
Exemple #9
0
/*
 * Dump resources.
 */
static void dmp_resrc( unsigned_16 size, unsigned_32 offset )
/***********************************************************/
{
    unsigned_16     i;
    lmf_resource    resrc;

    Wdputslc( "\n" );
    Banner( "Resource Table" );
    Wread( &resrc, sizeof( lmf_resource ) );
    Wdputs( "resource type (0==usage) = " );
    Puthex( resrc.res_type, 4 );
    Wdputslc( "H\n" );
    Wdputs( "zeros                    = " );
    for( i = 0; i < 3; i++ ) {              // 3 spares (zeros)
        Puthex( resrc.spare[i], 4 );
        Wdputs( "H   " );
    }
    Wdputslc( "\n" );
    size -= sizeof( lmf_resource );
    Wdputs( "size                     = " );
    Puthex( size, 4 );
    Wdputslc( "H\n" );
    offset += sizeof( lmf_resource );
    if( Options_dmp & RESRC_DMP ) {
        Dmp_seg_data( offset, size );
    }
}
Exemple #10
0
/*
 * bit_field_class - dump info
 */
static void bit_field_class( unsigned_8 *buff, bool bit )
/*******************************************************/
{
    unsigned_8  *ptr;
    unsigned_16 index;
    char        name[256];

    ptr = buff+3;
    Wdputs( "          field locator = " );
    ptr = Dump_location_expression( ptr, "            " );
    if( bit ) {
        ptr += 2;
    }
    ptr = Get_type_index( ptr, &index );
    Get_local_name( name, ptr, buff );
    Wdputs( "          name = \"" );
    Wdputs( name );
    Wdputs( "\"  type idx = " );
    Putdec( index );
    Wdputslc( "\n          attribute = " );
    attribute_byte( buff[2] );
    if( bit ) {
        Wdputslc( "  start bit = " );
        ptr++;
        Puthex( *ptr, 2 );
        Wdputslc( "  bit size = " );
        ptr++;
        Puthex( *ptr, 2 );
    }
    Wdputslc( "\n" );
}
Exemple #11
0
/*
 * bit_field_struct - dump info
 */
static void bit_field_struct( unsigned_8 *buff, unsigned_8 size, bool bit )
/*************************************************************************/
{
    unsigned_8  *ptr;
    unsigned_16 index;
    char        name[256];

    ptr = buff+2+size;
    if( bit ) {
        ptr += 2;
    }
    ptr = Get_type_index( ptr, &index );
    Get_local_name( name, ptr, buff );
    Wdputs( "          \"" );
    Wdputs( name );
    Wdputs( "\"  offset = " );
    ptr = buff+2;
    Puthex( *ptr, 2*size );
    Wdputs( "  type idx = " );
    Putdec( index );
    if( bit ) {
        Wdputslc( "\n        start bit = " );
        ptr++;
        Puthex( *ptr, 2 );
        Wdputslc( "  bit size = " );
        ptr++;
        Puthex( *ptr, 2 );
    }
    Wdputslc( "\n" );
}
Exemple #12
0
/*
 * Dump the file type.
 */
static void dmp_file_type( uint32_t type )
/****************************************/
{
    Wdputs( "file type:                                  " );
    switch( type ) {
    case MH_OBJECT:
        Wdputs( "Object file (MH_OBJECT)" );
        break;
    case MH_EXECUTE:
        Wdputs( "Executable program (MH_EXECUTE)" );
        break;
    case MH_BUNDLE:
        Wdputs( "Bundle/plug-in (MH_BUNDLE)" );
        break;
    case MH_DYLIB:
        Wdputs( "Shared lib (MH_DYLIB)" );
        break;
    case MH_PRELOAD:
        Wdputs( "Preload executable (MH_PRELOAD)" );
        break;
    case MH_CORE:
        Wdputs( "Core dum (MH_CORE)" );
        break;
    case MH_DYLINKER:
        Wdputs( "Dynlinker shlib (MH_DYLINKER)" );
        break;
    case MH_DSYM:
        Wdputs( "Debug symbols (MH_DSYM)" );
        break;
    default:
        Wdputs( "Unknown" );
    }
    Wdputslc( "\n" );
}
Exemple #13
0
/*
 * Dump the Mach-O command list.
 */
void dmp_cmd_list( unsigned_32 start, int n )
{
    int                         i;
    unsigned_32                 offset;
    uint32_t                    cmd, cmdsize;
    struct segment_command      seg;

    offset = start + sizeof( struct mach_header );
    for( i = 0; i < n; ++i ) {
        Wlseek( offset );
        Wread( &cmd, sizeof( cmd ) );
        Wread( &cmdsize, sizeof( cmdsize ) );
        Wlseek( offset );

        switch( cmd ) {
        case LC_SEGMENT:
            Wread( &seg, sizeof( seg ) );
            Dump_header( &seg, m_segment_msg );
            break;
        default:
            Wdputs( "\ncmd       = " );
            Puthex( cmd, 8 );
            Wdputs( "H\ncmdsize   = " );
            Puthex( cmdsize, 8 );
            Wdputs( "H" );
        }
        Wdputslc( "\n" );
        offset += cmdsize;
        Wlseek( offset );
    }
}
Exemple #14
0
/*
 * The copyright banner
 */
static void wbanner( void )
/*************************/
{
    Wdputs( banner1w( "Executable Image Dump Utility", BAN_VER_STR ) "\n" );
    Wdputs( banner2 "\n" );
    Wdputs( banner2a( "1984" ) "\n" );
    Wdputs( banner3 "\n" );
    Wdputs( banner3a "\n\n" );
}
Exemple #15
0
static void dump_aranges( const uint_8 *p, uint length )
/******************************************************/
{
    const uint_8    *end;
    const uint_8    *unit_end;
    uint_32         unit_length;
    uint_32         dbg_offset;
    uint_32         addr;
    uint_32         seg;
    uint_32         len;
    int             addr_size;
    int             seg_size;

    end = &p[length];
    addr_size = 0;
    while( p  < end ) {
        unit_length = get_u32( (uint_32 *)p );
        unit_end = &p[unit_length + sizeof( uint_32 )];
        Wdputs( "Length: " );
        Puthex( unit_length, 8 );
        Wdputslc( "\nVersion: " );
        Puthex( get_u16( (uint_16 *)(p + 4) ), 4 );
        Wdputslc( "\nDbg Info: " );
        dbg_offset = get_u32( (uint_32 *)(p + 6) );
        Puthex( dbg_offset, 8 );
        addr_size = *(p + 10);
        Wdputslc( "\nAddress Size " );
        Puthex( addr_size, 2 );
        seg_size = *(p + 11);
        Wdputslc( "\nSegment Size " );
        Puthex( seg_size, 2 );
        Wdputslc( "\n" );
        p += 12;
        Wdputslc( "    Address       Length\n" );
        while( p < unit_end ) {
            p = GetInt( p, &addr, addr_size );
            p = GetInt( p, &seg, seg_size );
            p = GetInt( p, &len, addr_size );
            if( addr == 0 && seg == 0 && len == 0 )
                break;
            Wdputs( "    " );
            if( seg_size != 0 ) {
                Puthex( seg, seg_size * 2 );
                Wdputs( ":" );
                Puthex( addr, addr_size * 2 );
            } else {
                Puthex( addr, addr_size * 2 );
                Wdputs( "     " );
            }
            Wdputs( " " );
            Puthex( len, addr_size * 2 );
            Wdputslc( "\n" );
        }
        p = unit_end;
    }
}
Exemple #16
0
/*
 * Dump the segment type.
 */
static void dmp_prog_type( unsigned_32 type )
/*******************************************/
{
    Wdputs( "segment type:                               " );
    switch( type ) {
    case PT_NULL:
        Wdputs( "unused segment" );
        break;
    case PT_LOAD:
        Wdputs( "loadable segment" );
        break;
    case PT_DYNAMIC:
        Wdputs( "dynamic linking info" );
        break;
    case PT_INTERP:
        Wdputs( "program interpreter" );
        break;
    case PT_NOTE:
        Wdputs( "comments & auxiliary info" );
        break;
    case PT_SHLIB:
        Wdputs( "unspecified semantics" );
        break;
    case PT_PHDR:
        Wdputs( "address of progam header" );
        break;
    case PT_LOPROC:
        Wdputs( "processor specific" );
        break;
    }
    Wdputslc( "\n" );
}
Exemple #17
0
/*
 * range - dump info
 */
static void range( unsigned_8 *ptr, unsigned_8 size )
/***************************************************/
{
    Wdputs( "          low bound = " );
    Puthex( *ptr, 2*size );
    Wdputs( "   high bound = " );
    ptr += size;
    Puthex( *ptr, 2*size );
    ptr += size;
    base_type_index( ptr );
}
Exemple #18
0
/*
 * enum_const - dump info
 */
static void enum_const( unsigned_8 *buff, unsigned_8 size )
/*********************************************************/
{
    char        name[256];

    Get_local_name( name, buff+2+size, buff );
    Wdputs( "          \"" );
    Wdputs( name );
    Wdputs( "\"   value = " );
    Puthex( *(buff+2), 2*size );
    Wdputslc( "\n" );
}
Exemple #19
0
/*
 * read from the image
 */
static void chkread( unsigned_32 amount )
/***************************************/
{
    if( Num_read < amount ) {
        Wdputs( "Error! Couldn't read from executable: " );
        if (errno == 0) {
            Wdputs( "reached EOF" );
        } else {
            Wdputs( strerror( errno ) );
        }
        Wdputslc( ".\n" );
        longjmp( Se_env, 1 );
    }
}
Exemple #20
0
extern void DumpFlags( unsigned_32 flags, unsigned_32 ignore, char **msg,
               char *prefix )
/***********************************************************************/
{
    char            name[MAX_FLAG_SIZE];
    char            *currpos;
    unsigned_32     mask;
    size_t          len;

    Wdputs( "          flags = " );
    Puthex( flags, 8 );
    Wdputs( " :  " );
    flags &= ~ignore;
    mask = 1;
    currpos = name;
    len = strlen( prefix );
    if( len > 0 ) {
        memcpy( currpos, prefix, len );
        currpos += len;
        *currpos = '|';
        currpos++;
    }
    while( flags != 0 ) {
        if( flags & 1 ) {
            if( *msg == NULL ) {
            if( currpos - name + 9 > MAX_FLAG_SIZE ) break;
                *currpos = '?';
                currpos++;
                ultoa( mask, currpos, 16 );
                currpos += strlen( currpos );
            } else {
                len = strlen( *msg );
                if( currpos - name + len + 1 > MAX_FLAG_SIZE ) break;
                memcpy( currpos, *msg, len );
                currpos += len;
            }
            *currpos = '|';
            currpos++;
        }
        msg++;
        flags >>= 1;
        mask <<= 1;
    }
    if( currpos != name ) {
        currpos--;
    }
    *currpos = '\0';
    Wdputs( name );
    Wdputslc( "\n" );
}
Exemple #21
0
static void dump_state( state_info *state )
/*****************************************/
{
    Wdputs( "-- file " );
    Putdec( state->file );
    Wdputs( " addr  " );
    if( state->segment != 0 ) {
        Puthex( state->segment, 4 );
        Wdputs( ":" );
    }
    Puthex( state->address, 8 );
    Wdputs( " line " );
    Putdec( state->line );
    Wdputs( " column " );
    Putdec( state->column );
    if( state->is_stmt ) {
        Wdputs( " is_stmt" );
    }
    if( state->basic_block ) {
        Wdputs( " basic_block" );
    }
    if( state->end_sequence ) {
        Wdputs( " end_sequence" );
    }
    Wdputslc( "\n" );
}
Exemple #22
0
/*
 * Dump a note section.
 */
static void dmp_sec_note( unsigned_32 offset, unsigned_32 size )
/**************************************************************/
{
    Elf_Note        note;
    unsigned_32     read = 0;
    unsigned_32     skip;
    char            *ptr;

    Wlseek( offset );
    while( read < size ) {
        Wdputslc( "\n" );
        Wread( &note, sizeof( note ) );
        read += sizeof( note );
        if( Byte_swap ) {
            SWAP_32( note.n_namesz );
            SWAP_32( note.n_descsz );
            SWAP_32( note.n_type );
        }
        ptr = Wmalloc( note.n_namesz );
        Wread( ptr, note.n_namesz );
        Wdputs( "    note name:                              " );
        Wdputs( ptr );
        Wdputslc( "\n" );
        Wdputs( "    descriptor length:                      " );
        Puthex( note.n_descsz, 8 );
        Wdputslc( "H\n" );
        Wdputs( "    note type:                              " );
        switch( note.n_type ) {
        case NT_PRSTATUS:
            Wdputs( "process status" );
            break;
        case NT_FPREGSET:
            Wdputs( "floating-point registers" );
            break;
        case NT_PRPSINFO:
            Wdputs( "process info" );
            break;
        default:
            Wdputs( "unknown (" );
            Puthex( note.n_type, 8 );
            Wdputs( "H)" );
        }
        Wdputslc( "\n" );
        free( ptr );

        /* Calculate rounded up note name length */
        skip = (note.n_namesz + ELF_ROUND) & ~ELF_ROUND;
        read += skip;
        Wlseek( offset + read );
        /* Calculate rounded up note descriptor length */
        skip = (note.n_descsz + ELF_ROUND) & ~ELF_ROUND;
        read += skip;
        Wlseek( offset + read );
    }
}
Exemple #23
0
/*
 * Dump rw end.
 */
static void dmp_rw_end( void )
/****************************/
{
    lmf_rw_end      rw_end;

    Wdputslc( "\n" );
    Banner( "Read/Write end" );
    Wread( &rw_end, sizeof( lmf_rw_end ) );
    Wdputs( "verify = " );
    Puthex( rw_end.verify, 4 );
    Wdputs( "H     signature = " );
    Puthex( rw_end.signature, 8 );
    Wdputslc( "H\n" );
}
Exemple #24
0
/*
 * Dump the ELF header, if any.
 */
bool Dmp_elf_header( unsigned long start )
/****************************************/
{
    Wread( &Elf_head, sizeof( Elf32_Ehdr ) );
    if( memcmp( Elf_head.e_ident, ELF_SIGNATURE, ELF_SIGNATURE_LEN ) ) {
        return( 0 );
    }
    Banner( "ELF Header" );
    if( start != 0 ) {
        Wdputs( "File Offset:" );
        Puthex( start, 8 );
        Wdputslc( "\n" );
    }
    Wdputs( "class (1==32-bit objects, 2==64-bit objs)   =       " );
    Puthex( Elf_head.e_ident[EI_CLASS], 2 );
    Wdputslc( "H\ndata  (1==little-endian, 2==big-endian)     =       " );
    Puthex( Elf_head.e_ident[EI_DATA], 2 );
    Wdputslc( "H\nversion                                     =       " );
    Puthex( Elf_head.e_ident[EI_VERSION], 2 );
    Wdputslc( "H\nOS/ABI type (0==unspecified)                =       " );
    Puthex( Elf_head.e_ident[EI_OSABI], 2 );
    Wdputslc( "H\nABI version (0==unspecified)                =       " );
    Puthex( Elf_head.e_ident[EI_ABIVERSION], 2 );
    Wdputslc( "H\n" );
    if( Elf_head.e_ident[EI_DATA] != NATIVE_ENDIAN ) {
        Byte_swap = TRUE;

        /* Byte swap ELF header */
        SWAP_16( Elf_head.e_type );
        SWAP_16( Elf_head.e_machine );
        SWAP_32( Elf_head.e_version );
        SWAP_32( Elf_head.e_entry );
        SWAP_32( Elf_head.e_phoff );
        SWAP_32( Elf_head.e_shoff );
        SWAP_32( Elf_head.e_flags );
        SWAP_16( Elf_head.e_ehsize );
        SWAP_16( Elf_head.e_phentsize );
        SWAP_16( Elf_head.e_phnum );
        SWAP_16( Elf_head.e_shentsize );
        SWAP_16( Elf_head.e_shnum );
        SWAP_16( Elf_head.e_shstrndx );
    }
    dmp_hdr_type( Elf_head.e_type );
    Dump_header( &Elf_head.e_type, elf_exe_msg );
    Wdputslc( "\n" );
    dmp_prog_sec( start );
    return( 1 );
}
Exemple #25
0
/*
 * Dump relocation fixup table.
 */
static void dmp_reloc_fixup( void )
/*********************************/
{
    unsigned_32     i;
    unsigned_32     reloc;

    if( Nlm_head.numberOfRelocationFixups == 0 ) {
        return;
    }
    Wdputslc( "\n" );
    Wlseek( Nlm_head.relocationFixupOffset );
    Banner( "Relocation Fixup Table" );
    Wdputslc( "80000000H = target is in code segment\n" );
    Wdputslc( "40000000H = source of fixup is in code segment\n" );
    for( i = 0; i < Nlm_head.numberOfRelocationFixups; i++ ) {
        Wread( &reloc, sizeof( unsigned_32 ) );
        if( i != 0 ) {
            if( (i) % 6 == 0 ) {
                Wdputslc( "\n" );
            } else {
                Wdputs( "      " );
            }
        }
        Puthex( reloc, 8 );
    }
    Wdputslc( "\n" );
}
Exemple #26
0
/*
 * Dump The Resource Table for Windows NE module
 */
static void dmp_resrc_tab_win( void )
/***********************************/
{
    unsigned_16                             res_type;
    auto struct resource_type_record        res_group;
    unsigned_32                             offset;

    Resrc_end = 0ul;
    Wread( &Resrc_shift_cnt, sizeof( unsigned_16 ) );
    offset = New_exe_off + Os2_head.resource_off + sizeof( unsigned_16 );
    Wdputs( "resource shift count: " );
    Putdec( Resrc_shift_cnt );
    Wdputslc( "\n" );
    for( ;; ) {
        Wlseek( offset );
        Wread( &res_group, sizeof( resource_type_record ) );
        offset += sizeof( resource_type_record );
        res_type = res_group.type;
        if( res_type == 0 ) {
            return;
        }
        dmp_resrc_type_nam( res_type );
        Wlseek( offset );
        dmp_resrc_ent( res_group.num_resources );
        offset += res_group.num_resources * sizeof( resource_record );
        Wdputslc( "\n" );
    }
}
Exemple #27
0
/*
 * Dump segments.
 */
static void dmp_seg( unsigned_16 size )
/*************************************/
{
    unsigned_16     i;
    unsigned_32     seg;

    if( !size ) {
        return;
    }
    Wdputslc( "segments = type:size\n" );
    Wdputslc( "type  0==read/write, 1==read-only, 2==execute/read, 3==execute-only\n" );
    for( i = 0; i < size; i++ ) {
        if( i != 0 ) {
            if( i % 6 == 0 ) {
                Wdputslc( "\n" );
            } else {
                Wdputs( "    " );
            }
        }
        Wread( &seg, sizeof( unsigned_32 ) );
        Puthex( seg >> 28, 1 );
        Wdputc( ':' );
        Puthex( seg, 7 );
    }
    Wdputslc( "\n" );
}
Exemple #28
0
static void DmpLocList( uint_32 start, uint addr_size )
/*****************************************************/
{
    uint_32         low;
    uint_32         high;
    int             len;
    uint_8 const    *p;
    uint_8 const    *stop;

    p = Sections[ DW_DEBUG_LOC ].data;
    stop = p + Sections[ DW_DEBUG_LOC ].max_offset;
    if( p == NULL ) {
        Wdputslc( "Error: No location list section\n" );
        return;
    }
    p += start;
    while( p < stop ) {
        p = GetInt( p, &low, addr_size );
        p = GetInt( p, &high, addr_size );
        if( low == high && low == 0 ) {
            Wdputslc( "        <end>\n" );
            return;
        }
        len = get_u16( (uint_16 *)p );
        p+= sizeof( uint_16 );
        Wdputslc( "\n         Range: " );
        Puthex( low, addr_size * 2 );
        Wdputs( ":" );
        Puthex( high, addr_size * 2 );
        Wdputslc( "\n" );
        DmpLoc( p, len, addr_size );
        p += len;
    }
}
Exemple #29
0
/*
 * Dump the type and offsets.
 */
static void dmp_type_offset( unsigned_32 bsize )
/**********************************************/
{
    unsigned_32             i;
    unsigned                prev;
    pe_fixup_entry          entry;

    Wdputslc( "type:offset               type --\n" );
    Wdputslc( "0 = ABSOLUTE, 1 = LOW, 2 = HIGH, 3 = HIGHLOW, 4 = HIGHADJUST, 5 = MIPSJMPADDR\n" );
    prev = 0;
    for( i = 0; i < bsize; i++ ) {
        Wread( &entry, sizeof( pe_fixup_entry ) );
        if( i != 0 ) {
            if( (i) % 8 == 0 ) {
                Wdputslc( "\n" );
            } else {
                Wdputs( "     " );
            }
        }
        if( prev == 4 ) {
            Wdputc( ' ' );
            Puthex( entry, 4 );
            prev = 0;
        } else {
            prev = entry >> 12;
            Puthex( prev, 1 );
            Wdputc( ':' );
            Puthex( entry, 3 );
        }
    }
    Wdputslc( "\n" );
}
Exemple #30
0
/*
 * Dump the coff object, if any.
 */
bool Dmp_coff_head( void )
/************************/
{
    coff_file_header    header;

    Wlseek( Coff_off );
    Wread( &header, sizeof( coff_file_header ) );
    if( header.cpu_type != IMAGE_FILE_MACHINE_I386
        && header.cpu_type != IMAGE_FILE_MACHINE_ALPHA
        && header.cpu_type != IMAGE_FILE_MACHINE_UNKNOWN
        && header.cpu_type != IMAGE_FILE_MACHINE_POWERPC ) {
        return 0;
    }
    Banner( "COFF object file" );
    Wdputs( "file offset = " );
    Puthex( Coff_off, 8 );
    Wdputslc( "H\n" );
    Wdputslc( "\n" );
    Dump_header( (char *)&header, coff_hdr_msg );
    DumpCoffHdrFlags( header.flags );
    load_string_table( &header );
    Wlseek( Coff_off + sizeof(coff_file_header) + header.opt_hdr_size );
    dmp_objects( header.num_sections );
    unload_string_table();
    dmp_symtab( header.sym_table, header.num_symbols );
    return 1;
}