Exemple #1
0
        internal void Read(PdbReader reader, int position,
                           byte[] bytes, int offset, int data)
        {
            if (position + data > contentSize)
            {
                throw new PdbException("DataStream can't read off end of stream. " +
                                       "(pos={0},siz={1})",
                                       position, data);
            }
            if (position == contentSize)
            {
                return;
            }

            int left = data;
            int page = position / reader.pageSize;
            int rema = position % reader.pageSize;

            // First get remained of first page.
            if (rema != 0)
            {
                int todo = reader.pageSize - rema;
                if (todo > left)
                {
                    todo = left;
                }

                reader.Seek(pages[page], rema);
                reader.Read(bytes, offset, todo);

                offset += todo;
                left   -= todo;
                page++;
            }

            // Now get the remaining pages.
            while (left > 0)
            {
                int todo = reader.pageSize;
                if (todo > left)
                {
                    todo = left;
                }

                reader.Seek(pages[page], 0);
                reader.Read(bytes, offset, todo);

                offset += todo;
                left   -= todo;
                page++;
            }
        }
Exemple #2
0
        private string ReadHashInternal(string pdbFileHash)
        {
            var bits = new BitAccess(0);

            using (var read = File.Open(pdbFileHash, FileMode.Open))
            {
                var head   = new PdbFileHeader(read, bits);
                var reader = new PdbReader(read, head.pageSize);
                var dir    = new MsfDirectory(reader, head, bits);

                bits.MinCapacity(28);
                reader.Seek(dir.streams[1].pages[0], 0);
                reader.Read(bits.Buffer, 0, 28);

                int  ver;
                int  sig;
                int  age;
                Guid guid;
                bits.ReadInt32(out ver); //  0..3  Version
                bits.ReadInt32(out sig); //  4..7  Signature
                bits.ReadInt32(out age); //  8..11 Age
                bits.ReadGuid(out guid); // 12..27 GUID
                return((guid.ToString("N") + age.ToString("x")).ToUpper());
            }
        }
Exemple #3
0
        /// <summary>
        /// </summary>
        /// <param name="reader">
        /// </param>
        /// <param name="position">
        /// </param>
        /// <param name="bytes">
        /// </param>
        /// <param name="offset">
        /// </param>
        /// <param name="data">
        /// </param>
        /// <exception cref="PdbException">
        /// </exception>
        internal void Read(PdbReader reader, int position, byte[] bytes, int offset, int data)
        {
            if (position + data > this.contentSize)
            {
                throw new PdbException("DataStream can't read off end of stream. " + "(pos={0},siz={1})", position, data);
            }

            if (position == this.contentSize)
            {
                return;
            }

            var left = data;
            var page = position / reader.pageSize;
            var rema = position % reader.pageSize;

            // First get remained of first page.
            if (rema != 0)
            {
                var todo = reader.pageSize - rema;
                if (todo > left)
                {
                    todo = left;
                }

                reader.Seek(this.pages[page], rema);
                reader.Read(bytes, offset, todo);

                offset += todo;
                left -= todo;
                page++;
            }

            // Now get the remaining pages.
            while (left > 0)
            {
                var todo = reader.pageSize;
                if (todo > left)
                {
                    todo = left;
                }

                reader.Seek(this.pages[page], 0);
                reader.Read(bytes, offset, todo);

                offset += todo;
                left -= todo;
                page++;
            }
        }