static BOOL dump_cv_sst_align_sym(const OMFDirEntry* omfde) { const char* rawdata = PRD(Offset(cv_base) + omfde->lfo, omfde->cb); if (!rawdata) {printf("Can't get srcAlignSym subsection details, aborting\n");return FALSE;} if (omfde->cb < sizeof(DWORD)) return TRUE; codeview_dump_symbols(rawdata + sizeof(DWORD), omfde->cb - sizeof(DWORD)); return TRUE; }
static BOOL dump_cv_sst_global_pub(const OMFDirEntry* omfde) { long fileoffset; const OMFSymHash* header; const BYTE* symbols; fileoffset = Offset(cv_base) + omfde->lfo; printf (" GlobalPub section starts at file offset 0x%lx\n", fileoffset); printf (" Symbol table starts at 0x%lx\n", fileoffset + sizeof (OMFSymHash)); printf ("\n ----- Begin Symbol Table -----\n"); header = PRD(fileoffset, sizeof(OMFSymHash)); if (!header) {printf("Can't get OMF-SymHash, aborting\n");return FALSE;} symbols = PRD(fileoffset + sizeof(OMFSymHash), header->cbSymbol); if (!symbols) {printf("Can't OMF-SymHash details, aborting\n"); return FALSE;} codeview_dump_symbols(symbols, header->cbSymbol); return TRUE; }
static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx) { PDB_SYMBOLS* symbols; unsigned char* modimage; const char* file; char* filesimage; DWORD filessize = 0; 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; switch (symbols->version) { case 0: /* VC 4.0 */ case 19960307: /* VC 5.0 */ case 19970606: /* VC 6.0 */ case 19990903: /* VC 7.0 */ break; default: printf("-Unknown symbol info version %d\n", symbols->version); } printf("Symbols:\n" "\tsignature: %08x\n" "\tversion: %u\n" "\tunknown: %08x\n" "\thash1_file: %08x\n" "\thash2_file: %08x\n" "\tgsym_file: %04x\n" "\tunknown1: %04x\n" "\tmodule_size: %08x\n" "\toffset_size: %08x\n" "\thash_size: %08x\n" "\tsrc_module_size: %08x\n" "\tpdbimport_size: %08x\n" "\tresvd0: %08x\n" "\tstream_idx_size: %08x\n" "\tunknown2_size: %08x\n" "\tresvd3: %04x\n" "\tmachine: %s\n" "\tresvd[4] %08x\n", symbols->signature, symbols->version, symbols->unknown, symbols->hash1_file, symbols->hash2_file, symbols->gsym_file, symbols->unknown1, symbols->module_size, symbols->offset_size, symbols->hash_size, symbols->srcmodule_size, symbols->pdbimport_size, symbols->resvd0, symbols->stream_index_size, symbols->unknown2_size, symbols->resvd3, get_machine_str( symbols->machine ), symbols->resvd4); if (symbols->offset_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, " "); } if (!(filesimage = read_string_table(reader))) printf("string table not found\n"); else filessize = *(const DWORD*)(filesimage + 8); if (symbols->srcmodule_size) { const PDB_SYMBOL_SOURCE*src; int i, j, cfile; const WORD* indx; const DWORD* offset; const char* start_cstr; 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); printf("\tSource Modules\n" "\t\tnModules: %u\n" "\t\tnSrcFiles: %u\n", src->nModules, src->nSrcFiles); /* usage of table seems to be as follows: * two arrays of WORD (src->nModules as size) * - first array contains index into files for "module" compilation * (module = compilation unit ??) * - second array contains the number of source files in module * an array of DWORD (src->nSrcFiles as size) * - contains offset (in following string table) of the source file name * a string table * - each string is a pascal string (ie. with its length as first BYTE) or * 0-terminated string (depending on version) */ indx = &src->table[src->nModules]; offset = (const DWORD*)&src->table[2 * src->nModules]; cstr = (const char*)&src->table[2 * (src->nModules + src->nSrcFiles)]; start_cstr = cstr; for (i = cfile = 0; i < src->nModules; i++) { printf("\t\tModule[%2d]:\n", i); cfile = src->table[i]; for (j = cfile; j < src->nSrcFiles && j < cfile + indx[i]; j++) { /* FIXME: in some cases, it's a p_string but WHEN ? */ if (cstr + offset[j] >= (const char*)start_cstr /* wrap around */ && cstr + offset[j] < (const char*)src + symbols->srcmodule_size) printf("\t\t\tSource file: %s\n", cstr + offset[j]); else printf("\t\t\tSource file: <<out of bounds>>\n"); } } } if (symbols->pdbimport_size) { const PDB_SYMBOL_IMPORT* imp; const char* first; const char* last; const char* ptr; printf("\t------------import--------------\n"); imp = (const PDB_SYMBOL_IMPORT*)((const char*)symbols + sizeof(PDB_SYMBOLS) + symbols->module_size + symbols->offset_size + symbols->hash_size + symbols->srcmodule_size); first = (const char*)imp; last = (const char*)imp + symbols->pdbimport_size; while (imp < (const PDB_SYMBOL_IMPORT*)last) { ptr = (const char*)imp + sizeof(*imp) + strlen(imp->filename); printf("\tImport: %lx\n" "\t\tUnknown1: %08x\n" "\t\tUnknown2: %08x\n" "\t\tTimeDateStamp: %08x\n" "\t\tAge: %08u\n" "\t\tfile1: %s\n" "\t\tfile2: %s\n", (ULONG_PTR)((const char*)imp - (const char*)first), imp->unknown1, imp->unknown2, imp->TimeDateStamp, imp->Age, imp->filename, ptr); imp = (const PDB_SYMBOL_IMPORT*)(first + ((ptr - first + strlen(ptr) + 1 + 3) & ~3)); } } if (symbols->stream_index_size) { printf("\t------------stream indexes--------------\n"); switch (symbols->stream_index_size) { case sizeof(PDB_STREAM_INDEXES_OLD): /* PDB_STREAM_INDEXES is a superset of PDB_STREAM_INDEX_OLD * FIXME: to be confirmed when all fields are fully understood */ 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" "\t?: %04x\n" "\t?: %04x\n" "\t?: %04x\n" "\t?: %04x\n" "\tSegments: %04x\n", sidx->FPO, sidx->unk0, sidx->unk1, sidx->unk2, sidx->unk3, sidx->segments); break; 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->pdbimport_size + symbols->unknown2_size, sizeof(*sidx)); printf("\tFPO: %04x\n" "\t?: %04x\n" "\t?: %04x\n" "\t?: %04x\n" "\t?: %04x\n" "\tSegments: %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->unk7); break; default: printf("unexpected size for stream index %d\n", symbols->stream_index_size); break; } } /* Read global symbol table */ modimage = reader->read_file(reader, symbols->gsym_file); if (modimage) { printf("\t------------globals-------------\n"); codeview_dump_symbols(modimage, pdb_get_file_size(reader, symbols->gsym_file)); free(modimage); } /* Read per-module symbol / linenumber tables */ file = (const char*)symbols + sizeof(PDB_SYMBOLS); while (file - (const char*)symbols < sizeof(PDB_SYMBOLS) + symbols->module_size) { int file_nr, symbol_size, lineno_size; const char* file_name; if (symbols->version < 19970000) { const PDB_SYMBOL_FILE* sym_file = (const PDB_SYMBOL_FILE*) file; file_nr = sym_file->file; file_name = sym_file->filename; symbol_size = sym_file->symbol_size; lineno_size = sym_file->lineno_size; printf("\t--------symbol file----------- %s\n", file_name); printf("\tgot symbol_file\n" "\t\tunknown1: %08x\n" "\t\trange\n" "\t\t\tsegment: %04x\n" "\t\t\tpad1: %04x\n" "\t\t\toffset: %08x\n" "\t\t\tsize: %08x\n" "\t\t\tcharacteristics: %08x\n" "\t\t\tindex: %04x\n" "\t\t\tpad2: %04x\n" "\t\tflag: %04x\n" "\t\tfile: %04x\n" "\t\tsymb size: %08x\n" "\t\tline size: %08x\n" "\t\tunknown2: %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, sym_file->file, sym_file->symbol_size, sym_file->lineno_size, sym_file->unknown2, sym_file->nSrcFiles, sym_file->attribute); } else { const PDB_SYMBOL_FILE_EX* sym_file = (const PDB_SYMBOL_FILE_EX*) file; file_nr = sym_file->file; file_name = sym_file->filename; symbol_size = sym_file->symbol_size; lineno_size = sym_file->lineno_size; printf("\t--------symbol file----------- %s\n", file_name); printf("\t\tunknown1: %08x\n" "\t\trange\n" "\t\t\tsegment: %04x\n" "\t\t\tpad1: %04x\n" "\t\t\toffset: %08x\n" "\t\t\tsize: %08x\n" "\t\t\tcharacteristics: %08x\n" "\t\t\tindex: %04x\n" "\t\t\tpad2: %04x\n" "\t\t\ttimestamp: %08x\n" "\t\t\tunknown: %08x\n" "\t\tflag: %04x\n" "\t\tfile: %04x\n" "\t\tsymb size: %08x\n" "\t\tline size: %08x\n" "\t\tunknown2: %08x\n" "\t\tnSrcFiles: %08x\n" "\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, sym_file->range.unknown, sym_file->flag, sym_file->file, sym_file->symbol_size, sym_file->lineno_size, sym_file->unknown2, sym_file->nSrcFiles, sym_file->attribute, sym_file->reserved[0], sym_file->reserved[1]); } modimage = reader->read_file(reader, file_nr); if (modimage) { int total_size = pdb_get_file_size(reader, file_nr); if (symbol_size) codeview_dump_symbols((const char*)modimage + sizeof(DWORD), symbol_size); /* line number info */ if (lineno_size) codeview_dump_linetab((const char*)modimage + symbol_size, lineno_size, TRUE, " "); /* anyway, lineno_size doesn't see to really be the size of the line number information, and * it's not clear yet when to call for linetab2... */ codeview_dump_linetab2((const char*)modimage + symbol_size + lineno_size, total_size - (symbol_size + lineno_size), filesimage ? filesimage + 12 : NULL, filessize, " "); /* what's that part ??? */ if (0) dump_data(modimage + symbol_size + lineno_size, total_size - (symbol_size + lineno_size), " "); free(modimage); } file_name += strlen(file_name) + 1; file = (char*)((DWORD_PTR)(file_name + strlen(file_name) + 1 + 3) & ~3); } free(symbols); free(filesimage); }