Index: /trunk/src/VBox/Additions/common/crOpenGL/context.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/context.c	(revision 34294)
+++ /trunk/src/VBox/Additions/common/crOpenGL/context.c	(revision 34295)
@@ -501,35 +501,33 @@
 {
     RECT rect;
-    HWND hwnd;
-
-    if (!window->drawable) {
+
+    if (!window->drawable || !window->hWnd) {
         *w = *h = 0;
         return;
     }
 
-    hwnd = WindowFromDC( window->drawable );
-
-    if (!hwnd) {
-        *w = 0;
-        *h = 0;
-    }
-    else {
-        if (!GetClientRect(hwnd, &rect))
-        {
-            crWarning("GetClientRect failed for %p", hwnd);
-            *w = *h = 0;
-            return;
-        }
-        *w = rect.right - rect.left;
-        *h = rect.bottom - rect.top;
-        if (!ClientToScreen( hwnd, (LPPOINT) &rect ))
-        {
-            crWarning("ClientToScreen failed for %p", hwnd);
-            *w = *h = 0;
-            return;
-        }
-        *x = rect.left;
-        *y = rect.top;
-    }
+    if (window->hWnd!=WindowFromDC(window->drawable))
+    {
+        crWarning("Window(%i) DC is no longer valid", window->spuWindow);
+        return;
+    }
+
+    if (!GetClientRect(window->hWnd, &rect))
+    {
+        crWarning("GetClientRect failed for %p", window->hWnd);
+        *w = *h = 0;
+        return;
+    }
+    *w = rect.right - rect.left;
+    *h = rect.bottom - rect.top;
+
+    if (!ClientToScreen( window->hWnd, (LPPOINT) &rect ))
+    {
+        crWarning("ClientToScreen failed for %p", window->hWnd);
+        *w = *h = 0;
+        return;
+    }
+    *x = rect.left;
+    *y = rect.top;
 }
 
@@ -537,9 +535,7 @@
 GetWindowTitle( const WindowInfo *window, char *title )
 {
-    HWND hwnd;
     /* XXX - we don't handle recurseUp */
-    hwnd = WindowFromDC( window->drawable );
-    if (hwnd)
-        GetWindowText(hwnd, title, 100);
+    if (window->hWnd)
+        GetWindowText(window->hWnd, title, 100);
     else
         title[0] = 0;
@@ -558,5 +554,11 @@
     // apparently the "window" parameter passed to this 
     // function contains the native window information
-    HWND NATIVEhwnd = WindowFromDC( window->drawable ); 
+    HWND NATIVEhwnd = window->hWnd;
+
+    if (NATIVEhwnd!=WindowFromDC(window->drawable))
+    {
+        crWarning("Window(%i) DC is no longer valid", window->spuWindow);
+        return;
+    }
 
     // get the native window's height and width
@@ -1028,5 +1030,5 @@
                 {
 #ifdef WINDOWS
-                        if (!WindowFromDC(context->currentDrawable->drawable))
+                        if (context->currentDrawable->hWnd!=WindowFromDC(context->currentDrawable->drawable))
                         {
                             crWindowDestroy((GLint)context->currentDrawable->hWnd);
Index: /trunk/src/VBox/Additions/common/crOpenGL/load.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/load.c	(revision 34294)
+++ /trunk/src/VBox/Additions/common/crOpenGL/load.c	(revision 34295)
@@ -142,5 +142,5 @@
 {
 #ifdef WINDOWS
-    if (!WindowFromDC(pWindow->drawable))
+    if (pWindow->hWnd!=WindowFromDC(pWindow->drawable))
     {
         return false;
@@ -197,4 +197,9 @@
     if (!stub.currentContext)
         return;
+
+#if defined(WINDOWS) && defined(VBOX_WITH_WDDM)
+    if (stub.bRunningUnderWDDM)
+        return;
+#endif
 
 #if defined(CR_NEWWINTRACK) && !defined(WINDOWS)
@@ -657,4 +662,7 @@
         int i;
 
+# ifdef VBOX_WITH_WDDM
+        stub.bRunningUnderWDDM = false;
+# endif
         /* Apply viewport hack only if we're running under wine */
         if (NULL!=GetModuleHandle("wined3d.dll") || NULL != GetModuleHandle("wined3dwddm.dll"))
@@ -726,4 +734,12 @@
     }
 
+    if (!stubSystemWindowExist(pWindow))
+    {
+        crWindowDestroy((GLint)pWindow->hWnd);
+        return;
+    }
+
+    stub.spu->dispatch_table.VBoxPackSetInjectID(pWindow->u32ClientID);
+
     if (!pWindow->mapped)
     {
@@ -841,4 +857,8 @@
     }
 
+#if defined(WINDOWS) && defined(VBOX_WITH_WDDM)
+    if (stub.bRunningUnderWDDM)
+        return;
+#endif
     stubCheckWindowState(pWindow, GL_TRUE);
 }
@@ -884,4 +904,5 @@
                     crDebug("running with VBoxDispD3D");
                     stub.trackWindowVisibleRgn = 0;
+                    stub.bRunningUnderWDDM = true;
                 }
             }
@@ -932,4 +953,5 @@
                         crWarning("VBoxDispMpTstCallbacks.pfnGetRegions failed with 0x%x", hr);
                     }
+                    crHashtableWalk(stub.windowTable, stubSyncTrCheckWindowsCB, NULL);
                 }
             }
Index: /trunk/src/VBox/Additions/common/crOpenGL/stub.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/stub.c	(revision 34294)
+++ /trunk/src/VBox/Additions/common/crOpenGL/stub.c	(revision 34295)
@@ -268,7 +268,12 @@
 
     if (!pWindow) return GL_FALSE;
-    hwnd = WindowFromDC(pWindow->drawable);
+    hwnd = pWindow->hWnd;
     if (!hwnd) return GL_FALSE;
 
+    if (hwnd!=WindowFromDC(pWindow->drawable))
+    {
+        crWarning("Window(%i) DC is no longer valid", pWindow->spuWindow);
+        return GL_FALSE;
+    }
     
     hVisRgn = CreateRectRgn(0,0,0,0);
Index: /trunk/src/VBox/Additions/common/crOpenGL/stub.h
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/stub.h	(revision 34294)
+++ /trunk/src/VBox/Additions/common/crOpenGL/stub.h	(revision 34295)
@@ -246,4 +246,7 @@
     HHOOK           hMessageHook;
 # endif
+# ifdef VBOX_WITH_WDDM
+    bool            bRunningUnderWDDM;
+# endif
 #endif
 
