Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / metadata / mono-security-windows.c
index f6d088dd0c7b11b50d6bc20bfc73bc6bfdc875fc..bfdc96a9bb2804621bd149e99b7d36cd3967ee72 100644 (file)
@@ -1,5 +1,6 @@
-/*
- * mono-security-windows.c: Windows security support.
+/**
+ * \file
+ * Windows security support.
  *
  * Copyright 2016 Microsoft
  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
@@ -68,7 +69,7 @@ GetSidName (gunichar2 *server, PSID sid, gint32 *size)
 }
 
 gpointer
-ves_icall_System_Security_Principal_WindowsIdentity_GetCurrentToken (void)
+mono_security_principal_windows_identity_get_current_token (void)
 {
        gpointer token = NULL;
 
@@ -85,6 +86,13 @@ ves_icall_System_Security_Principal_WindowsIdentity_GetCurrentToken (void)
        return token;
 }
 
+gpointer
+ves_icall_System_Security_Principal_WindowsIdentity_GetCurrentToken (MonoError *error)
+{
+       error_init (error);
+       return mono_security_principal_windows_identity_get_current_token ();
+}
+
 gint32
 mono_security_win_get_token_name (gpointer token, gunichar2 ** uniname)
 {
@@ -103,34 +111,33 @@ mono_security_win_get_token_name (gpointer token, gunichar2 ** uniname)
 }
 #endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
 
-MonoString*
-ves_icall_System_Security_Principal_WindowsIdentity_GetTokenName (gpointer token)
+MonoStringHandle
+ves_icall_System_Security_Principal_WindowsIdentity_GetTokenName (gpointer token, MonoError *error)
 {
-       MonoError error;
-       MonoString *result = NULL;
+       MonoStringHandle result;
        gunichar2 *uniname = NULL;
        gint32 size = 0;
 
-       mono_error_init (&error);
+       error_init (error);
 
        size = mono_security_win_get_token_name (token, &uniname);
 
        if (size > 0) {
-               result = mono_string_new_utf16_checked (mono_domain_get (), uniname, size, &error);
+               result = mono_string_new_utf16_handle (mono_domain_get (), uniname, size, error);
        }
        else
-               result = mono_string_new (mono_domain_get (), "");
+               result = mono_string_new_handle (mono_domain_get (), "", error);
 
        if (uniname)
                g_free (uniname);
 
-       mono_error_set_pending_exception (&error);
        return result;
 }
 
 gpointer
-ves_icall_System_Security_Principal_WindowsIdentity_GetUserToken (MonoString *username)
+ves_icall_System_Security_Principal_WindowsIdentity_GetUserToken (MonoStringHandle username, MonoError *error)
 {
+       error_init (error);
        gpointer token = NULL;
 
        /* TODO: MS has something like this working in Windows 2003 (client and
@@ -263,7 +270,7 @@ GetCurrentUserSid (void)
 {
        PSID sid = NULL;
        guint32 size = 0;
-       gpointer token = ves_icall_System_Security_Principal_WindowsIdentity_GetCurrentToken ();
+       gpointer token = mono_security_principal_windows_identity_get_current_token ();
 
        GetTokenInformation (token, TokenUser, NULL, size, (PDWORD)&size);
        if (size > 0) {