示例#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
文件: DbiModule.cs 项目: slamj1/dnlib
        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;
                }
            }
        }
示例#3
0
文件: PdbReader.cs 项目: slamj1/dnlib
        internal void GetCustomDebugInfos(DbiFunction symMethod, MethodDef method, CilBody body, IList <PdbCustomDebugInfo> result)
        {
            const string CDI_NAME    = "MD2";
            var          asyncMethod = PseudoCustomDebugInfoFactory.TryCreateAsyncMethod(method.Module, method, body, symMethod.AsyncKickoffMethod, symMethod.AsyncStepInfos, symMethod.AsyncCatchHandlerILOffset);

            if (asyncMethod != null)
            {
                result.Add(asyncMethod);
            }

            var cdiData = symMethod.Root.GetSymAttribute(CDI_NAME);

            if (cdiData == null)
            {
                return;
            }
            PdbCustomDebugInfoReader.Read(method, body, result, cdiData);
        }
示例#4
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;
            }
        }
示例#5
0
文件: DbiModule.cs 项目: slamj1/dnlib
        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;
            }
        }
示例#6
0
		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;
				}
			}
		}
示例#7
0
文件: DbiModule.cs 项目: bprg/dnlib
        void ReadLines(DbiFunction[] funcs, Dictionary<long, DbiDocument> documents, IImageStream stream, long end)
        {
            var address = PdbAddress.ReadAddress(stream);

            int first = 0;
            int last = funcs.Length - 1;
            int found = -1;
            while (first <= last) {
                var index = first + ((last - first) >> 1);
                var addr = funcs[index].Address;
                if (addr < address) {
                    first = index + 1;
                }
                else if (addr > address) {
                    last = index - 1;
                }
                else {
                    found = index;
                    break;
                }
            }
            if (found == -1)
                return;

            var flags = stream.ReadUInt16();
            stream.Position += 4;

            if (funcs[found].Lines == null) {
                while (found > 0) {
                    var prevFunc = funcs[found - 1];
                    if (prevFunc != null || prevFunc.Address != address)
                        break;
                    found--;
                }
            }
            else {
                while (found < funcs.Length - 1 && funcs[found] != null) {
                    var nextFunc = funcs[found + 1];
                    if (nextFunc.Address != address)
                        break;
                    found++;
                }
            }
            var func = funcs[found];
            if (func.Lines != null)
                return;
            func.Lines = new List<DbiSourceLine>();

            while (stream.Position < end) {
                var document = documents[stream.ReadUInt32()];
                var count = stream.ReadUInt32();
                stream.Position += 4;

                const int LINE_ENTRY_SIZE = 8;
                const int COL_ENTRY_SIZE = 4;
                var lineTablePos = stream.Position;
                var colTablePos = stream.Position + count * LINE_ENTRY_SIZE;

                for (uint i = 0; i < count; i++) {
                    stream.Position = lineTablePos + i * LINE_ENTRY_SIZE;

                    var line = new DbiSourceLine {
                        Document = document
                    };
                    line.Offset = stream.ReadUInt32();
                    var lineFlags = stream.ReadUInt32();

                    line.LineBegin = lineFlags & 0x00ffffff;
                    line.LineEnd = line.LineBegin + ((lineFlags >> 24) & 0x7F);
                    if ((flags & 1) != 0) {
                        stream.Position = colTablePos + i * COL_ENTRY_SIZE;
                        line.ColumnBegin = stream.ReadUInt16();
                        line.ColumnEnd = stream.ReadUInt16();
                    }

                    func.Lines.Add(line);
                }
            }
        }
示例#8
0
文件: DbiModule.cs 项目: bprg/dnlib
        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;
            }
        }