Esempio n. 1
0
        /// <summary>
        /// </summary>
        /// <param name="read">
        /// </param>
        /// <param name="bits">
        /// </param>
        /// <param name="readAllStrings">
        /// </param>
        /// <returns>
        /// </returns>
        /// <exception cref="PdbException">
        /// </exception>
        internal static PdbFunction[] LoadFunctions(Stream read, BitAccess bits, bool readAllStrings)
        {
            var head   = new PdbFileHeader(read, bits);
            var reader = new PdbReader(read, head.pageSize);
            var dir    = new MsfDirectory(reader, head, bits);

            DbiModuleInfo[] modules = null;
            DbiDbgHdr       header;

            dir.streams[1].Read(reader, bits);
            var nameIndex = LoadNameIndex(bits);
            int nameStream;

            if (!nameIndex.TryGetValue("/names", out nameStream))
            {
                throw new PdbException("No `name' stream");
            }

            dir.streams[nameStream].Read(reader, bits);
            var names = LoadNameStream(bits);

            dir.streams[3].Read(reader, bits);
            LoadDbiStream(bits, out modules, out header, readAllStrings);

            var funcList = new ArrayList();

            if (modules != null)
            {
                for (var m = 0; m < modules.Length; m++)
                {
                    if (modules[m].stream > 0)
                    {
                        dir.streams[modules[m].stream].Read(reader, bits);
                        LoadFuncsFromDbiModule(bits, modules[m], names, funcList, readAllStrings, dir, nameIndex, reader);
                    }
                }
            }

            var funcs = (PdbFunction[])funcList.ToArray(typeof(PdbFunction));

            // After reading the functions, apply the token remapping table if it exists.
            if (header.snTokenRidMap != 0 && header.snTokenRidMap != 0xffff)
            {
                dir.streams[header.snTokenRidMap].Read(reader, bits);
                var ridMap = new uint[dir.streams[header.snTokenRidMap].Length / 4];
                bits.ReadUInt32(ridMap);

                foreach (var func in funcs)
                {
                    func.token = 0x06000000 | ridMap[func.token & 0xffffff];
                }
            }

            //Array.Sort(funcs, PdbFunction.byAddress);
            Array.Sort(funcs, PdbFunction.byToken);

            return(funcs);
        }
Esempio n. 2
0
        /// <summary>
        /// </summary>
        /// <param name="read">
        /// </param>
        /// <param name="bits">
        /// </param>
        /// <param name="readAllStrings">
        /// </param>
        /// <returns>
        /// </returns>
        /// <exception cref="PdbException">
        /// </exception>
        internal static PdbFunction[] LoadFunctions(Stream read, BitAccess bits, bool readAllStrings)
        {
            var head = new PdbFileHeader(read, bits);
            var reader = new PdbReader(read, head.pageSize);
            var dir = new MsfDirectory(reader, head, bits);
            DbiModuleInfo[] modules = null;
            DbiDbgHdr header;

            dir.streams[1].Read(reader, bits);
            var nameIndex = LoadNameIndex(bits);
            int nameStream;
            if (!nameIndex.TryGetValue("/names", out nameStream))
            {
                throw new PdbException("No `name' stream");
            }

            dir.streams[nameStream].Read(reader, bits);
            var names = LoadNameStream(bits);

            dir.streams[3].Read(reader, bits);
            LoadDbiStream(bits, out modules, out header, readAllStrings);

            var funcList = new ArrayList();

            if (modules != null)
            {
                for (var m = 0; m < modules.Length; m++)
                {
                    if (modules[m].stream > 0)
                    {
                        dir.streams[modules[m].stream].Read(reader, bits);
                        LoadFuncsFromDbiModule(bits, modules[m], names, funcList, readAllStrings, dir, nameIndex, reader);
                    }
                }
            }

            var funcs = (PdbFunction[])funcList.ToArray(typeof(PdbFunction));

            // After reading the functions, apply the token remapping table if it exists.
            if (header.snTokenRidMap != 0 && header.snTokenRidMap != 0xffff)
            {
                dir.streams[header.snTokenRidMap].Read(reader, bits);
                var ridMap = new uint[dir.streams[header.snTokenRidMap].Length / 4];
                bits.ReadUInt32(ridMap);

                foreach (var func in funcs)
                {
                    func.token = 0x06000000 | ridMap[func.token & 0xffffff];
                }
            }

            //Array.Sort(funcs, PdbFunction.byAddress);
            Array.Sort(funcs, PdbFunction.byToken);

            return funcs;
        }
Esempio n. 3
0
        /// <summary>
        /// </summary>
        /// <param name="streams">
        /// </param>
        /// <param name="bits">
        /// </param>
        internal void WriteMeta(DataStream[] streams, BitAccess bits)
        {
            var head = new PdbFileHeader(this.pageSize);

            this.WriteDirectory(streams, out head.directoryRoot, out head.directorySize, bits);
            this.WriteFreeMap();

            head.freePageMap = 2;
            head.pagesUsed   = this.usedBytes / this.pageSize;

            this.writer.Seek(0, SeekOrigin.Begin);
            head.Write(this.writer, bits);
        }
Esempio n. 4
0
        /// <summary>
        /// </summary>
        /// <param name="streams">
        /// </param>
        /// <param name="bits">
        /// </param>
        internal void WriteMeta(DataStream[] streams, BitAccess bits)
        {
            var head = new PdbFileHeader(this.pageSize);

            this.WriteDirectory(streams, out head.directoryRoot, out head.directorySize, bits);
            this.WriteFreeMap();

            head.freePageMap = 2;
            head.pagesUsed = this.usedBytes / this.pageSize;

            this.writer.Seek(0, SeekOrigin.Begin);
            head.Write(this.writer, bits);
        }