Пример #1
0
        /// <summary>
        /// </summary>
        /// <param name="bits">
        /// </param>
        /// <param name="modules">
        /// </param>
        /// <param name="header">
        /// </param>
        /// <param name="readStrings">
        /// </param>
        /// <exception cref="PdbException">
        /// </exception>
        /// <exception cref="PdbDebugException">
        /// </exception>
        private static void LoadDbiStream(BitAccess bits, out DbiModuleInfo[] modules, out DbiDbgHdr header, bool readStrings)
        {
            var 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.
            var modList = new ArrayList();
            var end = bits.Position + dh.gpmodiSize;
            while (bits.Position < end)
            {
                var 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;
        }