VBoxRestore.cpp revision 4604ab7d38c2bd2dfc255aa1facffdf81c1c9153
/** @file
*
* VBoxRestore - Restore notification
*
*/
/*
* 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.
*/
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include "VBoxService.h"
#include "VBoxRestore.h"
#include <VBoxDisplay.h>
#include <VBoxGuestInternal.h>
#include "helpers.h"
typedef struct _VBOXRESTORECONTEXT
{
const VBOXSERVICEENV *pEnv;
static VBOXRESTORECONTEXT gCtx = {0};
{
dprintf(("VBoxRestoreInit\n"));
*pfStartThread = true;
*ppInstance = &gCtx;
return VINF_SUCCESS;
}
{
dprintf(("VBoxRestoreDestroy\n"));
return;
}
void VBoxRestoreSession()
{
}
void VBoxRestoreCheckVRDP()
{
/* Check VRDP activity */
/* send to display driver */
{
if (!DeviceIoControl (gCtx.pEnv->hDriver, (ret) ? IOCTL_VBOXGUEST_ENABLE_VRDP_SESSION : IOCTL_VBOXGUEST_DISABLE_VRDP_SESSION, NULL, 0, NULL, 0, &cbReturned, NULL))
{
dprintf(("VBoxRestoreThread: DeviceIOControl(CtlMask) failed, SeamlessChangeThread exited\n"));
}
}
}
/**
* Thread function to wait for and process seamless mode change
* requests
*/
{
bool fTerminate = false;
maskInfo.u32NotMask = 0;
if (DeviceIoControl (gVBoxDriver, IOCTL_VBOXGUEST_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL))
{
dprintf(("VBoxRestoreThread: DeviceIOControl(CtlMask - or) succeeded\n"));
}
else
{
dprintf(("VBoxRestoreThread: DeviceIOControl(CtlMask) failed, SeamlessChangeThread exited\n"));
return 0;
}
do
{
/* wait for a seamless change event */
if (DeviceIoControl(gVBoxDriver, IOCTL_VBOXGUEST_WAITEVENT, &waitEvent, sizeof(waitEvent), &waitEvent, sizeof(waitEvent), &cbReturned, NULL))
{
dprintf(("VBoxRestoreThread: DeviceIOControl succeded\n"));
/* are we supposed to stop? */
break;
dprintf(("VBoxRestoreThread: checking event\n"));
/* did we get the right event? */
else
/** @todo Don't poll, but wait for connect/disconnect events */
}
else
{
dprintf(("VBoxService: error 0 from DeviceIoControl IOCTL_VBOXGUEST_WAITEVENT\n"));
/* sleep a bit to not eat too much CPU in case the above call always fails */
{
fTerminate = true;
break;
}
}
}
while (!fTerminate);
if (DeviceIoControl (gVBoxDriver, IOCTL_VBOXGUEST_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL))
{
dprintf(("VBoxRestoreThread: DeviceIOControl(CtlMask - not) succeeded\n"));
}
else
{
dprintf(("VBoxRestoreThread: DeviceIOControl(CtlMask) failed\n"));
}
dprintf(("VBoxRestoreThread: finished seamless change request thread\n"));
return 0;
}