Index: /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp	(revision 32929)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp	(revision 32930)
@@ -7381,5 +7381,5 @@
 VOID vboxVDbgDoMpPrint(const PVBOXWDDMDISP_DEVICE pDevice, LPCSTR szString)
 {
-    uint32_t cbString = strlen(szString) + 1;
+    uint32_t cbString = (uint32_t)strlen(szString) + 1;
     uint32_t cbCmd = RT_OFFSETOF(VBOXDISPIFESCAPE_DBGPRINT, aStringBuf[cbString]);
     PVBOXDISPIFESCAPE_DBGPRINT pCmd = (PVBOXDISPIFESCAPE_DBGPRINT)RTMemAllocZ(cbCmd);
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoMisc.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoMisc.cpp	(revision 32929)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoMisc.cpp	(revision 32930)
@@ -511,4 +511,9 @@
     const WCHAR* pKeyPrefix;
     UINT cbKeyPrefix;
+    UNICODE_STRING* pVGuid = vboxWddmVGuidGet(pDevExt);
+    Assert(pVGuid);
+    if (!pVGuid)
+        return STATUS_UNSUCCESSFUL;
+
     winVersion_t ver = vboxQueryWinVersion();
     if (ver == WINVISTA)
@@ -524,11 +529,11 @@
     }
 
-    ULONG cbResult = cbKeyPrefix + pDevExt->VideoGuid.Length + 2 + 8; // L"\\" + "XXXX"
+    ULONG cbResult = cbKeyPrefix + pVGuid->Length + 2 + 8; // L"\\" + "XXXX"
     if (cbBuf >= cbResult)
     {
         wcscpy(pBuf, pKeyPrefix);
         pSuffix = pBuf + (cbKeyPrefix-2)/2;
-        memcpy(pSuffix, pDevExt->VideoGuid.Buffer, pDevExt->VideoGuid.Length);
-        pSuffix += pDevExt->VideoGuid.Length/2;
+        memcpy(pSuffix, pVGuid->Buffer, pVGuid->Length);
+        pSuffix += pVGuid->Length/2;
         pSuffix[0] = L'\\';
         pSuffix += 1;
@@ -757,2 +762,36 @@
             sizeof(val));
 }
+
+UNICODE_STRING* vboxWddmVGuidGet(PDEVICE_EXTENSION pDevExt)
+{
+    if (pDevExt->VideoGuid.Buffer)
+        return &pDevExt->VideoGuid;
+
+    Assert(KeGetCurrentIrql() == PASSIVE_LEVEL);
+    WCHAR VideoGuidBuf[512];
+    ULONG cbVideoGuidBuf = sizeof (VideoGuidBuf);
+    NTSTATUS Status = vboxWddmRegQueryVideoGuidString(cbVideoGuidBuf, VideoGuidBuf, &cbVideoGuidBuf);
+    Assert(Status == STATUS_SUCCESS);
+    if (Status == STATUS_SUCCESS)
+    {
+        PWCHAR pBuf = (PWCHAR)vboxWddmMemAllocZero(cbVideoGuidBuf);
+        Assert(pBuf);
+        if (pBuf)
+        {
+            memcpy(pBuf, VideoGuidBuf, cbVideoGuidBuf);
+            RtlInitUnicodeString(&pDevExt->VideoGuid, pBuf);
+            return &pDevExt->VideoGuid;
+        }
+    }
+
+    return NULL;
+}
+
+VOID vboxWddmVGuidFree(PDEVICE_EXTENSION pDevExt)
+{
+    if (pDevExt->VideoGuid.Buffer)
+    {
+        vboxWddmMemFree(pDevExt->VideoGuid.Buffer);
+        pDevExt->VideoGuid.Buffer = NULL;
+    }
+}
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoMisc.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoMisc.h	(revision 32929)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoMisc.h	(revision 32930)
@@ -93,3 +93,7 @@
 NTSTATUS vboxWddmRegQueryValueDword(IN HANDLE hKey, IN PWCHAR pName, OUT PDWORD pDword);
 NTSTATUS vboxWddmRegSetValueDword(IN HANDLE hKey, IN PWCHAR pName, OUT DWORD val);
+
+UNICODE_STRING* vboxWddmVGuidGet(PDEVICE_EXTENSION pDevExt);
+VOID vboxWddmVGuidFree(PDEVICE_EXTENSION pDevExt);
+
 #endif /* #ifndef ___VBoxVideoMisc_h__ */
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp	(revision 32929)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp	(revision 32930)
@@ -475,6 +475,4 @@
     PWCHAR pName = (PWCHAR)(((uint8_t*)pDevExt) + VBOXWDDM_ROUNDBOUND(sizeof (DEVICE_EXTENSION), 8));
     RtlInitUnicodeString(&pDevExt->RegKeyName, pName);
-    pName += (pDevExt->RegKeyName.Length + 2)/2;
-    RtlInitUnicodeString(&pDevExt->VideoGuid, pName);
 #ifdef VBOXWDDM_RENDER_FROM_SHADOW
     for (int i = 0; i < RT_ELEMENTS(pDevExt->aSources); ++i)
@@ -512,26 +510,16 @@
     if (Status == STATUS_SUCCESS)
     {
-        WCHAR VideoGuidBuf[512];
-        ULONG cbVideoGuidBuf = sizeof (VideoGuidBuf);
-
-        Status = vboxWddmRegQueryVideoGuidString(cbVideoGuidBuf, VideoGuidBuf, &cbVideoGuidBuf);
-        Assert(Status == STATUS_SUCCESS);
-        if (Status == STATUS_SUCCESS)
-        {
-            pDevExt = (PDEVICE_EXTENSION)vboxWddmMemAllocZero(VBOXWDDM_ROUNDBOUND(sizeof (DEVICE_EXTENSION), 8) + cbRegKeyBuf + cbVideoGuidBuf);
-            if (pDevExt)
-            {
-                PWCHAR pName = (PWCHAR)(((uint8_t*)pDevExt) + VBOXWDDM_ROUNDBOUND(sizeof (DEVICE_EXTENSION), 8));
-                memcpy(pName, RegKeyBuf, cbRegKeyBuf);
-                pName += cbRegKeyBuf/2;
-                memcpy(pName, VideoGuidBuf, cbVideoGuidBuf);
-                vboxWddmDevExtZeroinit(pDevExt, PhysicalDeviceObject);
-                *MiniportDeviceContext = pDevExt;
-            }
-            else
-            {
-                Status  = STATUS_NO_MEMORY;
-                drprintf(("VBoxVideoWddm: ERROR, failed to create context\n"));
-            }
+        pDevExt = (PDEVICE_EXTENSION)vboxWddmMemAllocZero(VBOXWDDM_ROUNDBOUND(sizeof (DEVICE_EXTENSION), 8) + cbRegKeyBuf);
+        if (pDevExt)
+        {
+            PWCHAR pName = (PWCHAR)(((uint8_t*)pDevExt) + VBOXWDDM_ROUNDBOUND(sizeof (DEVICE_EXTENSION), 8));
+            memcpy(pName, RegKeyBuf, cbRegKeyBuf);
+            vboxWddmDevExtZeroinit(pDevExt, PhysicalDeviceObject);
+            *MiniportDeviceContext = pDevExt;
+        }
+        else
+        {
+            Status  = STATUS_NO_MEMORY;
+            drprintf(("VBoxVideoWddm: ERROR, failed to create context\n"));
         }
     }
@@ -567,4 +555,6 @@
     {
         PDEVICE_EXTENSION pContext = (PDEVICE_EXTENSION)MiniportDeviceContext;
+
+        vboxWddmVGuidGet(pContext);
 
         /* Save DeviceHandle and function pointers supplied by the DXGKRNL_INTERFACE structure passed to DxgkInterface. */
@@ -665,4 +655,6 @@
     {
         VbglTerminate();
+
+        vboxWddmVGuidFree(pDevExt);
 
         /* revert back to the state we were right after the DxgkDdiAddDevice */
@@ -3438,7 +3430,12 @@
     PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)hAdapter;
     Assert((UINT)pDevExt->u.primary.cDisplays > pSetVidPnSourceAddress->VidPnSourceId);
+
+    PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pSetVidPnSourceAddress->VidPnSourceId];
+    Status= vboxWddmDisplaySettingsQueryPos(pDevExt, pSetVidPnSourceAddress->VidPnSourceId, &pSource->VScreenPos);
+    Assert(Status == STATUS_SUCCESS);
+    Status = STATUS_SUCCESS;
+
     if ((UINT)pDevExt->u.primary.cDisplays > pSetVidPnSourceAddress->VidPnSourceId)
     {
-        PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pSetVidPnSourceAddress->VidPnSourceId];
         PVBOXWDDM_ALLOCATION pAllocation;
         Assert(pSetVidPnSourceAddress->hAllocation);
@@ -3463,4 +3460,5 @@
             Assert(pAllocation->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE
                     || pAllocation->enmType == VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC);
+
             if (
 #ifdef VBOXWDDM_RENDER_FROM_SHADOW
@@ -3473,7 +3471,5 @@
                 /* to ensure the resize request gets issued in case we exit a full-screen D3D mode */
                 pSource->offVram = VBOXVIDEOOFFSET_VOID;
-#endif
-                Status= vboxWddmDisplaySettingsQueryPos(pDevExt, pSetVidPnSourceAddress->VidPnSourceId, &pSource->VScreenPos);
-                Assert(Status == STATUS_SUCCESS);
+#else
                 /* should not generally happen, but still inform host*/
                 Status = vboxWddmGhDisplaySetInfo(pDevExt, pSource, pSetVidPnSourceAddress->VidPnSourceId);
@@ -3481,4 +3477,5 @@
                 if (Status != STATUS_SUCCESS)
                     drprintf((__FUNCTION__": vboxWddmGhDisplaySetInfo failed, Status (0x%x)\n", Status));
+#endif
             }
         }
@@ -3517,7 +3514,12 @@
     PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)hAdapter;
     Assert((UINT)pDevExt->u.primary.cDisplays > pSetVidPnSourceVisibility->VidPnSourceId);
+
+    PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pSetVidPnSourceVisibility->VidPnSourceId];
+    Status= vboxWddmDisplaySettingsQueryPos(pDevExt, pSetVidPnSourceVisibility->VidPnSourceId, &pSource->VScreenPos);
+    Assert(Status == STATUS_SUCCESS);
+    Status = STATUS_SUCCESS;
+
     if ((UINT)pDevExt->u.primary.cDisplays > pSetVidPnSourceVisibility->VidPnSourceId)
     {
-        PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pSetVidPnSourceVisibility->VidPnSourceId];
         PVBOXWDDM_ALLOCATION pAllocation = pSource->pPrimaryAllocation;
         if (pAllocation)
@@ -3541,11 +3543,10 @@
                         /* to ensure the resize request gets issued in case we exit a full-screen D3D mode */
                         pSource->offVram = VBOXVIDEOOFFSET_VOID;
-#endif
-                        Status= vboxWddmDisplaySettingsQueryPos(pDevExt, pSetVidPnSourceVisibility->VidPnSourceId, &pSource->VScreenPos);
-                        Assert(Status == STATUS_SUCCESS);
+#else
                         Status = vboxWddmGhDisplaySetInfo(pDevExt, pSource, pSetVidPnSourceVisibility->VidPnSourceId);
                         Assert(Status == STATUS_SUCCESS);
                         if (Status != STATUS_SUCCESS)
                             drprintf((__FUNCTION__": vboxWddmGhDisplaySetInfo failed, Status (0x%x)\n", Status));
+#endif
                     }
                 }
@@ -4717,6 +4718,6 @@
             {
                 pDevExt->aSources[i].offVram = VBOXVIDEOOFFSET_VOID;
-                Status= vboxWddmDisplaySettingsQueryPos(pDevExt, i, &pDevExt->aSources[i].VScreenPos);
-                Assert(Status == STATUS_SUCCESS);
+                NTSTATUS tmpStatus= vboxWddmDisplaySettingsQueryPos(pDevExt, i, &pDevExt->aSources[i].VScreenPos);
+                Assert(tmpStatus == STATUS_SUCCESS);
             }
         }
