Commit 97d2e9d9 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

winedump: Introduce a helper to print PE section's characteristics.

parent edc479ee
......@@ -381,27 +381,9 @@ static void dump_pe_header(void)
dump_optional_header((const IMAGE_OPTIONAL_HEADER32*)&PE_nt_headers->OptionalHeader, PE_nt_headers->FileHeader.SizeOfOptionalHeader);
}
void dump_section(const IMAGE_SECTION_HEADER *sectHead, const char* strtable)
void dump_section_characteristics(DWORD characteristics, const char* sep)
{
unsigned offset;
/* long section name ? */
if (strtable && sectHead->Name[0] == '/' &&
((offset = atoi((const char*)sectHead->Name + 1)) < *(const DWORD*)strtable))
printf(" %.8s (%s)", sectHead->Name, strtable + offset);
else
printf(" %-8.8s", sectHead->Name);
printf(" VirtSize: 0x%08x VirtAddr: 0x%08x\n",
(UINT)sectHead->Misc.VirtualSize, (UINT)sectHead->VirtualAddress);
printf(" raw data offs: 0x%08x raw data size: 0x%08x\n",
(UINT)sectHead->PointerToRawData, (UINT)sectHead->SizeOfRawData);
printf(" relocation offs: 0x%08x relocations: 0x%08x\n",
(UINT)sectHead->PointerToRelocations, (UINT)sectHead->NumberOfRelocations);
printf(" line # offs: %-8u line #'s: %-8u\n",
(UINT)sectHead->PointerToLinenumbers, (UINT)sectHead->NumberOfLinenumbers);
printf(" characteristics: 0x%08x\n", (UINT)sectHead->Characteristics);
printf(" ");
#define X(b,s) if (sectHead->Characteristics & b) printf(" " s)
#define X(b,s) if (characteristics & b) printf("%s%s", sep, s)
/* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
/* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
/* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
......@@ -429,9 +411,9 @@ void dump_section(const IMAGE_SECTION_HEADER *sectHead, const char* strtable)
X(IMAGE_SCN_MEM_LOCKED, "MEM_LOCKED");
X(IMAGE_SCN_MEM_PRELOAD, "MEM_PRELOAD");
switch (sectHead->Characteristics & IMAGE_SCN_ALIGN_MASK)
switch (characteristics & IMAGE_SCN_ALIGN_MASK)
{
#define X2(b,s) case b: printf(" " s); break
#define X2(b,s) case b: printf("%s%s", sep, s); break
X2(IMAGE_SCN_ALIGN_1BYTES, "ALIGN_1BYTES");
X2(IMAGE_SCN_ALIGN_2BYTES, "ALIGN_2BYTES");
X2(IMAGE_SCN_ALIGN_4BYTES, "ALIGN_4BYTES");
......@@ -459,6 +441,30 @@ void dump_section(const IMAGE_SECTION_HEADER *sectHead, const char* strtable)
X(IMAGE_SCN_MEM_READ, "MEM_READ");
X(IMAGE_SCN_MEM_WRITE, "MEM_WRITE");
#undef X
}
void dump_section(const IMAGE_SECTION_HEADER *sectHead, const char* strtable)
{
unsigned offset;
/* long section name ? */
if (strtable && sectHead->Name[0] == '/' &&
((offset = atoi((const char*)sectHead->Name + 1)) < *(const DWORD*)strtable))
printf(" %.8s (%s)", sectHead->Name, strtable + offset);
else
printf(" %-8.8s", sectHead->Name);
printf(" VirtSize: 0x%08x VirtAddr: 0x%08x\n",
(UINT)sectHead->Misc.VirtualSize, (UINT)sectHead->VirtualAddress);
printf(" raw data offs: 0x%08x raw data size: 0x%08x\n",
(UINT)sectHead->PointerToRawData, (UINT)sectHead->SizeOfRawData);
printf(" relocation offs: 0x%08x relocations: 0x%08x\n",
(UINT)sectHead->PointerToRelocations, (UINT)sectHead->NumberOfRelocations);
printf(" line # offs: %-8u line #'s: %-8u\n",
(UINT)sectHead->PointerToLinenumbers, (UINT)sectHead->NumberOfLinenumbers);
printf(" characteristics: 0x%08x\n", (UINT)sectHead->Characteristics);
printf(" ");
dump_section_characteristics(sectHead->Characteristics, " ");
printf("\n\n");
}
......
......@@ -233,6 +233,7 @@ void print_fake_dll(void);
void dump_file_header(const IMAGE_FILE_HEADER *);
void dump_optional_header(const IMAGE_OPTIONAL_HEADER32 *, UINT);
void dump_section(const IMAGE_SECTION_HEADER *, const char* strtable);
void dump_section_characteristics(DWORD characteristics, const char* sep);
enum FileSig get_kind_exec(void);
void dos_dump( void );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment