internal StrongName(StrongNamePublicKeyBlob blob, String name, Version version, Assembly assembly) { if (name == null) throw new ArgumentNullException(nameof(name)); if (String.IsNullOrEmpty(name)) throw new ArgumentException(Environment.GetResourceString("Argument_EmptyStrongName")); if (blob == null) throw new ArgumentNullException(nameof(blob)); if (version == null) throw new ArgumentNullException(nameof(version)); Contract.EndContractBlock(); RuntimeAssembly rtAssembly = assembly as RuntimeAssembly; if (assembly != null && rtAssembly == null) throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeAssembly"), nameof(assembly)); m_publicKeyBlob = blob; m_name = name; m_version = version; m_assembly = rtAssembly; }
internal QCallAssembly(ref System.Reflection.RuntimeAssembly assembly) { _ptr = Unsafe.AsPointer(ref assembly); _assembly = assembly.GetUnderlyingNativeHandle(); }
internal unsafe ManifestResourceStream(RuntimeAssembly manifestAssembly, byte *pointer, long length, long capacity, FileAccess access) : base(pointer, length, capacity, access) { _manifestAssembly = manifestAssembly; }
private static extern string[] GetManifestResourceNames(RuntimeAssembly assembly);
internal extern void nInit(out RuntimeAssembly assembly, bool forIntrospection, bool raiseResolveEvent);
private static extern void GetImageRuntimeVersion(RuntimeAssembly assembly, StringHandleOnStack retString);
private static extern int GetManifestResourceInfo(RuntimeAssembly assembly, string resourceName, ObjectHandleOnStack assemblyRef, StringHandleOnStack retFileName);
private static extern RuntimeAssembly nLoad(AssemblyName fileName, string codeBase, RuntimeAssembly assemblyContext, ref StackCrawlMark stackMark, bool throwOnFileNotFound, IntPtr ptrLoadContextBinder);
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable public override Object Invoke( Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) { INVOCATION_FLAGS invocationFlags = InvocationFlags; if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE) != 0) { ThrowNoInvokeException(); } // check basic method consistency. This call will throw if there are problems in the target/method relationship CheckConsistency(obj); #if FEATURE_APPX if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0) { StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; RuntimeAssembly caller = RuntimeAssembly.GetExecutingAssembly(ref stackMark); if (caller != null && !caller.IsSafeForReflection()) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", FullName)); } } #endif if (obj != null) { #if FEATURE_CORECLR // For unverifiable code, we require the caller to be critical. // Adding the INVOCATION_FLAGS_NEED_SECURITY flag makes that check happen invocationFlags |= INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY; #else // FEATURE_CORECLR new SecurityPermission(SecurityPermissionFlag.SkipVerification).Demand(); #endif // FEATURE_CORECLR } #if !FEATURE_CORECLR if ((invocationFlags & (INVOCATION_FLAGS.INVOCATION_FLAGS_RISKY_METHOD | INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY)) != 0) { if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_RISKY_METHOD) != 0) { CodeAccessPermission.Demand(PermissionType.ReflectionMemberAccess); } if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY) != 0) { RuntimeMethodHandle.PerformSecurityCheck(obj, this, m_declaringType, (uint)m_invocationFlags); } } #endif // !FEATURE_CORECLR Signature sig = Signature; // get the signature int formalCount = sig.Arguments.Length; int actualCount = (parameters != null) ? parameters.Length : 0; if (formalCount != actualCount) { throw new TargetParameterCountException(Environment.GetResourceString("Arg_ParmCnt")); } // if we are here we passed all the previous checks. Time to look at the arguments if (actualCount > 0) { Object[] arguments = CheckArguments(parameters, binder, invokeAttr, culture, sig); Object retValue = RuntimeMethodHandle.InvokeMethod(obj, arguments, sig, false); // copy out. This should be made only if ByRef are present. for (int index = 0; index < arguments.Length; index++) { parameters[index] = arguments[index]; } return(retValue); } return(RuntimeMethodHandle.InvokeMethod(obj, null, sig, false)); }
[System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod public static Assembly GetExecutingAssembly() { StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; return(RuntimeAssembly.GetExecutingAssembly(ref stackMark)); }
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable public override Object Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) { INVOCATION_FLAGS invocationFlags = InvocationFlags; // get the declaring TypeHandle early for consistent exceptions in IntrospectionOnly context RuntimeTypeHandle declaringTypeHandle = m_declaringType.TypeHandle; if ((invocationFlags & (INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE | INVOCATION_FLAGS.INVOCATION_FLAGS_CONTAINS_STACK_POINTERS | INVOCATION_FLAGS.INVOCATION_FLAGS_NO_CTOR_INVOKE)) != 0) { ThrowNoInvokeException(); } #if FEATURE_APPX if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0) { StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; RuntimeAssembly caller = RuntimeAssembly.GetExecutingAssembly(ref stackMark); if (caller != null && !caller.IsSafeForReflection()) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", FullName)); } } #endif if ((invocationFlags & (INVOCATION_FLAGS.INVOCATION_FLAGS_RISKY_METHOD | INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY | INVOCATION_FLAGS.INVOCATION_FLAGS_IS_DELEGATE_CTOR)) != 0) { #if !FEATURE_CORECLR if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_RISKY_METHOD) != 0) { CodeAccessPermission.Demand(PermissionType.ReflectionMemberAccess); } if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY) != 0) #endif // !FEATURE_CORECLR RuntimeMethodHandle.PerformSecurityCheck(null, this, m_declaringType, (uint)(m_invocationFlags | INVOCATION_FLAGS.INVOCATION_FLAGS_CONSTRUCTOR_INVOKE)); #if !FEATURE_CORECLR if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_IS_DELEGATE_CTOR) != 0) { new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); } #endif // !FEATURE_CORECLR } // get the signature Signature sig = Signature; int formalCount = sig.Arguments.Length; int actualCount = (parameters != null) ? parameters.Length : 0; if (formalCount != actualCount) { throw new TargetParameterCountException(Environment.GetResourceString("Arg_ParmCnt")); } // We don't need to explicitly invoke the class constructor here, // JIT/NGen will insert the call to .cctor in the instance ctor. // if we are here we passed all the previous checks. Time to look at the arguments if (actualCount > 0) { Object[] arguments = CheckArguments(parameters, binder, invokeAttr, culture, sig); Object retValue = RuntimeMethodHandle.InvokeMethod(null, arguments, sig, true); // copy out. This should be made only if ByRef are present. for (int index = 0; index < arguments.Length; index++) { parameters[index] = arguments[index]; } return(retValue); } return(RuntimeMethodHandle.InvokeMethod(null, null, sig, true)); }
internal static extern int GetToken(RuntimeAssembly assembly);
internal static extern RuntimeModule GetManifestModule(RuntimeAssembly assembly);
private AssemblyNameFlags GetFlags() { RuntimeAssembly runtimeAssembly = this; return(GetFlags(new QCallAssembly(ref runtimeAssembly))); }
private AssemblyHashAlgorithm GetHashAlgorithm() { RuntimeAssembly runtimeAssembly = this; return(GetHashAlgorithm(new QCallAssembly(ref runtimeAssembly))); }
private static extern unsafe byte *GetResource(RuntimeAssembly assembly, string resourceName, out uint length);
internal static Attribute[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType, bool includeSecCa, out int count) { count = 0; bool flag = (caType == ((RuntimeType)typeof(object))) || (caType == ((RuntimeType)typeof(Attribute))); if ((!flag && (s_pca.GetValueOrDefault(caType) == null)) && !IsSecurityAttribute(caType)) { return(new Attribute[0]); } List <Attribute> list = new List <Attribute>(); if (includeSecCa && (flag || IsSecurityAttribute(caType))) { object[] objArray; GetSecurityAttributes(assembly.ManifestModule.ModuleHandle.GetRuntimeModule(), RuntimeAssembly.GetToken(assembly.GetNativeHandle()), true, out objArray); if (objArray != null) { foreach (object obj2 in objArray) { if ((caType == obj2.GetType()) || obj2.GetType().IsSubclassOf(caType)) { list.Add((Attribute)obj2); } } } } count = list.Count; return(list.ToArray()); }
private static extern void GetModule(RuntimeAssembly assembly, string name, ObjectHandleOnStack retModule);
internal static bool IsDefined(RuntimeAssembly assembly, RuntimeType caType) { int num; return(GetCustomAttributes(assembly, caType, true, out num).Length > 0); }
private static extern void GetLocation(RuntimeAssembly assembly, StringHandleOnStack retString);
internal extern void nInit(out RuntimeAssembly assembly, bool raiseResolveEvent);
private static extern void GetCodeBase(RuntimeAssembly assembly, bool copiedName, StringHandleOnStack retString);
private static extern void GetFullName(RuntimeAssembly assembly, StringHandleOnStack retString);
[System.Security.SecurityCritical] // auto-generated internal void nInit() { RuntimeAssembly dummy = null; nInit(out dummy, false, false); }
private static extern void GetEntryPoint(RuntimeAssembly assembly, ObjectHandleOnStack retMethod);
private static extern AssemblyName[] GetReferencedAssemblies(RuntimeAssembly assembly);
private static extern void GetType(RuntimeAssembly assembly, string name, bool throwOnError, bool ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive);
private static extern bool FCallIsDynamic(RuntimeAssembly assembly);
private static extern void GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes);
internal static extern bool GetIsCollectible(RuntimeAssembly assembly);
internal static IList <CustomAttributeData> GetCustomAttributesInternal(RuntimeAssembly target) { return(CustomAttribute.GetCustomAttributesData(target)); }