示例#1
0
        private void ReadFunctions(IImageStream stream)
        {
            if (stream.ReadUInt32() != 4)
            {
                throw new PdbException("Invalid signature");
            }

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

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

                default:
                    stream.Position = end;
                    break;
                }
            }
        }
示例#2
0
        private void ReadLines(PdbReader reader, IImageStream stream)
        {
            var docs = new Dictionary <long, DbiDocument>();

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

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

                stream.Position = end;
            }

            var sortedFuncs = new DbiFunction[Functions.Count];

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

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

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

                stream.Position = end;
            }
        }