Continueing PDB support in winedump: - stricter size checks (to protect against bogus files) - more bits of PDB files dumped (ranges, sections, OMF details...) - keeping cleaning up some internal fields names
-- v2: winedump: Be stricter about sizes while walking module's list. winedump: Properly dump segment map information from PDB/DBI stream. winedump: Dump correctly ranges' part of DBI stream. winedump: Explain a bit more errors on hash header. winedump: Correctly dump PDB_STREAM_INDEX.segment. winedump: Introduce a helper to print PE section's characteristics.
From: Eric Pouech eric.pouech@gmail.com
Signed-off-by: Eric Pouech eric.pouech@gmail.com --- tools/winedump/pe.c | 136 ++++++++++++++++++++------------------ tools/winedump/winedump.h | 1 + 2 files changed, 72 insertions(+), 65 deletions(-)
diff --git a/tools/winedump/pe.c b/tools/winedump/pe.c index 7ec378a19b8..ed30d54cece 100644 --- a/tools/winedump/pe.c +++ b/tools/winedump/pe.c @@ -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 */ @@ -409,57 +391,81 @@ void dump_section(const IMAGE_SECTION_HEADER *sectHead, const char* strtable) /* #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 - Reserved */ /* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
- X(IMAGE_SCN_CNT_CODE, "CODE"); - X(IMAGE_SCN_CNT_INITIALIZED_DATA, "INITIALIZED_DATA"); - X(IMAGE_SCN_CNT_UNINITIALIZED_DATA, "UNINITIALIZED_DATA"); + X(IMAGE_SCN_CNT_CODE, "CODE"); + X(IMAGE_SCN_CNT_INITIALIZED_DATA, "INITIALIZED_DATA"); + X(IMAGE_SCN_CNT_UNINITIALIZED_DATA, "UNINITIALIZED_DATA");
- X(IMAGE_SCN_LNK_OTHER, "LNK_OTHER"); - X(IMAGE_SCN_LNK_INFO, "LNK_INFO"); + X(IMAGE_SCN_LNK_OTHER, "LNK_OTHER"); + X(IMAGE_SCN_LNK_INFO, "LNK_INFO"); /* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */ - X(IMAGE_SCN_LNK_REMOVE, "LNK_REMOVE"); - X(IMAGE_SCN_LNK_COMDAT, "LNK_COMDAT"); - -/* 0x00002000 - Reserved */ -/* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */ - X(IMAGE_SCN_MEM_FARDATA, "MEM_FARDATA"); - -/* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */ - X(IMAGE_SCN_MEM_PURGEABLE, "MEM_PURGEABLE"); - X(IMAGE_SCN_MEM_16BIT, "MEM_16BIT"); - X(IMAGE_SCN_MEM_LOCKED, "MEM_LOCKED"); - X(IMAGE_SCN_MEM_PRELOAD, "MEM_PRELOAD"); - - switch (sectHead->Characteristics & IMAGE_SCN_ALIGN_MASK) - { -#define X2(b,s) case b: printf(" " s); break - X2(IMAGE_SCN_ALIGN_1BYTES, "ALIGN_1BYTES"); - X2(IMAGE_SCN_ALIGN_2BYTES, "ALIGN_2BYTES"); - X2(IMAGE_SCN_ALIGN_4BYTES, "ALIGN_4BYTES"); - X2(IMAGE_SCN_ALIGN_8BYTES, "ALIGN_8BYTES"); - X2(IMAGE_SCN_ALIGN_16BYTES, "ALIGN_16BYTES"); - X2(IMAGE_SCN_ALIGN_32BYTES, "ALIGN_32BYTES"); - X2(IMAGE_SCN_ALIGN_64BYTES, "ALIGN_64BYTES"); - X2(IMAGE_SCN_ALIGN_128BYTES, "ALIGN_128BYTES"); - X2(IMAGE_SCN_ALIGN_256BYTES, "ALIGN_256BYTES"); - X2(IMAGE_SCN_ALIGN_512BYTES, "ALIGN_512BYTES"); - X2(IMAGE_SCN_ALIGN_1024BYTES, "ALIGN_1024BYTES"); - X2(IMAGE_SCN_ALIGN_2048BYTES, "ALIGN_2048BYTES"); - X2(IMAGE_SCN_ALIGN_4096BYTES, "ALIGN_4096BYTES"); - X2(IMAGE_SCN_ALIGN_8192BYTES, "ALIGN_8192BYTES"); + X(IMAGE_SCN_LNK_REMOVE, "LNK_REMOVE"); + X(IMAGE_SCN_LNK_COMDAT, "LNK_COMDAT"); + +/* 0x00002000 - Reserved */ +/* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */ + X(IMAGE_SCN_MEM_FARDATA, "MEM_FARDATA"); + +/* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */ + X(IMAGE_SCN_MEM_PURGEABLE, "MEM_PURGEABLE"); + X(IMAGE_SCN_MEM_16BIT, "MEM_16BIT"); + X(IMAGE_SCN_MEM_LOCKED, "MEM_LOCKED"); + X(IMAGE_SCN_MEM_PRELOAD, "MEM_PRELOAD"); + + switch (characteristics & IMAGE_SCN_ALIGN_MASK) + { +#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"); + X2(IMAGE_SCN_ALIGN_8BYTES, "ALIGN_8BYTES"); + X2(IMAGE_SCN_ALIGN_16BYTES, "ALIGN_16BYTES"); + X2(IMAGE_SCN_ALIGN_32BYTES, "ALIGN_32BYTES"); + X2(IMAGE_SCN_ALIGN_64BYTES, "ALIGN_64BYTES"); + X2(IMAGE_SCN_ALIGN_128BYTES, "ALIGN_128BYTES"); + X2(IMAGE_SCN_ALIGN_256BYTES, "ALIGN_256BYTES"); + X2(IMAGE_SCN_ALIGN_512BYTES, "ALIGN_512BYTES"); + X2(IMAGE_SCN_ALIGN_1024BYTES, "ALIGN_1024BYTES"); + X2(IMAGE_SCN_ALIGN_2048BYTES, "ALIGN_2048BYTES"); + X2(IMAGE_SCN_ALIGN_4096BYTES, "ALIGN_4096BYTES"); + X2(IMAGE_SCN_ALIGN_8192BYTES, "ALIGN_8192BYTES"); #undef X2 - } + }
- X(IMAGE_SCN_LNK_NRELOC_OVFL, "LNK_NRELOC_OVFL"); + X(IMAGE_SCN_LNK_NRELOC_OVFL, "LNK_NRELOC_OVFL");
- X(IMAGE_SCN_MEM_DISCARDABLE, "MEM_DISCARDABLE"); - X(IMAGE_SCN_MEM_NOT_CACHED, "MEM_NOT_CACHED"); - X(IMAGE_SCN_MEM_NOT_PAGED, "MEM_NOT_PAGED"); - X(IMAGE_SCN_MEM_SHARED, "MEM_SHARED"); - X(IMAGE_SCN_MEM_EXECUTE, "MEM_EXECUTE"); - X(IMAGE_SCN_MEM_READ, "MEM_READ"); - X(IMAGE_SCN_MEM_WRITE, "MEM_WRITE"); + X(IMAGE_SCN_MEM_DISCARDABLE, "MEM_DISCARDABLE"); + X(IMAGE_SCN_MEM_NOT_CACHED, "MEM_NOT_CACHED"); + X(IMAGE_SCN_MEM_NOT_PAGED, "MEM_NOT_PAGED"); + X(IMAGE_SCN_MEM_SHARED, "MEM_SHARED"); + X(IMAGE_SCN_MEM_EXECUTE, "MEM_EXECUTE"); + X(IMAGE_SCN_MEM_READ, "MEM_READ"); + X(IMAGE_SCN_MEM_WRITE, "MEM_WRITE"); #undef X - printf("\n\n"); +} + +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"); }
static void dump_sections(const void *base, const void* addr, unsigned num_sect) diff --git a/tools/winedump/winedump.h b/tools/winedump/winedump.h index caa47392144..84694f21b0b 100644 --- a/tools/winedump/winedump.h +++ b/tools/winedump/winedump.h @@ -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 );
From: Eric Pouech eric.pouech@gmail.com
This stream actually contains PE's IMAGE_SECTION_HEADER. So reflect the content by renaming segment into section, and use some helpers winedump's pe side.
Signed-off-by: Eric Pouech eric.pouech@gmail.com --- include/wine/mscvpdb.h | 4 ++-- tools/winedump/pdb.c | 51 ++++++++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 26 deletions(-)
diff --git a/include/wine/mscvpdb.h b/include/wine/mscvpdb.h index 7aff95c3e76..9563a70e1ce 100644 --- a/include/wine/mscvpdb.h +++ b/include/wine/mscvpdb.h @@ -2575,7 +2575,7 @@ typedef struct unsigned short unk1; unsigned short unk2; unsigned short unk3; - unsigned short segments; + unsigned short sections_stream; } PDB_STREAM_INDEXES_OLD;
typedef struct @@ -2585,7 +2585,7 @@ typedef struct unsigned short unk1; unsigned short unk2; unsigned short unk3; - unsigned short segments; + unsigned short sections_stream; unsigned short unk4; unsigned short unk5; unsigned short unk6; diff --git a/tools/winedump/pdb.c b/tools/winedump/pdb.c index 31f4fd3bc46..e98776c67b9 100644 --- a/tools/winedump/pdb.c +++ b/tools/winedump/pdb.c @@ -336,7 +336,7 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx PDB_STRING_TABLE* filesimage; char tcver[32];
- sidx->FPO = sidx->unk0 = sidx->unk1 = sidx->unk2 = sidx->unk3 = sidx->segments = + sidx->FPO = sidx->unk0 = sidx->unk1 = sidx->unk2 = sidx->unk3 = sidx->sections_stream = sidx->unk4 = sidx->unk5 = sidx->unk6 = sidx->FPO_EXT = sidx->unk7 = -1;
symbols = reader->read_stream(reader, 3); @@ -509,9 +509,9 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx "\t?: %04x\n" "\t?: %04x\n" "\t?: %04x\n" - "\tSegments: %04x\n", + "\tSections stream: %04x\n", sidx->FPO, sidx->unk0, sidx->unk1, sidx->unk2, sidx->unk3, - sidx->segments); + sidx->sections_stream); break; case sizeof(PDB_STREAM_INDEXES): memcpy(sidx, @@ -524,14 +524,14 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx "\t?: %04x\n" "\t?: %04x\n" "\t?: %04x\n" - "\tSegments: %04x\n" + "\tSection stream: %04x\n" "\t?: %04x\n" "\t?: %04x\n" "\t?: %04x\n" "\tFPO-ext: %04x\n" "\t?: %04x\n", sidx->FPO, sidx->unk0, sidx->unk1, sidx->unk2, sidx->unk3, - sidx->segments, sidx->unk4, sidx->unk5, sidx->unk6, sidx->FPO_EXT, + sidx->sections_stream, sidx->unk4, sidx->unk5, sidx->unk6, sidx->FPO_EXT, sidx->unk7); break; default: @@ -957,33 +957,36 @@ static void pdb_dump_fpo_ext(struct pdb_reader* reader, unsigned stream_idx) free(strbase); }
-static void pdb_dump_segments(struct pdb_reader* reader, unsigned stream_idx) +static void pdb_dump_sections(struct pdb_reader* reader, unsigned stream_idx) { - const char* segs; - DWORD size; - const char* ptr; + const char* segs; + DWORD size; + const IMAGE_SECTION_HEADER* sect_hdr;
if (stream_idx == (WORD)-1) return; segs = reader->read_stream(reader, stream_idx);
if (segs) { + printf("Sections:\n"); size = pdb_get_stream_size(reader, stream_idx); - for (ptr = segs; ptr < segs + size; ) + for (sect_hdr = (const IMAGE_SECTION_HEADER*)segs; (const char*)sect_hdr < segs + size; sect_hdr++) { - printf("Segment %s\n", ptr); - ptr += (strlen(ptr) + 1 + 3) & ~3; - printf("\tdword[0]: %08x\n", *(UINT *)ptr); ptr += 4; - printf("\tdword[1]: %08x\n", *(UINT *)ptr); ptr += 4; - printf("\tdword[2]: %08x\n", *(UINT *)ptr); ptr += 4; - printf("\tdword[3]: %08x\n", *(UINT *)ptr); ptr += 4; - printf("\tdword[4]: %08x\n", *(UINT *)ptr); ptr += 4; - printf("\tdword[5]: %08x\n", *(UINT *)ptr); ptr += 4; - printf("\tdword[6]: %08x\n", *(UINT *)ptr); ptr += 4; - printf("\tdword[7]: %08x\n", *(UINT *)ptr); ptr += 4; + printf("\tSection: %-8.8s\n", sect_hdr->Name); + printf("\t\tVirtual size: %08x\n", (unsigned)sect_hdr->Misc.VirtualSize); + printf("\t\tVirtualAddress: %08x\n", (unsigned)sect_hdr->VirtualAddress); + printf("\t\tSizeOfRawData: %08x\n", (unsigned)sect_hdr->SizeOfRawData); + printf("\t\tPointerToRawData: %08x\n", (unsigned)sect_hdr->PointerToRawData); + printf("\t\tPointerToRelocations: %08x\n", (unsigned)sect_hdr->PointerToRelocations); + printf("\t\tPointerToLinenumbers: %08x\n", (unsigned)sect_hdr->PointerToLinenumbers); + printf("\t\tNumberOfRelocations: %u\n", (unsigned)sect_hdr->NumberOfRelocations); + printf("\t\tNumberOfLinenumbers: %u\n", (unsigned)sect_hdr->NumberOfLinenumbers); + printf("\t\tCharacteristics: %08x", (unsigned)sect_hdr->Characteristics); + dump_section_characteristics(sect_hdr->Characteristics, " "); + printf("\n"); } free((char*)segs); - } else printf("nosdfsdffd\n"); + } }
static const char pdb2[] = "Microsoft C/C++ program database 2.00"; @@ -1071,7 +1074,7 @@ static void pdb_jg_dump(void) pdb_dump_types(&reader, 4, "IPI"); pdb_dump_symbols(&reader, &sidx); pdb_dump_fpo(&reader, sidx.FPO); - pdb_dump_segments(&reader, sidx.segments); + pdb_dump_sections(&reader, sidx.sections_stream); } else printf("-Unable to get root\n");
@@ -1161,7 +1164,7 @@ static void pdb_ds_dump(void) * - global and public streams: from symbol stream header * those streams get their indexes out of the PDB_STREAM_INDEXES object * - FPO data - * - segments + * - sections * - extended FPO data */ mark_stream_been_read(&reader, 0); /* mark stream #0 as read */ @@ -1219,7 +1222,7 @@ static void pdb_ds_dump(void) pdb_dump_symbols(&reader, &sidx); pdb_dump_fpo(&reader, sidx.FPO); pdb_dump_fpo_ext(&reader, sidx.FPO_EXT); - pdb_dump_segments(&reader, sidx.segments); + pdb_dump_sections(&reader, sidx.sections_stream); } else printf("-Unable to get root\n");
From: Eric Pouech eric.pouech@gmail.com
Signed-off-by: Eric Pouech eric.pouech@gmail.com --- tools/winedump/pdb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/winedump/pdb.c b/tools/winedump/pdb.c index e98776c67b9..5ab1b515691 100644 --- a/tools/winedump/pdb.c +++ b/tools/winedump/pdb.c @@ -249,7 +249,10 @@ static void dump_dbi_hash_table(const BYTE* root, unsigned size, const char* nam sizeof(DBI_HASH_HEADER) + hdr->hash_records_size + DBI_BITMAP_HASH_SIZE > size || (size - (sizeof(DBI_HASH_HEADER) + hdr->hash_records_size + DBI_BITMAP_HASH_SIZE)) % sizeof(unsigned)) { - printf("%s\t\tIncorrect hash structure\n", pfx); + if (size >= sizeof(DBI_HASH_HEADER) && !hdr->hash_records_size) + printf("%s\t\tEmpty hash structure\n", pfx); + else + printf("%s\t\tIncorrect hash structure\n", pfx); } else {
From: Eric Pouech eric.pouech@gmail.com
The ranges describe for a PE image all the contributions of each compilation unit towards the various sections.
Renaming offset_size into ranges_size which is closer to its actual content.
Signed-off-by: Eric Pouech eric.pouech@gmail.com --- dlls/dbghelp/msc.c | 8 +-- include/wine/mscvpdb.h | 4 +- tools/winedump/pdb.c | 111 ++++++++++++++++++++++++++++++----------- 3 files changed, 89 insertions(+), 34 deletions(-)
diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index 1ecb01024d1..5f149e88b94 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -3270,7 +3270,7 @@ static void pdb_convert_symbols_header(PDB_SYMBOLS* symbols, const PDB_SYMBOLS_OLD* old = (const PDB_SYMBOLS_OLD*)image; symbols->version = 0; symbols->module_size = old->module_size; - symbols->offset_size = old->offset_size; + symbols->sectcontrib_size = old->sectcontrib_size; symbols->hash_size = old->hash_size; symbols->srcmodule_size = old->srcmodule_size; symbols->pdbimport_size = 0; @@ -3633,8 +3633,8 @@ static void pdb_process_symbol_imports(const struct process* pcs, int i = 0; struct pdb_file_info sf0 = pdb_module_info->pdb_files[0];
- imp = (const PDB_SYMBOL_IMPORT*)((const char*)symbols_image + sizeof(PDB_SYMBOLS) + - symbols->module_size + symbols->offset_size + + imp = (const PDB_SYMBOL_IMPORT*)((const char*)symbols_image + sizeof(PDB_SYMBOLS) + + symbols->module_size + symbols->sectcontrib_size + symbols->hash_size + symbols->srcmodule_size); first = imp; last = (const char*)imp + symbols->pdbimport_size; @@ -3745,7 +3745,7 @@ static BOOL pdb_process_internal(const struct process* pcs, break; case sizeof(PDB_STREAM_INDEXES): psi = (PDB_STREAM_INDEXES*)((const char*)symbols_image + sizeof(PDB_SYMBOLS) + - symbols.module_size + symbols.offset_size + + symbols.module_size + symbols.sectcontrib_size + symbols.hash_size + symbols.srcmodule_size + symbols.pdbimport_size + symbols.unknown2_size); pdb_file->fpoext_stream = psi->FPO_EXT; diff --git a/include/wine/mscvpdb.h b/include/wine/mscvpdb.h index 9563a70e1ce..efd88608a7f 100644 --- a/include/wine/mscvpdb.h +++ b/include/wine/mscvpdb.h @@ -2539,7 +2539,7 @@ typedef struct _PDB_SYMBOLS_OLD unsigned short gsym_stream; unsigned short pad; unsigned int module_size; - unsigned int offset_size; + unsigned int sectcontrib_size; unsigned int hash_size; unsigned int srcmodule_size; } PDB_SYMBOLS_OLD, *PPDB_SYMBOLS_OLD; @@ -2556,7 +2556,7 @@ typedef struct _PDB_SYMBOLS unsigned short gsym_stream; unsigned short rbldVer; unsigned int module_size; - unsigned int offset_size; + unsigned int sectcontrib_size; unsigned int hash_size; unsigned int srcmodule_size; unsigned int pdbimport_size; diff --git a/tools/winedump/pdb.c b/tools/winedump/pdb.c index 5ab1b515691..5dacb948bdf 100644 --- a/tools/winedump/pdb.c +++ b/tools/winedump/pdb.c @@ -370,7 +370,7 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx "\tgsym_stream: %u\n" "\trbldVer: %u\n" "\tmodule_size: %08x\n" - "\toffset_size: %08x\n" + "\tsectcontrib_size: %08x\n" "\thash_size: %08x\n" "\tsrc_module_size: %08x\n" "\tpdbimport_size: %08x\n" @@ -390,7 +390,7 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx symbols->gsym_stream, symbols->rbldVer, symbols->module_size, - symbols->offset_size, + symbols->sectcontrib_size, symbols->hash_size, symbols->srcmodule_size, symbols->pdbimport_size, @@ -401,13 +401,64 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx get_machine_str( symbols->machine ), symbols->resvd4);
- if (symbols->offset_size) + if (symbols->sectcontrib_size) { - const BYTE* src; - - printf("\t----------offsets------------\n"); - src = (const BYTE*)((const char*)symbols + sizeof(PDB_SYMBOLS) + symbols->module_size); - dump_data(src, symbols->offset_size, " "); + const BYTE* src = (const BYTE*)symbols + sizeof(PDB_SYMBOLS) + symbols->module_size; + const BYTE* last = src + symbols->sectcontrib_size; + unsigned version, size; + + printf("\t----------section contrib------------\n"); + version = *(unsigned*)src; + printf("\tVersion: %#x (%d)\n", version, version - 0xeffe0000); + switch (version) + { + case 0xeffe0000 + 19970605: size = sizeof(PDB_SYMBOL_RANGE_EX); break; + case 0xeffe0000 + 20140516: size = sizeof(PDB_SYMBOL_RANGE_EX) + sizeof(unsigned); break; + default: printf("\t\tUnsupported version number\n"); size = 0; + } + if (size) + { + const PDB_SYMBOL_RANGE_EX* range; + + if ((symbols->sectcontrib_size - sizeof(unsigned)) % size) + printf("Incoherent size: %zu = %zu * %u + %zu\n", + symbols->sectcontrib_size - sizeof(unsigned), + (symbols->sectcontrib_size - sizeof(unsigned)) / size, + size, + (symbols->sectcontrib_size - sizeof(unsigned)) % size); + if ((symbols->sectcontrib_size - sizeof(unsigned)) % size) + if ((symbols->sectcontrib_size - sizeof(unsigned)) % size) + src += sizeof(unsigned); + while (src + size <= last) + { + range = (const PDB_SYMBOL_RANGE_EX*)(src + sizeof(unsigned)); + printf("\tRange #%tu\n", + ((const BYTE*)range - ((const BYTE*)symbols + sizeof(PDB_SYMBOLS) + symbols->module_size)) / size); + printf("\t\tsegment: %04x\n" + "\t\tpad1: %04x\n" + "\t\toffset: %08x\n" + "\t\tsize: %08x\n" + "\t\tcharacteristics: %08x", + range->segment, + range->pad1, + range->offset, + range->size, + range->characteristics); + dump_section_characteristics(range->characteristics, " "); + printf("\n" + "\t\tindex: %04x\n" + "\t\tpad2: %04x\n" + "\t\ttimestamp: %08x\n" + "\t\tunknown: %08x\n", + range->index, + range->pad2, + range->timestamp, + range->unknown); + if (version == 0xeffe0000 + 20140516) + printf("\t\tcoff_section: %08x\n", *(unsigned*)(range + 1)); + src += size; + } + } }
if (!(filesimage = read_string_table(reader))) printf("string table not found\n"); @@ -422,8 +473,8 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx const char* cstr;
printf("\t----------src module------------\n"); - src = (const PDB_SYMBOL_SOURCE*)((const char*)symbols + sizeof(PDB_SYMBOLS) + - symbols->module_size + symbols->offset_size + symbols->hash_size); + src = (const PDB_SYMBOL_SOURCE*)((const char*)symbols + sizeof(PDB_SYMBOLS) + + symbols->module_size + symbols->sectcontrib_size + symbols->hash_size); printf("\tSource Modules\n" "\t\tnModules: %u\n" "\t\tnSrcFiles: %u\n", @@ -468,8 +519,8 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx const char* ptr;
printf("\t------------import--------------\n"); - imp = (const PDB_SYMBOL_IMPORT*)((const char*)symbols + sizeof(PDB_SYMBOLS) + - symbols->module_size + symbols->offset_size + + imp = (const PDB_SYMBOL_IMPORT*)((const char*)symbols + sizeof(PDB_SYMBOLS) + + symbols->module_size + symbols->sectcontrib_size + symbols->hash_size + symbols->srcmodule_size); first = (const char*)imp; last = (const char*)imp + symbols->pdbimport_size; @@ -504,7 +555,7 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx */ memcpy(sidx, (const char*)symbols + sizeof(PDB_SYMBOLS) + symbols->module_size + - symbols->offset_size + symbols->hash_size + symbols->srcmodule_size + + symbols->sectcontrib_size + symbols->hash_size + symbols->srcmodule_size + symbols->pdbimport_size + symbols->unknown2_size, sizeof(PDB_STREAM_INDEXES_OLD)); printf("\tFPO: %04x\n" @@ -519,7 +570,7 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx case sizeof(PDB_STREAM_INDEXES): memcpy(sidx, (const char*)symbols + sizeof(PDB_SYMBOLS) + symbols->module_size + - symbols->offset_size + symbols->hash_size + symbols->srcmodule_size + + symbols->sectcontrib_size + symbols->hash_size + symbols->srcmodule_size + symbols->pdbimport_size + symbols->unknown2_size, sizeof(*sidx)); printf("\tFPO: %04x\n" @@ -578,7 +629,15 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx "\t\t\tpad1: %04x\n" "\t\t\toffset: %08x\n" "\t\t\tsize: %08x\n" - "\t\t\tcharacteristics: %08x\n" + "\t\t\tcharacteristics: %08x", + sym_file->unknown1, + sym_file->range.segment, + sym_file->range.pad1, + sym_file->range.offset, + sym_file->range.size, + sym_file->range.characteristics); + dump_section_characteristics(sym_file->range.characteristics, " "); + printf("\n" "\t\t\tindex: %04x\n" "\t\t\tpad2: %04x\n" "\t\tflag: %04x\n" @@ -588,12 +647,6 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx "\t\tline2 size: %08x\n" "\t\tnSrcFiles: %08x\n" "\t\tattribute: %08x\n", - sym_file->unknown1, - sym_file->range.segment, - sym_file->range.pad1, - sym_file->range.offset, - sym_file->range.size, - sym_file->range.characteristics, sym_file->range.index, sym_file->range.pad2, sym_file->flag, @@ -623,7 +676,15 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx "\t\t\tpad1: %04x\n" "\t\t\toffset: %08x\n" "\t\t\tsize: %08x\n" - "\t\t\tcharacteristics: %08x\n" + "\t\t\tcharacteristics: %08x", + sym_file->unknown1, + sym_file->range.segment, + sym_file->range.pad1, + sym_file->range.offset, + sym_file->range.size, + sym_file->range.characteristics); + dump_section_characteristics(sym_file->range.characteristics, " "); + printf("\n" "\t\t\tindex: %04x\n" "\t\t\tpad2: %04x\n" "\t\t\ttimestamp: %08x\n" @@ -637,12 +698,6 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx "\t\tattribute: %08x\n" "\t\treserved/0: %08x\n" "\t\treserved/1: %08x\n", - sym_file->unknown1, - sym_file->range.segment, - sym_file->range.pad1, - sym_file->range.offset, - sym_file->range.size, - sym_file->range.characteristics, sym_file->range.index, sym_file->range.pad2, sym_file->range.timestamp,
From: Eric Pouech eric.pouech@gmail.com
Changing fields' names to match better their content.
Signed-off-by: Eric Pouech eric.pouech@gmail.com --- dlls/dbghelp/msc.c | 6 +++--- include/wine/mscvpdb.h | 4 ++-- tools/winedump/pdb.c | 43 ++++++++++++++++++++++++++++++++++++------ 3 files changed, 42 insertions(+), 11 deletions(-)
diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index 5f149e88b94..d4aef183677 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -3271,7 +3271,7 @@ static void pdb_convert_symbols_header(PDB_SYMBOLS* symbols, symbols->version = 0; symbols->module_size = old->module_size; symbols->sectcontrib_size = old->sectcontrib_size; - symbols->hash_size = old->hash_size; + symbols->segmap_size = old->segmap_size; symbols->srcmodule_size = old->srcmodule_size; symbols->pdbimport_size = 0; symbols->global_hash_stream = old->global_hash_stream; @@ -3635,7 +3635,7 @@ static void pdb_process_symbol_imports(const struct process* pcs,
imp = (const PDB_SYMBOL_IMPORT*)((const char*)symbols_image + sizeof(PDB_SYMBOLS) + symbols->module_size + symbols->sectcontrib_size + - symbols->hash_size + symbols->srcmodule_size); + symbols->segmap_size + symbols->srcmodule_size); first = imp; last = (const char*)imp + symbols->pdbimport_size; while (imp < (const PDB_SYMBOL_IMPORT*)last) @@ -3746,7 +3746,7 @@ static BOOL pdb_process_internal(const struct process* pcs, case sizeof(PDB_STREAM_INDEXES): psi = (PDB_STREAM_INDEXES*)((const char*)symbols_image + sizeof(PDB_SYMBOLS) + symbols.module_size + symbols.sectcontrib_size + - symbols.hash_size + symbols.srcmodule_size + + symbols.segmap_size + symbols.srcmodule_size + symbols.pdbimport_size + symbols.unknown2_size); pdb_file->fpoext_stream = psi->FPO_EXT; break; diff --git a/include/wine/mscvpdb.h b/include/wine/mscvpdb.h index efd88608a7f..19fcab33ab9 100644 --- a/include/wine/mscvpdb.h +++ b/include/wine/mscvpdb.h @@ -2540,7 +2540,7 @@ typedef struct _PDB_SYMBOLS_OLD unsigned short pad; unsigned int module_size; unsigned int sectcontrib_size; - unsigned int hash_size; + unsigned int segmap_size; unsigned int srcmodule_size; } PDB_SYMBOLS_OLD, *PPDB_SYMBOLS_OLD;
@@ -2557,7 +2557,7 @@ typedef struct _PDB_SYMBOLS unsigned short rbldVer; unsigned int module_size; unsigned int sectcontrib_size; - unsigned int hash_size; + unsigned int segmap_size; unsigned int srcmodule_size; unsigned int pdbimport_size; unsigned int resvd0; diff --git a/tools/winedump/pdb.c b/tools/winedump/pdb.c index 5dacb948bdf..787a62fe624 100644 --- a/tools/winedump/pdb.c +++ b/tools/winedump/pdb.c @@ -371,7 +371,7 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx "\trbldVer: %u\n" "\tmodule_size: %08x\n" "\tsectcontrib_size: %08x\n" - "\thash_size: %08x\n" + "\tsegmap_size: %08x\n" "\tsrc_module_size: %08x\n" "\tpdbimport_size: %08x\n" "\tresvd0: %08x\n" @@ -391,7 +391,7 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx symbols->rbldVer, symbols->module_size, symbols->sectcontrib_size, - symbols->hash_size, + symbols->segmap_size, symbols->srcmodule_size, symbols->pdbimport_size, symbols->resvd0, @@ -474,7 +474,7 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx
printf("\t----------src module------------\n"); src = (const PDB_SYMBOL_SOURCE*)((const char*)symbols + sizeof(PDB_SYMBOLS) + - symbols->module_size + symbols->sectcontrib_size + symbols->hash_size); + symbols->module_size + symbols->sectcontrib_size + symbols->segmap_size); printf("\tSource Modules\n" "\t\tnModules: %u\n" "\t\tnSrcFiles: %u\n", @@ -521,7 +521,7 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx printf("\t------------import--------------\n"); imp = (const PDB_SYMBOL_IMPORT*)((const char*)symbols + sizeof(PDB_SYMBOLS) + symbols->module_size + symbols->sectcontrib_size + - symbols->hash_size + symbols->srcmodule_size); + symbols->segmap_size + symbols->srcmodule_size); first = (const char*)imp; last = (const char*)imp + symbols->pdbimport_size; while (imp < (const PDB_SYMBOL_IMPORT*)last) @@ -544,6 +544,37 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx imp = (const PDB_SYMBOL_IMPORT*)(first + ((ptr - first + strlen(ptr) + 1 + 3) & ~3)); } } + if (symbols->segmap_size) + { + const struct OMFSegMap* segmap = (const struct OMFSegMap*)((const BYTE*)symbols + sizeof(PDB_SYMBOLS) + + symbols->module_size + symbols->sectcontrib_size); + const struct OMFSegMapDesc* desc = (const struct OMFSegMapDesc*)(segmap + 1); + + printf("\t--------------segment map----------------\n"); + printf("\tNumber of segments: %x\n", segmap->cSeg); + printf("\tNumber of logical segments: %x\n", segmap->cSegLog); + /* FIXME check mapping old symbols */ + for (; (const BYTE*)(desc + 1) <= ((const BYTE*)(segmap + 1) + symbols->segmap_size); desc++) + { + printf("\t\tSegment descriptor #%tu\n", desc - (const struct OMFSegMapDesc*)(segmap + 1)); + printf("\t\t\tFlags: %04x (%c%c%c%s%s%s%s)\n", + desc->flags, + (desc->flags & 0x01) ? 'R' : '-', + (desc->flags & 0x02) ? 'W' : '-', + (desc->flags & 0x04) ? 'X' : '-', + (desc->flags & 0x08) ? " 32bit-linear" : "", + (desc->flags & 0x100) ? " selector" : "", + (desc->flags & 0x200) ? " absolute" : "", + (desc->flags & 0x400) ? " group" : ""); + printf("\t\t\tOverlay: %04x\n", desc->ovl); + printf("\t\t\tGroup: %04x\n", desc->group); + printf("\t\t\tFrame: %04x\n", desc->frame); + printf("\t\t\tSegment name: %s\n", desc->iSegName == 0xffff ? "none" : pdb_get_string_table_entry(filesimage, desc->iSegName)); + printf("\t\t\tClass name: %s\n", desc->iClassName == 0xffff ? "none" : pdb_get_string_table_entry(filesimage, desc->iClassName)); + printf("\t\t\tOffset: %08x\n", desc->offset); + printf("\t\t\tSize: %04x\n", desc->cbSeg); + } + } if (symbols->stream_index_size) { printf("\t------------stream indexes--------------\n"); @@ -555,7 +586,7 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx */ memcpy(sidx, (const char*)symbols + sizeof(PDB_SYMBOLS) + symbols->module_size + - symbols->sectcontrib_size + symbols->hash_size + symbols->srcmodule_size + + symbols->sectcontrib_size + symbols->segmap_size + symbols->srcmodule_size + symbols->pdbimport_size + symbols->unknown2_size, sizeof(PDB_STREAM_INDEXES_OLD)); printf("\tFPO: %04x\n" @@ -570,7 +601,7 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx case sizeof(PDB_STREAM_INDEXES): memcpy(sidx, (const char*)symbols + sizeof(PDB_SYMBOLS) + symbols->module_size + - symbols->sectcontrib_size + symbols->hash_size + symbols->srcmodule_size + + symbols->sectcontrib_size + symbols->segmap_size + symbols->srcmodule_size + symbols->pdbimport_size + symbols->unknown2_size, sizeof(*sidx)); printf("\tFPO: %04x\n"
From: Eric Pouech eric.pouech@gmail.com
Signed-off-by: Eric Pouech eric.pouech@gmail.com --- tools/winedump/pdb.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/tools/winedump/pdb.c b/tools/winedump/pdb.c index 787a62fe624..b13161c6c7a 100644 --- a/tools/winedump/pdb.c +++ b/tools/winedump/pdb.c @@ -637,6 +637,9 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx /* Read per-module symbol / linenumber tables */ file = (const char*)symbols + sizeof(PDB_SYMBOLS); while (file - (const char*)symbols < sizeof(PDB_SYMBOLS) + symbols->module_size) + while ((file - (const char*)symbols + sizeof(symbols->version) < sizeof(PDB_SYMBOLS) + symbols->module_size) && + (file - (const char*)symbols + + symbols->version < 19970000 ? sizeof(PDB_SYMBOL_FILE) : sizeof(PDB_SYMBOL_FILE_EX)) < sizeof(PDB_SYMBOLS) + symbols->module_size) { int stream_nr, symbol_size, lineno_size, lineno2_size; const char* file_name;
V2: - added missing first patch of the serie