Commit a7cdc540 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

winedump: Make use of PDB_STREAM_INDEXES in order to get rid of hardwired indexes.

parent 5199d04b
...@@ -222,7 +222,7 @@ static void *read_string_table(struct pdb_reader* reader) ...@@ -222,7 +222,7 @@ static void *read_string_table(struct pdb_reader* reader)
return NULL; return NULL;
} }
static void pdb_dump_symbols(struct pdb_reader* reader) static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx)
{ {
PDB_SYMBOLS* symbols; PDB_SYMBOLS* symbols;
unsigned char* modimage; unsigned char* modimage;
...@@ -230,8 +230,10 @@ static void pdb_dump_symbols(struct pdb_reader* reader) ...@@ -230,8 +230,10 @@ static void pdb_dump_symbols(struct pdb_reader* reader)
char* filesimage; char* filesimage;
DWORD filessize = 0; DWORD filessize = 0;
symbols = reader->read_file(reader, 3); sidx->FPO = sidx->unk0 = sidx->unk1 = sidx->unk2 = sidx->unk3 = sidx->segments =
sidx->unk4 = sidx->unk5 = sidx->unk6 = sidx->FPO_EXT = sidx->unk7 = -1;
symbols = reader->read_file(reader, 3);
if (!symbols) return; if (!symbols) return;
switch (symbols->version) switch (symbols->version)
...@@ -377,32 +379,33 @@ static void pdb_dump_symbols(struct pdb_reader* reader) ...@@ -377,32 +379,33 @@ static void pdb_dump_symbols(struct pdb_reader* reader)
} }
if (symbols->stream_index_size) if (symbols->stream_index_size)
{ {
const PDB_STREAM_INDEXES_OLD* sidx_old;
const PDB_STREAM_INDEXES* sidx;
printf("\t------------stream indexes--------------\n"); printf("\t------------stream indexes--------------\n");
switch (symbols->stream_index_size) switch (symbols->stream_index_size)
{ {
case sizeof(PDB_STREAM_INDEXES_OLD): case sizeof(PDB_STREAM_INDEXES_OLD):
sidx_old = (const PDB_STREAM_INDEXES_OLD*)((const char*)symbols + sizeof(PDB_SYMBOLS) + /* PDB_STREAM_INDEXES is a superset of PDB_STREAM_INDEX_OLD
symbols->module_size + symbols->offset_size + * FIXME: to be confirmed when all fields are fully understood
symbols->hash_size + symbols->srcmodule_size + */
symbols->pdbimport_size + symbols->unknown2_size); memcpy(sidx,
(const char*)symbols + sizeof(PDB_SYMBOLS) + symbols->module_size +
symbols->offset_size + symbols->hash_size + symbols->srcmodule_size +
symbols->pdbimport_size + symbols->unknown2_size,
sizeof(PDB_STREAM_INDEXES_OLD));
printf("\tFPO: %04x\n" printf("\tFPO: %04x\n"
"\t?: %04x\n" "\t?: %04x\n"
"\t?: %04x\n" "\t?: %04x\n"
"\t?: %04x\n" "\t?: %04x\n"
"\t?: %04x\n" "\t?: %04x\n"
"\tSegments: %04x\n", "\tSegments: %04x\n",
sidx_old->FPO, sidx_old->unk0, sidx_old->unk1, sidx_old->unk2, sidx_old->unk3, sidx->FPO, sidx->unk0, sidx->unk1, sidx->unk2, sidx->unk3,
sidx_old->segments); sidx->segments);
break; break;
case sizeof(PDB_STREAM_INDEXES): case sizeof(PDB_STREAM_INDEXES):
sidx = (const PDB_STREAM_INDEXES*)((const char*)symbols + sizeof(PDB_SYMBOLS) + memcpy(sidx,
symbols->module_size + symbols->offset_size + (const char*)symbols + sizeof(PDB_SYMBOLS) + symbols->module_size +
symbols->hash_size + symbols->srcmodule_size + symbols->offset_size + symbols->hash_size + symbols->srcmodule_size +
symbols->pdbimport_size + symbols->unknown2_size); symbols->pdbimport_size + symbols->unknown2_size,
sizeof(*sidx));
printf("\tFPO: %04x\n" printf("\tFPO: %04x\n"
"\t?: %04x\n" "\t?: %04x\n"
"\t?: %04x\n" "\t?: %04x\n"
...@@ -613,16 +616,15 @@ static void pdb_dump_types(struct pdb_reader* reader) ...@@ -613,16 +616,15 @@ static void pdb_dump_types(struct pdb_reader* reader)
free(types); free(types);
} }
static void pdb_dump_fpo(struct pdb_reader* reader) static void pdb_dump_fpo(struct pdb_reader* reader, unsigned stream_idx)
{ {
FPO_DATA* fpo; FPO_DATA* fpo;
PDB_FPO_DATA* fpoext; unsigned i, size;
unsigned i, size, strsize;
char* strbase;
const char* frame_type[4] = {"Fpo", "Trap", "Tss", "NonFpo"}; const char* frame_type[4] = {"Fpo", "Trap", "Tss", "NonFpo"};
fpo = reader->read_file(reader, 5); if (stream_idx == (WORD)-1) return;
size = pdb_get_file_size(reader, 5); fpo = reader->read_file(reader, stream_idx);
size = pdb_get_file_size(reader, stream_idx);
if (fpo && (size % sizeof(*fpo)) == 0) if (fpo && (size % sizeof(*fpo)) == 0)
{ {
size /= sizeof(*fpo); size /= sizeof(*fpo);
...@@ -636,13 +638,21 @@ static void pdb_dump_fpo(struct pdb_reader* reader) ...@@ -636,13 +638,21 @@ static void pdb_dump_fpo(struct pdb_reader* reader)
} }
} }
free(fpo); free(fpo);
}
static void pdb_dump_fpo_ext(struct pdb_reader* reader, unsigned stream_idx)
{
PDB_FPO_DATA* fpoext;
unsigned i, size, strsize;
char* strbase;
if (stream_idx == (WORD)-1) return;
strbase = read_string_table(reader); strbase = read_string_table(reader);
if (!strbase) return; if (!strbase) return;
strsize = *(const DWORD*)(strbase + 8); strsize = *(const DWORD*)(strbase + 8);
fpoext = reader->read_file(reader, 10); fpoext = reader->read_file(reader, stream_idx);
size = pdb_get_file_size(reader, 10); size = pdb_get_file_size(reader, stream_idx);
if (fpoext && (size % sizeof(*fpoext)) == 0) if (fpoext && (size % sizeof(*fpoext)) == 0)
{ {
size /= sizeof(*fpoext); size /= sizeof(*fpoext);
...@@ -689,6 +699,7 @@ static void pdb_jg_dump(void) ...@@ -689,6 +699,7 @@ static void pdb_jg_dump(void)
DWORD* ok_bits; DWORD* ok_bits;
DWORD numok, count; DWORD numok, count;
unsigned i; unsigned i;
PDB_STREAM_INDEXES sidx;
printf("Root:\n" printf("Root:\n"
"\tVersion: %u\n" "\tVersion: %u\n"
...@@ -743,6 +754,7 @@ static void pdb_jg_dump(void) ...@@ -743,6 +754,7 @@ static void pdb_jg_dump(void)
printf("-Unknown root block version %d\n", reader.u.jg.root->Version); printf("-Unknown root block version %d\n", reader.u.jg.root->Version);
} }
pdb_dump_types(&reader); pdb_dump_types(&reader);
pdb_dump_symbols(&reader, &sidx);
#if 0 #if 0
/* segments info, index is unknown */ /* segments info, index is unknown */
{ {
...@@ -765,7 +777,6 @@ static void pdb_jg_dump(void) ...@@ -765,7 +777,6 @@ static void pdb_jg_dump(void)
free(segs); free(segs);
} }
#endif #endif
pdb_dump_symbols(&reader);
} }
else printf("-Unable to get root\n"); else printf("-Unable to get root\n");
...@@ -849,11 +860,11 @@ static void pdb_ds_dump(void) ...@@ -849,11 +860,11 @@ static void pdb_ds_dump(void)
* 2: types * 2: types
* 3: modules * 3: modules
* other known streams: * other known streams:
* string table: it's index is in the stream table from ROOT object under "/names" * - string table: it's index is in the stream table from ROOT object under "/names"
* those other streams are likely not to have a fixed stream number * those streams get their indexes out of the PDB_STREAM_INDEXES object
* 5: FPO data * - FPO data
* 8: segments * - segments
* 10: extended FPO data * - extended FPO data
*/ */
reader.u.ds.root = reader.read_file(&reader, 1); reader.u.ds.root = reader.read_file(&reader, 1);
if (reader.u.ds.root) if (reader.u.ds.root)
...@@ -862,6 +873,7 @@ static void pdb_ds_dump(void) ...@@ -862,6 +873,7 @@ static void pdb_ds_dump(void)
DWORD* ok_bits; DWORD* ok_bits;
DWORD numok, count; DWORD numok, count;
unsigned i; unsigned i;
PDB_STREAM_INDEXES sidx;
printf("Root:\n" printf("Root:\n"
"\tVersion: %u\n" "\tVersion: %u\n"
...@@ -906,8 +918,9 @@ static void pdb_ds_dump(void) ...@@ -906,8 +918,9 @@ static void pdb_ds_dump(void)
if (numok) printf(">>> unmatched present field with found\n"); if (numok) printf(">>> unmatched present field with found\n");
pdb_dump_types(&reader); pdb_dump_types(&reader);
pdb_dump_symbols(&reader); pdb_dump_symbols(&reader, &sidx);
pdb_dump_fpo(&reader); pdb_dump_fpo(&reader, sidx.FPO);
pdb_dump_fpo_ext(&reader, sidx.FPO_EXT);
} }
else printf("-Unable to get root\n"); else printf("-Unable to get root\n");
......
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