예제 #1
0
        void ReadFunctions(DataReader reader)
        {
            if (reader.ReadUInt32() != 4)
            {
                throw new PdbException("Invalid signature");
            }

            while (reader.Position < reader.Length)
            {
                var size  = reader.ReadUInt16();
                var begin = reader.Position;
                var end   = begin + size;

                var type = (SymbolType)reader.ReadUInt16();
                switch (type)
                {
                case SymbolType.S_GMANPROC:
                case SymbolType.S_LMANPROC:
                    var func = new DbiFunction();
                    func.Read(ref reader, end);
                    Functions.Add(func);
                    break;

                default:
                    reader.Position = end;
                    break;
                }
            }
        }
예제 #2
0
        void ReadLines(PdbReader pdbReader, DataReader reader)
        {
            var docs = new Dictionary <uint, DbiDocument>();

            reader.Position = 0;
            while (reader.Position < reader.Length)
            {
                var sig   = (ModuleStreamType)reader.ReadUInt32();
                var size  = reader.ReadUInt32();
                var begin = reader.Position;
                var end   = (begin + size + 3) & ~3U;

                if (sig == ModuleStreamType.FileInfo)
                {
                    ReadFiles(pdbReader, docs, ref reader, end);
                }

                reader.Position = end;
            }

            var sortedFuncs = new DbiFunction[Functions.Count];

            Functions.CopyTo(sortedFuncs, 0);
            Array.Sort(sortedFuncs, (a, b) => a.Address.CompareTo(b.Address));

            reader.Position = 0;
            while (reader.Position < reader.Length)
            {
                var sig   = (ModuleStreamType)reader.ReadUInt32();
                var size  = reader.ReadUInt32();
                var begin = reader.Position;
                var end   = begin + size;

                if (sig == ModuleStreamType.Lines)
                {
                    ReadLines(sortedFuncs, docs, ref reader, end);
                }

                reader.Position = end;
            }
        }