Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
 internal QCallAssembly(ref System.Reflection.RuntimeAssembly assembly)
 {
     _ptr      = Unsafe.AsPointer(ref assembly);
     _assembly = assembly.GetUnderlyingNativeHandle();
 }
Ejemplo n.º 3
0
 internal unsafe ManifestResourceStream(RuntimeAssembly manifestAssembly, byte *pointer, long length, long capacity, FileAccess access) : base(pointer, length, capacity, access)
 {
     _manifestAssembly = manifestAssembly;
 }
Ejemplo n.º 4
0
 private static extern string[] GetManifestResourceNames(RuntimeAssembly assembly);
Ejemplo n.º 5
0
 internal extern void nInit(out RuntimeAssembly assembly, bool forIntrospection, bool raiseResolveEvent);
Ejemplo n.º 6
0
 private static extern void GetImageRuntimeVersion(RuntimeAssembly assembly, StringHandleOnStack retString);
Ejemplo n.º 7
0
 private static extern int GetManifestResourceInfo(RuntimeAssembly assembly,
                                                   string resourceName,
                                                   ObjectHandleOnStack assemblyRef,
                                                   StringHandleOnStack retFileName);
Ejemplo n.º 8
0
 private static extern RuntimeAssembly nLoad(AssemblyName fileName,
                                             string codeBase,
                                             RuntimeAssembly assemblyContext,
                                             ref StackCrawlMark stackMark,
                                             bool throwOnFileNotFound,
                                             IntPtr ptrLoadContextBinder);
Ejemplo n.º 9
0
        [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));
        }
Ejemplo n.º 10
0
        [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));
        }
Ejemplo n.º 11
0
        [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));
        }
Ejemplo n.º 12
0
 internal static extern int GetToken(RuntimeAssembly assembly);
Ejemplo n.º 13
0
 internal static extern RuntimeModule GetManifestModule(RuntimeAssembly assembly);
Ejemplo n.º 14
0
        private AssemblyNameFlags GetFlags()
        {
            RuntimeAssembly runtimeAssembly = this;

            return(GetFlags(new QCallAssembly(ref runtimeAssembly)));
        }
Ejemplo n.º 15
0
        private AssemblyHashAlgorithm GetHashAlgorithm()
        {
            RuntimeAssembly runtimeAssembly = this;

            return(GetHashAlgorithm(new QCallAssembly(ref runtimeAssembly)));
        }
Ejemplo n.º 16
0
 private static extern unsafe byte *GetResource(RuntimeAssembly assembly,
                                                string resourceName,
                                                out uint length);
Ejemplo n.º 17
0
        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());
        }
Ejemplo n.º 18
0
 private static extern void GetModule(RuntimeAssembly assembly, string name, ObjectHandleOnStack retModule);
Ejemplo n.º 19
0
        internal static bool IsDefined(RuntimeAssembly assembly, RuntimeType caType)
        {
            int num;

            return(GetCustomAttributes(assembly, caType, true, out num).Length > 0);
        }
Ejemplo n.º 20
0
 private static extern void GetLocation(RuntimeAssembly assembly, StringHandleOnStack retString);
Ejemplo n.º 21
0
 internal extern void nInit(out RuntimeAssembly assembly, bool raiseResolveEvent);
Ejemplo n.º 22
0
 private static extern void GetCodeBase(RuntimeAssembly assembly,
                                        bool copiedName,
                                        StringHandleOnStack retString);
Ejemplo n.º 23
0
 private static extern void GetFullName(RuntimeAssembly assembly, StringHandleOnStack retString);
Ejemplo n.º 24
0
        [System.Security.SecurityCritical]  // auto-generated
        internal void nInit()
        {
            RuntimeAssembly dummy = null;

            nInit(out dummy, false, false);
        }
Ejemplo n.º 25
0
 private static extern void GetEntryPoint(RuntimeAssembly assembly, ObjectHandleOnStack retMethod);
Ejemplo n.º 26
0
 private static extern AssemblyName[] GetReferencedAssemblies(RuntimeAssembly assembly);
Ejemplo n.º 27
0
 private static extern void GetType(RuntimeAssembly assembly,
                                    string name,
                                    bool throwOnError,
                                    bool ignoreCase,
                                    ObjectHandleOnStack type,
                                    ObjectHandleOnStack keepAlive);
Ejemplo n.º 28
0
 private static extern bool FCallIsDynamic(RuntimeAssembly assembly);
Ejemplo n.º 29
0
 private static extern void GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes);
Ejemplo n.º 30
0
 internal static extern bool GetIsCollectible(RuntimeAssembly assembly);
Ejemplo n.º 31
0
 internal static IList <CustomAttributeData> GetCustomAttributesInternal(RuntimeAssembly target)
 {
     return(CustomAttribute.GetCustomAttributesData(target));
 }