Esempio n. 1
0
 public override void Parse(CLRMetaDataParser parser)
 {
     Parent = parser.ReadHasCustomAttribute();
     Constructor = parser.ReadCustomAttributeType();
     m_rawValue = parser.ReadBlob();
     m_tables = parser.Tables;
 }
Esempio n. 2
0
        public override void Parse(CLRMetaDataParser parser)
        {
            if (parser.ReadU16() != 0)
                throw new ParseFailedException("Bad Generation value");
            Name = parser.ReadString();
            Mvid = parser.ReadGuid();
            CLRGuid encId = parser.ReadGuid();
            CLRGuid encBaseId = parser.ReadGuid();

            if (encId != null || encBaseId != null)
                throw new ParseFailedException("Unexpected EncId/EncBaseId values");
        }
Esempio n. 3
0
        public override void Parse(CLRMetaDataParser parser)
        {
            Offset = parser.ReadU32();
            uint flags = parser.ReadU32();
            uint visibility = (flags & 0x7);

            if (visibility < 0x1 || visibility > 0x2)
                throw new ParseFailedException("Unexpected visibility on manifest resource");
            Visibility = (ManifestResourceVisibility)visibility;

            Name = parser.ReadString();
            Implementation = parser.ReadImplementation();
        }
Esempio n. 4
0
        public override void Parse(CLRMetaDataParser parser)
        {
            uint semantics = parser.ReadU16();
            Setter = ((semantics & 0x1) != 0);
            Getter = ((semantics & 0x2) != 0);
            Other = ((semantics & 0x4) != 0);
            AddOn = ((semantics & 0x8) != 0);
            RemoveOn = ((semantics & 0x10) != 0);
            Fire = ((semantics & 0x20) != 0);

            Method = (CLRMethodDefRow)parser.ReadTable(CLRMetaDataTables.TableIndex.MethodDef);
            Association = parser.ReadHasSemantics();
        }
Esempio n. 5
0
        public override void Parse(CLRMetaDataParser parser)
        {
            Number = parser.ReadU16();
            uint flags = parser.ReadU16();
            Owner = parser.ReadTypeOrMethodDef();
            Name = parser.ReadString();

            Constraints = new List<CLRGenericParamConstraintRow>();

            Variance = (VarianceEnum)(flags & 0x3);

            ReferenceTypeConstraint = ((flags & 0x4) != 0);
            NotNullableValueTypeConstraint = ((flags & 0x8) != 0);
            DefaultConstructorConstraint = ((flags & 0x10) != 0);
        }
Esempio n. 6
0
        public override void Parse(CLRMetaDataParser parser)
        {
            Type = (CLRSigType.ElementType)parser.ReadU8();
            if (parser.ReadU8() != 0)
                throw new ParseFailedException("Pad missing");

            Parent = parser.ReadHasConstant();
            Value = parser.ReadBlob();

            ICLRHasConstant hcParent = (ICLRHasConstant)Parent;
            CLRConstantRow[] newConstants;
            if (hcParent.AttachedConstants != null)
            {
                CLRConstantRow[] oldConstants = hcParent.AttachedConstants;
                newConstants = new CLRConstantRow[oldConstants.Length + 1];
                for (int i = 0; i < oldConstants.Length; i++)
                    newConstants[i] = oldConstants[i];
            }
            else
                newConstants = new CLRConstantRow[1];
            newConstants[newConstants.Length - 1] = this;
            hcParent.AttachedConstants = newConstants;
        }
Esempio n. 7
0
        public override void Parse(CLRMetaDataParser parser)
        {
            MajorVersion = parser.ReadU16();
            MinorVersion = parser.ReadU16();
            BuildNumber = parser.ReadU16();
            RevisionNumber = parser.ReadU16();
            uint flags = parser.ReadU32();
            PublicKeyOrToken = parser.ReadBlob();
            Name = parser.ReadString();
            Culture = parser.ReadString();
            HashValue = parser.ReadBlob();

            HasPublicKey = ((flags & 0x1) != 0);
            Retargetable = ((flags & 0x100) != 0);
            DisableJITcompileOptimizer = ((flags & 0x4000) != 0);
            EnableJITcompileTracking = ((flags & 0x8000) != 0);
        }
Esempio n. 8
0
 public override void Parse(CLRMetaDataParser parser)
 {
     Class = (CLRTypeDefRow)parser.ReadTable(CLRMetaDataTables.TableIndex.TypeDef);
     Interface = parser.ReadTypeDefOrRefOrSpec();
 }
Esempio n. 9
0
            public CLRTableRow Parse(CLRMetaDataParser parser, CLRMetaDataTables tables)
            {
                uint code = parser.ReadU16();

                uint tag = (code & m_tagMask);
                if (tag > m_maxTag)
                    throw new ParseFailedException("Invalid coded tag");
                ICLRTable table = tables.GetTable((int)m_tableIndexes[tag]);
                if (table.NumRows > m_maxCompactRows)
                {
                    uint highCode = parser.ReadU16();
                    code |= (highCode << 16);
                }
                uint row = code >> (int)m_tagBits;
                if (row == 0)
                    return null;
                return table.GetRow(row - 1);
            }
Esempio n. 10
0
        public override void Parse(CLRMetaDataParser parser)
        {
            HashAlgId = (AssemblyHashAlgorithm)parser.ReadU32();
            if (HashAlgId != AssemblyHashAlgorithm.None && HashAlgId != AssemblyHashAlgorithm.ReservedMD5 && HashAlgId != AssemblyHashAlgorithm.SHA1)
                throw new ParseFailedException("Unknown hash algorith");
            MajorVersion = parser.ReadU16();
            MinorVersion = parser.ReadU16();
            BuildNumber = parser.ReadU16();
            RevisionNumber = parser.ReadU16();

            uint flags = parser.ReadU32();

            PublicKey = parser.ReadBlob();
            Name = parser.ReadString();
            Culture = parser.ReadString();

            HasPublicKey = ((flags & 0x1) != 0);
            Retargetable = ((flags & 0x100) != 0);
            DisableJITcompileOptimizer = ((flags & 0x4000) != 0);
            EnableJITcompileTracking = ((flags & 0x8000) != 0);
        }
Esempio n. 11
0
 public override void Parse(CLRMetaDataParser parser)
 {
     ResolutionScope = parser.ReadResolutionScope();
     TypeName = parser.ReadString();
     TypeNamespace = parser.ReadString();
 }
Esempio n. 12
0
 public override void ResolveSpans(CLRTableRow nextRow, CLRMetaDataParser parser)
 {
     Fields = CLRSpanResolver<CLRTypeDefRow, CLRFieldRow>.Resolve(this, nextRow, ref m_firstField, parser,
         CLRMetaDataTables.TableIndex.Field, nextRowTyped => { return nextRowTyped.m_firstField; });
     MethodDefs = CLRSpanResolver<CLRTypeDefRow, CLRMethodDefRow>.Resolve(this, nextRow, ref m_firstMethodDef, parser,
         CLRMetaDataTables.TableIndex.MethodDef, nextRowTyped => { return nextRowTyped.m_firstMethodDef; });
 }
Esempio n. 13
0
 public override void Parse(CLRMetaDataParser parser)
 {
     PackingSize = parser.ReadU16();
     ClassSize = parser.ReadU32();
     Parent = (CLRTypeDefRow)parser.ReadTable(CLRMetaDataTables.TableIndex.TypeDef);
 }
Esempio n. 14
0
 public override void Parse(CLRMetaDataParser parser)
 {
     Method = parser.ReadMethodDefOrRef();
     Instantiation = new CLRSigMethodSpec(new CLRSignatureParser(parser.ReadBlob(), parser.Tables));
 }
Esempio n. 15
0
 public override void Parse(CLRMetaDataParser parser)
 {
     RVA = parser.ReadU32();
     Field = (CLRFieldRow)parser.ReadTable(CLRMetaDataTables.TableIndex.Field);
 }
Esempio n. 16
0
 public virtual void ResolveSpans(CLRTableRow nextRow, CLRMetaDataParser parser)
 {
 }
Esempio n. 17
0
 public virtual void Parse(CLRMetaDataParser parser)
 {
     throw new NotImplementedException();
 }
Esempio n. 18
0
 public override void Parse(CLRMetaDataParser parser)
 {
     Signature = parser.ReadBlob();
 }
Esempio n. 19
0
 public override void Parse(CLRMetaDataParser parser)
 {
     Parent = (CLRTypeDefRow)parser.ReadTable(CLRMetaDataTables.TableIndex.TypeDef);
     m_firstProperty = parser.ReadTableRawRow(CLRMetaDataTables.TableIndex.Property);
 }
 public override void Parse(CLRMetaDataParser parser)
 {
     Owner = (CLRGenericParamRow)parser.ReadTable(CLRMetaDataTables.TableIndex.GenericParam);
     Constraint = parser.ReadTypeDefOrRefOrSpec();
 }
Esempio n. 21
0
        public CLRMetaDataTables(StreamParser parser, CLRMetaData metaData, CLRMetaStreamBinaryData binData)
        {
            MetaData = metaData;

            parser.Skip(4); // Reserved
            byte majorVersion = parser.ReadU8();
            byte minorVersion = parser.ReadU8();

            byte heapSizes = parser.ReadU8();
            parser.Skip(1); // Reserved
            ulong validMask = parser.ReadU64();
            ulong sortedMask = parser.ReadU64();

            m_rowCounts = new uint[64];
            for (int i = 0; i < 64; i++)
            {
                if ((validMask & ((ulong)1 << i)) != 0)
                    m_rowCounts[i] = parser.ReadU32();
            }

            StringOffsets32Bit = ((heapSizes & 1) != 0);
            GuidOffsets32Bit = ((heapSizes & 2) != 0);
            BlobOffsets32Bit = ((heapSizes & 4) != 0);

            if (majorVersion != 2 || minorVersion != 0)
                throw new ParseFailedException("Unknown metadata table version");

            m_clrTables = new ICLRTable[64];
            AddTable(0x00, new CLRTable<CLRModuleRow>());
            AddTable(0x01, new CLRTable<CLRTypeRefRow>());
            AddTable(0x02, new CLRTable<CLRTypeDefRow>());
            AddTable(0x04, new CLRTable<CLRFieldRow>());
            AddTable(0x06, new CLRTable<CLRMethodDefRow>());
            AddTable(0x08, new CLRTable<CLRParamRow>());
            AddTable(0x09, new CLRTable<CLRInterfaceImplRow>());
            AddTable(0x0a, new CLRTable<CLRMemberRefRow>());
            AddTable(0x0b, new CLRTable<CLRConstantRow>());
            AddTable(0x0c, new CLRTable<CLRCustomAttributeRow>());
            AddTable(0x0d, new CLRTable<CLRFieldMarshalRow>());
            AddTable(0x0e, new CLRTable<CLRDeclSecurityRow>());
            AddTable(0x0f, new CLRTable<CLRClassLayoutRow>());
            AddTable(0x10, new CLRTable<CLRFieldLayoutRow>());
            AddTable(0x11, new CLRTable<CLRStandAloneSigRow>());
            AddTable(0x12, new CLRTable<CLREventMapRow>());
            AddTable(0x14, new CLRTable<CLREventRow>());
            AddTable(0x15, new CLRTable<CLRPropertyMapRow>());
            AddTable(0x17, new CLRTable<CLRPropertyRow>());
            AddTable(0x18, new CLRTable<CLRMethodSemanticsRow>());
            AddTable(0x19, new CLRTable<CLRMethodImplRow>());
            AddTable(0x1a, new CLRTable<CLRModuleRefRow>());
            AddTable(0x1b, new CLRTable<CLRTypeSpecRow>());
            AddTable(0x1c, new CLRTable<CLRImplMapRow>());
            AddTable(0x1d, new CLRTable<CLRFieldRVARow>());
            AddTable(0x20, new CLRTable<CLRAssemblyRow>());
            AddTable(0x21, new CLRTable<CLRAssemblyProcessorRow>());
            AddTable(0x22, new CLRTable<CLRAssemblyOSRow>());
            AddTable(0x23, new CLRTable<CLRAssemblyRefRow>());
            AddTable(0x24, new CLRTable<CLRAssemblyRefProcessorRow>());
            AddTable(0x25, new CLRTable<CLRAssemblyRefOSRow>());
            AddTable(0x26, new CLRTable<CLRFileRow>());
            AddTable(0x27, new CLRTable<CLRExportedTypeRow>());
            AddTable(0x28, new CLRTable<CLRManifestResourceRow>());
            AddTable(0x29, new CLRTable<CLRNestedClassRow>());
            AddTable(0x2a, new CLRTable<CLRGenericParamRow>());
            AddTable(0x2c, new CLRTable<CLRGenericParamConstraintRow>());
            AddTable(0x2b, new CLRTable<CLRMethodSpecRow>());

            MetaDataParser = new CLRMetaDataParser(parser, binData, this, StringOffsets32Bit, GuidOffsets32Bit, BlobOffsets32Bit);

            for (int i = 0; i < 64; i++)
            {
                if ((validMask & (ulong)1 << i) != 0)
                {
                    if (m_clrTables[i] == null)
                        throw new ParseFailedException("Unknown table type");
                    m_clrTables[i].Parse(MetaDataParser);
                }
            }
        }
Esempio n. 22
0
        public override void Parse(CLRMetaDataParser parser)
        {
            m_childClasses = new List<CLRTypeDefRow>();
            m_implementedInterfaces = new List<CLRTableRow>();
            m_methodImpls = new List<CLRMethodImplRow>();

            GenericParameters = null;

            uint flags = parser.ReadU32();

            uint vis = flags & 0x07;
            if (vis > 0x07)
                throw new ParseFailedException("Invalid visibility");

            uint layout = flags & 0x18;
            if (layout != 0x0 && layout != 0x08 && layout != 0x10)
                throw new ParseFailedException("Invalid layout");

            uint semantics = flags & 0x20;
            if (semantics != 0 && semantics != 0x20)
                throw new ParseFailedException("Invalid semantics");

            Visibility = (TypeVisibility)vis;
            ClassLayout = (TypeClassLayout)layout;
            Semantics = (TypeSemantics)semantics;
            IsAbstract = (flags & 0x80) != 0;
            IsSealed = (flags & 0x100) != 0;
            IsSpecialName = (flags & 0x400) != 0;
            IsImported = (flags & 0x1000) != 0;
            IsSerializable = (flags & 0x2000) != 0;
            StringFormat = (TypeStringFormat)(flags & 0x30000);
            CustomStringFormat = (byte)((flags & 0xc00000) >> 22);
            IsBeforeFieldInit = (flags & 0x100000) != 0;
            IsRTSpecialName = (flags & 0x800) != 0;
            HasSecurity = (flags & 0x40000) != 0;
            IsTypeForwarder = (flags & 0x200000) != 0;

            TypeName = parser.ReadString();
            TypeNamespace = parser.ReadString();
            Extends = parser.ReadTypeDefOrRefOrSpec();
            m_firstField = parser.ReadTableRawRow(CLRMetaDataTables.TableIndex.Field);
            m_firstMethodDef = parser.ReadTableRawRow(CLRMetaDataTables.TableIndex.MethodDef);

            if (m_firstField == 0 || m_firstMethodDef == 0)
                throw new ParseFailedException("Invalid method/field def span");
        }
Esempio n. 23
0
 public override void ResolveSpans(CLRTableRow nextRow, CLRMetaDataParser parser)
 {
     PropertyList = CLRSpanResolver<CLRPropertyMapRow, CLRPropertyRow>.Resolve(this, nextRow, ref m_firstProperty, parser,
         CLRMetaDataTables.TableIndex.Property, nextRowTyped => { return nextRowTyped.m_firstProperty; });
 }
Esempio n. 24
0
 public override void Parse(CLRMetaDataParser parser)
 {
     Class = (CLRTypeDefRow)parser.ReadTable(CLRMetaDataTables.TableIndex.TypeDef);
     MethodBody = parser.ReadMethodDefOrRef();
     MethodDeclaration = parser.ReadMethodDefOrRef();
 }