Index: trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPDevExt.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPDevExt.h	(revision 40373)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPDevExt.h	(revision 40387)
@@ -178,9 +178,9 @@
 #else
     /* all memory layout info should be initialized */
-    Assert(pDevExt->u.primary.Vdma.CmdHeap.area.offBase);
+    Assert(pDevExt->u.primary.Vdma.CmdHeap.Heap.area.offBase);
     /* page aligned */
-    Assert(!(pDevExt->u.primary.Vdma.CmdHeap.area.offBase & 0xfff));
-
-    return pDevExt->u.primary.Vdma.CmdHeap.area.offBase & ~0xfffUL;
+    Assert(!(pDevExt->u.primary.Vdma.CmdHeap.Heap.area.offBase & 0xfff));
+
+    return pDevExt->u.primary.Vdma.CmdHeap.Heap.area.offBase & ~0xfffUL;
 #endif
 }
Index: trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPHGSMI.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPHGSMI.cpp	(revision 40373)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPHGSMI.cpp	(revision 40387)
@@ -154,5 +154,9 @@
 {
     VBoxMPCmnUnmapAdapterMemory(pCommon, &pCommon->pvMiniportHeap);
+#ifdef VBOX_WDDM_MINIPORT
+    VBoxSHGSMITerm(&pCommon->guestCtx.heapCtx);
+#else
     HGSMIHeapDestroy(&pCommon->guestCtx.heapCtx);
+#endif
 
     /* Unmap the adapter information needed for HGSMI IO. */
Index: trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPShgsmi.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPShgsmi.cpp	(revision 40373)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPShgsmi.cpp	(revision 40387)
@@ -26,10 +26,10 @@
 }
 
-void vboxSHGSMICommandFree (struct _HGSMIHEAP * pHeap, PVBOXSHGSMIHEADER pCmd)
-{
-    HGSMIHeapFree (pHeap, pCmd);
-}
-
-DECLINLINE(void) vboxSHGSMICommandRelease (struct _HGSMIHEAP * pHeap, PVBOXSHGSMIHEADER pCmd)
+void vboxSHGSMICommandFree (PVBOXSHGSMI pHeap, PVBOXSHGSMIHEADER pCmd)
+{
+    VBoxSHGSMIHeapFree(pHeap, pCmd);
+}
+
+DECLINLINE(void) vboxSHGSMICommandRelease (PVBOXSHGSMI pHeap, PVBOXSHGSMIHEADER pCmd)
 {
     uint32_t cRefs = ASMAtomicDecU32(&pCmd->cRefs);
@@ -39,10 +39,10 @@
 }
 
-DECLCALLBACK(void) vboxSHGSMICompletionSetEvent(struct _HGSMIHEAP * pHeap, void *pvCmd, void *pvContext)
+DECLCALLBACK(void) vboxSHGSMICompletionSetEvent(PVBOXSHGSMI pHeap, void *pvCmd, void *pvContext)
 {
     RTSemEventSignal((RTSEMEVENT)pvContext);
 }
 
-DECLCALLBACK(void) vboxSHGSMICompletionCommandRelease(struct _HGSMIHEAP * pHeap, void *pvCmd, void *pvContext)
+DECLCALLBACK(void) vboxSHGSMICompletionCommandRelease(PVBOXSHGSMI pHeap, void *pvCmd, void *pvContext)
 {
     vboxSHGSMICommandRelease (pHeap, VBoxSHGSMIBufferHeader(pvCmd));
@@ -50,5 +50,5 @@
 
 /* do not wait for completion */
-DECLINLINE(const VBOXSHGSMIHEADER*) vboxSHGSMICommandPrepAsynch (struct _HGSMIHEAP * pHeap, PVBOXSHGSMIHEADER pHeader)
+DECLINLINE(const VBOXSHGSMIHEADER*) vboxSHGSMICommandPrepAsynch (PVBOXSHGSMI pHeap, PVBOXSHGSMIHEADER pHeader)
 {
     /* ensure the command is not removed until we're processing it */
@@ -57,5 +57,5 @@
 }
 
-DECLINLINE(void) vboxSHGSMICommandDoneAsynch (struct _HGSMIHEAP * pHeap, const VBOXSHGSMIHEADER* pHeader)
+DECLINLINE(void) vboxSHGSMICommandDoneAsynch (PVBOXSHGSMI pHeap, const VBOXSHGSMIHEADER* pHeader)
 {
     if(!(ASMAtomicReadU32((volatile uint32_t *)&pHeader->fFlags) & VBOXSHGSMI_FLAG_HG_ASYNCH))
@@ -69,5 +69,5 @@
 }
 
-const VBOXSHGSMIHEADER* VBoxSHGSMICommandPrepAsynchEvent (struct _HGSMIHEAP * pHeap, PVOID pvBuff, RTSEMEVENT hEventSem)
+const VBOXSHGSMIHEADER* VBoxSHGSMICommandPrepAsynchEvent (PVBOXSHGSMI pHeap, PVOID pvBuff, RTSEMEVENT hEventSem)
 {
     PVBOXSHGSMIHEADER pHeader = VBoxSHGSMIBufferHeader (pvBuff);
@@ -79,5 +79,5 @@
 }
 
-const VBOXSHGSMIHEADER* VBoxSHGSMICommandPrepSynch (struct _HGSMIHEAP * pHeap, PVOID pCmd)
+const VBOXSHGSMIHEADER* VBoxSHGSMICommandPrepSynch (PVBOXSHGSMI pHeap, PVOID pCmd)
 {
     RTSEMEVENT hEventSem;
@@ -91,10 +91,10 @@
 }
 
-void VBoxSHGSMICommandDoneAsynch (struct _HGSMIHEAP * pHeap, const VBOXSHGSMIHEADER * pHeader)
+void VBoxSHGSMICommandDoneAsynch (PVBOXSHGSMI pHeap, const VBOXSHGSMIHEADER * pHeader)
 {
     vboxSHGSMICommandDoneAsynch(pHeap, pHeader);
 }
 
-int VBoxSHGSMICommandDoneSynch (struct _HGSMIHEAP * pHeap, const VBOXSHGSMIHEADER* pHeader)
+int VBoxSHGSMICommandDoneSynch (PVBOXSHGSMI pHeap, const VBOXSHGSMIHEADER* pHeader)
 {
     VBoxSHGSMICommandDoneAsynch (pHeap, pHeader);
@@ -107,10 +107,10 @@
 }
 
-void VBoxSHGSMICommandCancelAsynch (struct _HGSMIHEAP * pHeap, const VBOXSHGSMIHEADER* pHeader)
+void VBoxSHGSMICommandCancelAsynch (PVBOXSHGSMI pHeap, const VBOXSHGSMIHEADER* pHeader)
 {
     vboxSHGSMICommandRelease(pHeap, (PVBOXSHGSMIHEADER)pHeader);
 }
 
-void VBoxSHGSMICommandCancelSynch (struct _HGSMIHEAP * pHeap, const VBOXSHGSMIHEADER* pHeader)
+void VBoxSHGSMICommandCancelSynch (PVBOXSHGSMI pHeap, const VBOXSHGSMIHEADER* pHeader)
 {
     VBoxSHGSMICommandCancelAsynch (pHeap, pHeader);
@@ -119,5 +119,5 @@
 }
 
-const VBOXSHGSMIHEADER* VBoxSHGSMICommandPrepAsynch (struct _HGSMIHEAP * pHeap, PVOID pvBuff, PFNVBOXSHGSMICMDCOMPLETION pfnCompletion, PVOID pvCompletion, uint32_t fFlags)
+const VBOXSHGSMIHEADER* VBoxSHGSMICommandPrepAsynch (PVBOXSHGSMI pHeap, PVOID pvBuff, PFNVBOXSHGSMICMDCOMPLETION pfnCompletion, PVOID pvCompletion, uint32_t fFlags)
 {
     fFlags &= ~VBOXSHGSMI_FLAG_GH_ASYNCH_CALLBACK_IRQ;
@@ -130,5 +130,5 @@
 }
 
-const VBOXSHGSMIHEADER* VBoxSHGSMICommandPrepAsynchIrq (struct _HGSMIHEAP * pHeap, PVOID pvBuff, PFNVBOXSHGSMICMDCOMPLETION_IRQ pfnCompletion, PVOID pvCompletion, uint32_t fFlags)
+const VBOXSHGSMIHEADER* VBoxSHGSMICommandPrepAsynchIrq (PVBOXSHGSMI pHeap, PVOID pvBuff, PFNVBOXSHGSMICMDCOMPLETION_IRQ pfnCompletion, PVOID pvCompletion, uint32_t fFlags)
 {
     fFlags |= VBOXSHGSMI_FLAG_GH_ASYNCH_CALLBACK_IRQ | VBOXSHGSMI_FLAG_GH_ASYNCH_IRQ;
@@ -142,8 +142,41 @@
 }
 
-void* VBoxSHGSMICommandAlloc (struct _HGSMIHEAP * pHeap, HGSMISIZE cbData, uint8_t u8Channel, uint16_t u16ChannelInfo)
+void* VBoxSHGSMIHeapAlloc(PVBOXSHGSMI pHeap, HGSMISIZE cbData, uint8_t u8Channel, uint16_t u16ChannelInfo)
+{
+    KIRQL OldIrql;
+    void* pvData;
+    Assert(KeGetCurrentIrql() <= DISPATCH_LEVEL);
+    KeAcquireSpinLock(&pHeap->HeapLock, &OldIrql);
+    pvData = HGSMIHeapAlloc(&pHeap->Heap, cbData, u8Channel, u16ChannelInfo);
+    KeReleaseSpinLock(&pHeap->HeapLock, OldIrql);
+    if (!pvData)
+        WARN(("HGSMIHeapAlloc failed!"));
+    return pvData;
+}
+
+void VBoxSHGSMIHeapFree(PVBOXSHGSMI pHeap, void *pvBuffer)
+{
+    KIRQL OldIrql;
+    Assert(KeGetCurrentIrql() <= DISPATCH_LEVEL);
+    KeAcquireSpinLock(&pHeap->HeapLock, &OldIrql);
+    HGSMIHeapFree(&pHeap->Heap, pvBuffer);
+    KeReleaseSpinLock(&pHeap->HeapLock, OldIrql);
+}
+
+int VBoxSHGSMIInit(PVBOXSHGSMI pHeap, void *pvBase, HGSMISIZE cbArea, HGSMIOFFSET offBase, bool fOffsetBased)
+{
+    KeInitializeSpinLock(&pHeap->HeapLock);
+    return HGSMIHeapSetup(&pHeap->Heap, pvBase, cbArea, offBase, fOffsetBased);
+}
+
+void VBoxSHGSMITerm(PVBOXSHGSMI pHeap)
+{
+    HGSMIHeapDestroy(&pHeap->Heap);
+}
+
+void* VBoxSHGSMICommandAlloc(PVBOXSHGSMI pHeap, HGSMISIZE cbData, uint8_t u8Channel, uint16_t u16ChannelInfo)
 {
     /* Issue the flush command. */
-    PVBOXSHGSMIHEADER pHeader = (PVBOXSHGSMIHEADER)HGSMIHeapAlloc (pHeap, cbData + sizeof (VBOXSHGSMIHEADER), u8Channel, u16ChannelInfo);
+    PVBOXSHGSMIHEADER pHeader = (PVBOXSHGSMIHEADER)VBoxSHGSMIHeapAlloc(pHeap, cbData + sizeof (VBOXSHGSMIHEADER), u8Channel, u16ChannelInfo);
     Assert(pHeader);
     if (pHeader)
@@ -155,5 +188,5 @@
 }
 
-void VBoxSHGSMICommandFree (struct _HGSMIHEAP * pHeap, void *pvBuffer)
+void VBoxSHGSMICommandFree(PVBOXSHGSMI pHeap, void *pvBuffer)
 {
     PVBOXSHGSMIHEADER pHeader = VBoxSHGSMIBufferHeader(pvBuffer);
@@ -161,30 +194,8 @@
 }
 
-//int VBoxSHGSMISetup (PVBOXSHGSMIHEAP pHeap,
-//                void *pvBase,
-//                HGSMISIZE cbArea,
-//                HGSMIOFFSET offBase,
-//                bool fOffsetBased,
-//                PFNVBOXSHGSMINOTIFYHOST pfnNotifyHost,
-//                PFNVBOXSHGSMINOTIFYHOST pvNotifyHost)
-//{
-//    /* Setup a HGSMI heap within the adapter information area. */
-//    return HGSMIHeapSetup (&pHeap->Heap,
-//                         pvBuffer,
-//                         cbBuffer,
-//                         offBuffer,
-//                         false /*fOffsetBased*/);
-//}
-//
-//int VBoxSHGSMIDestroy (PVBOXSHGSMIHEAP pHeap)
-//{
-//    HGSMIHeapDestroy (pHeap);
-//    return VINF_SUCCESS;
-//}
-
 #define VBOXSHGSMI_CMD2LISTENTRY(_pCmd) ((PVBOXVTLIST_ENTRY)&(_pCmd)->pvNext)
 #define VBOXSHGSMI_LISTENTRY2CMD(_pEntry) ( (PVBOXSHGSMIHEADER)((uint8_t *)(_pEntry) - RT_OFFSETOF(VBOXSHGSMIHEADER, pvNext)) )
 
-int VBoxSHGSMICommandProcessCompletion (struct _HGSMIHEAP * pHeap, VBOXSHGSMIHEADER* pCur, bool bIrq, PVBOXVTLIST pPostProcessList)
+int VBoxSHGSMICommandProcessCompletion (PVBOXSHGSMI pHeap, VBOXSHGSMIHEADER* pCur, bool bIrq, PVBOXVTLIST pPostProcessList)
 {
     int rc = VINF_SUCCESS;
@@ -229,5 +240,5 @@
 }
 
-int VBoxSHGSMICommandPostprocessCompletion (struct _HGSMIHEAP * pHeap, PVBOXVTLIST pPostProcessList)
+int VBoxSHGSMICommandPostprocessCompletion (PVBOXSHGSMI pHeap, PVBOXVTLIST pPostProcessList)
 {
     PVBOXVTLIST_ENTRY pNext, pCur;
Index: trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPShgsmi.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPShgsmi.h	(revision 40373)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPShgsmi.h	(revision 40387)
@@ -22,33 +22,44 @@
 #include <iprt/cdefs.h>
 #include <VBox/VBoxVideo.h>
-#include "../../common/VBoxVideoTools.h"
 
-typedef DECLCALLBACK(void) FNVBOXSHGSMICMDCOMPLETION(struct _HGSMIHEAP * pHeap, void *pvCmd, void *pvContext);
+#include "common/VBoxMPUtils.h"
+
+typedef struct VBOXSHGSMI
+{
+    KSPIN_LOCK HeapLock;
+    HGSMIHEAP Heap;
+} VBOXSHGSMI, *PVBOXSHGSMI;
+
+typedef DECLCALLBACK(void) FNVBOXSHGSMICMDCOMPLETION(PVBOXSHGSMI pHeap, void *pvCmd, void *pvContext);
 typedef FNVBOXSHGSMICMDCOMPLETION *PFNVBOXSHGSMICMDCOMPLETION;
 
-typedef DECLCALLBACK(void) FNVBOXSHGSMICMDCOMPLETION_IRQ(struct _HGSMIHEAP * pHeap, void *pvCmd, void *pvContext,
+typedef DECLCALLBACK(void) FNVBOXSHGSMICMDCOMPLETION_IRQ(PVBOXSHGSMI pHeap, void *pvCmd, void *pvContext,
                                         PFNVBOXSHGSMICMDCOMPLETION *ppfnCompletion, void **ppvCompletion);
 typedef FNVBOXSHGSMICMDCOMPLETION_IRQ *PFNVBOXSHGSMICMDCOMPLETION_IRQ;
 
 
-const VBOXSHGSMIHEADER* VBoxSHGSMICommandPrepAsynchEvent(struct _HGSMIHEAP * pHeap, PVOID pvBuff, RTSEMEVENT hEventSem);
-const VBOXSHGSMIHEADER* VBoxSHGSMICommandPrepSynch(struct _HGSMIHEAP * pHeap, PVOID pCmd);
-const VBOXSHGSMIHEADER* VBoxSHGSMICommandPrepAsynch(struct _HGSMIHEAP * pHeap, PVOID pvBuff, PFNVBOXSHGSMICMDCOMPLETION pfnCompletion, PVOID pvCompletion, uint32_t fFlags);
-const VBOXSHGSMIHEADER* VBoxSHGSMICommandPrepAsynchIrq(struct _HGSMIHEAP * pHeap, PVOID pvBuff, PFNVBOXSHGSMICMDCOMPLETION_IRQ pfnCompletion, PVOID pvCompletion, uint32_t fFlags);
+const VBOXSHGSMIHEADER* VBoxSHGSMICommandPrepAsynchEvent(PVBOXSHGSMI pHeap, PVOID pvBuff, RTSEMEVENT hEventSem);
+const VBOXSHGSMIHEADER* VBoxSHGSMICommandPrepSynch(PVBOXSHGSMI pHeap, PVOID pCmd);
+const VBOXSHGSMIHEADER* VBoxSHGSMICommandPrepAsynch(PVBOXSHGSMI pHeap, PVOID pvBuff, PFNVBOXSHGSMICMDCOMPLETION pfnCompletion, PVOID pvCompletion, uint32_t fFlags);
+const VBOXSHGSMIHEADER* VBoxSHGSMICommandPrepAsynchIrq(PVBOXSHGSMI pHeap, PVOID pvBuff, PFNVBOXSHGSMICMDCOMPLETION_IRQ pfnCompletion, PVOID pvCompletion, uint32_t fFlags);
 
-void VBoxSHGSMICommandDoneAsynch(struct _HGSMIHEAP * pHeap, const VBOXSHGSMIHEADER* pHeader);
-int VBoxSHGSMICommandDoneSynch(struct _HGSMIHEAP * pHeap, const VBOXSHGSMIHEADER* pHeader);
-void VBoxSHGSMICommandCancelAsynch(struct _HGSMIHEAP * pHeap, const VBOXSHGSMIHEADER* pHeader);
-void VBoxSHGSMICommandCancelSynch(struct _HGSMIHEAP * pHeap, const VBOXSHGSMIHEADER* pHeader);
+void VBoxSHGSMICommandDoneAsynch(PVBOXSHGSMI pHeap, const VBOXSHGSMIHEADER* pHeader);
+int VBoxSHGSMICommandDoneSynch(PVBOXSHGSMI pHeap, const VBOXSHGSMIHEADER* pHeader);
+void VBoxSHGSMICommandCancelAsynch(PVBOXSHGSMI pHeap, const VBOXSHGSMIHEADER* pHeader);
+void VBoxSHGSMICommandCancelSynch(PVBOXSHGSMI pHeap, const VBOXSHGSMIHEADER* pHeader);
 
-DECLINLINE(HGSMIOFFSET) VBoxSHGSMICommandOffset(struct _HGSMIHEAP * pHeap, const VBOXSHGSMIHEADER* pHeader)
+DECLINLINE(HGSMIOFFSET) VBoxSHGSMICommandOffset(PVBOXSHGSMI pHeap, const VBOXSHGSMIHEADER* pHeader)
 {
-    return HGSMIHeapBufferOffset(pHeap, (void*)pHeader);
+    return HGSMIHeapBufferOffset(&pHeap->Heap, (void*)pHeader);
 }
 
-void* VBoxSHGSMICommandAlloc(struct _HGSMIHEAP * pHeap, HGSMISIZE cbData, uint8_t u8Channel, uint16_t u16ChannelInfo);
-void VBoxSHGSMICommandFree(struct _HGSMIHEAP * pHeap, void *pvBuffer);
-int VBoxSHGSMICommandProcessCompletion(struct _HGSMIHEAP * pHeap, VBOXSHGSMIHEADER* pCmd, bool bIrq, PVBOXVTLIST pPostProcessList);
-int VBoxSHGSMICommandPostprocessCompletion(struct _HGSMIHEAP * pHeap, PVBOXVTLIST pPostProcessList);
+int VBoxSHGSMIInit(PVBOXSHGSMI pHeap, void *pvBase, HGSMISIZE cbArea, HGSMIOFFSET offBase, bool fOffsetBased);
+void VBoxSHGSMITerm(PVBOXSHGSMI pHeap);
+void* VBoxSHGSMIHeapAlloc(PVBOXSHGSMI pHeap, HGSMISIZE cbData, uint8_t u8Channel, uint16_t u16ChannelInfo);
+void VBoxSHGSMIHeapFree(PVBOXSHGSMI pHeap, void *pvBuffer);
+void* VBoxSHGSMICommandAlloc(PVBOXSHGSMI pHeap, HGSMISIZE cbData, uint8_t u8Channel, uint16_t u16ChannelInfo);
+void VBoxSHGSMICommandFree(PVBOXSHGSMI pHeap, void *pvBuffer);
+int VBoxSHGSMICommandProcessCompletion(PVBOXSHGSMI pHeap, VBOXSHGSMIHEADER* pCmd, bool bIrq, struct VBOXVTLIST * pPostProcessList);
+int VBoxSHGSMICommandPostprocessCompletion(PVBOXSHGSMI pHeap, struct VBOXVTLIST * pPostProcessList);
 
 #endif /* #ifndef ___VBoxMPShgsmi_h___ */
Index: trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVdma.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVdma.cpp	(revision 40373)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVdma.cpp	(revision 40387)
@@ -1315,5 +1315,5 @@
     {
         pCmd->enmCtl = enmCtl;
-        pCmd->u32Offset = pInfo->CmdHeap.area.offBase;
+        pCmd->u32Offset = pInfo->CmdHeap.Heap.area.offBase;
         pCmd->i32Result = VERR_NOT_SUPPORTED;
 
@@ -1372,5 +1372,4 @@
 
 #ifdef VBOX_WITH_VDMA
-    KeInitializeSpinLock(&pInfo->HeapLock);
     Assert((offBuffer & 0xfff) == 0);
     Assert((cbBuffer & 0xfff) == 0);
@@ -1396,5 +1395,5 @@
     {
         /* Setup a HGSMI heap within the adapter information area. */
-        rc = HGSMIHeapSetup (&pInfo->CmdHeap,
+        rc = VBoxSHGSMIInit(&pInfo->CmdHeap,
                              pvBuffer,
                              cbBuffer,
@@ -1488,5 +1487,6 @@
             rc = vboxVdmaDisable (pDevExt, pInfo);
 #ifdef VBOX_WITH_VDMA
-        VBoxMPCmnUnmapAdapterMemory(VBoxCommonFromDeviceExt(pDevExt), (void**)&pInfo->CmdHeap.area.pu8Base);
+        VBoxSHGSMITerm(&pInfo->CmdHeap);
+        VBoxMPCmnUnmapAdapterMemory(VBoxCommonFromDeviceExt(pDevExt), (void**)&pInfo->CmdHeap.Heap.area.pu8Base);
 #endif
     }
@@ -1499,8 +1499,5 @@
 void vboxVdmaCBufDrFree (PVBOXVDMAINFO pInfo, PVBOXVDMACBUF_DR pDr)
 {
-    KIRQL OldIrql;
-    KeAcquireSpinLock(&pInfo->HeapLock, &OldIrql);
     VBoxSHGSMICommandFree (&pInfo->CmdHeap, pDr);
-    KeReleaseSpinLock(&pInfo->HeapLock, OldIrql);
 }
 
@@ -1508,8 +1505,5 @@
 {
     uint32_t cbDr = VBOXVDMACBUF_DR_SIZE(cbTrailingData);
-    KIRQL OldIrql;
-    KeAcquireSpinLock(&pInfo->HeapLock, &OldIrql);
     PVBOXVDMACBUF_DR pDr = (PVBOXVDMACBUF_DR)VBoxSHGSMICommandAlloc (&pInfo->CmdHeap, cbDr, HGSMI_CH_VBVA, VBVA_VDMA_CMD);
-    KeReleaseSpinLock(&pInfo->HeapLock, OldIrql);
     Assert(pDr);
     if (pDr)
@@ -1521,5 +1515,5 @@
 }
 
-static DECLCALLBACK(void) vboxVdmaCBufDrCompletion(struct _HGSMIHEAP * pHeap, void *pvCmd, void *pvContext)
+static DECLCALLBACK(void) vboxVdmaCBufDrCompletion(PVBOXSHGSMI pHeap, void *pvCmd, void *pvContext)
 {
     PVBOXMP_DEVEXT pDevExt = (PVBOXMP_DEVEXT)pvContext;
@@ -1529,5 +1523,5 @@
 }
 
-static DECLCALLBACK(void) vboxVdmaCBufDrCompletionIrq(struct _HGSMIHEAP * pHeap, void *pvCmd, void *pvContext,
+static DECLCALLBACK(void) vboxVdmaCBufDrCompletionIrq(PVBOXSHGSMI pHeap, void *pvCmd, void *pvContext,
                                         PFNVBOXSHGSMICMDCOMPLETION *ppfnCompletion, void **ppvCompletion)
 {
Index: trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVdma.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVdma.h	(revision 40373)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVdma.h	(revision 40387)
@@ -291,6 +291,5 @@
 {
 #ifdef VBOX_WITH_VDMA
-    KSPIN_LOCK HeapLock;
-    HGSMIHEAP CmdHeap;
+    VBOXSHGSMI CmdHeap;
 #endif
     UINT      uLastCompletedPagingBufferCmdFenceId;
Index: trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp	(revision 40373)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp	(revision 40387)
@@ -288,11 +288,11 @@
 #endif
 
-HGSMIHEAP* vboxWddmHgsmiGetHeapFromCmdOffset(PVBOXMP_DEVEXT pDevExt, HGSMIOFFSET offCmd)
+PVBOXSHGSMI vboxWddmHgsmiGetHeapFromCmdOffset(PVBOXMP_DEVEXT pDevExt, HGSMIOFFSET offCmd)
 {
 #ifdef VBOX_WITH_VDMA
-    if(HGSMIAreaContainsOffset(&pDevExt->u.primary.Vdma.CmdHeap.area, offCmd))
+    if(HGSMIAreaContainsOffset(&pDevExt->u.primary.Vdma.CmdHeap.Heap.area, offCmd))
         return &pDevExt->u.primary.Vdma.CmdHeap;
 #endif
-    if (HGSMIAreaContainsOffset(&VBoxCommonFromDeviceExt(pDevExt)->guestCtx.heapCtx.area, offCmd))
+    if (HGSMIAreaContainsOffset(&VBoxCommonFromDeviceExt(pDevExt)->guestCtx.heapCtx.Heap.area, offCmd))
         return &VBoxCommonFromDeviceExt(pDevExt)->guestCtx.heapCtx;
     return NULL;
@@ -311,8 +311,8 @@
 {
 #ifdef VBOX_WITH_VDMA
-    if(HGSMIAreaContainsOffset(&pDevExt->u.primary.Vdma.CmdHeap.area, offCmd))
+    if(HGSMIAreaContainsOffset(&pDevExt->u.primary.Vdma.CmdHeap.Heap.area, offCmd))
         return VBOXWDDM_HGSMICMD_TYPE_DMACMD;
 #endif
-    if (HGSMIAreaContainsOffset(&VBoxCommonFromDeviceExt(pDevExt)->guestCtx.heapCtx.area, offCmd))
+    if (HGSMIAreaContainsOffset(&VBoxCommonFromDeviceExt(pDevExt)->guestCtx.heapCtx.Heap.area, offCmd))
         return VBOXWDDM_HGSMICMD_TYPE_CTL;
     return VBOXWDDM_HGSMICMD_TYPE_UNDEFINED;
@@ -1171,5 +1171,5 @@
                     VBOXWDDM_HGSMICMD_TYPE enmType = vboxWddmHgsmiGetCmdTypeFromOffset(pDevExt, offCmd);
                     PVBOXVTLIST pList;
-                    HGSMIHEAP * pHeap = NULL;
+                    PVBOXSHGSMI pHeap = NULL;
                     switch (enmType)
                     {
@@ -1191,5 +1191,5 @@
                     {
                         uint16_t chInfo;
-                        uint8_t *pvCmd = HGSMIBufferDataAndChInfoFromOffset (&pHeap->area, offCmd, &chInfo);
+                        uint8_t *pvCmd = HGSMIBufferDataAndChInfoFromOffset (&pHeap->Heap.area, offCmd, &chInfo);
                         Assert(pvCmd);
                         if (pvCmd)
