winedump: Simplify code a bit by using IMAGE_FIRST_SECTION() macro.

This commit is contained in:
Eric Pouech 2011-05-01 09:46:27 +02:00 committed by Alexandre Julliard
parent b722e77299
commit 0957cd03dd
3 changed files with 7 additions and 10 deletions

View File

@ -570,12 +570,11 @@ void dump_coff_symbol_table(const IMAGE_SYMBOL *coff_symbols, unsigned num_sy
}
}
void dump_coff(unsigned long coffbase, unsigned long len, const void* pmt)
void dump_coff(unsigned long coffbase, unsigned long len, const IMAGE_SECTION_HEADER* sectHead)
{
const IMAGE_COFF_SYMBOLS_HEADER *coff = PRD(coffbase, len);
const IMAGE_SYMBOL *coff_symbols =
(const IMAGE_SYMBOL *) ((const char *)coff + coff->LvaToFirstSymbol);
const IMAGE_SECTION_HEADER *sectHead = pmt;
dump_coff_symbol_table(coff_symbols, coff->NumberOfSymbols, sectHead);
}

View File

@ -882,8 +882,8 @@ static void dump_dir_debug_dir(const IMAGE_DEBUG_DIRECTORY* idd, int idx)
case IMAGE_DEBUG_TYPE_UNKNOWN:
break;
case IMAGE_DEBUG_TYPE_COFF:
dump_coff(idd->PointerToRawData, idd->SizeOfData,
(const char*)PE_nt_headers + sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER) + PE_nt_headers->FileHeader.SizeOfOptionalHeader);
dump_coff(idd->PointerToRawData, idd->SizeOfData,
IMAGE_FIRST_SECTION(PE_nt_headers));
break;
case IMAGE_DEBUG_TYPE_CODEVIEW:
dump_codeview(idd->PointerToRawData, idd->SizeOfData);
@ -1383,9 +1383,7 @@ static void dump_debug(void)
unsigned i;
const IMAGE_SECTION_HEADER* sectHead;
sectHead = (const IMAGE_SECTION_HEADER*)
((const char*)PE_nt_headers + sizeof(DWORD) +
sizeof(IMAGE_FILE_HEADER) + PE_nt_headers->FileHeader.SizeOfOptionalHeader);
sectHead = IMAGE_FIRST_SECTION(PE_nt_headers);
for (i = 0; i < PE_nt_headers->FileHeader.NumberOfSections; i++, sectHead++)
{
@ -1456,8 +1454,7 @@ void pe_dump(void)
{
dump_pe_header();
/* FIXME: should check ptr */
dump_sections(PRD(0, 1), (const char*)PE_nt_headers + sizeof(DWORD) +
sizeof(IMAGE_FILE_HEADER) + PE_nt_headers->FileHeader.SizeOfOptionalHeader,
dump_sections(PRD(0, 1), IMAGE_FIRST_SECTION(PE_nt_headers),
PE_nt_headers->FileHeader.NumberOfSections);
}
else if (!globals.dumpsect)

View File

@ -260,7 +260,8 @@ void codeview_dump_linetab2(const char* linetab, DWORD size, const ch
void dump_stabs(const void* pv_stabs, unsigned szstabs, const char* stabstr, unsigned szstr);
void dump_codeview(unsigned long ptr, unsigned long len);
void dump_coff(unsigned long coffbase, unsigned long len, const void* sect_map);
void dump_coff(unsigned long coffbase, unsigned long len,
const IMAGE_SECTION_HEADER *sectHead);
void dump_coff_symbol_table(const IMAGE_SYMBOL *coff_symbols, unsigned num_sym,
const IMAGE_SECTION_HEADER *sectHead);
void dump_frame_pointer_omission(unsigned long base, unsigned long len);