VirtualBox

Changeset 36446 in vbox for trunk/src/VBox/Additions/WINNT


Ignore:
Timestamp:
Mar 28, 2011 9:42:12 AM (14 years ago)
Author:
vboxsync
Message:

VBoxGINA: Implemented support for handling/ignoring remote (desktop) sessions.

Location:
trunk/src/VBox/Additions/WINNT/VBoxGINA
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxGINA/Helper.cpp

    r30853 r36446  
    55
    66/*
    7  * Copyright (C) 2006-2010 Oracle Corporation
     7 * Copyright (C) 2006-2011 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2424#include <VBox/VMMDev.h>
    2525#include <iprt/string.h>
     26
     27/* remote session handling */
     28DWORD g_dwHandleRemoteSessions = 0;
    2629
    2730/* the credentials */
     
    4952}
    5053
     54/**
     55 * Detects whether our process is running in a remote session or not.
     56 *
     57 * @return  bool        true if running in a remote session, false if not.
     58 */
     59bool isRemoteSession(void)
     60{
     61    return (0 != GetSystemMetrics(SM_REMOTESESSION)) ? true : false;
     62}
     63
     64/**
     65 * Loads the global configuration from registry.
     66 *
     67 * @return  DWORD       Windows error code.
     68 */
     69DWORD loadConfiguration(void)
     70{
     71    HKEY hKey;
     72    /** @todo Add some registry wrapper function(s) as soon as we got more values to retrieve. */
     73    DWORD dwRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Oracle\\VirtualBox Guest Additions\\AutoLogon",
     74                               0L, KEY_QUERY_VALUE, &hKey);
     75    if (dwRet == ERROR_SUCCESS)
     76    {
     77        DWORD dwValue;
     78        DWORD dwType = REG_DWORD;
     79        DWORD dwSize = sizeof(DWORD);
     80
     81        dwRet = RegQueryValueEx(hKey, L"HandleRemoteSessions", NULL, &dwType, (LPBYTE)&dwValue, &dwSize);
     82        if (   dwRet  == ERROR_SUCCESS
     83            && dwType == REG_DWORD
     84            && dwSize == sizeof(DWORD))
     85        {
     86            g_dwHandleRemoteSessions = dwValue;
     87        }
     88        RegCloseKey(hKey);
     89    }
     90    return dwRet;
     91}
     92
     93/**
     94 * Determines whether we should handle the current session or not.
     95 *
     96 * @return  bool        true if we should handle this session, false if not.
     97 */
     98bool handleCurrentSession(void)
     99{
     100    bool fHandle = false;
     101    if (isRemoteSession())
     102    {
     103        if (g_dwHandleRemoteSessions) /* Force remote session handling. */
     104            fHandle = true;
     105    }
     106    else /* No remote session. */
     107        fHandle = true;
     108    return fHandle;
     109}
     110
    51111void credentialsReset(void)
    52112{
     
    58118bool credentialsAvailable(void)
    59119{
     120    if (!handleCurrentSession())
     121        return false;
     122
    60123    HANDLE vboxDriver = getVBoxDriver();
    61124    if (vboxDriver ==  INVALID_HANDLE_VALUE)
     
    80143bool credentialsRetrieve(void)
    81144{
     145    if (!handleCurrentSession())
     146        return false;
     147
    82148    Log(("VBoxGINA::credentialsRetrieve\n"));
    83149
     
    161227bool credentialsPollerCreate(void)
    162228{
     229    if (!handleCurrentSession())
     230        return false;
     231
    163232    Log(("VBoxGINA::credentialsPollerCreate\n"));
    164233
  • trunk/src/VBox/Additions/WINNT/VBoxGINA/Helper.h

    r30852 r36446  
    44
    55/*
    6  * Copyright (C) 2006-2010 Oracle Corporation
     6 * Copyright (C) 2006-2011 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2626extern wchar_t g_Domain[];
    2727
     28DWORD loadConfiguration();
     29bool handleCurrentSession(void);
     30
    2831void credentialsReset(void);
    2932bool credentialsAvailable(void);
  • trunk/src/VBox/Additions/WINNT/VBoxGINA/VBoxGINA.cpp

    r36283 r36446  
    112112#endif
    113113
    114     Log(("VBoxGINA::WlxNegotiate: dwWinlogonVersion: %d\n", dwWinlogonVersion));
    115 
    116     /* load the standard Microsoft GINA DLL */
     114    Log(("VBoxGINA::WlxNegotiate: dwWinlogonVersion: %ld\n", dwWinlogonVersion));
     115
     116    /* Load global configuration from registry. */
     117    DWORD dwRet = loadConfiguration();
     118    if (ERROR_SUCCESS != dwRet)
     119        Log(("VBoxGINA: Error loading global configuration, error=%ld\n", dwRet));
     120
     121    /* If we have a remote session (that is, a connection via remote desktop /
     122     * terminal services) deny it if not specified explicitly. */
     123    if (!handleCurrentSession())
     124        Log(("VBoxGINA: Handling of remote desktop sessions is disabled.\n"));
     125
     126    /* Load the standard Microsoft GINA DLL. */
    117127    if (!(hDll = LoadLibrary(TEXT("MSGINA.DLL"))))
    118128    {
    119         Log(("VBoxGINA::WlxNegotiate: failed loading MSGINA! last error = %d\n", GetLastError()));
     129        Log(("VBoxGINA::WlxNegotiate: failed loading MSGINA! Last error=%ld\n", GetLastError()));
    120130        return FALSE;
    121131    }
     
    444454 * GINA 1.3 entry points
    445455 */
    446 BOOL WINAPI WlxNetworkProviderLoad (PVOID pWlxContext, PWLX_MPR_NOTIFY_INFO pNprNotifyInfo)
     456BOOL WINAPI WlxNetworkProviderLoad(PVOID pWlxContext, PWLX_MPR_NOTIFY_INFO pNprNotifyInfo)
    447457{
    448458    Log(("VBoxGINA::WlxNetworkProviderLoad\n"));
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