VBoxRestore.cpp revision f89791b8a3692c4368c020bbb9c9981209759e95
fe06619ae576367ff3568e6abd99fb8ad28cc73avboxsync * VBoxRestore - Restore notification
8cd393943ea52545c4d063f5a94436639f0f80b6vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
8cd393943ea52545c4d063f5a94436639f0f80b6vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
8cd393943ea52545c4d063f5a94436639f0f80b6vboxsync * available from http://www.virtualbox.org. This file is free software;
8cd393943ea52545c4d063f5a94436639f0f80b6vboxsync * you can redistribute it and/or modify it under the terms of the GNU
fe06619ae576367ff3568e6abd99fb8ad28cc73avboxsync * General Public License (GPL) as published by the Free Software
fe06619ae576367ff3568e6abd99fb8ad28cc73avboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
fe06619ae576367ff3568e6abd99fb8ad28cc73avboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
fe06619ae576367ff3568e6abd99fb8ad28cc73avboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
d46ee884c41b808b239563b1978468aae12e33a2vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
d46ee884c41b808b239563b1978468aae12e33a2vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
01b2e367e947049139a5d5813ccc1fa162b11f76vboxsync * additional information or have any questions.
d46ee884c41b808b239563b1978468aae12e33a2vboxsyncint VBoxRestoreInit(const VBOXSERVICEENV *pEnv, void **ppInstance, bool *pfStartThread)
d46ee884c41b808b239563b1978468aae12e33a2vboxsyncvoid VBoxRestoreDestroy(const VBOXSERVICEENV *pEnv, void *pInstance)
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync /* Check VRDP activity */
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync /* send to display driver */
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync ret = ExtEscape(hdc, VBOXESC_ISVRDPACTIVE, 0, NULL, 0, NULL);
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync dprintf(("VBoxRestoreSession -> VRDP activate state = %d\n", ret));
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync if (!DeviceIoControl (gCtx.pEnv->hDriver, (ret) ? IOCTL_VBOXGUEST_ENABLE_VRDP_SESSION : IOCTL_VBOXGUEST_DISABLE_VRDP_SESSION, NULL, 0, NULL, 0, &cbReturned, NULL))
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync dprintf(("VBoxRestoreThread: DeviceIOControl(CtlMask) failed, SeamlessChangeThread exited\n"));
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync * Thread function to wait for and process seamless mode change
d8523ff7d948462e328eec88b602effe2e7f7080vboxsyncunsigned __stdcall VBoxRestoreThread(void *pInstance)
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync VBOXRESTORECONTEXT *pCtx = (VBOXRESTORECONTEXT *)pInstance;
01b2e367e947049139a5d5813ccc1fa162b11f76vboxsync bool fTerminate = false;
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync if (DeviceIoControl (gVBoxDriver, IOCTL_VBOXGUEST_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL))
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync dprintf(("VBoxRestoreThread: DeviceIOControl(CtlMask - or) succeeded\n"));
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync dprintf(("VBoxRestoreThread: DeviceIOControl(CtlMask) failed, SeamlessChangeThread exited\n"));
6063286f0f0d78e627c9ef48073f5753da93ba10vboxsync /* wait for a seamless change event */
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync if (DeviceIoControl(gVBoxDriver, IOCTL_VBOXGUEST_WAITEVENT, &waitEvent, sizeof(waitEvent), &waitEvent, sizeof(waitEvent), &cbReturned, NULL))
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync dprintf(("VBoxRestoreThread: DeviceIOControl succeded\n"));
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync /* are we supposed to stop? */
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync if (WaitForSingleObject(pCtx->pEnv->hStopEvent, 0) == WAIT_OBJECT_0)
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync /* did we get the right event? */
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_RESTORED)
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync /** @todo Don't poll, but wait for connect/disconnect events */
b099c6398b85f527d7343cb1da573e1e95f9fd10vboxsync PostMessage(gToolWindow, WM_VBOX_CHECK_VRDP, 0, 0);
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync dprintf(("VBoxTray: error 0 from DeviceIoControl IOCTL_VBOXGUEST_WAITEVENT\n"));
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync /* sleep a bit to not eat too much CPU in case the above call always fails */
d8523ff7d948462e328eec88b602effe2e7f7080vboxsync if (WaitForSingleObject(pCtx->pEnv->hStopEvent, 10) == WAIT_OBJECT_0)
fe06619ae576367ff3568e6abd99fb8ad28cc73avboxsync if (DeviceIoControl (gVBoxDriver, IOCTL_VBOXGUEST_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL))
fe06619ae576367ff3568e6abd99fb8ad28cc73avboxsync dprintf(("VBoxRestoreThread: DeviceIOControl(CtlMask - not) succeeded\n"));
fe06619ae576367ff3568e6abd99fb8ad28cc73avboxsync dprintf(("VBoxRestoreThread: DeviceIOControl(CtlMask) failed\n"));
8cd393943ea52545c4d063f5a94436639f0f80b6vboxsync dprintf(("VBoxRestoreThread: finished seamless change request thread\n"));