Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / metadata / mono-security-windows-uwp.c
1 /**
2  * \file
3  * UWP security support for Mono.
4  *
5  * Copyright 2016 Microsoft
6  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
7 */
8 #include <config.h>
9 #include <glib.h>
10 #include "mono/utils/mono-compiler.h"
11
12 #if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
13 #include <windows.h>
14 #include "mono/metadata/mono-security-windows-internals.h"
15
16 gpointer
17 mono_security_principal_windows_identity_get_current_token ()
18 {
19         g_unsupported_api ("OpenThreadToken, OpenProcessToken");
20
21         SetLastError (ERROR_NOT_SUPPORTED);
22         return NULL;
23 }
24
25 gpointer
26 ves_icall_System_Security_Principal_WindowsIdentity_GetCurrentToken (MonoError *error)
27 {
28         error_init (error);
29
30         mono_error_set_not_supported (error, G_UNSUPPORTED_API, "OpenThreadToken, OpenProcessToken");
31         return mono_security_principal_windows_identity_get_current_token ();
32 }
33
34 MonoArray*
35 ves_icall_System_Security_Principal_WindowsIdentity_GetRoles (gpointer token)
36 {
37         MonoError mono_error;
38         error_init (&mono_error);
39
40         g_unsupported_api ("GetTokenInformation");
41
42         mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "GetTokenInformation");
43         mono_error_set_pending_exception (&mono_error);
44
45         SetLastError (ERROR_NOT_SUPPORTED);
46
47         return NULL;
48 }
49
50 gpointer
51 ves_icall_System_Security_Principal_WindowsImpersonationContext_DuplicateToken (gpointer token)
52 {
53         MonoError mono_error;
54         error_init (&mono_error);
55
56         g_unsupported_api ("DuplicateToken");
57
58         mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "DuplicateToken");
59         mono_error_set_pending_exception (&mono_error);
60
61         SetLastError (ERROR_NOT_SUPPORTED);
62
63         return NULL;
64 }
65
66 gboolean
67 ves_icall_System_Security_Principal_WindowsImpersonationContext_SetCurrentToken (gpointer token)
68 {
69         MonoError mono_error;
70         error_init (&mono_error);
71
72         g_unsupported_api ("ImpersonateLoggedOnUser");
73
74         mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "ImpersonateLoggedOnUser");
75         mono_error_set_pending_exception (&mono_error);
76
77         SetLastError (ERROR_NOT_SUPPORTED);
78
79         return FALSE;
80 }
81
82 gboolean
83 ves_icall_System_Security_Principal_WindowsImpersonationContext_RevertToSelf (void)
84 {
85         MonoError mono_error;
86         error_init (&mono_error);
87
88         g_unsupported_api ("RevertToSelf");
89
90         mono_error_set_not_supported(&mono_error, G_UNSUPPORTED_API, "RevertToSelf");
91         mono_error_set_pending_exception (&mono_error);
92
93         SetLastError (ERROR_NOT_SUPPORTED);
94
95         return FALSE;
96 }
97
98 gint32
99 mono_security_win_get_token_name (gpointer token, gunichar2 ** uniname)
100 {
101         MonoError mono_error;
102         error_init (&mono_error);
103
104         g_unsupported_api ("GetTokenInformation");
105
106         mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "GetTokenInformation");
107         mono_error_set_pending_exception (&mono_error);
108
109         SetLastError (ERROR_NOT_SUPPORTED);
110
111         return 0;
112 }
113
114 gboolean
115 mono_security_win_is_machine_protected (gunichar2 *path)
116 {
117         MonoError mono_error;
118         error_init (&mono_error);
119
120         g_unsupported_api ("GetNamedSecurityInfo, LocalFree");
121
122         mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "GetNamedSecurityInfo, LocalFree");
123         mono_error_set_pending_exception (&mono_error);
124
125         SetLastError (ERROR_NOT_SUPPORTED);
126
127         return FALSE;
128 }
129
130 gboolean
131 mono_security_win_is_user_protected (gunichar2 *path)
132 {
133         MonoError mono_error;
134         error_init (&mono_error);
135
136         g_unsupported_api ("GetNamedSecurityInfo, LocalFree");
137
138         mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "GetNamedSecurityInfo, LocalFree");
139         mono_error_set_pending_exception (&mono_error);
140
141         SetLastError (ERROR_NOT_SUPPORTED);
142
143         return FALSE;
144 }
145
146 gboolean
147 mono_security_win_protect_machine (gunichar2 *path)
148 {
149         MonoError mono_error;
150         error_init (&mono_error);
151
152         g_unsupported_api ("BuildTrusteeWithSid, SetEntriesInAcl, SetNamedSecurityInfo, LocalFree, FreeSid");
153
154         mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "BuildTrusteeWithSid, SetEntriesInAcl, SetNamedSecurityInfo, LocalFree, FreeSid");
155         mono_error_set_pending_exception (&mono_error);
156
157         SetLastError (ERROR_NOT_SUPPORTED);
158
159         return FALSE;
160 }
161
162 gboolean
163 mono_security_win_protect_user (gunichar2 *path)
164 {
165         MonoError mono_error;
166         error_init (&mono_error);
167
168         g_unsupported_api ("BuildTrusteeWithSid, SetEntriesInAcl, SetNamedSecurityInfo, LocalFree");
169
170         mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "BuildTrusteeWithSid, SetEntriesInAcl, SetNamedSecurityInfo, LocalFree");
171         mono_error_set_pending_exception (&mono_error);
172
173         SetLastError (ERROR_NOT_SUPPORTED);
174
175         return FALSE;
176 }
177 #else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
178
179 MONO_EMPTY_SOURCE_FILE (mono_security_windows_uwp);
180 #endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */