コード例 #1
0
ファイル: DbiModule.cs プロジェクト: slamj1/dnlib
        public void Read(IImageStream stream)
        {
            stream.Position += 34;
            StreamId         = stream.ReadUInt16();
            cbSyms           = stream.ReadUInt32();
            cbOldLines       = stream.ReadUInt32();
            cbLines          = stream.ReadUInt32();
            stream.Position += 16;

            if ((int)cbSyms < 0)
            {
                cbSyms = 0;
            }
            if ((int)cbOldLines < 0)
            {
                cbOldLines = 0;
            }
            if ((int)cbLines < 0)
            {
                cbLines = 0;
            }

            ModuleName = PdbReader.ReadCString(stream);
            ObjectName = PdbReader.ReadCString(stream);

            stream.Position = (stream.Position + 3) & (~3);
        }
コード例 #2
0
        public void Read(ref DataReader reader)
        {
            reader.Position += 34;
            StreamId         = reader.ReadUInt16();
            cbSyms           = reader.ReadUInt32();
            cbOldLines       = reader.ReadUInt32();
            cbLines          = reader.ReadUInt32();
            reader.Position += 16;

            if ((int)cbSyms < 0)
            {
                cbSyms = 0;
            }
            if ((int)cbOldLines < 0)
            {
                cbOldLines = 0;
            }
            if ((int)cbLines < 0)
            {
                cbLines = 0;
            }

            ModuleName = PdbReader.ReadCString(ref reader);
            ObjectName = PdbReader.ReadCString(ref reader);

            reader.Position = (reader.Position + 3) & (~3U);
        }
コード例 #3
0
 public void Read(IImageStream stream)
 {
     Addr1            = stream.ReadUInt32();
     stream.Position += 10;
     Flags            = stream.ReadUInt16();
     Name             = PdbReader.ReadCString(stream);
 }
コード例 #4
0
ファイル: DbiVariable.cs プロジェクト: slamj1/dnlib
 public void Read(IImageStream stream)
 {
     index            = stream.ReadInt32();
     stream.Position += 10;
     attributes       = GetAttributes(stream.ReadUInt16());
     name             = PdbReader.ReadCString(stream);
 }
コード例 #5
0
 public void Read(ref DataReader reader)
 {
     index            = reader.ReadInt32();
     reader.Position += 10;
     attributes       = GetAttributes(reader.ReadUInt16());
     name             = PdbReader.ReadCString(ref reader);
 }
コード例 #6
0
ファイル: DbiScope.cs プロジェクト: zanderphh/ConfuserEx-Plus
        public void Read(RecursionCounter counter, IImageStream stream, uint scopeEnd)
        {
            if (!counter.Increment())
            {
                throw new PdbException("Scopes too deep");
            }

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

                var      type     = (SymbolType)stream.ReadUInt16();
                DbiScope child    = null;
                uint?    childEnd = null;
                switch (type)
                {
                case SymbolType.S_BLOCK32:
                {
                    stream.Position += 4;
                    childEnd         = stream.ReadUInt32();
                    var len  = stream.ReadUInt32();
                    var addr = PdbAddress.ReadAddress(stream);
                    var name = PdbReader.ReadCString(stream);
                    child = new DbiScope(name, addr.Offset, len);
                    break;
                }

                case SymbolType.S_UNAMESPACE:
                    Namespaces.Add(new DbiNamespace(PdbReader.ReadCString(stream)));
                    break;

                case SymbolType.S_MANSLOT:
                {
                    var variable = new DbiVariable();
                    variable.Read(stream);
                    Variables.Add(variable);
                    break;
                }
                }

                stream.Position = end;
                if (child != null)
                {
                    child.Read(counter, stream, childEnd.Value);
                    Children.Add(child);
                    child = null;
                }
            }
            counter.Decrement();
            if (stream.Position != scopeEnd)
            {
                Debugger.Break();
            }
        }
コード例 #7
0
        public bool Read(ref DataReader reader)
        {
            index            = reader.ReadInt32();
            reader.Position += 10;
            ushort flags = reader.ReadUInt16();

            attributes = GetAttributes(flags);
            name       = PdbReader.ReadCString(ref reader);

            const int fIsParam = 1;

            return((flags & fIsParam) == 0);
        }
コード例 #8
0
ファイル: DbiFunction.cs プロジェクト: liangran10000/dnlib-1
        public void Read(IImageStream stream, long recEnd)
        {
            stream.Position += 4;
            var end = stream.ReadUInt32();

            stream.Position += 4;
            var len = stream.ReadUInt32();

            stream.Position += 8;
            Token            = stream.ReadUInt32();
            Address          = PdbAddress.ReadAddress(stream);
            stream.Position += 1 + 2;
            Name             = PdbReader.ReadCString(stream);

            stream.Position = recEnd;
            Root            = new DbiScope("", Address.Offset, len);
            Root.Read(new RecursionCounter(), stream, end);
            FixOffsets(new RecursionCounter(), Root);
        }
コード例 #9
0
        public void Read(RecursionCounter counter, ref DataReader reader, uint scopeEnd)
        {
            if (!counter.Increment())
            {
                throw new PdbException("Scopes too deep");
            }

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

                var      type     = (SymbolType)reader.ReadUInt16();
                DbiScope child    = null;
                uint?    childEnd = null;
                string   name;
                switch (type)
                {
                case SymbolType.S_BLOCK32: {
                    reader.Position += 4;
                    childEnd         = reader.ReadUInt32();
                    var len  = reader.ReadUInt32();
                    var addr = PdbAddress.ReadAddress(ref reader);
                    name  = PdbReader.ReadCString(ref reader);
                    child = new DbiScope(method, this, name, addr.Offset, len);
                    break;
                }

                case SymbolType.S_UNAMESPACE:
                    namespacesList.Add(new DbiNamespace(PdbReader.ReadCString(ref reader)));
                    break;

                case SymbolType.S_MANSLOT: {
                    var variable = new DbiVariable();
                    if (variable.Read(ref reader))
                    {
                        localsList.Add(variable);
                    }
                    break;
                }

                case SymbolType.S_OEM:
                    if ((ulong)reader.Position + 20 > end)
                    {
                        break;
                    }
                    if (!ReadAndCompareBytes(ref reader, end, dotNetOemGuid))
                    {
                        Debug.Fail("Unknown OEM record GUID, not .NET GUID");
                        break;
                    }
                    reader.Position += 4;                            // typeIndex or 0
                    name             = ReadUnicodeString(ref reader, end);
                    Debug.Assert(name != null);
                    if (name == null)
                    {
                        break;
                    }
                    var data = reader.ReadBytes((int)(end - reader.Position));
                    if (oemInfos == null)
                    {
                        oemInfos = new List <OemInfo>(1);
                    }
                    oemInfos.Add(new OemInfo(name, data));
                    break;

                case SymbolType.S_MANCONSTANT:
                    uint   signatureToken = reader.ReadUInt32();
                    object value;
                    if (!NumericReader.TryReadNumeric(ref reader, end, out value))
                    {
                        break;
                    }
                    name = PdbReader.ReadCString(ref reader);
                    if (constants == null)
                    {
                        constants = new List <ConstantInfo>();
                    }
                    constants.Add(new ConstantInfo(name, signatureToken, value));
                    break;

                case SymbolType.S_END:
                    break;

                default:
                    break;
                }

                reader.Position = end;
                if (child != null)
                {
                    child.Read(counter, ref reader, childEnd.Value);
                    childrenList.Add(child);
                    child = null;
                }
            }
            counter.Decrement();
            if (reader.Position != scopeEnd)
            {
                Debugger.Break();
            }
        }