Esempio n. 1
0
        /// <summary>
        /// Reads the specified reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="pageSize">Holds the size of a single page in the file.</param>
        /// <param name="rootStream">The root stream.</param>
        /// <returns></returns>
        public static bool Read(BinaryReader reader, int pageSize, out PdbRootStream rootStream)
        {
            rootStream.streams = reader.ReadInt32();
            Debug.WriteLine(String.Format(@"PdbRootStream: PDB file contains {0} streams.", rootStream.streams));
            rootStream.streamLength = new int[rootStream.streams];
            rootStream.streamPages  = new int[rootStream.streams][];
            for (int i = 0; i < rootStream.streams; i++)
            {
                rootStream.streamLength[i] = reader.ReadInt32();
            }

            for (int i = 0; i < rootStream.streams; i++)
            {
                Debug.WriteLine(String.Format("\tPDB Stream #{0} (Length {1} bytes)", i, rootStream.streamLength[i]));
                if (rootStream.streamLength[i] > 0)
                {
                    rootStream.streamPages[i] = new int[(rootStream.streamLength[i] / pageSize) + 1];
                    for (int j = 0; j < rootStream.streamPages[i].Length; j++)
                    {
                        rootStream.streamPages[i][j] = reader.ReadInt32();
                        Debug.WriteLine(String.Format("\t\tPage {0} (at offset {1})", rootStream.streamPages[i][j], rootStream.streamPages[i][j] * pageSize));
                    }
                }
            }

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Reads the specified reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="pageSize">Holds the size of a single page in the file.</param>
        /// <param name="rootStream">The root stream.</param>
        /// <returns></returns>
        public static bool Read(BinaryReader reader, int pageSize, out PdbRootStream rootStream)
        {
            rootStream.streams = reader.ReadInt32();
            Debug.WriteLine(String.Format(@"PdbRootStream: PDB file contains {0} streams.", rootStream.streams));
            rootStream.streamLength = new int[rootStream.streams];
            rootStream.streamPages = new int[rootStream.streams][];
            for (int i = 0; i < rootStream.streams; i++)
                rootStream.streamLength[i] = reader.ReadInt32();

            for (int i = 0; i < rootStream.streams; i++)
            {
                Debug.WriteLine(String.Format("\tPDB Stream #{0} (Length {1} bytes)", i, rootStream.streamLength[i]));
                if (rootStream.streamLength[i] > 0)
                {
                    rootStream.streamPages[i] = new int[(rootStream.streamLength[i] / pageSize) + 1];
                    for (int j = 0; j < rootStream.streamPages[i].Length; j++)
                    {
                        rootStream.streamPages[i][j] = reader.ReadInt32();
                        Debug.WriteLine(String.Format("\t\tPage {0} (at offset {1})", rootStream.streamPages[i][j], rootStream.streamPages[i][j] * pageSize));
                    }
                }
            }

            return true;
        }
Esempio n. 3
0
        /// <summary>
        /// Loads the root stream.
        /// </summary>
        private void LoadRootStream()
        {
            // The root stream length
            int dwStreamLength = this.header.dwRootBytes;
            // Calculate the number of pages of the root stream
            int pageCount = (dwStreamLength / this.header.dwPageSize) + 1;

            // Allocate page list
            int[] pages = new int[pageCount];

            // Read the pages
            this.stream.Position = this.header.dwIndexPage * this.header.dwPageSize;
            for (int i = 0; i < pageCount; i++)
            {
                pages[i] = this.reader.ReadInt32();
                Debug.WriteLine(String.Format(@"PdbReader: Root stream page {0} (at offset {1})", pages[i], pages[i] * this.header.dwPageSize));
            }

            using (PdbStream pdbStream = GetStream(pages, dwStreamLength))
                using (BinaryReader rootReader = new BinaryReader(pdbStream))
                {
                    PdbRootStream.Read(rootReader, this.header.dwPageSize, out this.root);
                }
        }