コード例 #1
0
        internal unsafe static IRuntimeFieldInfo ResolveFieldHandleInternal(RuntimeModule module, int fieldToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
        {
            ModuleHandle.ValidateModulePointer(module);
            if (!ModuleHandle.GetMetadataImport(module.GetNativeHandle()).IsValidToken(fieldToken))
            {
                throw new ArgumentOutOfRangeException("metadataToken", Environment.GetResourceString("Argument_InvalidToken", new object[]
                {
                    fieldToken,
                    new ModuleHandle(module)
                }));
            }
            int typeInstCount;

            IntPtr[] array = RuntimeTypeHandle.CopyRuntimeTypeHandles(typeInstantiationContext, out typeInstCount);
            int      methodInstCount;

            IntPtr[] array2 = RuntimeTypeHandle.CopyRuntimeTypeHandles(methodInstantiationContext, out methodInstCount);
            fixed(IntPtr *ptr = array)
            {
                fixed(IntPtr *ptr2 = array2)
                {
                    IRuntimeFieldInfo result = null;

                    ModuleHandle.ResolveField(module.GetNativeHandle(), fieldToken, ptr, typeInstCount, ptr2, methodInstCount, JitHelpers.GetObjectHandleOnStack <IRuntimeFieldInfo>(ref result));
                    GC.KeepAlive(typeInstantiationContext);
                    GC.KeepAlive(methodInstantiationContext);
                    return(result);
                }
            }
        }
コード例 #2
0
        internal static unsafe IRuntimeFieldInfo ResolveFieldHandleInternal(RuntimeModule module, int fieldToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
        {
            int num;
            int num2;

            ValidateModulePointer(module);
            if (!GetMetadataImport(module.GetNativeHandle()).IsValidToken(fieldToken))
            {
                throw new ArgumentOutOfRangeException("metadataToken", Environment.GetResourceString("Argument_InvalidToken", new object[] { fieldToken, new ModuleHandle(module) }));
            }
            IntPtr[] ptrArray  = RuntimeTypeHandle.CopyRuntimeTypeHandles(typeInstantiationContext, out num);
            IntPtr[] ptrArray2 = RuntimeTypeHandle.CopyRuntimeTypeHandles(methodInstantiationContext, out num2);
            fixed(IntPtr *ptrRef = ptrArray)
            {
                fixed(IntPtr *ptrRef2 = ptrArray2)
                {
                    IRuntimeFieldInfo o = null;

                    ResolveField(module.GetNativeHandle(), fieldToken, ptrRef, num, ptrRef2, num2, JitHelpers.GetObjectHandleOnStack <IRuntimeFieldInfo>(ref o));
                    GC.KeepAlive(typeInstantiationContext);
                    GC.KeepAlive(methodInstantiationContext);
                    return(o);
                }
            }
        }
コード例 #3
0
 internal static unsafe RuntimeMethodHandleInternal ResolveMethodHandleInternalCore(RuntimeModule module, int methodToken, IntPtr[] typeInstantiationContext, int typeInstCount, IntPtr[] methodInstantiationContext, int methodInstCount)
 {
     ModuleHandle.ValidateModulePointer(module);
     if (!ModuleHandle.GetMetadataImport(module.GetNativeHandle()).IsValidToken(methodToken))
     {
         throw new ArgumentOutOfRangeException("metadataToken", Environment.GetResourceString("Argument_InvalidToken", (object)methodToken, (object)new ModuleHandle(module)));
         fixed(IntPtr *typeInstArgs = typeInstantiationContext)
         fixed(IntPtr * methodInstArgs = methodInstantiationContext)
         return(ModuleHandle.ResolveMethod(module.GetNativeHandle(), methodToken, typeInstArgs, typeInstCount, methodInstArgs, methodInstCount));
 }
コード例 #4
0
        internal static unsafe RuntimeMethodHandleInternal ResolveMethodHandleInternalCore(RuntimeModule module, int methodToken, IntPtr[] typeInstantiationContext, int typeInstCount, IntPtr[] methodInstantiationContext, int methodInstCount)
        {
            ValidateModulePointer(module);
            if (!GetMetadataImport(module.GetNativeHandle()).IsValidToken(methodToken))
            {
                throw new ArgumentOutOfRangeException("metadataToken", Environment.GetResourceString("Argument_InvalidToken", new object[] { methodToken, new ModuleHandle(module) }));
            }

            fixed(IntPtr *ptrRef = typeInstantiationContext)
            {
                fixed(IntPtr *ptrRef2 = methodInstantiationContext)
                {
                    return(ResolveMethod(module.GetNativeHandle(), methodToken, ptrRef, typeInstCount, ptrRef2, methodInstCount));
                }
            }
        }
コード例 #5
0
        internal static Attribute GetCustomAttribute(int token, RuntimeModule scope)
        {
            int        sizeParamIndex = 0;
            int        sizeConst      = 0;
            string     marshalType    = (string)null;
            string     marshalCookie  = (string)null;
            string     safeArrayUserDefinedSubType1 = (string)null;
            int        iidParamIndex = 0;
            ConstArray fieldMarshal  = ModuleHandle.GetMetadataImport(scope.GetNativeHandle()).GetFieldMarshal(token);

            if (fieldMarshal.Length == 0)
            {
                return((Attribute)null);
            }
            UnmanagedType unmanagedType;
            VarEnum       safeArraySubType;
            UnmanagedType arraySubType;

            MetadataImport.GetMarshalAs(fieldMarshal, out unmanagedType, out safeArraySubType, out safeArrayUserDefinedSubType1, out arraySubType, out sizeParamIndex, out sizeConst, out marshalType, out marshalCookie, out iidParamIndex);
            RuntimeType safeArrayUserDefinedSubType2 = safeArrayUserDefinedSubType1 == null || safeArrayUserDefinedSubType1.Length == 0 ? (RuntimeType)null : RuntimeTypeHandle.GetTypeByNameUsingCARules(safeArrayUserDefinedSubType1, scope);
            RuntimeType marshalTypeRef = (RuntimeType)null;

            try
            {
                marshalTypeRef = marshalType == null ? (RuntimeType)null : RuntimeTypeHandle.GetTypeByNameUsingCARules(marshalType, scope);
            }
            catch (TypeLoadException ex)
            {
            }
            return((Attribute) new MarshalAsAttribute(unmanagedType, safeArraySubType, safeArrayUserDefinedSubType2, arraySubType, (short)sizeParamIndex, sizeConst, marshalType, marshalTypeRef, marshalCookie, iidParamIndex));
        }
コード例 #6
0
        internal static RuntimeAssembly GetAssembly(RuntimeModule module)
        {
            RuntimeAssembly result = null;

            ModuleHandle.GetAssembly(module.GetNativeHandle(), JitHelpers.GetObjectHandleOnStack <RuntimeAssembly>(ref result));
            return(result);
        }
コード例 #7
0
        internal static RuntimeType GetModuleType(RuntimeModule module)
        {
            RuntimeType result = null;

            ModuleHandle.GetModuleType(module.GetNativeHandle(), JitHelpers.GetObjectHandleOnStack <RuntimeType>(ref result));
            return(result);
        }
コード例 #8
0
        internal static Attribute GetCustomAttribute(int token, RuntimeModule scope)
        {
            int        num           = 0;
            int        sizeConst     = 0;
            string     text          = null;
            string     marshalCookie = null;
            string     text2         = null;
            int        iidParamIndex = 0;
            ConstArray fieldMarshal  = ModuleHandle.GetMetadataImport(scope.GetNativeHandle()).GetFieldMarshal(token);

            if (fieldMarshal.Length == 0)
            {
                return(null);
            }
            UnmanagedType val;
            VarEnum       safeArraySubType;
            UnmanagedType arraySubType;

            MetadataImport.GetMarshalAs(fieldMarshal, out val, out safeArraySubType, out text2, out arraySubType, out num, out sizeConst, out text, out marshalCookie, out iidParamIndex);
            RuntimeType safeArrayUserDefinedSubType = (text2 == null || text2.Length == 0) ? null : RuntimeTypeHandle.GetTypeByNameUsingCARules(text2, scope);
            RuntimeType marshalTypeRef = null;

            try
            {
                marshalTypeRef = ((text == null) ? null : RuntimeTypeHandle.GetTypeByNameUsingCARules(text, scope));
            }
            catch (TypeLoadException)
            {
            }
            return(new MarshalAsAttribute(val, safeArraySubType, safeArrayUserDefinedSubType, arraySubType, (short)num, sizeConst, text, marshalTypeRef, marshalCookie, iidParamIndex));
        }
コード例 #9
0
        internal static Attribute GetCustomAttribute(int token, RuntimeModule scope)
        {
            UnmanagedType type;
            UnmanagedType type2;
            VarEnum       enum2;
            int           sizeParamIndex = 0;
            int           sizeConst      = 0;
            string        marshalType    = null;
            string        marshalCookie  = null;
            string        safeArrayUserDefinedSubType = null;
            int           iidParamIndex = 0;
            ConstArray    fieldMarshal  = ModuleHandle.GetMetadataImport(scope.GetNativeHandle()).GetFieldMarshal(token);

            if (fieldMarshal.Length == 0)
            {
                return(null);
            }
            MetadataImport.GetMarshalAs(fieldMarshal, out type, out enum2, out safeArrayUserDefinedSubType, out type2, out sizeParamIndex, out sizeConst, out marshalType, out marshalCookie, out iidParamIndex);
            RuntimeType type3          = ((safeArrayUserDefinedSubType == null) || (safeArrayUserDefinedSubType.Length == 0)) ? null : RuntimeTypeHandle.GetTypeByNameUsingCARules(safeArrayUserDefinedSubType, scope);
            RuntimeType marshalTypeRef = null;

            try
            {
                marshalTypeRef = (marshalType == null) ? null : RuntimeTypeHandle.GetTypeByNameUsingCARules(marshalType, scope);
            }
            catch (TypeLoadException)
            {
            }
            return(new MarshalAsAttribute(type, enum2, type3, type2, (short)sizeParamIndex, sizeConst, marshalType, marshalTypeRef, marshalCookie, iidParamIndex));
        }
コード例 #10
0
        internal static void GetPEKind(RuntimeModule module, out PortableExecutableKinds peKind, out ImageFileMachine machine)
        {
            int num;
            int num2;

            ModuleHandle.GetPEKind(module.GetNativeHandle(), out num, out num2);
            peKind  = (PortableExecutableKinds)num;
            machine = (ImageFileMachine)num2;
        }
コード例 #11
0
        internal static RuntimeType GetTypeByNameUsingCARules(string name, RuntimeModule scope)
        {
            if ((name == null) || (name.Length == 0))
            {
                throw new ArgumentException("name");
            }
            RuntimeType o = null;

            GetTypeByNameUsingCARules(name, scope.GetNativeHandle(), JitHelpers.GetObjectHandleOnStack <RuntimeType>(ref o));
            return(o);
        }
コード例 #12
0
ファイル: attributes.cs プロジェクト: SixGodZhang/Source
        [System.Security.SecurityCritical]  // auto-generated
        internal static Attribute GetCustomAttribute(int token, RuntimeModule scope)
        {
            UnmanagedType unmanagedType, arraySubType;
            VarEnum       safeArraySubType;
            int           sizeParamIndex = 0, sizeConst = 0;
            string        marshalTypeName = null, marshalCookie = null, safeArrayUserDefinedTypeName = null;
            int           iidParamIndex = 0;
            ConstArray    nativeType    = ModuleHandle.GetMetadataImport(scope.GetNativeHandle()).GetFieldMarshal(token);

            if (nativeType.Length == 0)
            {
                return(null);
            }

            MetadataImport.GetMarshalAs(nativeType,
                                        out unmanagedType, out safeArraySubType, out safeArrayUserDefinedTypeName, out arraySubType, out sizeParamIndex,
                                        out sizeConst, out marshalTypeName, out marshalCookie, out iidParamIndex);

            RuntimeType safeArrayUserDefinedType = safeArrayUserDefinedTypeName == null || safeArrayUserDefinedTypeName.Length == 0 ? null :
                                                   RuntimeTypeHandle.GetTypeByNameUsingCARules(safeArrayUserDefinedTypeName, scope);
            RuntimeType marshalTypeRef = null;

            try
            {
                marshalTypeRef = marshalTypeName == null ? null : RuntimeTypeHandle.GetTypeByNameUsingCARules(marshalTypeName, scope);
            }
            catch (System.TypeLoadException)
            {
                // The user may have supplied a bad type name string causing this TypeLoadException
                // Regardless, we return the bad type name
                Contract.Assert(marshalTypeName != null);
            }

            return(new MarshalAsAttribute(
                       unmanagedType, safeArraySubType, safeArrayUserDefinedType, arraySubType,
                       (short)sizeParamIndex, sizeConst, marshalTypeName, marshalTypeRef, marshalCookie, iidParamIndex));
        }
コード例 #13
0
 internal bool IsVisibleFromModule(RuntimeModule module)
 {
     return(IsVisibleFromModule(this.GetNativeHandle(), module.GetNativeHandle()));
 }
コード例 #14
0
        internal static unsafe IRuntimeFieldInfo ResolveFieldHandleInternal(RuntimeModule module, int fieldToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
        {
            ModuleHandle.ValidateModulePointer(module);
            if (!ModuleHandle.GetMetadataImport(module.GetNativeHandle()).IsValidToken(fieldToken))
                throw new ArgumentOutOfRangeException("metadataToken", Environment.GetResourceString("Argument_InvalidToken", (object)fieldToken, (object)new ModuleHandle(module)));
}
コード例 #15
0
 internal static bool ContainsPropertyMatchingHash(RuntimeModule module, int propertyToken, uint hash)
 {
     return(ModuleHandle._ContainsPropertyMatchingHash(module.GetNativeHandle(), propertyToken, hash));
 }
コード例 #16
0
 internal static MetadataImport GetMetadataImport(RuntimeModule module)
 {
     return(new MetadataImport(ModuleHandle._GetMetadataImport(module.GetNativeHandle()), module));
 }
コード例 #17
0
 internal static bool IsVisibleFromModule(IRuntimeMethodInfo method, RuntimeModule source)
 {
     return(_IsVisibleFromModule(method, source.GetNativeHandle()));
 }