private CustomAttributeData(RuntimeModule scope, CustomAttributeRecord caRecord) { this.m_scope = scope; this.m_ctor = (RuntimeConstructorInfo) RuntimeType.GetMethodBase(scope, (int) caRecord.tkCtor); ParameterInfo[] parametersNoCopy = this.m_ctor.GetParametersNoCopy(); this.m_ctorParams = new CustomAttributeCtorParameter[parametersNoCopy.Length]; for (int i = 0; i < parametersNoCopy.Length; i++) { this.m_ctorParams[i] = new CustomAttributeCtorParameter(InitCustomAttributeType((RuntimeType) parametersNoCopy[i].ParameterType)); } FieldInfo[] fields = this.m_ctor.DeclaringType.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); PropertyInfo[] properties = this.m_ctor.DeclaringType.GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); this.m_namedParams = new CustomAttributeNamedParameter[properties.Length + fields.Length]; for (int j = 0; j < fields.Length; j++) { this.m_namedParams[j] = new CustomAttributeNamedParameter(fields[j].Name, CustomAttributeEncoding.Field, InitCustomAttributeType((RuntimeType) fields[j].FieldType)); } for (int k = 0; k < properties.Length; k++) { this.m_namedParams[k + fields.Length] = new CustomAttributeNamedParameter(properties[k].Name, CustomAttributeEncoding.Property, InitCustomAttributeType((RuntimeType) properties[k].PropertyType)); } this.m_members = new MemberInfo[fields.Length + properties.Length]; fields.CopyTo(this.m_members, 0); properties.CopyTo(this.m_members, fields.Length); CustomAttributeEncodedArgument.ParseAttributeArguments(caRecord.blob, ref this.m_ctorParams, ref this.m_namedParams, this.m_scope); }
private static void ValidateModulePointer(RuntimeModule module) { if (module == null) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NullModuleHandle")); } }
[System.Security.SecurityCritical] // auto-generated internal void GetCallableMethod(RuntimeModule module, DynamicMethod dm) { dm.m_methodHandle = ModuleHandle.GetDynamicMethod(dm, module, m_methodBuilder.Name, (byte[])m_scope[m_methodSigToken], new DynamicResolver(this)); }
internal static void ParseAttributeArguments(ConstArray attributeBlob, ref CustomAttributeCtorParameter[] customAttributeCtorParameters, ref CustomAttributeNamedParameter[] customAttributeNamedParameters, RuntimeModule customAttributeModule) { if (customAttributeModule == null) { throw new ArgumentNullException("customAttributeModule"); } if ((customAttributeCtorParameters.Length != 0) || (customAttributeNamedParameters.Length != 0)) { ParseAttributeArguments(attributeBlob.Signature, attributeBlob.Length, ref customAttributeCtorParameters, ref customAttributeNamedParameters, (RuntimeAssembly) customAttributeModule.Assembly); } }
private extern static IntPtr _GetMetadataImport(RuntimeModule module);
[System.Security.SecuritySafeCritical] // auto-generated internal static RuntimeType GetModuleType(RuntimeModule module) { RuntimeType type = null; GetModuleType(module.GetNativeHandle(), JitHelpers.GetObjectHandleOnStack(ref type)); return type; }
[System.Security.SecurityCritical] // auto-generated internal static bool ContainsPropertyMatchingHash(RuntimeModule module, int propertyToken, uint hash) { return _ContainsPropertyMatchingHash(module.GetNativeHandle(), propertyToken, hash); }
private extern static RuntimeMethodHandleInternal ResolveMethod(RuntimeModule module, int methodToken, IntPtr* typeInstArgs, int typeInstCount, IntPtr* methodInstArgs, int methodInstCount);
private extern static void ResolveType(RuntimeModule module, int typeToken, IntPtr* typeInstArgs, int typeInstCount, IntPtr* methodInstArgs, int methodInstCount, ObjectHandleOnStack type);
internal static extern IRuntimeMethodInfo GetDynamicMethod(DynamicMethod method, RuntimeModule module, string name, byte[] sig, Resolver resolver);
internal static bool IsDefined(RuntimeModule module, RuntimeType caType) { return(PseudoCustomAttribute.IsDefined(module, caType) || CustomAttribute.IsCustomAttributeDefined(module, module.MetadataToken, caType)); }
internal static void ParseAttributeArguments(ConstArray attributeBlob, ref CustomAttributeCtorParameter[] customAttributeCtorParameters, ref CustomAttributeNamedParameter[] customAttributeNamedParameters, RuntimeModule customAttributeModule) { if (customAttributeModule == null) { throw new ArgumentNullException("customAttributeModule"); } if (customAttributeCtorParameters.Length != 0 || customAttributeNamedParameters.Length != 0) { CustomAttributeEncodedArgument.ParseAttributeArguments(attributeBlob.Signature, attributeBlob.Length, ref customAttributeCtorParameters, ref customAttributeNamedParameters, (RuntimeAssembly)customAttributeModule.Assembly); } }
private static extern void GetType(RuntimeModule module, string className, bool ignoreCase, bool throwOnError, ObjectHandleOnStack type);
// Token: 0x0600448A RID: 17546 RVA: 0x000FC4C5 File Offset: 0x000FA6C5 internal static bool IsDefined(RuntimeModule module, RuntimeType caType) { return(false); }
// Token: 0x06004489 RID: 17545 RVA: 0x000FC4BF File Offset: 0x000FA6BF internal static Attribute[] GetCustomAttributes(RuntimeModule module, RuntimeType caType, out int count) { count = 0; return(null); }
internal static void GetSecurityAttributes(RuntimeModule module, int token, bool assembly, out object[] securityAttributes) { PseudoCustomAttribute._GetSecurityAttributes(module.GetNativeHandle(), token, assembly, out securityAttributes); }
internal static extern void CheckAttributeAccess(RuntimeFieldHandle fieldHandle, RuntimeModule decoratedTarget);
private unsafe static object[] GetCustomAttributes(RuntimeModule decoratedModule, int decoratedMetadataToken, int pcaCount, RuntimeType attributeFilterType, bool mustBeInheritable, IList derivedAttributes, bool isDecoratedTargetSecurityTransparent) { if (decoratedModule.Assembly.ReflectionOnly) { throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyCA")); } MetadataImport metadataImport = decoratedModule.MetadataImport; CustomAttributeRecord[] customAttributeRecords = CustomAttributeData.GetCustomAttributeRecords(decoratedModule, decoratedMetadataToken); Type elementType = (attributeFilterType == null || attributeFilterType.IsValueType || attributeFilterType.ContainsGenericParameters) ? typeof(object) : attributeFilterType; if (attributeFilterType == null && customAttributeRecords.Length == 0) { return(CustomAttribute.CreateAttributeArrayHelper(elementType, 0)); } object[] array = CustomAttribute.CreateAttributeArrayHelper(elementType, customAttributeRecords.Length); int num = 0; SecurityContextFrame securityContextFrame = default(SecurityContextFrame); securityContextFrame.Push(decoratedModule.GetRuntimeAssembly()); Assembly assembly = null; for (int i = 0; i < customAttributeRecords.Length; i++) { object obj = null; CustomAttributeRecord caRecord = customAttributeRecords[i]; IRuntimeMethodInfo runtimeMethodInfo = null; RuntimeType runtimeType = null; int num2 = 0; IntPtr intPtr = caRecord.blob.Signature; IntPtr intPtr2 = (IntPtr)((void *)((byte *)((void *)intPtr) + caRecord.blob.Length)); int num3 = (int)((long)((byte *)((void *)intPtr2) - (byte *)((void *)intPtr))); bool flag; bool isVarArg; if (CustomAttribute.FilterCustomAttributeRecord(caRecord, metadataImport, ref assembly, decoratedModule, decoratedMetadataToken, attributeFilterType, mustBeInheritable, array, derivedAttributes, out runtimeType, out runtimeMethodInfo, out flag, out isVarArg)) { if (runtimeMethodInfo != null) { RuntimeMethodHandle.CheckLinktimeDemands(runtimeMethodInfo, decoratedModule, isDecoratedTargetSecurityTransparent); } RuntimeConstructorInfo.CheckCanCreateInstance(runtimeType, isVarArg); if (flag) { obj = CustomAttribute.CreateCaObject(decoratedModule, runtimeMethodInfo, ref intPtr, intPtr2, out num2); } else { obj = RuntimeTypeHandle.CreateCaInstance(runtimeType, runtimeMethodInfo); if (num3 == 0) { num2 = 0; } else { if (Marshal.ReadInt16(intPtr) != 1) { throw new CustomAttributeFormatException(); } intPtr = (IntPtr)((void *)((byte *)((void *)intPtr) + 2)); num2 = (int)Marshal.ReadInt16(intPtr); intPtr = (IntPtr)((void *)((byte *)((void *)intPtr) + 2)); } } for (int j = 0; j < num2; j++) { IntPtr signature = caRecord.blob.Signature; string text; bool flag2; RuntimeType runtimeType2; object obj2; CustomAttribute.GetPropertyOrFieldData(decoratedModule, ref intPtr, intPtr2, out text, out flag2, out runtimeType2, out obj2); try { if (flag2) { if (runtimeType2 == null && obj2 != null) { runtimeType2 = (RuntimeType)obj2.GetType(); if (runtimeType2 == CustomAttribute.Type_RuntimeType) { runtimeType2 = CustomAttribute.Type_Type; } } RuntimePropertyInfo runtimePropertyInfo; if (runtimeType2 == null) { runtimePropertyInfo = (runtimeType.GetProperty(text) as RuntimePropertyInfo); } else { runtimePropertyInfo = (runtimeType.GetProperty(text, runtimeType2, Type.EmptyTypes) as RuntimePropertyInfo); } if (runtimePropertyInfo == null) { throw new CustomAttributeFormatException(string.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString(flag2 ? "RFLCT.InvalidPropFail" : "RFLCT.InvalidFieldFail"), text)); } RuntimeMethodInfo runtimeMethodInfo2 = runtimePropertyInfo.GetSetMethod(true) as RuntimeMethodInfo; if (runtimeMethodInfo2.IsPublic) { RuntimeMethodHandle.CheckLinktimeDemands(runtimeMethodInfo2, decoratedModule, isDecoratedTargetSecurityTransparent); runtimeMethodInfo2.UnsafeInvoke(obj, BindingFlags.Default, null, new object[] { obj2 }, null); } } else { RtFieldInfo rtFieldInfo = runtimeType.GetField(text) as RtFieldInfo; if (isDecoratedTargetSecurityTransparent) { RuntimeFieldHandle.CheckAttributeAccess(rtFieldInfo.FieldHandle, decoratedModule.GetNativeHandle()); } rtFieldInfo.CheckConsistency(obj); rtFieldInfo.UnsafeSetValue(obj, obj2, BindingFlags.Default, Type.DefaultBinder, null); } } catch (Exception inner) { throw new CustomAttributeFormatException(string.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString(flag2 ? "RFLCT.InvalidPropFail" : "RFLCT.InvalidFieldFail"), text), inner); } } if (!intPtr.Equals(intPtr2)) { throw new CustomAttributeFormatException(); } array[num++] = obj; } } securityContextFrame.Pop(); if (num == customAttributeRecords.Length && pcaCount == 0) { return(array); } object[] array2 = CustomAttribute.CreateAttributeArrayHelper(elementType, num + pcaCount); Array.Copy(array, 0, array2, 0, num); return(array2); }
private static void ValidateModulePointer(RuntimeModule module) { // Make sure we have a valid Module to resolve against. if (module == null) throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NullModuleHandle")); }
private unsafe static bool FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, ref Assembly lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, bool mustBeInheritable, object[] attributes, IList derivedAttributes, out RuntimeType attributeType, out IRuntimeMethodInfo ctor, out bool ctorHasParameters, out bool isVarArg) { ctor = null; attributeType = null; ctorHasParameters = false; isVarArg = false; IntPtr signature = caRecord.blob.Signature; IntPtr intPtr = (IntPtr)((void *)((byte *)((void *)signature) + caRecord.blob.Length)); attributeType = (decoratedModule.ResolveType(scope.GetParentToken(caRecord.tkCtor), null, null) as RuntimeType); if (!attributeFilterType.IsAssignableFrom(attributeType)) { return(false); } if (!CustomAttribute.AttributeUsageCheck(attributeType, mustBeInheritable, attributes, derivedAttributes)) { return(false); } if ((attributeType.Attributes & TypeAttributes.WindowsRuntime) == TypeAttributes.WindowsRuntime) { return(false); } RuntimeAssembly runtimeAssembly = (RuntimeAssembly)attributeType.Assembly; RuntimeAssembly runtimeAssembly2 = (RuntimeAssembly)decoratedModule.Assembly; if (runtimeAssembly != lastAptcaOkAssembly && !RuntimeAssembly.AptcaCheck(runtimeAssembly, runtimeAssembly2)) { return(false); } lastAptcaOkAssembly = runtimeAssembly2; ConstArray methodSignature = scope.GetMethodSignature(caRecord.tkCtor); isVarArg = ((methodSignature[0] & 5) > 0); ctorHasParameters = (methodSignature[1] > 0); if (ctorHasParameters) { ctor = ModuleHandle.ResolveMethodHandleInternal(decoratedModule.GetNativeHandle(), caRecord.tkCtor); } else { ctor = attributeType.GetTypeHandleInternal().GetDefaultConstructor(); if (ctor == null && !attributeType.IsValueType) { throw new MissingMethodException(".ctor"); } } MetadataToken token = default(MetadataToken); if (decoratedToken.IsParamDef) { token = new MetadataToken(scope.GetParentToken(decoratedToken)); token = new MetadataToken(scope.GetParentToken(token)); } else if (decoratedToken.IsMethodDef || decoratedToken.IsProperty || decoratedToken.IsEvent || decoratedToken.IsFieldDef) { token = new MetadataToken(scope.GetParentToken(decoratedToken)); } else if (decoratedToken.IsTypeDef) { token = decoratedToken; } else if (decoratedToken.IsGenericPar) { token = new MetadataToken(scope.GetParentToken(decoratedToken)); if (token.IsMethodDef) { token = new MetadataToken(scope.GetParentToken(token)); } } RuntimeTypeHandle sourceTypeHandle = token.IsTypeDef ? decoratedModule.ModuleHandle.ResolveTypeHandle(token) : default(RuntimeTypeHandle); return(RuntimeMethodHandle.IsCAVisibleFromDecoratedType(attributeType.TypeHandle, ctor, sourceTypeHandle, decoratedModule)); }
[System.Security.SecuritySafeCritical] // auto-generated internal static IRuntimeMethodInfo ResolveMethodHandleInternal(RuntimeModule module, int methodToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) { int typeInstCount, methodInstCount; IntPtr[] typeInstantiationContextHandles = RuntimeTypeHandle.CopyRuntimeTypeHandles(typeInstantiationContext, out typeInstCount); IntPtr[] methodInstantiationContextHandles = RuntimeTypeHandle.CopyRuntimeTypeHandles(methodInstantiationContext, out methodInstCount); RuntimeMethodHandleInternal handle = ResolveMethodHandleInternalCore(module, methodToken, typeInstantiationContextHandles, typeInstCount, methodInstantiationContextHandles, methodInstCount); IRuntimeMethodInfo retVal = new RuntimeMethodInfoStub(handle, RuntimeMethodHandle.GetLoaderAllocator(handle)); GC.KeepAlive(typeInstantiationContext); GC.KeepAlive(methodInstantiationContext); return retVal; }
private unsafe static extern object _CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, byte **ppBlob, byte *pEndBlob, int *pcNamedArgs);
private extern static void ResolveField(RuntimeModule module, int fieldToken, IntPtr* typeInstArgs, int typeInstCount, IntPtr* methodInstArgs, int methodInstCount, ObjectHandleOnStack retField);
private unsafe static extern void _GetPropertyOrFieldData(RuntimeModule pModule, byte **ppBlobStart, byte *pBlobEnd, out string name, out bool bIsProperty, out RuntimeType type, out object value);
[System.Security.SecuritySafeCritical] // auto-generated internal static RuntimeAssembly GetAssembly(RuntimeModule module) { RuntimeAssembly retAssembly = null; GetAssembly(module.GetNativeHandle(), JitHelpers.GetObjectHandleOnStack(ref retAssembly)); return retAssembly; }
internal static bool IsAttributeDefined(RuntimeModule decoratedModule, int decoratedMetadataToken, int attributeCtorToken) { return(CustomAttribute.IsCustomAttributeDefined(decoratedModule, decoratedMetadataToken, (RuntimeType)null, attributeCtorToken, false)); }
[System.Security.SecuritySafeCritical] // auto-generated internal static void GetPEKind(RuntimeModule module, out PortableExecutableKinds peKind, out ImageFileMachine machine) { int lKind, lMachine; GetPEKind(module.GetNativeHandle(), out lKind, out lMachine); peKind = (PortableExecutableKinds)lKind; machine = (ImageFileMachine)lMachine; }
private static bool IsCustomAttributeDefined(RuntimeModule decoratedModule, int decoratedMetadataToken, RuntimeType attributeFilterType) { return(CustomAttribute.IsCustomAttributeDefined(decoratedModule, decoratedMetadataToken, attributeFilterType, 0, false)); }
private extern static void GetTypeByNameUsingCARules(string name, RuntimeModule scope, ObjectHandleOnStack type);
private static object[] GetCustomAttributes(RuntimeModule decoratedModule, int decoratedMetadataToken, int pcaCount, RuntimeType attributeFilterType, bool isDecoratedTargetSecurityTransparent) { return(CustomAttribute.GetCustomAttributes(decoratedModule, decoratedMetadataToken, pcaCount, attributeFilterType, false, (IList)null, isDecoratedTargetSecurityTransparent)); }
private extern static bool IsResource(RuntimeModule module);
private static unsafe object[] GetCustomAttributes(RuntimeModule decoratedModule, int decoratedMetadataToken, int pcaCount, RuntimeType attributeFilterType, bool mustBeInheritable, IList derivedAttributes, bool isDecoratedTargetSecurityTransparent) { if (decoratedModule.Assembly.ReflectionOnly) { throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyCA")); } MetadataImport metadataImport = decoratedModule.MetadataImport; CustomAttributeRecord[] attributeRecords = CustomAttributeData.GetCustomAttributeRecords(decoratedModule, decoratedMetadataToken); Type elementType = (attributeFilterType == (RuntimeType)null || attributeFilterType.IsValueType ? 1 : (attributeFilterType.ContainsGenericParameters ? 1 : 0)) != 0 ? typeof(object) : (Type)attributeFilterType; if (attributeFilterType == (RuntimeType)null && attributeRecords.Length == 0) { return(CustomAttribute.CreateAttributeArrayHelper(elementType, 0)); } object[] attributeArrayHelper1 = CustomAttribute.CreateAttributeArrayHelper(elementType, attributeRecords.Length); int length = 0; SecurityContextFrame securityContextFrame = new SecurityContextFrame(); securityContextFrame.Push(decoratedModule.GetRuntimeAssembly()); Assembly lastAptcaOkAssembly = (Assembly)null; for (int index1 = 0; index1 < attributeRecords.Length; ++index1) { CustomAttributeRecord caRecord = attributeRecords[index1]; IRuntimeMethodInfo ctor = (IRuntimeMethodInfo)null; RuntimeType attributeType = (RuntimeType)null; int namedArgs = 0; IntPtr ptr1 = caRecord.blob.Signature; IntPtr blobEnd = (IntPtr)((void *)((IntPtr)(void *)ptr1 + caRecord.blob.Length)); int num = (int)((sbyte *)(void *)blobEnd - (sbyte *)(void *)ptr1); bool ctorHasParameters; bool isVarArg; if (CustomAttribute.FilterCustomAttributeRecord(caRecord, metadataImport, ref lastAptcaOkAssembly, decoratedModule, (MetadataToken)decoratedMetadataToken, attributeFilterType, mustBeInheritable, attributeArrayHelper1, derivedAttributes, out attributeType, out ctor, out ctorHasParameters, out isVarArg)) { if (ctor != null) { RuntimeMethodHandle.CheckLinktimeDemands(ctor, decoratedModule, isDecoratedTargetSecurityTransparent); } RuntimeConstructorInfo.CheckCanCreateInstance((Type)attributeType, isVarArg); object target; if (ctorHasParameters) { target = CustomAttribute.CreateCaObject(decoratedModule, ctor, ref ptr1, blobEnd, out namedArgs); } else { target = RuntimeTypeHandle.CreateCaInstance(attributeType, ctor); if (num == 0) { namedArgs = 0; } else { if ((int)Marshal.ReadInt16(ptr1) != 1) { throw new CustomAttributeFormatException(); } IntPtr ptr2 = (IntPtr)((void *)((IntPtr)(void *)ptr1 + 2)); namedArgs = (int)Marshal.ReadInt16(ptr2); ptr1 = (IntPtr)((void *)((IntPtr)(void *)ptr2 + 2)); } } for (int index2 = 0; index2 < namedArgs; ++index2) { IntPtr signature = caRecord.blob.Signature; string name; bool isProperty; RuntimeType type; object obj; CustomAttribute.GetPropertyOrFieldData(decoratedModule, ref ptr1, blobEnd, out name, out isProperty, out type, out obj); try { if (isProperty) { if (type == (RuntimeType)null && obj != null) { type = (RuntimeType)obj.GetType(); if (type == CustomAttribute.Type_RuntimeType) { type = CustomAttribute.Type_Type; } } RuntimePropertyInfo runtimePropertyInfo = !(type == (RuntimeType)null) ? attributeType.GetProperty(name, (Type)type, Type.EmptyTypes) as RuntimePropertyInfo : attributeType.GetProperty(name) as RuntimePropertyInfo; if ((PropertyInfo)runtimePropertyInfo == (PropertyInfo)null) { throw new CustomAttributeFormatException(string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Environment.GetResourceString(isProperty ? "RFLCT.InvalidPropFail" : "RFLCT.InvalidFieldFail"), (object)name)); } RuntimeMethodInfo runtimeMethodInfo = runtimePropertyInfo.GetSetMethod(true) as RuntimeMethodInfo; if (runtimeMethodInfo.IsPublic) { RuntimeMethodHandle.CheckLinktimeDemands((IRuntimeMethodInfo)runtimeMethodInfo, decoratedModule, isDecoratedTargetSecurityTransparent); runtimeMethodInfo.UnsafeInvoke(target, BindingFlags.Default, (Binder)null, new object[1] { obj }, (CultureInfo)null); } } else { RtFieldInfo rtFieldInfo = attributeType.GetField(name) as RtFieldInfo; if (isDecoratedTargetSecurityTransparent) { RuntimeFieldHandle.CheckAttributeAccess(rtFieldInfo.FieldHandle, decoratedModule.GetNativeHandle()); } rtFieldInfo.CheckConsistency(target); rtFieldInfo.UnsafeSetValue(target, obj, BindingFlags.Default, Type.DefaultBinder, (CultureInfo)null); } } catch (Exception ex) { throw new CustomAttributeFormatException(string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Environment.GetResourceString(isProperty ? "RFLCT.InvalidPropFail" : "RFLCT.InvalidFieldFail"), (object)name), ex); } } if (!ptr1.Equals((object)blobEnd)) { throw new CustomAttributeFormatException(); } attributeArrayHelper1[length++] = target; } } securityContextFrame.Pop(); if (length == attributeRecords.Length && pcaCount == 0) { return(attributeArrayHelper1); } object[] attributeArrayHelper2 = CustomAttribute.CreateAttributeArrayHelper(elementType, length + pcaCount); Array.Copy((Array)attributeArrayHelper1, 0, (Array)attributeArrayHelper2, 0, length); return(attributeArrayHelper2); }
internal QCallModule(ref System.Reflection.RuntimeModule module) { _ptr = Unsafe.AsPointer(ref module); _module = module.GetUnderlyingNativeHandle(); }
private static unsafe bool FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, ref Assembly lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, bool mustBeInheritable, object[] attributes, IList derivedAttributes, out RuntimeType attributeType, out IRuntimeMethodInfo ctor, out bool ctorHasParameters, out bool isVarArg) { ctor = (IRuntimeMethodInfo)null; attributeType = (RuntimeType)null; ctorHasParameters = false; isVarArg = false; IntPtr num = (IntPtr)((void *)((IntPtr)(void *)caRecord.blob.Signature + caRecord.blob.Length)); attributeType = decoratedModule.ResolveType(scope.GetParentToken((int)caRecord.tkCtor), (Type[])null, (Type[])null) as RuntimeType; if (!attributeFilterType.IsAssignableFrom((TypeInfo)attributeType) || !CustomAttribute.AttributeUsageCheck(attributeType, mustBeInheritable, attributes, derivedAttributes) || (attributeType.Attributes & TypeAttributes.WindowsRuntime) == TypeAttributes.WindowsRuntime) { return(false); } RuntimeAssembly targetAssembly = (RuntimeAssembly)attributeType.Assembly; RuntimeAssembly sourceAssembly = (RuntimeAssembly)decoratedModule.Assembly; if ((Assembly)targetAssembly != lastAptcaOkAssembly && !RuntimeAssembly.AptcaCheck(targetAssembly, sourceAssembly)) { return(false); } lastAptcaOkAssembly = (Assembly)sourceAssembly; ConstArray methodSignature = scope.GetMethodSignature(caRecord.tkCtor); isVarArg = ((uint)methodSignature[0] & 5U) > 0U; ctorHasParameters = (uint)methodSignature[1] > 0U; RuntimeTypeHandle runtimeTypeHandle1; if (ctorHasParameters) { ctor = ModuleHandle.ResolveMethodHandleInternal(decoratedModule.GetNativeHandle(), (int)caRecord.tkCtor); } else { // ISSUE: explicit reference operation // ISSUE: variable of a reference type IRuntimeMethodInfo& local = @ctor; runtimeTypeHandle1 = attributeType.GetTypeHandleInternal(); IRuntimeMethodInfo defaultConstructor = runtimeTypeHandle1.GetDefaultConstructor();
internal ModuleHandle(RuntimeModule module) { m_ptr = module; }
internal bool IsTransientInternal() { RuntimeModule thisAsLocal = this; return(RuntimeModule.nIsTransientInternal(JitHelpers.GetQCallModuleOnStack(ref thisAsLocal))); }
internal static extern int GetToken(RuntimeModule module);
void GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine) { RuntimeModule.GetPEKind(_impl, out peKind, out machine); }
[System.Security.SecuritySafeCritical] // auto-generated internal static RuntimeType ResolveTypeHandleInternal(RuntimeModule module, int typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) { ValidateModulePointer(module); if (!ModuleHandle.GetMetadataImport(module).IsValidToken(typeToken)) throw new ArgumentOutOfRangeException("metadataToken", Environment.GetResourceString("Argument_InvalidToken", typeToken, new ModuleHandle(module))); int typeInstCount, methodInstCount; IntPtr[] typeInstantiationContextHandles = RuntimeTypeHandle.CopyRuntimeTypeHandles(typeInstantiationContext, out typeInstCount); IntPtr[] methodInstantiationContextHandles = RuntimeTypeHandle.CopyRuntimeTypeHandles(methodInstantiationContext, out methodInstCount); fixed (IntPtr* typeInstArgs = typeInstantiationContextHandles, methodInstArgs = methodInstantiationContextHandles) { RuntimeType type = null; ResolveType(module, typeToken, typeInstArgs, typeInstCount, methodInstArgs, methodInstCount, JitHelpers.GetObjectHandleOnStack(ref type)); GC.KeepAlive(typeInstantiationContext); GC.KeepAlive(methodInstantiationContext); return type; } }
private static extern bool IsResource(RuntimeModule module);
internal static IRuntimeMethodInfo ResolveMethodHandleInternal(RuntimeModule module, int methodToken) { return ModuleHandle.ResolveMethodHandleInternal(module, methodToken, null, null); }
internal bool IsTransientInternal() { RuntimeModule thisAsLocal = this; return(RuntimeModule.nIsTransientInternal(new QCallModule(ref thisAsLocal))); }
[System.Security.SecurityCritical] // auto-generated internal static RuntimeMethodHandleInternal ResolveMethodHandleInternalCore(RuntimeModule module, int methodToken, IntPtr[] typeInstantiationContext, int typeInstCount, IntPtr[] methodInstantiationContext, int methodInstCount) { ValidateModulePointer(module); if (!ModuleHandle.GetMetadataImport(module.GetNativeHandle()).IsValidToken(methodToken)) throw new ArgumentOutOfRangeException("metadataToken", Environment.GetResourceString("Argument_InvalidToken", methodToken, new ModuleHandle(module))); fixed (IntPtr* typeInstArgs = typeInstantiationContext, methodInstArgs = methodInstantiationContext) { return ResolveMethod(module.GetNativeHandle(), methodToken, typeInstArgs, typeInstCount, methodInstArgs, methodInstCount); } }
// Token: 0x0600443D RID: 17469 RVA: 0x000FA6D0 File Offset: 0x000F88D0 internal CustomAttributeTypedArgument(RuntimeModule scope, CustomAttributeEncodedArgument encodedArg) { CustomAttributeEncoding customAttributeEncoding = encodedArg.CustomAttributeType.EncodedType; if (customAttributeEncoding == CustomAttributeEncoding.Undefined) { throw new ArgumentException("encodedArg"); } if (customAttributeEncoding == CustomAttributeEncoding.Enum) { this.m_argumentType = CustomAttributeTypedArgument.ResolveType(scope, encodedArg.CustomAttributeType.EnumName); this.m_value = CustomAttributeTypedArgument.EncodedValueToRawValue(encodedArg.PrimitiveValue, encodedArg.CustomAttributeType.EncodedEnumType); return; } if (customAttributeEncoding == CustomAttributeEncoding.String) { this.m_argumentType = typeof(string); this.m_value = encodedArg.StringValue; return; } if (customAttributeEncoding == CustomAttributeEncoding.Type) { this.m_argumentType = typeof(Type); this.m_value = null; if (encodedArg.StringValue != null) { this.m_value = CustomAttributeTypedArgument.ResolveType(scope, encodedArg.StringValue); return; } } else if (customAttributeEncoding == CustomAttributeEncoding.Array) { customAttributeEncoding = encodedArg.CustomAttributeType.EncodedArrayType; Type type; if (customAttributeEncoding == CustomAttributeEncoding.Enum) { type = CustomAttributeTypedArgument.ResolveType(scope, encodedArg.CustomAttributeType.EnumName); } else { type = CustomAttributeTypedArgument.CustomAttributeEncodingToType(customAttributeEncoding); } this.m_argumentType = type.MakeArrayType(); if (encodedArg.ArrayValue == null) { this.m_value = null; return; } CustomAttributeTypedArgument[] array = new CustomAttributeTypedArgument[encodedArg.ArrayValue.Length]; for (int i = 0; i < array.Length; i++) { array[i] = new CustomAttributeTypedArgument(scope, encodedArg.ArrayValue[i]); } this.m_value = Array.AsReadOnly <CustomAttributeTypedArgument>(array); return; } else { this.m_argumentType = CustomAttributeTypedArgument.CustomAttributeEncodingToType(customAttributeEncoding); this.m_value = CustomAttributeTypedArgument.EncodedValueToRawValue(encodedArg.PrimitiveValue, customAttributeEncoding); } }
[System.Security.SecuritySafeCritical] // auto-generated internal static IRuntimeFieldInfo ResolveFieldHandleInternal(RuntimeModule module, int fieldToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) { ValidateModulePointer(module); if (!ModuleHandle.GetMetadataImport(module.GetNativeHandle()).IsValidToken(fieldToken)) throw new ArgumentOutOfRangeException("metadataToken", Environment.GetResourceString("Argument_InvalidToken", fieldToken, new ModuleHandle(module))); // defensive copy to be sure array is not mutated from the outside during processing int typeInstCount, methodInstCount; IntPtr [] typeInstantiationContextHandles = RuntimeTypeHandle.CopyRuntimeTypeHandles(typeInstantiationContext, out typeInstCount); IntPtr [] methodInstantiationContextHandles = RuntimeTypeHandle.CopyRuntimeTypeHandles(methodInstantiationContext, out methodInstCount); fixed (IntPtr* typeInstArgs = typeInstantiationContextHandles, methodInstArgs = methodInstantiationContextHandles) { IRuntimeFieldInfo field = null; ResolveField(module.GetNativeHandle(), fieldToken, typeInstArgs, typeInstCount, methodInstArgs, methodInstCount, JitHelpers.GetObjectHandleOnStack(ref field)); GC.KeepAlive(typeInstantiationContext); GC.KeepAlive(methodInstantiationContext); return field; } }
private static extern RuntimeType[] GetTypes(RuntimeModule module);
private extern static bool _ContainsPropertyMatchingHash(RuntimeModule module, int propertyToken, uint hash);
static private extern void GetSignerCertificate(RuntimeModule module, ObjectHandleOnStack retData);
private extern static void GetAssembly(RuntimeModule handle, ObjectHandleOnStack retAssembly);
private extern static void GetType(RuntimeModule module, String className, bool ignoreCase, bool throwOnError, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive);
internal extern static void GetModuleType(RuntimeModule handle, ObjectHandleOnStack type);
private static extern bool nIsTransientInternal(RuntimeModule module);
private extern static void GetPEKind(RuntimeModule handle, out int peKind, out int machine);
private extern static void GetScopeName(RuntimeModule module, StringHandleOnStack retString);
internal extern static int GetMDStreamVersion(RuntimeModule module);
private extern static void GetFullyQualifiedName(RuntimeModule module, StringHandleOnStack retString);
[System.Security.SecurityCritical] // auto-generated internal static MetadataImport GetMetadataImport(RuntimeModule module) { return new MetadataImport(_GetMetadataImport(module.GetNativeHandle()), module); }
private extern static RuntimeType[] GetTypes(RuntimeModule module);
[System.Security.SecuritySafeCritical] // auto-generated internal static RuntimeType GetTypeByNameUsingCARules(string name, RuntimeModule scope) { if (name == null || name.Length == 0) throw new ArgumentException("name"); Contract.EndContractBlock(); RuntimeType type = null; GetTypeByNameUsingCARules(name, scope.GetNativeHandle(), JitHelpers.GetObjectHandleOnStack(ref type)); return type; }
internal bool IsTransientInternal() { return(RuntimeModule.nIsTransientInternal(this.GetNativeHandle())); }