static void DumpDbiStream(BitAccess bits, out int globalsStream, out int publicsStream, out int symbolsStream, out DbiModuleInfo[] modules) { globalsStream = 0; publicsStream = 0; symbolsStream = 0; DbiHeader dh = new DbiHeader(bits); Console.WriteLine(" ** DBI sig={0}, ver={1}, age={2}, vers={3:x4}, "+ "pdb={4}, pdb2={5}", dh.sig, dh.ver, dh.age, dh.vers, dh.pdbver, dh.pdbver2); if (dh.sig != -1 || dh.ver != 19990903) { throw new IOException("Unknown DBI Stream version"); } Console.WriteLine(" mach={0:x4}, flags={1:x4}, globals={2}, publics={3}, symbols={4}", dh.machine, dh.flags, dh.gssymStream, dh.pssymStream, dh.symrecStream); Console.WriteLine(" gpmod={0}, seccon={1}, secmap={2}, filinf={3}, ", dh.gpmodiSize, dh.secconSize, dh.secmapSize, dh.filinfSize); Console.WriteLine(" tsmap={0}, dbghdr={1}, ecinf={2}, mfc={3}", dh.tsmapSize, dh.dbghdrSize, dh.ecinfoSize, dh.mfcIndex); Console.WriteLine(" sizes={0}", bits.Position + dh.gpmodiSize + dh.secconSize + dh.secmapSize + dh.filinfSize + dh.tsmapSize + dh.dbghdrSize + dh.ecinfoSize); globalsStream = dh.gssymStream; publicsStream = dh.pssymStream; symbolsStream = dh.symrecStream; // Read gpmod section. ArrayList modList = new ArrayList(); int end = bits.Position + dh.gpmodiSize; while (bits.Position < end) { DbiModuleInfo mod = new DbiModuleInfo(bits, true); Dump(mod); modList.Add(mod); } if (bits.Position != end) { throw new Exception("off!"); } // Read seccon section. end = bits.Position + dh.secconSize; Console.WriteLine(" SecCon:"); Dump(bits.Buffer, bits.Position, end); bits.Position = end; // Read secmap section. end = bits.Position + dh.secmapSize; Console.WriteLine(" SecMap:"); Dump(bits.Buffer, bits.Position, end); bits.Position = end; // Read filinf section. end = bits.Position + dh.filinfSize; Console.WriteLine(" FilInf:"); Dump(bits.Buffer, bits.Position, end); bits.Position = end; // Read tsmap section. end = bits.Position + dh.tsmapSize; Console.WriteLine(" TSMap:"); Dump(bits.Buffer, bits.Position, end); bits.Position = end; // Read ecinfo section. end = bits.Position + dh.ecinfoSize; Console.WriteLine(" ECInfo:"); Dump(bits.Buffer, bits.Position, end); DumpNameStream(bits); bits.Position = end; // Read dbghdr section. end = bits.Position + dh.dbghdrSize; Console.WriteLine(" DbgHdr:"); if (dh.dbghdrSize > 0) { int beg = bits.Position; Dump(bits.Buffer, bits.Position, end); bits.Position = beg; DbiDbgHdr ddh = new DbiDbgHdr(bits); Console.WriteLine(" sechdr={0}, ridmap={1}", ddh.snSectionHdr, ddh.snTokenRidMap); } bits.Position = end; if (modList.Count > 0) { modules = (DbiModuleInfo[])modList.ToArray(typeof(DbiModuleInfo)); } else { modules = null; } }
static void LoadDbiStream(BitAccess bits, out DbiModuleInfo[] modules, out DbiDbgHdr header, bool readStrings) { DbiHeader dh = new DbiHeader(bits); header = new DbiDbgHdr(); if (dh.sig != -1 || dh.ver != 19990903) { throw new PdbException("Unsupported DBI Stream version, sig={0}, ver={1}", dh.sig, dh.ver); } // Read gpmod section. ArrayList modList = new ArrayList(); int end = bits.Position + dh.gpmodiSize; while (bits.Position < end) { DbiModuleInfo mod = new DbiModuleInfo(bits, readStrings); modList.Add(mod); } if (bits.Position != end) { throw new PdbDebugException("Error reading DBI stream, pos={0} != {1}", bits.Position, end); } if (modList.Count > 0) { modules = (DbiModuleInfo[])modList.ToArray(typeof(DbiModuleInfo)); } else { modules = null; } // Skip the Section Contribution substream. bits.Position += dh.secconSize; // Skip the Section Map substream. bits.Position += dh.secmapSize; // Skip the File Info substream. bits.Position += dh.filinfSize; // Skip the TSM substream. bits.Position += dh.tsmapSize; // Skip the EC substream. bits.Position += dh.ecinfoSize; // Read the optional header. end = bits.Position + dh.dbghdrSize; if (dh.dbghdrSize > 0) { header = new DbiDbgHdr(bits); } bits.Position = end; }