Index: /trunk/src/VBox/Additions/WINNT/VBoxTray/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxTray/Makefile.kmk	(revision 51223)
+++ /trunk/src/VBox/Additions/WINNT/VBoxTray/Makefile.kmk	(revision 51224)
@@ -37,5 +37,4 @@
 	VBoxDisplay.cpp \
 	VBoxVRDP.cpp \
-	VBoxRestore.cpp \
 	VBoxIPC.cpp \
 	VBoxHelpers.cpp \
Index: unk/src/VBox/Additions/WINNT/VBoxTray/VBoxRestore.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxRestore.cpp	(revision 51223)
+++ 	(revision )
@@ -1,165 +1,0 @@
-/* $Id$ */
-/** @file
- * VBoxRestore - Restore notification.
- */
-
-/*
- * Copyright (C) 2006-2011 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * 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.
- */
-#define _WIN32_WINNT 0x0500
-#include <windows.h>
-#include "VBoxTray.h"
-#include "VBoxHelpers.h"
-#include "VBoxRestore.h"
-#include <VBoxDisplay.h>
-#include <VBox/VMMDev.h>
-#include <VBoxGuestInternal.h>
-#include <iprt/assert.h>
-
-
-typedef struct _VBOXRESTORECONTEXT
-{
-    const VBOXSERVICEENV *pEnv;
-
-    DWORD  fRDPState;
-} VBOXRESTORECONTEXT;
-
-
-static VBOXRESTORECONTEXT gCtx = {0};
-
-
-int VBoxRestoreInit(const VBOXSERVICEENV *pEnv, void **ppInstance, bool *pfStartThread)
-{
-    Log(("VBoxTray: VBoxRestoreInit\n"));
-
-    gCtx.pEnv      = pEnv;
-    gCtx.fRDPState = ERROR_NOT_SUPPORTED;
-
-    VBoxRestoreCheckVRDP();
-
-    *pfStartThread = true;
-    *ppInstance = &gCtx;
-    return VINF_SUCCESS;
-}
-
-
-void VBoxRestoreDestroy(const VBOXSERVICEENV *pEnv, void *pInstance)
-{
-    Log(("VBoxTray: VBoxRestoreDestroy\n"));
-    return;
-}
-
-void VBoxRestoreSession()
-{
-    VBoxRestoreCheckVRDP();
-}
-
-void VBoxRestoreCheckVRDP()
-{
-    VBOXDISPIFESCAPE escape = {0};
-    escape.escapeCode = VBOXESC_ISVRDPACTIVE;
-    /* Check VRDP activity. */
-
-    /* Send to display driver. */
-    DWORD dwRet = VBoxDispIfEscape(&gCtx.pEnv->dispIf, &escape, 0);
-    Log(("VBoxTray: VBoxRestoreCheckVRDP -> VRDP activate state = %d\n", dwRet));
-
-    if (dwRet != gCtx.fRDPState)
-    {
-        DWORD cbReturnIgnored;
-        if (!DeviceIoControl(gCtx.pEnv->hDriver,
-                             dwRet == NO_ERROR
-                             ? VBOXGUEST_IOCTL_ENABLE_VRDP_SESSION
-                             : VBOXGUEST_IOCTL_DISABLE_VRDP_SESSION,
-                             NULL, 0, NULL, 0, &cbReturnIgnored, NULL))
-        {
-            Log(("VBoxTray: VBoxRestoreCheckVRDP: DeviceIOControl failed, error = %ld\n", GetLastError()));
-        }
-        gCtx.fRDPState = dwRet;
-    }
-}
-
-/**
- * Thread function to wait for and process seamless mode change
- * requests
- */
-unsigned __stdcall VBoxRestoreThread(void *pInstance)
-{
-    VBOXRESTORECONTEXT *pCtx = (VBOXRESTORECONTEXT *)pInstance;
-    HANDLE gVBoxDriver = pCtx->pEnv->hDriver;
-    bool fTerminate = false;
-    VBoxGuestFilterMaskInfo maskInfo;
-    DWORD cbReturned;
-
-    maskInfo.u32OrMask = VMMDEV_EVENT_RESTORED;
-    maskInfo.u32NotMask = 0;
-    if (DeviceIoControl (gVBoxDriver, VBOXGUEST_IOCTL_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL))
-    {
-        Log(("VBoxTray: VBoxRestoreThread: DeviceIOControl(CtlMask - or) succeeded\n"));
-    }
-    else
-    {
-        Log(("VBoxTray: VBoxRestoreThread: DeviceIOControl(CtlMask) failed, SeamlessChangeThread exited\n"));
-        return 0;
-    }
-
-    do
-    {
-        /* wait for a seamless change event */
-        VBoxGuestWaitEventInfo waitEvent;
-        waitEvent.u32TimeoutIn = 5000;
-        waitEvent.u32EventMaskIn = VMMDEV_EVENT_RESTORED;
-        if (DeviceIoControl(gVBoxDriver, VBOXGUEST_IOCTL_WAITEVENT, &waitEvent, sizeof(waitEvent), &waitEvent, sizeof(waitEvent), &cbReturned, NULL))
-        {
-            Log(("VBoxTray: VBoxRestoreThread: DeviceIOControl succeeded\n"));
-
-            /* are we supposed to stop? */
-            if (WaitForSingleObject(pCtx->pEnv->hStopEvent, 0) == WAIT_OBJECT_0)
-                break;
-
-            Log(("VBoxTray: VBoxRestoreThread: checking event\n"));
-
-            /* did we get the right event? */
-            if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_RESTORED)
-                PostMessage(ghwndToolWindow, WM_VBOXTRAY_VM_RESTORED, 0, 0);
-            else
-                /** @todo Don't poll, but wait for connect/disconnect events */
-                PostMessage(ghwndToolWindow, WM_VBOXTRAY_VRDP_CHECK, 0, 0);
-        }
-        else
-        {
-            Log(("VBoxTray: VBoxTray: error 0 from DeviceIoControl VBOXGUEST_IOCTL_WAITEVENT\n"));
-
-            /* sleep a bit to not eat too much CPU in case the above call always fails */
-            if (WaitForSingleObject(pCtx->pEnv->hStopEvent, 10) == WAIT_OBJECT_0)
-            {
-                fTerminate = true;
-                break;
-            }
-        }
-    }
-    while (!fTerminate);
-
-    maskInfo.u32OrMask = 0;
-    maskInfo.u32NotMask = VMMDEV_EVENT_RESTORED;
-    if (DeviceIoControl (gVBoxDriver, VBOXGUEST_IOCTL_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL))
-    {
-        Log(("VBoxTray: VBoxRestoreThread: DeviceIOControl(CtlMask - not) succeeded\n"));
-    }
-    else
-    {
-        Log(("VBoxTray: VBoxRestoreThread: DeviceIOControl(CtlMask) failed\n"));
-    }
-
-    Log(("VBoxTray: VBoxRestoreThread: finished seamless change request thread\n"));
-    return 0;
-}
-
Index: /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp	(revision 51223)
+++ /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp	(revision 51224)
@@ -177,13 +177,4 @@
         VBoxSeamlessDestroy
     },
-#ifdef VBOX_WITH_VRDP_SESSION_HANDLING
-    {
-        "Restore",
-        VBoxRestoreInit,
-        VBoxRestoreThread,
-        NULL /* pfnStop */,
-        VBoxRestoreDestroy
-    },
-#endif
     {
         "VRDP",
@@ -1175,12 +1166,4 @@
             return 0;
 
-        case WM_VBOXTRAY_VM_RESTORED:
-            VBoxRestoreSession();
-            return 0;
-
-        case WM_VBOXTRAY_VRDP_CHECK:
-            VBoxRestoreCheckVRDP();
-            return 0;
-
         case WM_WTSSESSION_CHANGE:
         {
Index: /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.h	(revision 51223)
+++ /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.h	(revision 51224)
@@ -74,12 +74,4 @@
  */
 #define WM_VBOXTRAY_TRAY_ICON                   WM_APP + 40
-/**
- * VM/VMMDev related messsages.
- */
-#define WM_VBOXTRAY_VM_RESTORED                 WM_APP + 100
-/**
- * VRDP messages.
- */
-#define WM_VBOXTRAY_VRDP_CHECK                  WM_APP + 301
 
 
Index: /trunk/src/VBox/Additions/WINNT/include/VBoxGuestInternal.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/include/VBoxGuestInternal.h	(revision 51223)
+++ /trunk/src/VBox/Additions/WINNT/include/VBoxGuestInternal.h	(revision 51224)
@@ -16,16 +16,5 @@
 #define __VBoxGuestInternal_h__
 
-/** Uncomment to enable VRDP status checks */
-//#define VBOX_WITH_VRDP_SESSION_HANDLING
-
-/** Uncomment to enable the guest management extension in VBoxService */
-#define VBOX_WITH_MANAGEMENT
-
-/** IOCTL for VBoxGuest to enable a VRDP session */
-#define VBOXGUEST_IOCTL_ENABLE_VRDP_SESSION     IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2100, METHOD_BUFFERED, FILE_WRITE_ACCESS, 0)
-
-/** IOCTL for VBoxGuest to disable a VRDP session */
-#define VBOXGUEST_IOCTL_DISABLE_VRDP_SESSION    IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2101, METHOD_BUFFERED, FILE_WRITE_ACCESS, 0)
-
+/* no global definitions right now */
 
 #endif /* __VBoxGuestInternal_h__ */
Index: /trunk/src/VBox/Additions/common/VBoxGuest/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuest/Makefile.kmk	(revision 51223)
+++ /trunk/src/VBox/Additions/common/VBoxGuest/Makefile.kmk	(revision 51224)
@@ -38,5 +38,5 @@
  VBoxGuest_DEFS.linux    = KBUILD_MODNAME=KBUILD_STR\(vboxguest\) KBUILD_BASENAME=KBUILD_STR\(vboxguest\) DEBUG_HASH=2 DEBUG_HASH2=3 EXPORT_SYMTAB
  VBoxGuest_DEFS.solaris  = VBOX_SVN_REV=$(VBOX_SVN_REV)
- VBoxGuest_DEFS.win      = VBOX_GUESTDRV_WITH_RELEASE_LOGGER # VBOX_WITH_VRDP_SESSION_HANDLING
+ VBoxGuest_DEFS.win      = VBOX_GUESTDRV_WITH_RELEASE_LOGGER
  VBoxGuest_DEFS.darwin   = VBOX_GUESTDRV_WITH_RELEASE_LOGGER
  ifeq ($(KBUILD_TYPE),release)
Index: /trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp	(revision 51223)
+++ /trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp	(revision 51224)
@@ -742,83 +742,44 @@
     }
 
-    /*
-     * First process Windows specific stuff which cannot be handled
-     * by the common code used on all other platforms. In the default case
-     * we then finally handle the common cases.
-     */
-    switch (uCmd)
-    {
-#ifdef VBOX_WITH_VRDP_SESSION_HANDLING
-        case VBOXGUEST_IOCTL_ENABLE_VRDP_SESSION:
+    /* Verify that it's a buffered CTL. */
+    if ((pStack->Parameters.DeviceIoControl.IoControlCode & 0x3) == METHOD_BUFFERED)
+    {
+        /*
+         * Process the common IOCtls.
+         */
+        size_t cbDataReturned;
+        int vrc = VBoxGuestCommonIOCtl(uCmd, &pDevExt->Core, pSession, pBuf, cbData, &cbDataReturned);
+
+        LogFlowFunc(("rc=%Rrc, pBuf=0x%p, cbData=%u, cbDataReturned=%u\n",
+                     vrc, pBuf, cbData, cbDataReturned));
+
+        if (RT_SUCCESS(vrc))
         {
-            LogRelFunc(("ENABLE_VRDP_SESSION: Currently: %sabled\n",
-                        pDevExt->fVRDPEnabled? "en": "dis"));
-            if (!pDevExt->fVRDPEnabled)
+            if (RT_UNLIKELY(   cbDataReturned > cbData
+                            || cbDataReturned > pStack->Parameters.DeviceIoControl.OutputBufferLength))
             {
-                KUSER_SHARED_DATA *pSharedUserData = (KUSER_SHARED_DATA *)KI_USER_SHARED_DATA;
-
-                pDevExt->fVRDPEnabled            = true;
-                LogRelFunc(("ENABLE_VRDP_SESSION: Current active console ID: 0x%08X\n",
-                            pSharedUserData->ActiveConsoleId));
-                pDevExt->ulOldActiveConsoleId    = pSharedUserData->ActiveConsoleId;
-                pSharedUserData->ActiveConsoleId = 2;
+                LogFlowFunc(("Too much output data %u - expected %u!\n", cbDataReturned, cbData));
+                cbDataReturned = cbData;
+                Status = STATUS_BUFFER_TOO_SMALL;
             }
-            break;
+            if (cbDataReturned > 0)
+                cbOut = cbDataReturned;
         }
-
-        case VBOXGUEST_IOCTL_DISABLE_VRDP_SESSION:
+        else
         {
-            LogRelFunc(("DISABLE_VRDP_SESSION: Currently: %sabled\n",
-                        pDevExt->fVRDPEnabled? "en": "dis"));
-            if (pDevExt->fVRDPEnabled)
-            {
-                KUSER_SHARED_DATA *pSharedUserData = (KUSER_SHARED_DATA *)KI_USER_SHARED_DATA;
-
-                pDevExt->fVRDPEnabled            = false;
-                LogFlowFunc(("DISABLE_VRDP_SESSION: Current active console ID: 0x%08X\n",
-                             pSharedUserData->ActiveConsoleId));
-                pSharedUserData->ActiveConsoleId = pDevExt->ulOldActiveConsoleId;
-                pDevExt->ulOldActiveConsoleId    = 0;
-            }
-            break;
+            if (   vrc == VERR_NOT_SUPPORTED
+                || vrc == VERR_INVALID_PARAMETER)
+                Status = STATUS_INVALID_PARAMETER;
+            else if (vrc == VERR_OUT_OF_RANGE)
+                Status = STATUS_INVALID_BUFFER_SIZE;
+            else
+                Status = STATUS_UNSUCCESSFUL;
         }
-#else
-        /* Add at least one (bogus) fall through case to shut up MSVC! */
-        case 0:
-#endif
-        default:
-        {
-            /*
-             * Process the common IOCtls.
-             */
-            size_t cbDataReturned;
-            int vrc = VBoxGuestCommonIOCtl(uCmd, &pDevExt->Core, pSession, pBuf, cbData, &cbDataReturned);
-
-            LogFlowFunc(("rc=%Rrc, pBuf=0x%p, cbData=%u, cbDataReturned=%u\n",
-                         vrc, pBuf, cbData, cbDataReturned));
-
-            if (RT_SUCCESS(vrc))
-            {
-                if (RT_UNLIKELY(cbDataReturned > cbData))
-                {
-                    LogFlowFunc(("Too much output data %u - expected %u!\n", cbDataReturned, cbData));
-                    cbDataReturned = cbData;
-                    Status = STATUS_BUFFER_TOO_SMALL;
-                }
-                if (cbDataReturned > 0)
-                    cbOut = cbDataReturned;
-            }
-            else
-            {
-                if (   vrc == VERR_NOT_SUPPORTED
-                    || vrc == VERR_INVALID_PARAMETER)
-                    Status = STATUS_INVALID_PARAMETER;
-                else if (vrc == VERR_OUT_OF_RANGE)
-                    Status = STATUS_INVALID_BUFFER_SIZE;
-                else
-                    Status = STATUS_UNSUCCESSFUL;
-            }
-            break;
-        }
+    }
+    else
+    {
+        LogFlowFunc(("Not buffered request (%#x) - not supported\n",
+                     pStack->Parameters.DeviceIoControl.IoControlCode));
+        Status = STATUS_NOT_SUPPORTED;
     }
 
Index: /trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp	(revision 51223)
+++ /trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp	(revision 51224)
@@ -301,5 +301,5 @@
 *   Global Variables                                                           *
 *******************************************************************************/
-static const size_t cbChangeMemBalloonReq = RT_OFFSETOF(VMMDevChangeMemBalloon, aPhysPage[VMMDEV_MEMORY_BALLOON_CHUNK_PAGES]);
+static const uint32_t cbChangeMemBalloonReq = RT_OFFSETOF(VMMDevChangeMemBalloon, aPhysPage[VMMDEV_MEMORY_BALLOON_CHUNK_PAGES]);
 
 #if defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS)
@@ -427,5 +427,5 @@
             pReq->header.rc          = VERR_INTERNAL_ERROR;
             pReq->hypervisorSize     = cbHypervisor;
-            pReq->hypervisorStart    = (uintptr_t)RTR0MemObjAddress(hObj);
+            pReq->hypervisorStart    = (RTGCPTR32)(uintptr_t)RTR0MemObjAddress(hObj);
             if (    uAlignment == PAGE_SIZE
                 &&  pReq->hypervisorStart & (_4M - 1))
@@ -901,5 +901,4 @@
 {
     int rc, rc2;
-    unsigned i;
 
 #ifdef VBOX_GUESTDRV_WITH_RELEASE_LOGGER
@@ -957,7 +956,4 @@
     RTListInit(&pDevExt->FreeList);
     RTListInit(&pDevExt->SessionList);
-#ifdef VBOX_WITH_VRDP_SESSION_HANDLING
-    pDevExt->fVRDPEnabled = false;
-#endif
     pDevExt->fLoggingEnabled = false;
     pDevExt->f32PendingEvents = 0;
@@ -1905,5 +1901,5 @@
     const VMMDevRequestType enmType   = pReqHdr->requestType;
     const uint32_t          cbReq     = pReqHdr->size;
-    const uint32_t          cbMinSize = vmmdevGetRequestSize(enmType);
+    const uint32_t          cbMinSize = (uint32_t)vmmdevGetRequestSize(enmType);
 
     LogFlowFunc(("Type=%d\n", pReqHdr->requestType));
@@ -2508,36 +2504,4 @@
     return rc;
 }
-
-
-#ifdef VBOX_WITH_VRDP_SESSION_HANDLING
-/**
- * Enables the VRDP session and saves its session ID.
- *
- * @returns VBox status code.
- *
- * @param   pDevExt             The device extention.
- * @param   pSession            The session.
- */
-static int VBoxGuestCommonIOCtl_EnableVRDPSession(VBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession)
-{
-    /* Nothing to do here right now, since this only is supported on Windows at the moment. */
-    return VERR_NOT_IMPLEMENTED;
-}
-
-
-/**
- * Disables the VRDP session.
- *
- * @returns VBox status code.
- *
- * @param   pDevExt             The device extention.
- * @param   pSession            The session.
- */
-static int VBoxGuestCommonIOCtl_DisableVRDPSession(VBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession)
-{
-    /* Nothing to do here right now, since this only is supported on Windows at the moment. */
-    return VERR_NOT_IMPLEMENTED;
-}
-#endif /* VBOX_WITH_VRDP_SESSION_HANDLING */
 
 
@@ -2949,13 +2913,4 @@
                 break;
 
-#ifdef VBOX_WITH_VRDP_SESSION_HANDLING
-            case VBOXGUEST_IOCTL_ENABLE_VRDP_SESSION:
-                rc = VBoxGuestCommonIOCtl_EnableVRDPSession(pDevExt, pSession);
-                break;
-
-            case VBOXGUEST_IOCTL_DISABLE_VRDP_SESSION:
-                rc = VBoxGuestCommonIOCtl_DisableVRDPSession(pDevExt, pSession);
-                break;
-#endif /* VBOX_WITH_VRDP_SESSION_HANDLING */
             case VBOXGUEST_IOCTL_SET_MOUSE_STATUS:
                 CHECKRET_SIZE("SET_MOUSE_STATUS", sizeof(uint32_t));
Index: /trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h	(revision 51223)
+++ /trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h	(revision 51224)
@@ -162,7 +162,4 @@
      * #SessionSpinlock lock. */
     RTLISTANCHOR                SessionList;
-#ifdef VBOX_WITH_VRDP_SESSION_HANDLING
-    bool                        fVRDPEnabled;
-#endif
     /** Flag indicating whether logging to the release log
      *  is enabled. */
