Ejemplo n.º 1
0
            bool CheckOffsetToken(uint value)
            {
                switch (GoToMetadataKind)
                {
                case GoToMetadataKind.Blob:
                    if (mdHeaders.BlobStream == null)
                    {
                        return(false);
                    }
                    return(value < mdHeaders.BlobStream.Span.Span.Length);

                case GoToMetadataKind.Strings:
                    if (mdHeaders.StringsStream == null)
                    {
                        return(false);
                    }
                    return(value < mdHeaders.StringsStream.Span.Span.Length);

                case GoToMetadataKind.US:
                    if ((value >> 24) == 0x70)
                    {
                        value &= 0x00FFFFFF;
                    }
                    if (mdHeaders.USStream == null)
                    {
                        return(false);
                    }
                    return(value < mdHeaders.USStream.Span.Span.Length);

                case GoToMetadataKind.GUID:
                    return(value != 0 && mdHeaders.GUIDStream?.IsValidIndex(value) == true);

                case GoToMetadataKind.Table:
                    return(GetMDTable(value) != null);

                case GoToMetadataKind.MemberRva:
                    if (peHeaders == null)
                    {
                        return(false);
                    }
                    var mdTable = GetMDTable(value);
                    if (mdTable == null)
                    {
                        return(false);
                    }
                    if (mdTable.Table != Table.Method && mdTable.Table != Table.FieldRVA)
                    {
                        return(false);
                    }
                    // Column 0 is the RVA in both Method and FieldRVA tables
                    var pos = mdTable.Span.Start + ((value & 0x00FFFFFF) - 1) * mdTable.RowSize;
                    return(buffer.ReadUInt32(pos) != 0);

                default:
                    throw new InvalidOperationException();
                }
            }
Ejemplo n.º 2
0
        uint ReadFieldValue(HexBuffer buffer, ColumnInfo col)
        {
            var start = Span.Start + (ulong)col.Offset;

            if (col.Size == 2)
            {
                return(buffer.ReadUInt16(start));
            }
            else if (col.Size == 4)
            {
                return(buffer.ReadUInt32(start));
            }
            throw new InvalidOperationException();
        }
Ejemplo n.º 3
0
        HexSpan?GetResourceSpan(HexBuffer buffer, uint offset)
        {
            var start = ResourcesSpan.Start + offset;

            if (start + 4 > ResourcesSpan.End)
            {
                return(null);
            }
            uint size = buffer.ReadUInt32(start);
            var  end  = start + 4 + size;

            if (end > ResourcesSpan.End)
            {
                return(null);
            }
            return(HexSpan.FromBounds(start, end));
        }
Ejemplo n.º 4
0
 public UInt32FlagsHexField(HexBuffer buffer, string parentName, string name, HexPosition start)
     : base(buffer, parentName, name, start, 4)
 {
     data = new UInt32VM(buffer.ReadUInt32(start), a => UpdateValue(), false);
 }
Ejemplo n.º 5
0
 public UInt32HexField(HexBuffer buffer, string parentName, string name, HexPosition start, bool useDecimal = false)
     : base(buffer, parentName, name, start, 4)
 {
     data = new UInt32VM(buffer.ReadUInt32(start), a => UpdateValue(), useDecimal);
 }