From 1542722121130f9651109a84bea62ef27f36082b Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Thu, 7 Dec 2006 21:43:25 +0800 Subject: [PATCH] winedump: Export dump_section() for use outside of pe.c. --- tools/winedump/pe.c | 28 ++++++++++++++++------------ tools/winedump/winedump.h | 1 + 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/tools/winedump/pe.c b/tools/winedump/pe.c index b3360f4fe81..54bc6fb89d6 100644 --- a/tools/winedump/pe.c +++ b/tools/winedump/pe.c @@ -370,16 +370,10 @@ static void dump_pe_header(void) dump_optional_header((const IMAGE_OPTIONAL_HEADER32*)&PE_nt_headers->OptionalHeader, PE_nt_headers->FileHeader.SizeOfOptionalHeader); } -static void dump_sections(const void* addr, unsigned num_sect) +void dump_section(const IMAGE_SECTION_HEADER *sectHead) { - const IMAGE_SECTION_HEADER* sectHead = addr; - unsigned i; - - printf("Section Table\n"); - for (i = 0; i < num_sect; i++, sectHead++) - { - printf(" %02d %-8.8s VirtSize: %-8u VirtAddr: %-8u 0x%08x\n", - i + 1, sectHead->Name, sectHead->Misc.VirtualSize, sectHead->VirtualAddress, + printf(" %-8.8s VirtSize: %-8u VirtAddr: %-8u 0x%08x\n", + sectHead->Name, sectHead->Misc.VirtualSize, sectHead->VirtualAddress, sectHead->VirtualAddress); printf(" raw data offs: %-8u raw data size: %-8u\n", sectHead->PointerToRawData, sectHead->SizeOfRawData); @@ -448,8 +442,18 @@ static void dump_sections(const void* addr, unsigned num_sect) X(IMAGE_SCN_MEM_WRITE, "MEM_WRITE"); #undef X printf("\n\n"); +} + +static void dump_sections(const void *base, const void* addr, unsigned num_sect) +{ + const IMAGE_SECTION_HEADER* sectHead = addr; + unsigned i; + + printf("Section Table\n"); + for (i = 0; i < num_sect; i++, sectHead++) + { + dump_section(sectHead); } - printf("\n"); } static void dump_dir_exported_functions(void) @@ -858,7 +862,7 @@ void dbg_dump(void) separateDebugHead->NumberOfSections * sizeof(IMAGE_SECTION_HEADER))) {printf("Can't get the sections, aborting\n"); return;} - dump_sections(separateDebugHead + 1, separateDebugHead->NumberOfSections); + dump_sections(separateDebugHead, separateDebugHead + 1, separateDebugHead->NumberOfSections); nb_dbg = separateDebugHead->DebugDirectorySize / sizeof(IMAGE_DEBUG_DIRECTORY); debugDir = PRD(sizeof(IMAGE_SEPARATE_DEBUG_HEADER) + @@ -1193,7 +1197,7 @@ void pe_dump(void) { dump_pe_header(); /* FIXME: should check ptr */ - dump_sections((const char*)PE_nt_headers + sizeof(DWORD) + + dump_sections(PRD(0, 1), (const char*)PE_nt_headers + sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER) + PE_nt_headers->FileHeader.SizeOfOptionalHeader, PE_nt_headers->FileHeader.NumberOfSections); } diff --git a/tools/winedump/winedump.h b/tools/winedump/winedump.h index e48f252666c..5b1c68e658a 100644 --- a/tools/winedump/winedump.h +++ b/tools/winedump/winedump.h @@ -237,6 +237,7 @@ unsigned int strlenW( const unsigned short *str ); void dump_unicode_str( const unsigned short *str, int len ); void dump_file_header(const IMAGE_FILE_HEADER *); void dump_optional_header(const IMAGE_OPTIONAL_HEADER32 *, UINT); +void dump_section(const IMAGE_SECTION_HEADER *); enum FileSig get_kind_exec(void); void pe_dump( void );