Helper.cpp revision b357df727b216b85d4517efecf466a7b14c2e80c
/** @file
*
* VBoxGINA -- Windows Logon DLL for VirtualBox Helper Functions
*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#include <windows.h>
#include "winwlx.h"
#include "Helper.h"
#include "VBoxGINA.h"
#include <VBox/VBoxGuest.h>
/* the credentials */
wchar_t g_Username[VMMDEV_CREDENTIALS_STRLEN];
wchar_t g_Password[VMMDEV_CREDENTIALS_STRLEN];
wchar_t g_Domain[VMMDEV_CREDENTIALS_STRLEN];
HANDLE getVBoxDriver(void)
{
if (sVBoxDriver == INVALID_HANDLE_VALUE)
{
NULL,
NULL);
if (sVBoxDriver == INVALID_HANDLE_VALUE)
}
return sVBoxDriver;
}
void credentialsReset(void)
{
}
bool credentialsAvailable(void)
{
if (vboxDriver == INVALID_HANDLE_VALUE)
return false;
/* query the VMMDev whether there are credentials */
if (!DeviceIoControl(vboxDriver, VBOXGUEST_IOCTL_VMMREQUEST, &vmmreqCredentials, sizeof(vmmreqCredentials),
{
return false;
}
return fAvailable;
}
bool credentialsRetrieve(void)
{
Log(("VBoxGINA::credentialsRetrieve\n"));
if (vboxDriver == INVALID_HANDLE_VALUE)
return false;
/* to be safe, reset the credentials */
/* query the credentials */
if (!DeviceIoControl(vboxDriver, VBOXGUEST_IOCTL_VMMREQUEST, &vmmreqCredentials, sizeof(vmmreqCredentials),
{
return false;
}
/* convert from UTF-8 to UTF-16 and store in global variables */
{
}
{
}
{
}
Log(("VBoxGINA::credentialsRetrieve: returning user '%s', password '%s', domain '%s'\n",
return true;
}
/* handle of the poller thread */
/**
* Poller thread. Checks periodically whether there are credentials.
*/
{
Log(("VBoxGINA::credentialsPoller\n"));
do
{
if (credentialsAvailable())
{
Log(("VBoxGINA::credentialsPoller: got credentials, simulating C-A-D\n"));
/* tell WinLogon to start the attestation process */
/* time to say goodbye */
return 0;
}
/* wait a bit */
{
Log(("VBoxGINA::credentialsPoller: we were asked to terminate\n"));
/* we were asked to terminate, do that instantly! */
return 0;
}
}
while (1);
return 0;
}
bool credentialsPollerCreate(void)
{
Log(("VBoxGINA::credentialsPollerCreate\n"));
/* don't create more than one of them */
if (gThreadPoller != NIL_RTTHREAD)
{
Log(("VBoxGINA::credentialsPollerCreate: thread already running, returning!\n"));
return false;
}
/* create the poller thread */
RTTHREADFLAGS_WAITABLE, "creds");
if (VBOX_FAILURE(rc))
{
return false;
}
return true;
}
bool credentialsPollerTerminate(void)
{
Log(("VBoxGINA::credentialsPollerTerminate\n"));
if (gThreadPoller == NIL_RTTHREAD)
{
Log(("VBoxGINA::credentialsPollerTerminate: either thread or exit sem is NULL!\n"));
return false;
}
/* post termination event semaphore */
if (RT_SUCCESS(rc))
{
Log(("VBoxGINA::credentialsPollerTerminate: waiting for thread to terminate\n"));
/* wait until the thread has terminated */
}
else
{
/* failed to signal the thread - very unlikely - so no point in waiting long. */
}
/* now cleanup */
return true;
}