/* * 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" ); } }
/* * 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" ); }
/* * 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" ); }
/* * 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 */
/* * dump_hll - dump HLL data at offset 'base' from start of file */ static void dump_hll( unsigned_32 base ) /**************************************/ { hll_trailer header; hll_dirinfo dir_info; hll_dir_entry dir_entry; int i; Wlseek( base ); Wread( &header, sizeof( header ) ); if( memcmp( header.sig, HLL_NB04, HLL_SIG_SIZE ) != 0 ) { return; } Wlseek( base + header.offset ); Wread( &dir_info, sizeof( dir_info ) ); Dump_header( &dir_info , hll_dir_info_msg ); Wdputslc( "\n" ); for( i = 0; i < dir_info.cDir; ++i ) { Wlseek( base + header.offset + dir_info.cbDirHeader + i * dir_info.cbDirEntry ); Wread( &dir_entry, sizeof( dir_entry ) ); Dump_header( &dir_entry, hll_dir_entry_msg ); Wdputslc( "\n" ); dump_hll_subsection( base, &dir_entry ); } }
/* * 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" ); }
/* * 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" ); }
/* * 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" ); }
/* * 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( ¬e, 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 ); } }
/* * 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" ); }
/* * dump_addr_info - dump out address info */ static void dump_addr_info( section_dbg_header *sdh ) /***************************************************/ { unsigned_32 total_bytes; unsigned_32 bytes_read; seg_info *si; long cpos; long basepos; unsigned_32 len; int i; unsigned_32 seg_off; total_bytes = sdh->section_size - sdh->addr_offset; print_info_title( "Addr" ); bytes_read = 0; si = (seg_info *) Wbuff; basepos = cpos = Curr_sectoff + sdh->addr_offset; while( bytes_read < total_bytes ) { Wlseek( cpos ); Wread( Wbuff, sizeof( seg_info ) ); Wlseek( cpos ); len = sizeof( seg_info ) + (si->num-1) * sizeof( addr_info ); Wread( Wbuff, len ); Wdputs( " Base: fileoff = " ); Puthex( cpos-basepos, 8 ); Wdputs( "H seg = " ); Puthex( si->base.segment, 4 ); Wdputs( "H, off = " ); Puthex( si->base.offset, 8 ); Wdputslc( "H\n" ); seg_off = si->base.offset; for( i = 0; i < si->num; i++ ) { Putdecl( i, 6 ); Wdputs( ") fileoff = " ); Puthex( (long) cpos - basepos + sizeof( seg_info) + i * sizeof( addr_info ) - sizeof( addr_info ), 8 ); Wdputs( "H, Size = " ); Puthex( si->addr[i].size, 8 ); Wdputs( "H @" ); Puthex( seg_off, 8 ); Wdputs( "H, mod_index = " ); Putdec( si->addr[i].mod ); Wdputslc( "\n" ); seg_off += si->addr[i].size; } cpos += len; bytes_read += len; } } /* dump_addr_info */
/* * dump_rtn386 - dump a near or far routine defn (386) */ static void dump_rtn386( unsigned_8 *buff ) /*****************************************/ { int pro,epi; unsigned_32 ret_off; unsigned_8 *ptr; int num_parms; unsigned_16 index; char name[256]; int i; dump_block( buff, TRUE ); ptr = buff + sizeof( block_386 ); pro = *ptr++; epi = *ptr++; Wdputs( " prologue size = " ); Putdec( pro ); Wdputs( ", epilogue size = " ); Putdec( epi ); Wdputslc( "\n" ); ret_off = *(unsigned_32 *) ptr; ptr += sizeof( unsigned_32 ); Wdputs( " return address offset (from bp) = " ); Puthex( ret_off, 8 ); Wdputslc( "\n" ); ptr = Get_type_index( ptr, &index ); Wdputs( " return type: " ); Putdec( index ); Wdputslc( "\n" ); Wdputs( " return value: " ); ptr = Dump_location_expression( ptr, " " ); num_parms = *ptr++; for( i = 0; i < num_parms; i++ ) { Wdputs( " Parm " ); Putdec( i ); Wdputs( ": " ); ptr = Dump_location_expression( ptr, " " ); } Get_local_name( name, ptr, buff ); Wdputs( " Name = \"" ); Wdputs( name ); Wdputslc( "\"\n" ); } /* dump_rtn386 */
void Dump_all_sections( void ) /****************************/ { uint sect; sect = 0; for( ;; ) { Wdputs( sectionNames[ sect ] ); Wdputslc( ":\n" ); Dump_specific_section( sect, Sections[ sect ].data, Sections[ sect ].max_offset ); ++sect; if( sect == DW_DEBUG_MAX ) break; Wdputslc( "\n" ); } }
/* * 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" ); }
/* * 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 */
/* * Dump the segment type. */ static void dmp_hdr_type( unsigned_16 type ) /******************************************/ { Wdputs( "file type: " ); switch( type ) { case ET_NONE: Wdputs( "No file type" ); break; case ET_REL: Wdputs( "Relocatable file" ); break; case ET_EXEC: Wdputs( "Executable file" ); break; case ET_DYN: Wdputs( "Shared object file" ); break; case ET_CORE: Wdputs( "Core file" ); break; case ET_LOPROC: Wdputs( "Processor specific" ); break; } Wdputslc( "\n" ); }
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" ); }
/* * 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" ); }
/* * Dump the Mach-O command list. */ static 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 ); } }
/* * dump_global_info - dump out global info */ static void dump_global_info( section_dbg_header *sdh ) /*****************************************************/ { unsigned_32 total_bytes; unsigned_32 bytes_read; v3_gbl_info *gi; long cpos; char name[256]; total_bytes = sdh->addr_offset - sdh->gbl_offset; print_info_title( "Global" ); bytes_read = 0; gi = (v3_gbl_info *) Wbuff; cpos = Curr_sectoff + sdh->gbl_offset; while( bytes_read < total_bytes ) { Wlseek( cpos ); Wread( Wbuff, sizeof( v3_gbl_info ) + 255 ); bytes_read += sizeof( v3_gbl_info ) + gi->name[0]; cpos += sizeof( v3_gbl_info ) + gi->name[0]; get_len_prefix_string( name, gi->name ); Wdputs( " Name: " ); Wdputs( name ); Wdputslc( "\n" ); Wdputs( " address = " ); Puthex( gi->addr.segment, 4 ); Wdputc( ':' ); Puthex( gi->addr.offset, 8 ); Wdputslc( "\n" ); Wdputs( " module index = " ); Putdec( gi->mod ); Wdputslc( "\n" ); Wdputs( " kind: " ); if( gi->kind & GBL_KIND_STATIC ) { Wdputs( " (static pubdef)" ); } if( gi->kind & GBL_KIND_CODE ) { Wdputs( " (code)" ); } if( gi->kind & GBL_KIND_DATA ) { Wdputs( " (data)" ); } Wdputslc( "\n" ); } Wdputslc( "\n" ); } /* dump_global_info */
/* * printout a resource name */ static void dmp_resrc_nam( unsigned_16 res_type ) /***********************************************/ { char *name; Wdputc( ' ' ); if( res_type & SEG_RESRC_HIGH ) { res_type &= ~SEG_RESRC_HIGH; Wdputs( "resource id: " ); Putdec( res_type ); Wdputslc( "\n" ); } else { name = get_resrc_nam( res_type ); Wdputs( name ); Wdputslc( "\n" ); free( name ); } }
/* * attribute_byte - dump type of scalar item */ static void attribute_byte( unsigned_8 type ) /*******************************************/ { Puthex( type, 2 ); if( type & 0x1 ) { Wdputslc( ", internal" ); } if( type & 0x2 ) { Wdputslc( ", public" ); } if( type & 0x4 ) { Wdputslc( ", protected" ); } if( type & 0x8 ) { Wdputslc( ", private" ); } } /* attribute_byte */
static void set_dwarf( unsigned_32 start ) /****************************************/ { Elf32_Shdr elf_sec; unsigned_32 offset; char *string_table; int i; uint sect; unsigned_32 sectsizes[DR_DEBUG_NUM_SECTS]; unsigned_32 sections[DR_DEBUG_NUM_SECTS]; // grab the string table, if it exists if( !Elf_head.e_shstrndx ) { return; // no strings no dwarf } if( Elf_head.e_shnum == 0 ) { return; // no sections no dwarf } memset( sections, 0, DR_DEBUG_NUM_SECTS * sizeof( unsigned_32 ) ); memset( sectsizes, 0, DR_DEBUG_NUM_SECTS * sizeof( unsigned_32 ) ); offset = Elf_head.e_shoff + Elf_head.e_shstrndx * Elf_head.e_shentsize+start; Wlseek( offset ); Wread( &elf_sec, sizeof( Elf32_Shdr ) ); swap_shdr( &elf_sec ); string_table = Wmalloc( elf_sec.sh_size ); Wlseek( elf_sec.sh_offset + start ); Wread( string_table, elf_sec.sh_size ); for( i = 0; i < Elf_head.e_shnum; i++ ) { Wlseek( Elf_head.e_shoff + i * Elf_head.e_shentsize + start ); Wread( &elf_sec, sizeof( Elf32_Shdr ) ); swap_shdr( &elf_sec ); if( elf_sec.sh_type == SHT_PROGBITS ) { sect = Lookup_section_name( &string_table[elf_sec.sh_name] ); if ( sect < DW_DEBUG_MAX ) { sections[sect] = elf_sec.sh_offset + start; sectsizes[sect] = elf_sec.sh_size; } } } free( string_table ); for( i = 0; i < DR_DEBUG_NUM_SECTS; i += 1 ) { Sections[i].cur_offset = 0; Sections[i].max_offset = sectsizes[i]; if( sectsizes[i] != 0 ) { Wlseek( sections[i] ); Sections[i].data = Wmalloc( sectsizes[i] ); if( Sections[i].data == NULL ) { Wdputslc( "Not enough memory\n" ); exit( 1 ); } Wread( Sections[i].data, sectsizes[i] ); } } }
bool Dmp_ar_head( void ) /**********************/ { char sig[AR_IDENT_LEN]; ar_header hdr; unsigned long filesize; unsigned long size; Wlseek( 0 ); Wread( sig, AR_IDENT_LEN ); if( memcmp( sig, AR_IDENT, AR_IDENT_LEN ) != 0 ) return 0; filesize = WFileSize(); Coff_off = AR_IDENT_LEN; for(;;) { if( Coff_off + sizeof(ar_header) >= filesize ) break; Wread( &hdr, sizeof(ar_header) ); Coff_off += sizeof(ar_header); hdr.date[0]='\0'; Wdputs( "ar name = " ); Wdputs( hdr.name ); Wdputslc( "\n" ); hdr.header_ident[0] = '\0'; size = strtoul( hdr.size, NULL, 10 ); if( strcmp( hdr.name, "/ " ) == 0 || strcmp( hdr.name, "// " ) == 0 ) { Dmp_seg_data( Coff_off, size ); } else if( !Dmp_coff_head() ) { // then try and see if it's ELF Wlseek( Coff_off ); if( !Dmp_elf_header( Coff_off ) ) { Wdputslc( "archive entry not identified\n" ); Dmp_seg_data( Coff_off, size ); Wdputslc( "\n" ); } } if( size & 1 ) { size++; } Coff_off += size; Wlseek( Coff_off ); } return 1; }
/* * param_type_index - dump info */ static void param_type_index( unsigned_8 num_params, unsigned_8 *ptr ) /********************************************************************/ { unsigned_8 i; unsigned_16 index; if( *ptr & 0x80 ) { num_params /= 2; } for( i = 0; i < num_params; i++ ) { Wdputslc( "\n" ); Wdputs( " param " ); Putdec( i+1 ); Wdputs( ": type idx = " ); ptr = Get_type_index( ptr, &index ); Putdec( index ); } Wdputslc( "\n" ); }
bool Dmp_lib_head( void ) /***********************/ { char sig[LIBMAG_LEN]; Lib32_Hdr hdr; long filesize; unsigned long size; unsigned long Elf_off; Wlseek( 0 ); Wread( sig, LIBMAG_LEN ); if( memcmp( sig, LIBMAG, LIBMAG_LEN ) != 0 ) return 0; filesize = WFileSize(); Elf_off = LIBMAG_LEN + LIB_CLASS_LEN + LIB_DATA_LEN; Wlseek( Elf_off ); for( ;; ) { if( Elf_off + LIB_HEADER_SIZE >= filesize ) break; Wread( &hdr, LIB_HEADER_SIZE ); Elf_off += LIB_HEADER_SIZE; hdr.lib_date[0]='\0'; Wdputs( "lib name = " ); Wdputs( hdr.lib_name ); Wdputslc( "\n" ); hdr.lib_fmag[0] = '\0'; size = strtoul( hdr.lib_size, NULL, 10 ); if( !Dmp_elf_header( Elf_off ) ) { if( strcmp( hdr.lib_name, LIB_SYMTAB_NAME ) && strcmp( hdr.lib_name, LIB_LFTAB_NAME ) && strcmp( hdr.lib_name, LIB_FFTAB_NAME ) ) { Wdputslc( "archive entry not identified\n" ); } Dmp_seg_data( Elf_off, size ); Wdputslc( "\n" ); } if( size & 1 ) { size++; } Elf_off += size; Wlseek( Elf_off ); } return 1; }
/* * Dump the Resource Table. */ void Dmp_resources( void ) /************************/ { resource_dir_header pe_res_type; Data_off = 0; Wlseek( Res_off ); Wread( &pe_res_type, sizeof( resource_dir_header ) ); Banner( "Resource Directory Table" ); Dump_header( (char *)&pe_res_type.flags, pe_resource_msg ); Wdputslc( "\n" ); Wdputslc( "type id/string name id/string language id\n" ); Wdputslc( "============== ============== ===========\n" ); dmp_res_name_id( pe_res_type.num_name_entries, TRUE ); dmp_res_name_id( pe_res_type.num_id_entries, FALSE ); if( Options_dmp & RESRC_DMP ) { dmp_res_dir(); dmp_res_data(); } }
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; } }
/* * dump_cv_sstSrcLnSeg - dump sstSrcLnSeg at 'offset' from 'base' */ static void dump_cv_sstSrcLnSeg( unsigned_32 base, unsigned_32 offset ) /*********************************************************************/ { cv_linnum_seg src_ln; cv3_linnum_entry_16 lo_16; Wlseek( base + offset ); Wdputs( "==== sstSrcLnSeg at offset " ); Puthex( offset, 8 ); Wdputslc( "\n" ); Wdputs( " source file: \"" ); dump_name( 2 ); Wdputslc( "\"\n" ); Wread( &src_ln, sizeof( src_ln ) ); Dump_header( &src_ln, cv_sstSrcLnSeg_msg ); while( src_ln.cPair-- ) { Wread( &lo_16, sizeof( lo_16 ) ); Dump_header( &lo_16, cv_lnoff16_msg ); } Wdputslc( "\n" ); }
/* * dump_cv_sstLibraries - dump CV sstLibraries at 'offset' * from 'base' containing 'size' bytes */ static void dump_cv_sstLibraries( unsigned_32 base, unsigned_32 offset, unsigned_32 size ) /*********************************************************************/ { unsigned index = 0; unsigned_32 read = 0; Wlseek( base + offset ); Wdputs( "==== sstLibraries at offset " ); Puthex( offset, 8 ); Wdputslc( "\n" ); while( read < size ) { Wdputs( " index: " ); Puthex( index, 4 ); Wdputs( "H name: \"" ); read += dump_name( 0 ); Wdputslc( "\"\n" ); ++index; } Wdputslc( "\n" ); }