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