VirtualBox

Changeset 40211 in vbox for trunk


Ignore:
Timestamp:
Feb 22, 2012 2:25:36 PM (13 years ago)
Author:
vboxsync
Message:

VbglR3: Added functions for auto-logon facility reporting + remote session detection (Windows only atm), added function for UTF16 credentials retrieval.

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxGuestLib.h

    r39454 r40211  
    44
    55/*
    6  * Copyright (C) 2006-2010 Oracle Corporation
     6 * Copyright (C) 2006-2012 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    588588# endif /* VBOX_WITH_GUEST_CONTROL defined */
    589589
     590/** @name Auto-logon handling
     591 * @{ */
     592VBGLR3DECL(int)     VbglR3AutoLogonReportStatus(VBoxGuestFacilityStatus enmStatus);
     593VBGLR3DECL(bool)    VbglR3AutoLogonIsRemoteSession(void);
     594/** @}  */
     595
    590596/** @name User credentials handling
    591597 * @{ */
    592598VBGLR3DECL(int)     VbglR3CredentialsQueryAvailability(void);
    593599VBGLR3DECL(int)     VbglR3CredentialsRetrieve(char **ppszUser, char **ppszPassword, char **ppszDomain);
     600VBGLR3DECL(int)     VbglR3CredentialsRetrieveUtf16(PRTUTF16 *ppwszUser, PRTUTF16 *ppwszPassword, PRTUTF16 *ppwszDomain);
    594601VBGLR3DECL(void)    VbglR3CredentialsDestroy(char *pszUser, char *pszPassword, char *pszDomain, uint32_t cPasses);
     602VBGLR3DECL(void)    VbglR3CredentialsDestroyUtf16(PRTUTF16 pwszUser, PRTUTF16 pwszPassword, PRTUTF16 pwszDomain,
     603                                                  uint32_t cPasses);
    595604/** @}  */
    596605
  • trunk/src/VBox/Additions/common/VBoxGuestLib/Makefile.kmk

    r39454 r40211  
    55
    66#
    7 # Copyright (C) 2006-2010 Oracle Corporation
     7# Copyright (C) 2006-2012 Oracle Corporation
    88#
    99# This file is part of VirtualBox Open Source Edition (OSE), as
     
    9595        VBoxGuestR3Lib.cpp \
    9696        VBoxGuestR3LibAdditions.cpp \
     97        VBoxGuestR3LibAutoLogon.cpp \
    9798        VBoxGuestR3LibBalloon.cpp \
    9899        VBoxGuestR3LibClipboard.cpp \
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibCredentials.cpp

    r33540 r40211  
    7474VBGLR3DECL(int) VbglR3CredentialsRetrieve(char **ppszUser, char **ppszPassword, char **ppszDomain)
    7575{
     76    AssertPtrReturn(ppszUser, VERR_INVALID_POINTER);
     77    AssertPtrReturn(ppszPassword, VERR_INVALID_POINTER);
     78    AssertPtrReturn(ppszDomain, VERR_INVALID_POINTER);
     79
    7680    VMMDevCredentials Req;
    7781    RT_ZERO(Req);
     
    102106
    103107/**
     108 * Retrieves and clears the user credentials for logging into the guest OS.
     109 * UTF-16 version.
     110 *
     111 * @returns IPRT status value
     112 * @param   ppwszUser       Receives pointer of allocated user name string.
     113 *                          The returned pointer must be freed using VbglR3CredentialsDestroyUtf16().
     114 * @param   ppswzPassword   Receives pointer of allocated user password string.
     115 *                          The returned pointer must be freed using VbglR3CredentialsDestroyUtf16().
     116 * @param   ppwszDomain     Receives pointer of allocated domain name string.
     117 *                          The returned pointer must be freed using VbglR3CredentialsDestroyUtf16().
     118 */
     119VBGLR3DECL(int) VbglR3CredentialsRetrieveUtf16(PRTUTF16 *ppwszUser, PRTUTF16 *ppwszPassword, PRTUTF16 *ppwszDomain)
     120{
     121    AssertPtrReturn(ppwszUser, VERR_INVALID_POINTER);
     122    AssertPtrReturn(ppwszPassword, VERR_INVALID_POINTER);
     123    AssertPtrReturn(ppwszDomain, VERR_INVALID_POINTER);
     124
     125    char *pszUser, *pszPassword, *pszDomain;
     126    int rc = VbglR3CredentialsRetrieve(&pszUser, &pszPassword, &pszDomain);
     127    if (RT_SUCCESS(rc))
     128    {
     129        PRTUTF16 pwszUser = NULL;
     130        PRTUTF16 pwszPassword = NULL;
     131        PRTUTF16 pwszDomain = NULL;
     132
     133        rc = RTStrToUtf16(pszUser, &pwszUser);
     134        if (RT_SUCCESS(rc))
     135        {
     136            rc = RTStrToUtf16(pszPassword, &pwszPassword);
     137            if (RT_SUCCESS(rc))
     138                rc = RTStrToUtf16(pszDomain, &pwszDomain);
     139        }
     140
     141        if (RT_SUCCESS(rc))
     142        {
     143            *ppwszUser     = pwszUser;
     144            *ppwszPassword = pwszPassword;
     145            *ppwszDomain   = pwszDomain;
     146        }
     147        else
     148            VbglR3CredentialsDestroyUtf16(pwszUser, pwszPassword, pwszDomain,
     149                                          3 /* Passes */);
     150
     151        VbglR3CredentialsDestroy(pszUser, pszPassword, pszDomain,
     152                                 3 /* Passes */);
     153    }
     154
     155    return rc;
     156}
     157
     158/**
    104159 * Clears and frees the three strings.
    105160 *
     
    128183}
    129184
     185/**
     186 * Clears and frees the three strings. UTF-16 version.
     187 *
     188 * @param   pwszUser       Receives pointer of the user name string to destroy.
     189 *                         Optional.
     190 * @param   pwszPassword   Receives pointer of the password string to destroy.
     191 *                         Optional.
     192 * @param   pwszDomain     Receives pointer of allocated domain name string.
     193 *                         Optional.
     194 * @param   cPasses        Number of wipe passes.  The more the better + slower.
     195 */
     196VBGLR3DECL(void) VbglR3CredentialsDestroyUtf16(PRTUTF16 pwszUser, PRTUTF16 pwszPassword, PRTUTF16 pwszDomain,
     197                                               uint32_t cPasses)
     198{
     199    /* wipe first */
     200    if (pwszUser)
     201        RTMemWipeThoroughly(pwszUser,     RTUtf16Len(pwszUser) + 1,     cPasses);
     202    if (pwszPassword)
     203        RTMemWipeThoroughly(pwszPassword, RTUtf16Len(pwszPassword) + 1, cPasses);
     204    if (pwszDomain)
     205        RTMemWipeThoroughly(pwszDomain,   RTUtf16Len(pwszDomain) + 1,   cPasses);
     206
     207    /* then free. */
     208    RTUtf16Free(pwszUser);
     209    RTUtf16Free(pwszPassword);
     210    RTUtf16Free(pwszDomain);
     211}
     212
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette