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

            return(GetFlags(new QCallAssembly(ref runtimeAssembly)));
        }
Пример #15
0
        private AssemblyHashAlgorithm GetHashAlgorithm()
        {
            RuntimeAssembly runtimeAssembly = this;

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

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

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