12d685bd27cf67cdcad4ee2c45fc5db2fec5b46f
[mono.git] / mono / mini / declsec.h
1 /*
2  * declsec.h:  Declarative Security support
3  *
4  * Author:
5  *      Sebastien Pouliot  <sebastien@ximian.com>
6  *
7  * (C) 2004-2005 Novell (http://www.novell.com)
8  */
9
10 #ifndef _MONO_MINI_DECLSEC_H_
11 #define _MONO_MINI_DECLSEC_H_
12
13 #include <string.h>
14
15 #include "mono/metadata/class-internals.h"
16 #include "mono/metadata/domain-internals.h"
17 #include "mono/metadata/object.h"
18 #include "mono/metadata/tabledefs.h"
19 #include "mono/metadata/marshal.h"
20 #include "mono/metadata/security-manager.h"
21 #include "mono/metadata/exception.h"
22
23
24 /* Definitions */
25
26 #define MONO_SECMAN_FLAG_INIT(x)                (x & 0x2)
27 #define MONO_SECMAN_FLAG_GET_VALUE(x)           (x & 0x1)
28 #define MONO_SECMAN_FLAG_SET_VALUE(x,y)         do { x = ((y) ? 0x3 : 0x2); } while (0)
29
30 #define MONO_CAS_INITIAL_STACK_SIZE             6
31
32
33 /* keep in synch with RuntimeSecurityFrame in /mcs/class/corlib/System.Security/SecurityFrame.cs */
34 typedef struct {
35         MonoObject obj;
36         MonoAppDomain *domain;
37         MonoReflectionMethod *method;
38         MonoDeclSecurityEntry assert;
39         MonoDeclSecurityEntry deny;
40         MonoDeclSecurityEntry permitonly;
41 } MonoSecurityFrame;
42
43
44 /* limited flags used in MonoJitInfo for stack modifiers */
45 enum {
46         MONO_JITINFO_STACKMOD_ASSERT            = 0x01,
47         MONO_JITINFO_STACKMOD_DENY              = 0x02,
48         MONO_JITINFO_STACKMOD_PERMITONLY        = 0x04
49 };
50
51 enum {
52         MONO_JIT_SECURITY_OK                    = 0x00,
53         MONO_JIT_LINKDEMAND_PERMISSION          = 0x01,
54         MONO_JIT_LINKDEMAND_APTC                = 0x02,
55         MONO_JIT_LINKDEMAND_ECMA                = 0x04,
56         MONO_JIT_LINKDEMAND_PINVOKE             = 0x08
57 };
58
59 /* Prototypes */
60 MonoBoolean mono_method_has_declsec (MonoMethod *method);
61 void mono_declsec_cache_stack_modifiers (MonoJitInfo *jinfo);
62 MonoSecurityFrame* mono_declsec_create_frame (MonoDomain *domain, MonoJitInfo *jinfo);
63
64 guint32 mono_declsec_linkdemand (MonoDomain *domain, MonoMethod *caller, MonoMethod *callee);
65
66 #endif /* _MONO_MINI_DECLSEC_H_ */