[sgen] Never directly pin objects on the M&S major heap.
[mono.git] / mono / metadata / security-core-clr.c
index 82068daacf115074d67f0fd3c4ab0c96de5b48ae..0e165611a5363fea05698cf692d831e6b2d7e2b9 100644 (file)
@@ -409,25 +409,42 @@ mono_security_core_clr_require_elevated_permissions (void)
 }
 
 
-static MonoSecurityCoreCLRBehaviour security_core_clr_behaviour = MONO_SECURITY_CORE_CLR_BEHAVIOUR_MOONLIGHT;
+static MonoSecurityCoreCLROptions security_core_clr_options = MONO_SECURITY_CORE_CLR_OPTIONS_DEFAULT;
 
-/*
- * mono_security_core_clr_set_behaviour
+/**
+ * mono_security_core_clr_set_options:
+ * @options: the new options for the coreclr system to use
+ *
+ * By default, the CoreCLRs security model forbids execution trough reflection of methods not visible from the calling code.
+ * Even if the method being called is not in a platform assembly. For non moonlight CoreCLR users this restriction does not
+ * make a lot of sense, since the author could have just changed the non platform assembly to allow the method to be called.
+ * This function allows specific relaxations from the default behaviour to be set.
+ *
+ * Use MONO_SECURITY_CORE_CLR_OPTIONS_DEFAULT for the default coreclr coreclr behaviour as used in Moonlight.
+ *
+ * Use MONO_SECURITY_CORE_CLR_OPTIONS_RELAX_REFLECTION to allow transparent code to execute methods and access 
+ * fields that are not in platformcode, even if those methods and fields are private or otherwise not visible to the calling code.
+ *
+ * Use MONO_SECURITY_CORE_CLR_OPTIONS_RELAX_DELEGATE to allow delegates to be created that point at methods that are not in
+ * platformcode even if those methods and fields are private or otherwise not visible to the calling code.
  *
- *      Moonlight's security model forbids execution trough reflection of methods not visible from the calling code.
- *      Even if the method being called is not in a platform assembly. For non moonlight CoreCLR users this restriction does not
- *      make a lot of sense, since the author could have just changed the non platform assembly to allow the method to be called. 
  */
 
 void 
-mono_security_core_clr_set_behaviour (MonoSecurityCoreCLRBehaviour behaviour) {
-       security_core_clr_behaviour = behaviour;
+mono_security_core_clr_set_options (MonoSecurityCoreCLROptions options) {
+       security_core_clr_options = options;
 }
 
-MonoSecurityCoreCLRBehaviour
-mono_security_core_clr_get_behaviour ()
+/**
+ * mono_security_core_clr_get_options:
+ *
+ * Retrieves the current options used by the coreclr system.
+ */
+
+MonoSecurityCoreCLROptions
+mono_security_core_clr_get_options ()
 {
-       return security_core_clr_behaviour;
+       return security_core_clr_options;
 }
 
 
@@ -565,8 +582,7 @@ mono_security_core_clr_ensure_reflection_access_field (MonoClassField *field)
        if (mono_security_core_clr_method_level (caller, TRUE) != MONO_SECURITY_CORE_CLR_TRANSPARENT)
                return;
 
-       if (mono_security_core_clr_get_behaviour() == MONO_SECURITY_CORE_CLR_BEHAVIOUR_RELAXED)
-       {
+       if (mono_security_core_clr_get_options () & MONO_SECURITY_CORE_CLR_OPTIONS_RELAX_REFLECTION) {
                if (!mono_security_core_clr_is_platform_image (mono_field_get_parent(field)->image))
                        return;
        }
@@ -603,8 +619,7 @@ mono_security_core_clr_ensure_reflection_access_method (MonoMethod *method)
        if (mono_security_core_clr_method_level (caller, TRUE) != MONO_SECURITY_CORE_CLR_TRANSPARENT)
                return;
 
-       if (mono_security_core_clr_get_behaviour() == MONO_SECURITY_CORE_CLR_BEHAVIOUR_RELAXED)
-       {
+       if (mono_security_core_clr_get_options () & MONO_SECURITY_CORE_CLR_OPTIONS_RELAX_REFLECTION) {
                if (!mono_security_core_clr_is_platform_image (method->klass->image))
                        return;
        }
@@ -691,9 +706,8 @@ mono_security_core_clr_ensure_delegate_creation (MonoMethod *method, gboolean th
                        "Transparent method %s cannot create a delegate on Critical method %s.", 
                        caller, method));
        }
-       
-       if (mono_security_core_clr_get_behaviour() == MONO_SECURITY_CORE_CLR_BEHAVIOUR_RELAXED)
-       {
+
+       if (mono_security_core_clr_get_options () & MONO_SECURITY_CORE_CLR_OPTIONS_RELAX_DELEGATE) {
                if (!mono_security_core_clr_is_platform_image (method->klass->image))
                        return TRUE;
        }