Example #1
0
 internal GenericParameter(GenericParameterRow *pRow, PEFile peFile, IGenericParameterScope parent) :
     base(TypeKind.GenericParameter)
 {
     m_pRow   = (GenericParameterRow *)FluentAsserts.CheckNotNull((void *)pRow, "pRow");
     m_peFile = peFile.CheckNotNull("peFile");
     m_parent = parent.CheckNotNull("parent");
 }
Example #2
0
 internal GenericParameter(GenericParameterRow * pRow, PEFile peFile, IGenericParameterScope parent)
     : base(TypeKind.GenericParameter)
 {
     m_pRow = (GenericParameterRow *)FluentAsserts.CheckNotNull((void*) pRow, "pRow");
     m_peFile = peFile.CheckNotNull("peFile");
     m_parent = parent.CheckNotNull("parent");
 }
Example #3
0
 private Module(Assembly assembly, ModuleRow* moduleRow, PEFile peFile)
 {
     m_lockObject = new object();
     m_assembly = assembly.CheckNotNull("assembly");
     m_pModuleRow = (ModuleRow *)FluentAsserts.CheckNotNull((void *)moduleRow, "moduleRow");
     m_peFile = peFile.CheckNotNull("peFile");
     m_containsMetadata = true;
 }
Example #4
0
        internal unsafe MethodImplementation(MethodImplRow* pRow, PEFile peFile)
        {
            FluentAsserts.CheckNotNull((void *)pRow, "pRow");
            peFile.CheckNotNull("peFile");

            m_implementedMethod = new MethodReference(pRow->GetImplementedMethod(peFile));
            m_implementingMethod = new MethodReference(pRow->GetImplementingMethod(peFile));
        }
Example #5
0
 private Module(Assembly assembly, ModuleRow *moduleRow, PEFile peFile)
 {
     m_lockObject       = new object();
     m_assembly         = assembly.CheckNotNull("assembly");
     m_pModuleRow       = (ModuleRow *)FluentAsserts.CheckNotNull((void *)moduleRow, "moduleRow");
     m_peFile           = peFile.CheckNotNull("peFile");
     m_containsMetadata = true;
 }
Example #6
0
        internal unsafe MethodImplementation(MethodImplRow *pRow, PEFile peFile)
        {
            FluentAsserts.CheckNotNull((void *)pRow, "pRow");
            peFile.CheckNotNull("peFile");

            m_implementedMethod  = new MethodReference(pRow->GetImplementedMethod(peFile));
            m_implementingMethod = new MethodReference(pRow->GetImplementingMethod(peFile));
        }
 public OneBasedIndex GetOwner(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (GenericParameterConstraintRow* pThis = &this) {
         if (MetadataTable.GenericParam.IndexSize(peFile) == 2) {
             return new OneBasedIndex(*(ushort*) pThis);
         }
         return new OneBasedIndex(*(uint*) pThis);
     }
 }
Example #8
0
 public uint GetNameOffset(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (FieldRow * pThis = &this) {
         if (StreamID.Strings.IndexSize(peFile) == 2) {
             return *(ushort*) pThis;
         }
         return *(uint*) pThis;
     }
 }
Example #9
0
 public OneBasedIndex GetParent(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (EventMapRow * pThis = &this) {
         if (MetadataTable.TypeDef.IndexSize(peFile) == 2) {
             return new OneBasedIndex(*(ushort*) pThis);
         }
         return new OneBasedIndex(*(uint*) pThis);
     }
 }
Example #10
0
 public OneBasedIndex GetFieldIndex(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (FieldLayoutRow * pThis = &this) {
         byte* pField = (byte *)pThis + 4;
         if (MetadataTable.Field.IndexSize(peFile) == 2) {
             return new OneBasedIndex(*(ushort *)pField);
         }
         return new OneBasedIndex(*(uint*) pField);
     }
 }
Example #11
0
 public uint GetNameOffset(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (GenericParameterRow* pThis = &this) {
         var pOwner = (byte*) pThis + 4 + CodedIndex.TypeOrMethodDef.IndexSize(peFile);
         if (StreamID.Strings.IndexSize(peFile) == 2) {
             return *(ushort*) pOwner;
         }
         return *(uint*) pOwner;
     }
 }
Example #12
0
 public MethodDefOrRef GetImplementingMethod(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (MethodImplRow* pThis = &this) {
         var pImplementingMethod = (byte*) pThis + MetadataTable.TypeDef.IndexSize(peFile);
         if (CodedIndex.MethodDefOrRef.IndexSize(peFile) == 2) {
             return new MethodDefOrRef(new OneBasedIndex(*(ushort*) pImplementingMethod));
         }
         return new MethodDefOrRef(new OneBasedIndex(*(uint*) pImplementingMethod));
     }
 }
Example #13
0
 public uint GetTypeSignatureOffset(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (PropertyRow * pThis = & this) {
         var pType = (byte*) pThis + 2 + StreamID.Strings.IndexSize(peFile);
         if (StreamID.Blob.IndexSize(peFile) == 2) {
             return *(ushort*) pType;
         }
         return *(uint*) pType;
     }
 }
Example #14
0
 public uint GetMvidOffset(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (ModuleRow* pThis = &this) {
         var pMvid = (byte*) pThis + 2 + StreamID.Strings.IndexSize(peFile);
         if (StreamID.Guid.IndexSize(peFile) == 2) {
             return *(ushort*) pMvid;
         }
         return *(uint*) pMvid;
     }
 }
Example #15
0
 public uint GetEncBaseId(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (ModuleRow* pThis = &this) {
         var pBaseId = (byte*) pThis + 2 + StreamID.Strings.IndexSize(peFile) + StreamID.Guid.IndexSize(peFile)*2;
         if (StreamID.Guid.IndexSize(peFile) == 2) {
             return *(ushort*) pBaseId;
         }
         return *(uint*) pBaseId;
     }
 }
Example #16
0
 public uint GetSignatureOffset(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (MethodDefRow * pThis = &this) {
         var pSignature = (byte *)pThis + 8 + StreamID.Strings.IndexSize(peFile);
         if (StreamID.Blob.IndexSize(peFile) == 2) {
             return *(ushort *)(pSignature);
         }
         return *(uint *)pSignature;
     }
 }
Example #17
0
 public uint GetNativeTypeOffset(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (FieldMarshalRow * pThis = &this) {
         var pNativeType = (byte*) pThis + CodedIndex.HasFieldMarshal.IndexSize(peFile);
         if (StreamID.Blob.IndexSize(peFile) == 2) {
             return *(ushort*) pNativeType;
         }
         return *(uint*) pNativeType;
     }
 }
Example #18
0
 public OneBasedIndex GetEventListIndex(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (EventMapRow* pThis = &this) {
         var pEventList = (byte*) pThis + MetadataTable.TypeDef.IndexSize(peFile);
         if (MetadataTable.Event.IndexSize(peFile) == 2) {
             return new OneBasedIndex(*(ushort*) pEventList);
         }
         return new OneBasedIndex(*(uint*)pEventList);
     }
 }
Example #19
0
 public OneBasedIndex GetEnclosingClass(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (NestedClassRow* pThis = &this) {
         var pEnclosingClass = (byte*) pThis + MetadataTable.TypeDef.IndexSize(peFile);
         if (MetadataTable.TypeDef.IndexSize(peFile) == 2) {
             return new OneBasedIndex(*(ushort*) pEnclosingClass);
         }
         return new OneBasedIndex(*(uint*) pEnclosingClass);
     }
 }
Example #20
0
 public uint GetCultureOffset(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (AssemblyRow* pThis = &this) {
         var pCulture = (byte*) pThis + 16 + StreamID.Blob.IndexSize(peFile) + StreamID.Strings.IndexSize(peFile);
         if (StreamID.Strings.IndexSize(peFile) == 2) {
             return *(ushort*) pCulture;
         }
         return *(uint*) pCulture;
     }
 }
Example #21
0
 public uint GetNameOffset(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (MethodDefRow * pThis = &this) {
         var pName = (byte *)pThis +8;
         if (StreamID.Strings.IndexSize(peFile) == 2) {
             return *(ushort *)pName;
         }
         return *(uint *)pName;
     }
 }
Example #22
0
        public uint GetNameIndex(PEFile peFile)
        {
            peFile.CheckNotNull("peFile");

            fixed(PropertyRow * pThis = &this) {
                var pName = (byte*) pThis + 2;
                if (StreamID.Strings.IndexSize(peFile) == 2) {
                    return *(ushort*) pName;
                }
                return *(uint*) pName;
            }
        }
Example #23
0
 internal ModuleCollection(Assembly assembly, PEFile mainFile)
 {
     try {
         m_assembly     = assembly.CheckNotNull("assembly");
         m_mainFile     = mainFile.CheckNotNull("mainFile");
         m_otherModules = new object[MetadataTable.File.RowCount(m_mainFile)];
         m_lockObject   = new object();
     }
     catch {
         Dispose();
         throw;
     }
 }
Example #24
0
 public HasCustomAttribute GetParent(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (CustomAttributeRow * pThis = &this) {
         uint index;
         if (CodedIndex.HasCustomAttribute.IndexSize(peFile) == 2) {
             index = *(ushort*) pThis;
         }
         else {
             index = *(uint*) pThis;
         }
         return new HasCustomAttribute(new OneBasedIndex(index));
     }
 }
Example #25
0
 public HasFieldMarshal GetParent(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (FieldMarshalRow* pThis = &this) {
         uint index;
         if (CodedIndex.HasFieldMarshal.IndexSize(peFile) == 2) {
             index = *(ushort*) pThis;
         }
         else {
             index = *(uint*) pThis;
         }
         return new HasFieldMarshal(new OneBasedIndex(index));
     }
 }
 public TypeDefOrRef GetConstraint(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (GenericParameterConstraintRow* pThis = &this) {
         var pConstraint = (byte*) pThis + MetadataTable.GenericParam.IndexSize(peFile);
         uint index;
         if (CodedIndex.TypeDefOrRef.IndexSize(peFile) == 2) {
             index = *(ushort*) pConstraint;
         }
         else {
             index = *(uint*) pConstraint;
         }
         return new TypeDefOrRef(new OneBasedIndex(index));
     }
 }
Example #27
0
 public TypeDefOrRef GetExtendsToken(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (TypeDefRow* pThis = &this) {
         var pExtends = checked((byte*) pThis + 4 + 2*StreamID.Strings.IndexSize(peFile));
         uint index;
         if (CodedIndex.TypeDefOrRef.IndexSize(peFile) == 2) {
             index = *(ushort*) pExtends;
         }
         else {
             index = *(uint*) pExtends;
         }
         return new TypeDefOrRef(new OneBasedIndex(index));
     }
 }
Example #28
0
 public TypeDefOrRef GetEventType(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (EventRow * pThis = &this) {
         var pType = (byte*) pThis + 2 + StreamID.Strings.IndexSize(peFile);
         uint index;
         if (CodedIndex.TypeDefOrRef.IndexSize(peFile) == 2) {
             index = *(ushort*) pType;
         }
         else {
             index = *(uint*) pType;
         }
         return new TypeDefOrRef(new OneBasedIndex(index));
     }
 }
Example #29
0
        public uint GetValueOffset(PEFile peFile)
        {
            peFile.CheckNotNull("peFile");
            fixed (CustomAttributeRow * pThis = &this) {
                var pValue =
                    (byte*)pThis
                    + CodedIndex.HasCustomAttribute.IndexSize(peFile)
                    + CodedIndex.CustomAttributeConstructor.IndexSize(peFile);

                if (StreamID.Blob.IndexSize(peFile) == 2) {
                    return *(ushort*) pValue;
                }
                return *(uint*) pValue;
            }
        }
Example #30
0
 public CustomAttributeConstructor GetConstructor(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (CustomAttributeRow * pThis = &this) {
         var pConstructor = (byte*) pThis + CodedIndex.HasCustomAttribute.IndexSize(peFile);
         uint index;
         if (CodedIndex.CustomAttributeConstructor.IndexSize(peFile) == 2) {
             index = *(ushort*) pConstructor;
         }
         else {
             index = *(uint*) pConstructor;
         }
         return new CustomAttributeConstructor(new OneBasedIndex(index));
     }
 }
Example #31
0
 public OneBasedIndex GetParamListIndex(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (MethodDefRow * pThis = &this) {
         var pParamList =
             (byte *)pThis
             + 8
             + StreamID.Strings.IndexSize(peFile)
             + StreamID.Blob.IndexSize(peFile);
         if (MetadataTable.MethodDef.IndexSize(peFile) == 2) {
             return new OneBasedIndex(*(uint *)pParamList);
         }
         return new OneBasedIndex(*(ushort *)pParamList);
     }
 }
Example #32
0
 public TypeOrMethodDef GetOwner(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (GenericParameterRow* pThis = &this) {
         var pOwner = (byte*) pThis + 4;
         uint index;
         if (CodedIndex.TypeOrMethodDef.IndexSize(peFile) == 2) {
             index = *(ushort*) pOwner;
         }
         else {
             index = *(uint*) pOwner;
         }
         return new TypeOrMethodDef(new OneBasedIndex(index));
     }
 }
Example #33
0
 public OneBasedIndex GetMethodListToken(PEFile peFile)
 {
     peFile.CheckNotNull("peFile");
     fixed (TypeDefRow* pThis = &this) {
         var pFieldList = checked(
             (byte*) pThis
             + 4
             + 2*StreamID.Strings.IndexSize(peFile)
             + CodedIndex.TypeDefOrRef.IndexSize(peFile)
         );
         if (MetadataTable.MethodDef.IndexSize(peFile) == 2) {
             return new OneBasedIndex(*(ushort*) pFieldList);
         }
         return new OneBasedIndex(*(uint*) pFieldList);
     }
 }
Example #34
0
 public static uint IndexSize(this StreamID id, PEFile peFile)
 {
     return(peFile.CheckNotNull("peFile").GetHeapIndexSize(id));
 }
Example #35
0
 public unsafe static ZeroBasedIndex Find <T>(this MetadataTable table, T value, UnsafeSelector <T> selector, PEFile peFile)
 {
     return(peFile.CheckNotNull("peFile").Find(table, value, selector));
 }
Example #36
0
 public static uint IndexSize(this MetadataTable table, PEFile peFile)
 {
     return(peFile.CheckNotNull("peFile").GetTableIndexSize(table));
 }
Example #37
0
 public static int RowCount(this MetadataTable table, PEFile peFile)
 {
     return(peFile.CheckNotNull("peFile").GetRowCount(table));
 }
Example #38
0
 public static unsafe void *GetRow(this MetadataTable table, ZeroBasedIndex index, PEFile peFile)
 {
     return(peFile.CheckNotNull("peFile").GetRow(index, table));
 }
Example #39
0
 public unsafe static ZeroBasedIndex RowIndex(this MetadataTable table, void *pRow, PEFile peFile)
 {
     return(peFile.CheckNotNull("peFile").GetRowIndex(table, pRow));
 }
Example #40
0
 public static uint IndexSize(this CodedIndex type, PEFile peFile)
 {
     return(peFile.CheckNotNull("peFile").GetCodedIndexSize(type));
 }
Example #41
0
 public static uint IndexSize(this StreamID id, PEFile peFile)
 {
     return peFile.CheckNotNull("peFile").GetHeapIndexSize(id);
 }
Example #42
0
 internal CustomAttribute(CustomAttributeRow *pRow, PEFile peFile)
 {
     m_pRow   = (CustomAttributeRow *)FluentAsserts.CheckNotNull((void *)pRow, "pRow");
     m_peFile = peFile.CheckNotNull("peFile");
 }