[2020-02] Fix leak in assembly-specific dllmap lookups (#21053)
[mono-project.git] / mono / metadata / mono-security-windows-uwp.c
blob5923fe0e99b4ab3c884a95ee0c94e35615ab751d
1 /**
2 * \file
3 * UWP security support for Mono.
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"
12 #if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
14 #include <windows.h>
15 #include "mono/metadata/mono-security-windows-internals.h"
17 static void
18 mono_security_win_not_supported (const char *functions, MonoError *error)
20 g_unsupported_api (functions);
21 mono_error_set_not_supported (error, G_UNSUPPORTED_API, functions);
22 SetLastError (ERROR_NOT_SUPPORTED);
25 gpointer
26 mono_security_principal_windows_identity_get_current_token (MonoError *error)
28 // FIXME This is now supported by UWP.
29 mono_security_win_not_supported ("OpenThreadToken, OpenProcessToken", error);
30 return NULL;
33 gpointer
34 ves_icall_System_Security_Principal_WindowsIdentity_GetCurrentToken (MonoError *error)
36 return mono_security_principal_windows_identity_get_current_token (error);
39 MonoArrayHandle
40 ves_icall_System_Security_Principal_WindowsIdentity_GetRoles (gpointer token, MonoError *error)
42 mono_security_win_not_supported ("GetTokenInformation", error);
43 return NULL_HANDLE_ARRAY;
46 gpointer
47 ves_icall_System_Security_Principal_WindowsImpersonationContext_DuplicateToken (gpointer token, MonoError *error)
49 // FIXME This is now supported by UWP.
50 mono_security_win_not_supported ("DuplicateToken", error);
51 return NULL;
54 MonoBoolean
55 ves_icall_System_Security_Principal_WindowsImpersonationContext_SetCurrentToken (gpointer token, MonoError *error)
57 mono_security_win_not_supported ("ImpersonateLoggedOnUser", error);
58 return FALSE;
61 MonoBoolean
62 ves_icall_System_Security_Principal_WindowsImpersonationContext_RevertToSelf (MonoError *error)
64 mono_security_win_not_supported ("RevertToSelf", error);
65 return FALSE;
68 gint32
69 mono_security_win_get_token_name (gpointer token, gunichar2 **uniname, MonoError *error)
71 // FIXME This is now supported by UWP.
72 mono_security_win_not_supported ("GetTokenInformation", error);
73 return 0;
76 gboolean
77 mono_security_win_is_machine_protected (const gunichar2 *path, MonoError *error)
79 // FIXME This is now supported by UWP.
80 mono_security_win_not_supported ("GetNamedSecurityInfo, LocalFree", error);
81 return FALSE;
84 gboolean
85 mono_security_win_is_user_protected (const gunichar2 *path, MonoError *error)
87 // FIXME This is now supported by UWP.
88 mono_security_win_not_supported ("GetNamedSecurityInfo, LocalFree", error);
89 return FALSE;
92 gboolean
93 mono_security_win_protect_machine (const gunichar2 *path, MonoError *error)
95 // FIXME This is now supported by UWP. Except BuildTrusteeWithSid?
96 mono_security_win_not_supported ("BuildTrusteeWithSid, SetEntriesInAcl, SetNamedSecurityInfo, LocalFree, FreeSid", error);
97 return FALSE;
100 gboolean
101 mono_security_win_protect_user (const gunichar2 *path, MonoError *error)
103 // FIXME This is now supported by UWP. Except BuildTrusteeWithSid?
104 mono_security_win_not_supported ("BuildTrusteeWithSid, SetEntriesInAcl, SetNamedSecurityInfo, LocalFree", error);
105 return FALSE;
108 #else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
110 MONO_EMPTY_SOURCE_FILE (mono_security_windows_uwp);
112 #endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */