copying the latest Sys.Web.Services from trunk.
[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
31 /* keep in synch with RuntimeSecurityFrame in /mcs/class/corlib/System.Security/SecurityFrame.cs */
32 typedef struct {
33         MonoObject obj;
34         MonoReflectionMethod *method;
35         MonoDeclSecurityEntry assert;
36         MonoDeclSecurityEntry deny;
37         MonoDeclSecurityEntry permitonly;
38 } MonoSecurityFrame;
39
40
41 /* limited flags used in MonoJitInfo for stack modifiers */
42 enum {
43         MONO_JITINFO_STACKMOD_ASSERT            = 0x01,
44         MONO_JITINFO_STACKMOD_DENY              = 0x02,
45         MONO_JITINFO_STACKMOD_PERMITONLY        = 0x04
46 };
47
48 enum {
49         MONO_JIT_SECURITY_OK                    = 0x00,
50         MONO_JIT_LINKDEMAND_PERMISSION          = 0x01,
51         MONO_JIT_LINKDEMAND_APTC                = 0x02,
52         MONO_JIT_LINKDEMAND_ECMA                = 0x04,
53         MONO_JIT_LINKDEMAND_PINVOKE             = 0x08
54 };
55
56 /* Prototypes */
57 MonoBoolean mono_method_has_declsec (MonoMethod *method);
58 void mono_declsec_cache_stack_modifiers (MonoJitInfo *jinfo);
59 MonoSecurityFrame* mono_declsec_create_frame (MonoDomain *domain, MonoJitInfo *jinfo);
60
61 guint32 mono_declsec_linkdemand (MonoDomain *domain, MonoMethod *caller, MonoMethod *callee);
62
63 #endif /* _MONO_MINI_DECLSEC_H_ */