Index: /trunk/src/VBox/Additions/WINNT/Graphics/Display/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Display/Makefile.kmk	(revision 30461)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Display/Makefile.kmk	(revision 30462)
@@ -88,4 +88,6 @@
     wddm/VBoxDispD3DIf.cpp \
     wddm/VBoxDispCm.cpp \
+    wddm/VBoxDispMp.cpp \
+    wddm/VBoxDispMpTst.cpp \
 	wddm/VBoxDispD3D.def \
 	wddm/VBoxDispD3D.rc
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispCm.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispCm.cpp	(revision 30461)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispCm.cpp	(revision 30462)
@@ -106,4 +106,6 @@
 {
     VBOXWDDM_CREATECONTEXT_INFO Info;
+    Info.u32IfVersion = pDevice->u32IfVersion;
+    Info.u32IsD3D = VBOXDISPMODE_IS_3D(pDevice->pAdapter);
     Info.hUmEvent = (uint64_t)g_pVBoxCmMgr.Session.hEvent;
     Info.u64UmInfo = (uint64_t)pContext;
@@ -127,4 +129,7 @@
     if (hr == S_OK)
     {
+        Assert(pContext->ContextInfo.hContext);
+        pContext->ContextInfo.pPrivateDriverData = NULL;
+        pContext->ContextInfo.PrivateDriverDataSize = 0;
         vboxDispCmSessionCtxAdd(&g_pVBoxCmMgr.Session, pContext);
         pContext->pDevice = pDevice;
@@ -138,4 +143,5 @@
     Assert(pContext->ContextInfo.hContext);
     D3DDDICB_DESTROYCONTEXT DestroyContext;
+    Assert(pDevice->DefaultContext.ContextInfo.hContext);
     DestroyContext.hContext = pDevice->DefaultContext.ContextInfo.hContext;
     HRESULT hr = pDevice->RtCallbacks.pfnDestroyContextCb(pDevice->hDevice, &DestroyContext);
@@ -154,8 +160,8 @@
 }
 
-HRESULT vboxDispCmSessionCmdGet(PVBOXDISPCM_SESSION pSession, void *pvCmd, uint32_t cbCmd, DWORD dwMilliseconds)
-{
-    Assert(cbCmd >= VBOXDISPIFESCAPE_SIZE(sizeof (VBOXWDDM_GETVBOXVIDEOCMCMD_HDR)));
-    if (cbCmd < VBOXDISPIFESCAPE_SIZE(sizeof (VBOXWDDM_GETVBOXVIDEOCMCMD_HDR)))
+HRESULT vboxDispCmSessionCmdGet(PVBOXDISPCM_SESSION pSession, PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD pCmd, uint32_t cbCmd, DWORD dwMilliseconds)
+{
+    Assert(cbCmd >= sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD));
+    if (cbCmd < sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD))
         return E_INVALIDARG;
 
@@ -165,12 +171,11 @@
         case WAIT_OBJECT_0:
         {
-            PVBOXDISPIFESCAPE pEscape = (PVBOXDISPIFESCAPE)pvCmd;
             HRESULT hr = S_OK;
             D3DDDICB_ESCAPE DdiEscape;
             DdiEscape.Flags.Value = 0;
-            DdiEscape.pPrivateDriverData = pvCmd;
+            DdiEscape.pPrivateDriverData = pCmd;
             DdiEscape.PrivateDriverDataSize = cbCmd;
 
-            pEscape->escapeCode = VBOXESC_GETVBOXVIDEOCMCMD;
+            pCmd->EscapeHdr.escapeCode = VBOXESC_GETVBOXVIDEOCMCMD;
             /* lock to ensure the context is not distructed */
             EnterCriticalSection(&pSession->CritSect);
@@ -191,8 +196,7 @@
             {
                 LeaveCriticalSection(&pSession->CritSect);
-                PVBOXWDDM_GETVBOXVIDEOCMCMD_HDR pHdr = VBOXDISPIFESCAPE_DATA(pEscape, VBOXWDDM_GETVBOXVIDEOCMCMD_HDR);
-                pHdr->cbCmdsReturned = 0;
-                pHdr->cbRemainingCmds = 0;
-                pHdr->cbRemainingFirstCmd = 0;
+                pCmd->Hdr.cbCmdsReturned = 0;
+                pCmd->Hdr.cbRemainingCmds = 0;
+                pCmd->Hdr.cbRemainingFirstCmd = 0;
             }
 
@@ -201,9 +205,7 @@
         case WAIT_TIMEOUT:
         {
-            PVBOXDISPIFESCAPE pEscape = (PVBOXDISPIFESCAPE)pvCmd;
-            PVBOXWDDM_GETVBOXVIDEOCMCMD_HDR pHdr = VBOXDISPIFESCAPE_DATA(pEscape, VBOXWDDM_GETVBOXVIDEOCMCMD_HDR);
-            pHdr->cbCmdsReturned = 0;
-            pHdr->cbRemainingCmds = 0;
-            pHdr->cbRemainingFirstCmd = 0;
+            pCmd->Hdr.cbCmdsReturned = 0;
+            pCmd->Hdr.cbRemainingCmds = 0;
+            pCmd->Hdr.cbRemainingFirstCmd = 0;
             return S_OK;
         }
@@ -214,6 +216,6 @@
 }
 
-HRESULT vboxDispCmCmdGet(void *pvCmd, uint32_t cbCmd, DWORD dwMilliseconds)
-{
-    return vboxDispCmSessionCmdGet(&g_pVBoxCmMgr.Session, pvCmd, cbCmd, dwMilliseconds);
-}
+HRESULT vboxDispCmCmdGet(PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD pCmd, uint32_t cbCmd, DWORD dwMilliseconds)
+{
+    return vboxDispCmSessionCmdGet(&g_pVBoxCmMgr.Session, pCmd, cbCmd, dwMilliseconds);
+}
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp	(revision 30461)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp	(revision 30462)
@@ -1085,4 +1085,6 @@
                     LPVOID    lpReserved)
 {
+    BOOL bOk = TRUE;
+
     switch (dwReason)
     {
@@ -1091,5 +1093,10 @@
             RTR3Init();
 
-            vboxVDbgPrint(("VBoxDispD3D: DLL loaded.\n"));
+            HRESULT hr = vboxDispCmInit();
+            Assert(hr == S_OK);
+            if (hr == S_OK)
+                vboxVDbgPrint(("VBoxDispD3D: DLL loaded.\n"));
+            else
+                bOk = FALSE;
 
 //                VbglR3Init();
@@ -1099,5 +1106,10 @@
         case DLL_PROCESS_DETACH:
         {
-            vboxVDbgPrint(("VBoxDispD3D: DLL unloaded.\n"));
+            HRESULT hr = vboxDispCmTerm();
+            Assert(hr == S_OK);
+            if (hr == S_OK)
+                vboxVDbgPrint(("VBoxDispD3D: DLL unloaded.\n"));
+            else
+                bOk = FALSE;
 //                VbglR3Term();
             /// @todo RTR3Term();
@@ -1108,5 +1120,5 @@
             break;
     }
-    return TRUE;
+    return bOk;
 }
 
@@ -3621,14 +3633,10 @@
 
     PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
-    if (pDevice->DefaultContext.ContextInfo.hContext)
-    {
-        D3DDDICB_DESTROYCONTEXT DestroyContext;
-        DestroyContext.hContext = pDevice->DefaultContext.ContextInfo.hContext;
-        HRESULT tmpHr = pDevice->RtCallbacks.pfnDestroyContextCb(pDevice->hDevice, &DestroyContext);
-        Assert(tmpHr == S_OK);
-    }
-    RTMemFree(hDevice);
-    vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
-    return S_OK;
+    HRESULT hr = vboxDispCmCtxDestroy(pDevice, &pDevice->DefaultContext);
+    Assert(hr == S_OK);
+    if (hr == S_OK)
+        RTMemFree(pDevice);
+    vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
+    return hr;
 }
 
@@ -4106,44 +4114,8 @@
                     && !pCreateData->PatchLocationListSize)
             {
-                pDevice->DefaultContext.ContextInfo.NodeOrdinal = 0;
-                pDevice->DefaultContext.ContextInfo.EngineAffinity = 0;
-                pDevice->DefaultContext.ContextInfo.Flags.Value = 0;
-                pDevice->DefaultContext.ContextInfo.pPrivateDriverData = NULL;
-                pDevice->DefaultContext.ContextInfo.PrivateDriverDataSize = 0;
-                pDevice->DefaultContext.ContextInfo.hContext = 0;
-                pDevice->DefaultContext.ContextInfo.pCommandBuffer = NULL;
-                pDevice->DefaultContext.ContextInfo.CommandBufferSize = 0;
-                pDevice->DefaultContext.ContextInfo.pAllocationList = NULL;
-                pDevice->DefaultContext.ContextInfo.AllocationListSize = 0;
-                pDevice->DefaultContext.ContextInfo.pPatchLocationList = NULL;
-                pDevice->DefaultContext.ContextInfo.PatchLocationListSize = 0;
-
-                hr = pDevice->RtCallbacks.pfnCreateContextCb(pDevice->hDevice, &pDevice->DefaultContext.ContextInfo);
+                hr = vboxDispCmCtxCreate(pDevice, &pDevice->DefaultContext);
                 Assert(hr == S_OK);
                 if (hr == S_OK)
-                {
-                    if (VBOXDISPMODE_IS_3D(pAdapter))
-                    {
-                        /* we postpone IDirect3DDevice device creation to CreateResource,
-                         * where resource render target gets created,
-                         * which is actually done as part of d3dx.dll Direct3DDevice creation */
-                        vboxVDbgPrint((__FUNCTION__": D3D Device Created\n"));
-                        break;
-                    }
-                    else
-                    {
-                        /* DDraw */
-                        vboxVDbgPrint((__FUNCTION__": DirectDraw Device Created\n"));
-                        break;
-                    }
-
-                    D3DDDICB_DESTROYCONTEXT DestroyContext;
-                    DestroyContext.hContext = pDevice->DefaultContext.ContextInfo.hContext;
-
-                    HRESULT tmpHr = pDevice->RtCallbacks.pfnDestroyContextCb(pDevice->hDevice, &DestroyContext);
-                    Assert(tmpHr == S_OK);
-                }
-                else
-                    vboxVDbgPrintR((__FUNCTION__": pfnCreateContextCb failed, hr(%d)\n", hr));
+                    break;
             }
             else
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DCmn.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DCmn.h	(revision 30461)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DCmn.h	(revision 30462)
@@ -32,4 +32,5 @@
 #include "VBoxDispD3DIf.h"
 #include "../../Miniport/wddm/VBoxVideoIf.h"
+#include "VBoxDispCm.h"
 #include "VBoxDispD3D.h"
 
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoCm.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoCm.cpp	(revision 30461)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoCm.cpp	(revision 30462)
@@ -357,8 +357,8 @@
 }
 
-NTSTATUS vboxVideoCmEscape(PVBOXVIDEOCM_CTX pContext, PVBOXWDDM_GETVBOXVIDEOCMCMD_HDR pvCmd, uint32_t cbCmd)
-{
-    Assert(cbCmd >= VBOXWDDM_GETVBOXVIDEOCMCMD_DATA_OFFSET());
-    if (cbCmd < VBOXWDDM_GETVBOXVIDEOCMCMD_DATA_OFFSET())
+NTSTATUS vboxVideoCmEscape(PVBOXVIDEOCM_CTX pContext, PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD pCmd, uint32_t cbCmd)
+{
+    Assert(cbCmd >= sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD));
+    if (cbCmd < sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD))
         return STATUS_BUFFER_TOO_SMALL;
 
@@ -370,6 +370,6 @@
     uint32_t cbRemainingCmds = 0;
     uint32_t cbRemainingFirstCmd = 0;
-    uint8_t * pvData = VBOXWDDM_GETVBOXVIDEOCMCMD_DATA(pvCmd, uint8_t);
-    uint32_t cbData = cbCmd - VBOXWDDM_GETVBOXVIDEOCMCMD_DATA_OFFSET();
+    uint32_t cbData = cbCmd - sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD);
+    uint8_t * pvData = ((uint8_t *)pCmd) + sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD);
     bool bDetachMode = true;
     InitializeListHead(&DetachedList);
@@ -427,16 +427,16 @@
     ExReleaseFastMutex(&pSession->Mutex);
 
-    pvCmd->cbCmdsReturned = 0;
+    pCmd->Hdr.cbCmdsReturned = 0;
     for (pCurEntry = DetachedList.Blink; DetachedList.Blink != &DetachedList; pCurEntry = pCurEntry->Blink)
     {
         memcpy(pvData, &pHdr->CmdHdr, pHdr->CmdHdr.cbCmd);
         pvData += pHdr->CmdHdr.cbCmd;
-        pvCmd->cbCmdsReturned += pHdr->CmdHdr.cbCmd;
+        pCmd->Hdr.cbCmdsReturned += pHdr->CmdHdr.cbCmd;
         vboxVideoCmCmdReleaseByHdr(pHdr);
     }
 
-    pvCmd->cbRemainingCmds = cbRemainingCmds;
-    pvCmd->cbRemainingFirstCmd = cbRemainingFirstCmd;
-    pvCmd->u32Reserved = 0;
+    pCmd->Hdr.cbRemainingCmds = cbRemainingCmds;
+    pCmd->Hdr.cbRemainingFirstCmd = cbRemainingFirstCmd;
+    pCmd->Hdr.u32Reserved = 0;
 
     return STATUS_SUCCESS;
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoCm.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoCm.h	(revision 30461)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoCm.h	(revision 30462)
@@ -41,5 +41,5 @@
 void vboxVideoCmCmdSubmit(void *pvCmd, uint32_t cbSize);
 
-NTSTATUS vboxVideoCmEscape(PVBOXVIDEOCM_CTX pContext, PVBOXWDDM_GETVBOXVIDEOCMCMD_HDR pvCmd, uint32_t cbCmd);
+NTSTATUS vboxVideoCmEscape(PVBOXVIDEOCM_CTX pContext, PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD pCmd, uint32_t cbCmd);
 
 #endif /* #ifndef ___VBoxVideoCm_h___ */
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoIf.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoIf.h	(revision 30461)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoIf.h	(revision 30462)
@@ -23,8 +23,12 @@
 
 #include <VBox/VBoxVideo.h>
+#include "../../../include/VBoxDisplay.h"
+
+#include <iprt/assert.h>
+
 
 /* @todo: implement a check to ensure display & miniport versions match.
  * One would increase this whenever definitions in this file are changed */
-#define VBOXVIDEOIF_VERSION 3
+#define VBOXVIDEOIF_VERSION 4
 
 /* create allocation func */
@@ -145,4 +149,8 @@
 typedef struct VBOXWDDM_CREATECONTEXT_INFO
 {
+    /* interface version, i.e. 9 for d3d9, 8 for d3d8, etc. */
+    uint32_t u32IfVersion;
+    /* true if d3d false if ddraw */
+    uint32_t u32IsD3D;
     /* we use uint64_t instead of HANDLE to ensure structure def is the same for both 32-bit and 64-bit
      * since x64 kernel driver can be called by 32-bit UMD */
@@ -184,4 +192,6 @@
 }VBOXVIDEOCM_CMD_HDR, *PVBOXVIDEOCM_CMD_HDR;
 
+AssertCompile((sizeof (VBOXVIDEOCM_CMD_HDR) & 7) == 0);
+
 typedef struct VBOXVIDEOCM_CMD_RECTS
 {
@@ -201,8 +211,12 @@
 } VBOXWDDM_GETVBOXVIDEOCMCMD_HDR, *PVBOXWDDM_GETVBOXVIDEOCMCMD_HDR;
 
-#define VBOXWDDM_GETVBOXVIDEOCMCMD_DATA_OFFSET() ((sizeof (VBOXWDDM_GETVBOXVIDEOCMCMD_HDR) + 7) & ~7)
-#define VBOXWDDM_GETVBOXVIDEOCMCMD_DATA(_pHead, _t) ( (_t*)(((uint8_t*)(_pHead)) + VBOXWDDM_GETVBOXVIDEOCMCMD_DATA_OFFSET()))
-#define VBOXWDDM_GETVBOXVIDEOCMCMD_DATA_SIZE(_s) ( (_s) < VBOXWDDM_GETVBOXVIDEOCMCMD_DATA_OFFSET() ? 0 : (_s) - VBOXWDDM_GETVBOXVIDEOCMCMD_DATA_OFFSET() )
-#define VBOXWDDM_GETVBOXVIDEOCMCMD_SIZE(_cbData) ((_cbData) ? VBOXWDDM_GETVBOXVIDEOCMCMD_DATA_OFFSET() + (_cbData) : sizeof (VBOXWDDM_GETVBOXVIDEOCMCMD_HDR))
+typedef struct VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD
+{
+    VBOXDISPIFESCAPE EscapeHdr;
+    VBOXWDDM_GETVBOXVIDEOCMCMD_HDR Hdr;
+} VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD, *PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD;
+
+AssertCompile((sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD) & 7) == 0);
+AssertCompile(RT_OFFSETOF(VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD, EscapeHdr) == 0);
 
 /* query info func */
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp	(revision 30461)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp	(revision 30462)
@@ -2078,9 +2078,30 @@
         case VBOXVDMACMD_TYPE_DMA_PRESENT_BLT:
         {
+            PVBOXWDDM_DMA_PRESENT_BLT pBlt = (PVBOXWDDM_DMA_PRESENT_BLT)pPrivateData;
             uint32_t cContexts3D = ASMAtomicReadU32(&pDevExt->cContexts3D);
             if (cContexts3D)
             {
-
-            }
+                if (pPrivateData->fFlags.bShadow2PrimaryUpdate)
+                {
+                    RECT rect;
+                    Assert(pBlt->DstRects.cRects);
+                    if (pBlt->DstRects.cRects > 1)
+                    {
+                        rect = pBlt->DstRects.aRects[1];
+                        for (UINT i = 2; i < pBlt->DstRects.cRects; ++i)
+                        {
+                            vboxWddmRectUnited(&rect, &rect, &pBlt->DstRects.aRects[i]);
+                        }
+                    }
+                    else
+                        rect = pBlt->DstRects.aRects[0];
+
+                    VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pPrivateData->SrcAllocInfo.srcId];
+                    VBOXVBVA_OP(ReportDirtyRect, pDevExt, &pSource->Vbva, &rect);
+                }
+            }
+            else
+                Assert(!pPrivateData->fFlags.bShadow2PrimaryUpdate);
+
             VBOXWDDM_SHADOW_UPDATE_COMPLETION context;
             context.pDevExt = pDevExt;
@@ -2572,8 +2593,14 @@
             {
                 PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)pEscape->hContext;
-                Assert(pContext);
-                PVBOXWDDM_GETVBOXVIDEOCMCMD_HDR pHdr = VBOXDISPIFESCAPE_DATA(pEscapeHdr, VBOXWDDM_GETVBOXVIDEOCMCMD_HDR);
-                Status = vboxVideoCmEscape(&pContext->CmContext, pHdr, VBOXDISPIFESCAPE_DATA_SIZE(pEscape->PrivateDriverDataSize));
-                Assert(Status == STATUS_SUCCESS);
+                PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD pRegions = (PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD)pEscapeHdr;
+                Assert(pEscape->PrivateDriverDataSize >= sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD));
+                if (pEscape->PrivateDriverDataSize >= sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD))
+                {
+                    Status = vboxVideoCmEscape(&pContext->CmContext, pRegions, pEscape->PrivateDriverDataSize);
+                    Assert(Status == STATUS_SUCCESS);
+                }
+                else
+                    Status = STATUS_BUFFER_TOO_SMALL;
+
                 break;
             }
@@ -2653,6 +2680,6 @@
     {
         drprintf((__FUNCTION__": pEscape->PrivateDriverDataSize(%d) < (%d)\n", pEscape->PrivateDriverDataSize, sizeof (VBOXDISPIFESCAPE)));
-        Status = STATUS_INVALID_PARAMETER;
         AssertBreakpoint();
+        Status = STATUS_BUFFER_TOO_SMALL;
     }
 
@@ -3738,5 +3765,5 @@
                     Assert(cbCmd < UINT32_MAX/2);
                     Assert(cbCmd > sizeof (RECT));
-                    if (cbCmd < cbRects)
+                    if (cbCmd >= cbRects)
                     {
                         cbCmd -= cbRects;
@@ -3756,4 +3783,5 @@
                     }
 
+                    pPresent->pDmaBufferPrivateData = (uint8_t*)pPresent->pDmaBufferPrivateData + cbHead + cbRects;
                     pPresent->pDmaBuffer = ((uint8_t*)pPresent->pDmaBuffer) + VBOXWDDM_DUMMY_DMABUFFER_SIZE;
                     Assert(pPresent->DmaSize >= VBOXWDDM_DUMMY_DMABUFFER_SIZE);
@@ -4041,34 +4069,38 @@
         pContext->NodeOrdinal = pCreateContext->NodeOrdinal;
         vboxVideoCmCtxInitEmpty(&pContext->CmContext);
-        if (pCreateContext->Flags.SystemContext)
+        if (pCreateContext->Flags.SystemContext || pCreateContext->PrivateDriverDataSize == 0)
+        {
+            Assert(pCreateContext->PrivateDriverDataSize == 0);
+            Assert(!pCreateContext->pPrivateDriverData);
+            Assert(pCreateContext->Flags.Value == 1 || pCreateContext->Flags.Value == 0);
             pContext->enmType = VBOXWDDM_CONTEXT_TYPE_SYSTEM;
-        else if (pCreateContext->Flags.Value == 0)
-        {
+        }
+        else
+        {
+            Assert(pCreateContext->Flags.Value == 0);
             Assert(pCreateContext->PrivateDriverDataSize == sizeof (VBOXWDDM_CREATECONTEXT_INFO));
             Assert(pCreateContext->pPrivateDriverData);
             if (pCreateContext->PrivateDriverDataSize == sizeof (VBOXWDDM_CREATECONTEXT_INFO))
             {
-                pContext->enmType = VBOXWDDM_CONTEXT_TYPE_CUSTOM_3D;
                 PVBOXWDDM_CREATECONTEXT_INFO pInfo = (PVBOXWDDM_CREATECONTEXT_INFO)pCreateContext->pPrivateDriverData;
-                Status = vboxVideoCmCtxAdd(&pDevice->pAdapter->CmMgr, &pContext->CmContext, (HANDLE)pInfo->hUmEvent, pInfo->u64UmInfo);
-                Assert(Status == STATUS_SUCCESS);
-                if (Status == STATUS_SUCCESS)
+                if (pInfo->u32IsD3D)
                 {
-                    Assert(KeGetCurrentIrql() < DISPATCH_LEVEL);
-                    ExAcquireFastMutex(&pDevExt->ContextMutex);
-                    InsertHeadList(&pDevExt->ContextList3D, &pContext->ListEntry);
-                    ASMAtomicIncU32(&pDevExt->cContexts3D);
-                    ExReleaseFastMutex(&pDevExt->ContextMutex);
+                    pContext->enmType = VBOXWDDM_CONTEXT_TYPE_CUSTOM_3D;
+                    Status = vboxVideoCmCtxAdd(&pDevice->pAdapter->CmMgr, &pContext->CmContext, (HANDLE)pInfo->hUmEvent, pInfo->u64UmInfo);
+                    Assert(Status == STATUS_SUCCESS);
+                    if (Status == STATUS_SUCCESS)
+                    {
+                        Assert(KeGetCurrentIrql() < DISPATCH_LEVEL);
+                        ExAcquireFastMutex(&pDevExt->ContextMutex);
+                        InsertHeadList(&pDevExt->ContextList3D, &pContext->ListEntry);
+                        ASMAtomicIncU32(&pDevExt->cContexts3D);
+                        ExReleaseFastMutex(&pDevExt->ContextMutex);
+                    }
                 }
-            }
-            else
-            {
-                pContext->enmType = VBOXWDDM_CONTEXT_TYPE_CUSTOM_2D;
-            }
-        }
-        else
-        {
-            AssertBreakpoint(); /* we do not support custom contexts for now */
-            drprintf((__FUNCTION__ ", we do not support custom contexts for now, hDevice (0x%x)\n", hDevice));
+                else
+                {
+                    pContext->enmType = VBOXWDDM_CONTEXT_TYPE_CUSTOM_2D;
+                }
+            }
         }
 
Index: /trunk/src/VBox/Additions/WINNT/include/VBoxDisplay.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/include/VBoxDisplay.h	(revision 30461)
+++ /trunk/src/VBox/Additions/WINNT/include/VBoxDisplay.h	(revision 30462)
@@ -22,4 +22,6 @@
 # define VBOXESC_GETVBOXVIDEOCMCMD          0xABCD9004
 
+#include <iprt/assert.h>
+
 typedef struct
 {
@@ -42,6 +44,10 @@
 typedef struct VBOXDISPIFESCAPE
 {
-    int escapeCode;
+    int32_t escapeCode;
+    uint32_t u32CmdSpecific;
 } VBOXDISPIFESCAPE, *PVBOXDISPIFESCAPE;
+
+/* ensure command body is always 8-byte-aligned*/
+AssertCompile((sizeof (VBOXDISPIFESCAPE) & 7) == 0);
 
 #define VBOXDISPIFESCAPE_DATA_OFFSET() ((sizeof (VBOXDISPIFESCAPE) + 7) & ~7)
