Index: trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp	(revision 105679)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp	(revision 105749)
@@ -3493,5 +3493,5 @@
                 }
 
-                if (pEscape->PrivateDriverDataSize != sizeof (*pEscapeHdr))
+                if (pEscape->PrivateDriverDataSize < sizeof (VBOXDISPIFESCAPE_RECONNECT_TARGETS))
                 {
                     WARN(("VBOXESC_RECONNECT_TARGETS invalid private driver size %d\n", pEscape->PrivateDriverDataSize));
@@ -3500,12 +3500,21 @@
                 }
 
-                if (pEscapeHdr->u32CmdSpecific == 0)
-                {
-                    WARN(("VBOXESC_RECONNECT_TARGETS u32CmdSpecific is zero\n"));
+                if (pEscapeHdr->u32CmdSpecific != 0)
+                {
+                    WARN(("VBOXESC_RECONNECT_TARGETS u32CmdSpecific is not zero\n"));
                     Status = STATUS_INVALID_PARAMETER;
                     break;
                 }
 
-                uint32_t u32ConnectMask = pEscapeHdr->u32CmdSpecific;
+                VBOXDISPIFESCAPE_RECONNECT_TARGETS *pVBoxEscapeReconnectTargets = (VBOXDISPIFESCAPE_RECONNECT_TARGETS *)pEscape->pPrivateDriverData;
+                uint32_t u32ConnectMask = pVBoxEscapeReconnectTargets->u32ConnectMask;
+                uint32_t u32DisconnectMask = pVBoxEscapeReconnectTargets->u32DisconnectMask;
+
+                if (u32ConnectMask & u32DisconnectMask)
+                {
+                    WARN(("VBOXESC_RECONNECT_TARGETS (u32ConnectMask & u32DisconnectMask) is not zero\n"));
+                    Status = STATUS_INVALID_PARAMETER;
+                    break;
+                }
 
                 HANDLE hKey = NULL;
@@ -3520,5 +3529,12 @@
                 {
                     VBOXWDDM_TARGET *pTarget = &pDevExt->aTargets[i];
-                    bool fConnectReq = u32ConnectMask & RT_BIT(i);
+                    bool fConnectReq;
+
+                    if (u32ConnectMask & RT_BIT(i))
+                        fConnectReq = true;
+                    else if (u32DisconnectMask & RT_BIT(i))
+                        fConnectReq = false;
+                    else
+                        continue;
 
                     pTarget->fConfigured = true;
Index: trunk/src/VBox/Additions/WINNT/include/VBoxDisplay.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/include/VBoxDisplay.h	(revision 105679)
+++ trunk/src/VBox/Additions/WINNT/include/VBoxDisplay.h	(revision 105749)
@@ -133,4 +133,11 @@
 } VBOXDISPIFESCAPE_TARGETCONNECTIVITY;
 
+typedef struct VBOXDISPIFESCAPE_RECONNECT_TARGETS
+{
+    VBOXDISPIFESCAPE EscapeHdr;
+    uint32_t u32ConnectMask;
+    uint32_t u32DisconnectMask;
+} VBOXDISPIFESCAPE_RECONNECT_TARGETS;
+
 #endif /* VBOX_WITH_WDDM */
 
Index: trunk/src/VBox/Additions/common/VBoxService/VBoxServiceDisplayConfig.cpp
===================================================================
--- trunk/src/VBox/Additions/common/VBoxService/VBoxServiceDisplayConfig.cpp	(revision 105679)
+++ trunk/src/VBox/Additions/common/VBoxService/VBoxServiceDisplayConfig.cpp	(revision 105749)
@@ -121,12 +121,17 @@
     D3DKMT_ENUMADAPTERS EnumAdapters = {0};
     NTSTATUS rcNt;
-    uint32_t u32Mask = 0;
+    uint32_t u32ConnectMask = 0, u32DisconnectMask = 0;
 
     for(uint32_t i = 0; i < cDisplays; i++)
     {
-        u32Mask |= (paDisplays[i].fDisplayFlags & VMMDEV_DISPLAY_DISABLED) ? 0 : RT_BIT(i);
-    }
-
-    VGSvcVerbose(3, "ReconnectDisplays u32Mask 0x%x\n", u32Mask);
+        uint32_t u32Mask = RT_BIT(paDisplays[i].idDisplay);
+
+        if (paDisplays[i].fDisplayFlags & VMMDEV_DISPLAY_DISABLED)
+            u32DisconnectMask |= u32Mask;
+        else
+            u32ConnectMask |= u32Mask;
+    }
+
+    VGSvcVerbose(3, "ReconnectDisplays u32ConnectMask 0x%RX32, u32DisconnectMask 0x%RX32\n", u32ConnectMask, u32DisconnectMask);
 
     EnumAdapters.NumAdapters = RT_ELEMENTS(EnumAdapters.Adapters);
@@ -152,7 +157,10 @@
     if (hAdapter)
     {
-        VBOXDISPIFESCAPE EscapeHdr = {0};
-        EscapeHdr.escapeCode = VBOXESC_RECONNECT_TARGETS;
-        EscapeHdr.u32CmdSpecific = u32Mask;
+        VBOXDISPIFESCAPE_RECONNECT_TARGETS VBoxEscapeReconnectTargets = {{0}};
+
+        VBoxEscapeReconnectTargets.EscapeHdr.escapeCode = VBOXESC_RECONNECT_TARGETS;
+        VBoxEscapeReconnectTargets.EscapeHdr.u32CmdSpecific = 0;
+        VBoxEscapeReconnectTargets.u32ConnectMask = u32ConnectMask;
+        VBoxEscapeReconnectTargets.u32DisconnectMask = u32DisconnectMask;
 
         D3DKMT_ESCAPE EscapeData = {0};
@@ -160,6 +168,6 @@
         EscapeData.Type = D3DKMT_ESCAPE_DRIVERPRIVATE;
         EscapeData.Flags.HardwareAccess = 1;
-        EscapeData.pPrivateDriverData = &EscapeHdr;
-        EscapeData.PrivateDriverDataSize = sizeof (EscapeHdr);
+        EscapeData.pPrivateDriverData = &VBoxEscapeReconnectTargets;
+        EscapeData.PrivateDriverDataSize = sizeof (VBoxEscapeReconnectTargets);
 
         rcNt = g_pfnD3DKMTEscape(&EscapeData);
@@ -272,5 +280,5 @@
                     for(uint32_t i = 0; i < cDisplays; i++)
                     {
-                        VGSvcVerbose(2, "Display[%i] flags=%#x (%dx%d)\n", i,
+                        VGSvcVerbose(2, "%u) Display[%u] flags=%#x (%dx%d)\n", i, aDisplays[i].idDisplay,
                             aDisplays[i].fDisplayFlags,
                             aDisplays[i].cx, aDisplays[i].cy);
