Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / metadata / security-core-clr.h
1 /**
2  * \file
3  * CoreCLR security
4  *
5  * Author:
6  *      Mark Probst <mark.probst@gmail.com>
7  *
8  * (C) 2007, 2010 Novell, Inc
9  */
10
11 #ifndef _MONO_METADATA_SECURITY_CORE_CLR_H_
12 #define _MONO_METADATA_SECURITY_CORE_CLR_H_
13
14 #include <glib.h>
15 #include <mono/metadata/reflection.h>
16 #include <mono/utils/mono-compiler.h>
17
18 typedef enum {
19         /* We compare these values as integers, so the order must not
20            be changed. */
21         MONO_SECURITY_CORE_CLR_TRANSPARENT = 0,
22         MONO_SECURITY_CORE_CLR_SAFE_CRITICAL,
23         MONO_SECURITY_CORE_CLR_CRITICAL
24 } MonoSecurityCoreCLRLevel;
25
26 typedef enum {
27         //The following flags can be used in combination, and control specific behaviour of the CoreCLR securit system.
28
29         //Default coreclr behaviour, as used in moonlight.
30         MONO_SECURITY_CORE_CLR_OPTIONS_DEFAULT = 0,
31
32         //Allow transparent code to execute methods and access fields that are not in platformcode,
33         //even if those methods and fields are private or otherwise not visible to the calling code.
34         MONO_SECURITY_CORE_CLR_OPTIONS_RELAX_REFLECTION = 1,
35
36         //Allow delegates to be created that point at methods that are not in platformcode,
37         //even if those methods and fields are private or otherwise not visible to the calling code.
38         MONO_SECURITY_CORE_CLR_OPTIONS_RELAX_DELEGATE = 2
39 } MonoSecurityCoreCLROptions;
40
41 extern gboolean mono_security_core_clr_test;
42
43 extern void mono_security_core_clr_check_inheritance (MonoClass *klass);
44 extern void mono_security_core_clr_check_override (MonoClass *klass, MonoMethod *override, MonoMethod *base);
45
46 extern gboolean
47 mono_security_core_clr_ensure_reflection_access_field (MonoClassField *field, MonoError *error);
48 extern gboolean
49 mono_security_core_clr_ensure_reflection_access_method (MonoMethod *method, MonoError *error);
50 extern gboolean mono_security_core_clr_ensure_delegate_creation (MonoMethod *method, MonoError *error);
51 extern MonoException* mono_security_core_clr_ensure_dynamic_method_resolved_object (gpointer ref, MonoClass *handle_class);
52
53 extern gboolean mono_security_core_clr_can_access_internals (MonoImage *accessing, MonoImage* accessed);
54
55 extern MonoException* mono_security_core_clr_is_field_access_allowed (MonoMethod *caller, MonoClassField *field);
56 extern MonoException* mono_security_core_clr_is_call_allowed (MonoMethod *caller, MonoMethod *callee);
57
58 extern MonoSecurityCoreCLRLevel mono_security_core_clr_class_level (MonoClass *klass);
59 extern MonoSecurityCoreCLRLevel mono_security_core_clr_field_level (MonoClassField *field, gboolean with_class_level);
60 extern MonoSecurityCoreCLRLevel mono_security_core_clr_method_level (MonoMethod *method, gboolean with_class_level);
61
62 extern gboolean mono_security_core_clr_is_platform_image (MonoImage *image);
63 extern gboolean mono_security_core_clr_determine_platform_image (MonoImage *image);
64
65 extern MONO_API gboolean mono_security_core_clr_require_elevated_permissions (void);
66
67 extern MONO_API void mono_security_core_clr_set_options (MonoSecurityCoreCLROptions options);
68 extern MONO_API MonoSecurityCoreCLROptions mono_security_core_clr_get_options (void);
69
70 #endif  /* _MONO_METADATA_SECURITY_CORE_CLR_H_ */