Пример #1
0
        public PdbRoot(PdbStream stream)
        {
            Argument.IsNotNull(() => stream);

            Stream = stream;
            Streams = new List<PdbStream>();
        }
Пример #2
0
        public byte[] ReadPdbStreamBytes(PdbStream pdbStream)
        {
            Argument.IsNotNull(() => pdbStream);

            return ReadStreamBytes(pdbStream);
        }
Пример #3
0
 private BinaryReader StreamReader(PdbStream stream)
 {
     return new BinaryReader(ReadStream(stream));
 }
Пример #4
0
 private MemoryStream ReadStream(PdbStream stream)
 {
     return new MemoryStream(ReadStreamBytes(stream));
 }
Пример #5
0
        private byte[] ReadStreamBytes(PdbStream stream)
        {
            Argument.IsNotNull(() => stream);

            var bytes = new byte[stream.ByteCount];
            var pages = stream.Pages;

            if (pages.Length != 0)
            {
                for (var i = 0; i < pages.Length - 1; i++)
                {
                    ReadPage(bytes, pages[i], i * _pageByteCount, _pageByteCount);
                }

                var j = pages.Length - 1;
                ReadPage(bytes, pages[j], j * _pageByteCount, (stream.ByteCount - j * _pageByteCount));
            }

            return bytes;
        }
Пример #6
0
        public PdbStream GetRootPdbStream()
        {
            var pdbStream = new PdbStream();
            pdbStream.ByteCount = _rootByteCount;
            pdbStream.Pages = new int[CountPages(_rootByteCount)];

            GoToPage(RootPage);

            for (var i = 0; i < pdbStream.Pages.Length; i++)
            {
                pdbStream.Pages[i] = _br.ReadInt32();
            }

            return pdbStream;
        }
Пример #7
0
        private PdbRoot ReadRoot(PdbStream streamRoot)
        {
            Argument.IsNotNull(() => streamRoot);

            var root = new PdbRoot(streamRoot);
            using (var brDirectory = StreamReader(streamRoot))
            {
                var streamCount = brDirectory.ReadInt32();
                if (streamCount != 0x0131CA0B)
                {
                    var streams = root.Streams;
                    for (var i = 0; i < streamCount; i++)
                    {
                        var stream = new PdbStream();
                        streams.Add(stream);

                        var byteCount = brDirectory.ReadInt32();
                        stream.ByteCount = byteCount;

                        var pageCount = CountPages(byteCount);
                        stream.Pages = new int[pageCount];
                    }

                    for (var i = 0; i < streamCount; i++)
                    {
                        for (var j = 0; j < streams[i].Pages.Length; j++)
                        {
                            var page = brDirectory.ReadInt32();
                            streams[i].Pages[j] = page;
                        }
                    }
                }
            }

            return root;
        }
Пример #8
0
        public int AddStream(PdbStream stream)
        {
            Streams.Add(stream);

            return Streams.Count - 1;
        }