Index: trunk/src/VBox/Additions/WINNT/Graphics/Display/Makefile.kmk
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Display/Makefile.kmk	(revision 31661)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Display/Makefile.kmk	(revision 31687)
@@ -90,4 +90,5 @@
     wddm/VBoxDispCm.cpp \
     wddm/VBoxDispMp.cpp \
+    wddm/VBoxScreen.cpp \
     wddm/VBoxDispMpTst.cpp \
 	wddm/VBoxDispD3D.def \
Index: trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp	(revision 31661)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp	(revision 31687)
@@ -23,4 +23,5 @@
 #include "VBoxDispD3DCmn.h"
 #include "VBoxDispD3D.h"
+#include "VBoxScreen.h"
 
 #ifdef VBOXDISPMP_TEST
@@ -34,4 +35,6 @@
 
 #define VBOXWDDMDISP_WITH_TMPWORKAROUND 1
+
+static VBOXSCREENMONRUNNER g_VBoxScreenMonRunner;
 
 //#define VBOXWDDMOVERLAY_TEST
@@ -1344,10 +1347,9 @@
                     LPVOID    lpReserved)
 {
-    BOOL bOk = TRUE;
-
     switch (dwReason)
     {
         case DLL_PROCESS_ATTACH:
         {
+            vboxVDbgPrint(("VBoxDispD3D: DLL loaded.\n"));
 #ifdef VBOXWDDMDISP_DEBUG
             vboxVDbgVEHandlerRegister();
@@ -1357,16 +1359,27 @@
             HRESULT hr = vboxDispCmInit();
             Assert(hr == S_OK);
+            if (hr == S_OK)
+            {
 #ifdef VBOXDISPMP_TEST
-            if (hr == S_OK)
-            {
                 hr = vboxDispMpTstStart();
                 Assert(hr == S_OK);
-            }
+                if (hr == S_OK)
 #endif
-            if (hr == S_OK)
-                vboxVDbgPrint(("VBoxDispD3D: DLL loaded.\n"));
-            else
-                bOk = FALSE;
-
+                {
+                    hr = VBoxScreenMRunnerStart(&g_VBoxScreenMonRunner);
+                    Assert(hr == S_OK);
+                    /* succeed in any way */
+                    hr = S_OK;
+                    if (hr == S_OK)
+                    {
+                        vboxVDbgPrint(("VBoxDispD3D: DLL loaded OK\n"));
+                        return TRUE;
+                    }
+#ifdef VBOXDISPMP_TEST
+                    vboxDispMpTstStop();
+#endif
+                }
+                vboxDispCmTerm();
+            }
 //                VbglR3Init();
             break;
@@ -1378,17 +1391,22 @@
             vboxVDbgVEHandlerUnregister();
 #endif
-            HRESULT hr;
-#ifdef VBOXDISPMP_TEST
-            hr = vboxDispMpTstStop();
+            HRESULT hr = VBoxScreenMRunnerStop(&g_VBoxScreenMonRunner);
             Assert(hr == S_OK);
             if (hr == S_OK)
-#endif
-            {
-                hr = vboxDispCmTerm();
+            {
+#ifdef VBOXDISPMP_TEST
+                hr = vboxDispMpTstStop();
                 Assert(hr == S_OK);
                 if (hr == S_OK)
-                    vboxVDbgPrint(("VBoxDispD3D: DLL unloaded.\n"));
-                else
-                    bOk = FALSE;
+#endif
+                {
+                    hr = vboxDispCmTerm();
+                    Assert(hr == S_OK);
+                    if (hr == S_OK)
+                    {
+                        vboxVDbgPrint(("VBoxDispD3D: DLL unloaded.\n"));
+                        return TRUE;
+                    }
+                }
             }
 //                VbglR3Term();
@@ -1398,7 +1416,7 @@
 
         default:
-            break;
-    }
-    return bOk;
+            return TRUE;
+    }
+    return FALSE;
 }
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxScreen.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxScreen.cpp	(revision 31687)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxScreen.cpp	(revision 31687)
@@ -0,0 +1,545 @@
+/** @file
+ *
+ * VBoxVideo Display D3D User mode dll
+ *
+ * Copyright (C) 2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+#include "VBoxScreen.h"
+
+#include <iprt/log.h>
+
+
+typedef struct VBOXSCREENMONENUM
+{
+    PVBOXSCREENMON pMon;
+    UINT iCur;
+    HRESULT hr;
+    BOOL bChanged;
+} VBOXSCREENMONENUM, *PVBOXSCREENMONENUM;
+
+static VBOXSCREENMON g_VBoxScreenMon;
+
+
+#define VBOX_E_INSUFFICIENT_BUFFER HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)
+#define VBOX_E_NOT_SUPPORTED HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)
+
+typedef DECLCALLBACK(BOOLEAN) FNVBOXSCREENMON_ADAPTEROP(PVBOXSCREENMON pMon, D3DKMT_HANDLE hAdapter, LPCWSTR pDevName, PVOID pContext);
+typedef FNVBOXSCREENMON_ADAPTEROP *PFNVBOXSCREENMON_ADAPTEROP;
+static HRESULT vboxScreenMonWDDMAdapterOp(PVBOXSCREENMON pMon, LPCWSTR pDevName, PFNVBOXSCREENMON_ADAPTEROP pfnOp, PVOID pContext)
+{
+    D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME OpenAdapterData = {0};
+    wcsncpy(OpenAdapterData.DeviceName, pDevName, RT_ELEMENTS(OpenAdapterData.DeviceName) - 1 /* the last one is always \0 */);
+    HRESULT hr = S_OK;
+    NTSTATUS Status = pMon->pfnD3DKMTOpenAdapterFromGdiDisplayName(&OpenAdapterData);
+    Assert(!Status);
+    if (!Status)
+    {
+        BOOLEAN bCloseAdapter = pfnOp(pMon, OpenAdapterData.hAdapter, OpenAdapterData.DeviceName, pContext);
+
+        if (bCloseAdapter)
+        {
+            D3DKMT_CLOSEADAPTER ClosaAdapterData = {0};
+            ClosaAdapterData.hAdapter = OpenAdapterData.hAdapter;
+            Status = pMon->pfnD3DKMTCloseAdapter(&ClosaAdapterData);
+            if (Status)
+            {
+                Log((__FUNCTION__": pfnD3DKMTCloseAdapter failed, Status (0x%x)\n", Status));
+                /* ignore */
+                Status = 0;
+            }
+        }
+    }
+    else
+    {
+        Log((__FUNCTION__": pfnD3DKMTOpenAdapterFromGdiDisplayName failed, Status (0x%x)\n", Status));
+        hr = E_FAIL;
+    }
+
+    return hr;
+}
+
+typedef struct
+{
+    NTSTATUS Status;
+    PVBOXDISPIFESCAPE pEscape;
+    int cbData;
+} VBOXDISPIFWDDM_ESCAPEOP_CONTEXT, *PVBOXDISPIFWDDM_ESCAPEOP_CONTEXT;
+
+DECLCALLBACK(BOOLEAN) vboxScreenMonEscapeOp(PVBOXSCREENMON pMon, D3DKMT_HANDLE hAdapter, LPCWSTR pDevName, PVOID pContext)
+{
+    PVBOXDISPIFWDDM_ESCAPEOP_CONTEXT pCtx = (PVBOXDISPIFWDDM_ESCAPEOP_CONTEXT)pContext;
+
+    D3DKMT_ESCAPE EscapeData = {0};
+    EscapeData.hAdapter = hAdapter;
+    //EscapeData.hDevice = NULL;
+    EscapeData.Type = D3DKMT_ESCAPE_DRIVERPRIVATE;
+    EscapeData.Flags.HardwareAccess = 1;
+    EscapeData.pPrivateDriverData = pCtx->pEscape;
+    EscapeData.PrivateDriverDataSize = VBOXDISPIFESCAPE_SIZE(pCtx->cbData);
+    //EscapeData.hContext = NULL;
+
+    pCtx->Status = pMon->pfnD3DKMTEscape(&EscapeData);
+
+    return TRUE;
+}
+
+static HRESULT vboxScreenMonEscape(PVBOXSCREENMON pMon, PVBOXDISPIFESCAPE pEscape, int cbData)
+{
+    VBOXDISPIFWDDM_ESCAPEOP_CONTEXT Ctx = {0};
+    Ctx.pEscape = pEscape;
+    Ctx.cbData = cbData;
+    HRESULT hr = vboxScreenMonWDDMAdapterOp(pMon, L"\\\\.\\DISPLAY1", vboxScreenMonEscapeOp, &Ctx);
+    Assert(hr == S_OK);
+    if (hr == S_OK)
+    {
+        Assert(!Ctx.Status);
+        if (Ctx.Status)
+        {
+            if (Ctx.Status == 0xC00000BBL) /* not supported */
+                hr = VBOX_E_NOT_SUPPORTED;
+            else
+                hr = E_FAIL;
+            Log((__FUNCTION__": pfnD3DKMTEscape failed, Status (0x%x)\n", Ctx.Status));
+        }
+    }
+    else
+        Log((__FUNCTION__": vboxScreenMRunnerWDDMAdapterOp failed, hr (0x%x)\n", hr));
+
+    return hr;
+}
+
+static BOOL CALLBACK vboxScreenMonEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
+{
+    PVBOXSCREENMONENUM pEnum = (PVBOXSCREENMONENUM)dwData;
+    PVBOXSCREENMON pMon = pEnum->pMon;
+    UINT cbRequired = RT_OFFSETOF(VBOXSCREENLAYOUT, aScreens[pEnum->iCur]);
+    if (pEnum->hr == S_OK)
+    {
+        Assert(pEnum->iCur < VBOX_VIDEO_MAX_SCREENS);
+        if (pEnum->iCur < VBOX_VIDEO_MAX_SCREENS)
+        {
+            MONITORINFOEX minfo;
+            minfo.cbSize = sizeof (minfo);
+            if (GetMonitorInfo(hMonitor,  (LPMONITORINFO)&minfo))
+            {
+                D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME OpenAdapterData = {0};
+                wcsncpy(OpenAdapterData.DeviceName, minfo.szDevice, RT_ELEMENTS(OpenAdapterData.DeviceName) - 1 /* the last one is always \0 */);
+                NTSTATUS Status = pMon->pfnD3DKMTOpenAdapterFromGdiDisplayName(&OpenAdapterData);
+                Assert(!Status);
+                if (!Status)
+                {
+                    if (pMon->LoData.ScreenLayout.ScreenLayout.cScreens <= pEnum->iCur
+                            || pMon->LoData.ScreenLayout.ScreenLayout.aScreens[pEnum->iCur].VidPnSourceId != OpenAdapterData.VidPnSourceId
+                            || pMon->LoData.ScreenLayout.ScreenLayout.aScreens[pEnum->iCur].pos.x != lprcMonitor->left
+                            || pMon->LoData.ScreenLayout.ScreenLayout.aScreens[pEnum->iCur].pos.y != lprcMonitor->top)
+                    {
+                        pMon->LoData.ScreenLayout.ScreenLayout.aScreens[pEnum->iCur].VidPnSourceId = OpenAdapterData.VidPnSourceId;
+                        pMon->LoData.ScreenLayout.ScreenLayout.aScreens[pEnum->iCur].pos.x = lprcMonitor->left;
+                        pMon->LoData.ScreenLayout.ScreenLayout.aScreens[pEnum->iCur].pos.y = lprcMonitor->top;
+                        pEnum->bChanged = true;
+                    }
+
+                    D3DKMT_CLOSEADAPTER ClosaAdapterData = {0};
+                    ClosaAdapterData.hAdapter = OpenAdapterData.hAdapter;
+                    HRESULT tmpHr = pMon->pfnD3DKMTCloseAdapter(&ClosaAdapterData);
+                    Assert(tmpHr == S_OK);
+                }
+                else
+                {
+                    pEnum->hr = E_FAIL;
+                }
+            }
+            else
+            {
+                DWORD winEr = GetLastError();
+                HRESULT hr = HRESULT_FROM_WIN32(winEr);
+                Assert(0);
+                Assert(hr != S_OK);
+                Assert(hr != S_FALSE);
+                if (hr == S_OK || hr == S_FALSE)
+                    hr = E_FAIL;
+                pEnum->hr = hr;
+            }
+
+//            D3DKMT_OPENADAPTERFROMHDC Oa;
+//            memset(&Oa, 0, sizeof (D3DKMT_OPENADAPTERFROMHDC));
+//            Oa.hDc = hdcMonitor;
+//            HRESULT hr = pMon->pfnD3DKMTOpenAdapterFromHdc(&Oa);
+//            Assert(hr == S_OK);
+//            if (hr == S_OK)
+//            {
+//                if (pEnum->pScreenInfo->cScreens <= pEnum->iCur
+//                        || pEnum->pScreenInfo->aScreens[pEnum->iCur].VidPnSourceId != Oa.VidPnSourceId
+//                        || pEnum->pScreenInfo->aScreens[pEnum->iCur].pos.x != lprcMonitor->left
+//                        || pEnum->pScreenInfo->aScreens[pEnum->iCur].pos.y == lprcMonitor->top)
+//                {
+//                    pEnum->pScreenInfo->aScreens[pEnum->iCur].VidPnSourceId = Oa.VidPnSourceId;
+//                    pEnum->pScreenInfo->aScreens[pEnum->iCur].pos.x = lprcMonitor->left;
+//                    pEnum->pScreenInfo->aScreens[pEnum->iCur].pos.y = lprcMonitor->top;
+//                    pEnum->bChanged = true;
+//                }
+//
+//                D3DKMT_CLOSEADAPTER ClosaAdapterData = {0};
+//                ClosaAdapterData.hAdapter = Oa.hAdapter;
+//                HRESULT tmpHr = pMon->pfnD3DKMTCloseAdapter(&ClosaAdapterData);
+//                Assert(tmpHr == S_OK);
+//                pEnum->hr = hr;
+//            }
+        }
+        else
+        {
+            pEnum->hr = VBOX_E_INSUFFICIENT_BUFFER;
+        }
+    }
+
+    ++pEnum->iCur;
+
+    return TRUE;
+}
+
+
+//static HRESULT vboxScreenMonCheckUpdateChange(PVBOXSCREENMON pMon)
+static HRESULT vboxScreenMonCheckUpdateChange()
+{
+    PVBOXSCREENMON pMon = &g_VBoxScreenMon;
+    VBOXSCREENMONENUM monEnum = {0};
+    monEnum.pMon = pMon;
+
+    BOOL bResult = EnumDisplayMonitors(NULL, NULL, vboxScreenMonEnumProc, (LPARAM)&monEnum);
+    if (bResult)
+    {
+        Assert(monEnum.hr == S_OK);
+        if (monEnum.hr == S_OK && monEnum.bChanged)
+        {
+            Assert(monEnum.iCur);
+            pMon->LoData.ScreenLayout.ScreenLayout.cScreens = monEnum.iCur;
+
+            UINT cbSize = RT_OFFSETOF(VBOXSCREENLAYOUT, aScreens[pMon->LoData.ScreenLayout.ScreenLayout.cScreens]);
+            HRESULT hr = vboxScreenMonEscape(pMon, &pMon->LoData.ScreenLayout.EscapeHdr, cbSize);
+            Assert(hr == S_OK);
+            return hr;
+        }
+        return monEnum.hr;
+    }
+
+    DWORD winEr = GetLastError();
+    HRESULT hr = HRESULT_FROM_WIN32(winEr);
+    Assert(0);
+    Assert(hr != S_OK);
+    Assert(hr != S_FALSE);
+    if (hr == S_OK || hr == S_FALSE)
+        hr = E_FAIL;
+    return hr;
+}
+
+static LRESULT CALLBACK vboxScreenMonWndProc(HWND hwnd,
+    UINT uMsg,
+    WPARAM wParam,
+    LPARAM lParam
+)
+{
+    switch(uMsg)
+    {
+        case WM_DISPLAYCHANGE:
+        {
+            HRESULT hr = vboxScreenMonCheckUpdateChange();
+            Assert(hr == S_OK);
+        }
+        case WM_CLOSE:
+            Log((__FUNCTION__": got WM_CLOSE for hwnd(0x%x)", hwnd));
+            return 0;
+        case WM_DESTROY:
+            Log((__FUNCTION__": got WM_DESTROY for hwnd(0x%x)", hwnd));
+            return 0;
+        case WM_NCHITTEST:
+            Log((__FUNCTION__": got WM_NCHITTEST for hwnd(0x%x)\n", hwnd));
+            return HTNOWHERE;
+    }
+
+    return DefWindowProc(hwnd, uMsg, wParam, lParam);
+}
+
+#define VBOXSCREENMONWND_NAME L"VboxScreenMonWnd"
+
+HRESULT vboxScreenMonWndCreate(HWND *phWnd)
+{
+    HRESULT hr = S_OK;
+    HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL);
+    /* Register the Window Class. */
+    WNDCLASS wc;
+    if (!GetClassInfo(hInstance, VBOXSCREENMONWND_NAME, &wc))
+    {
+        wc.style = CS_OWNDC;
+        wc.lpfnWndProc = vboxScreenMonWndProc;
+        wc.cbClsExtra = 0;
+        wc.cbWndExtra = 0;
+        wc.hInstance = hInstance;
+        wc.hIcon = NULL;
+        wc.hCursor = NULL;
+        wc.hbrBackground = NULL;
+        wc.lpszMenuName = NULL;
+        wc.lpszClassName = VBOXSCREENMONWND_NAME;
+        if (!RegisterClass(&wc))
+        {
+            DWORD winErr = GetLastError();
+            Log((__FUNCTION__": RegisterClass failed, winErr(%d)\n", winErr));
+            hr = E_FAIL;
+        }
+    }
+
+    if (hr == S_OK)
+    {
+        HWND hWnd = CreateWindowEx (WS_EX_TOOLWINDOW,
+                                        VBOXSCREENMONWND_NAME, VBOXSCREENMONWND_NAME,
+                                        WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_DISABLED,
+                                        -100, -100,
+                                        10, 10,
+                                        NULL, //GetDesktopWindow() /* hWndParent */,
+                                        NULL /* hMenu */,
+                                        hInstance,
+                                        NULL /* lpParam */);
+        Assert(hWnd);
+        if (hWnd)
+        {
+            *phWnd = hWnd;
+        }
+        else
+        {
+            DWORD winErr = GetLastError();
+            Log((__FUNCTION__": CreateWindowEx failed, winErr(%d)\n", winErr));
+            hr = E_FAIL;
+        }
+    }
+
+    return hr;
+}
+
+static HRESULT vboxScreenMonWndDestroy(HWND hWnd)
+{
+    BOOL bResult = DestroyWindow(hWnd);
+    if (bResult)
+        return S_OK;
+
+    DWORD winErr = GetLastError();
+    Log((__FUNCTION__": DestroyWindow failed, winErr(%d) for hWnd(0x%x)\n", winErr, hWnd));
+    Assert(0);
+
+    return HRESULT_FROM_WIN32(winErr);
+}
+
+//HRESULT vboxScreenMonInit(PVBOXSCREENMON pMon)
+HRESULT vboxScreenMonInit()
+{
+    PVBOXSCREENMON pMon = &g_VBoxScreenMon;
+    HRESULT hr = S_OK;
+
+    memset(pMon, 0, sizeof (VBOXSCREENMON));
+
+    pMon->LoData.ScreenLayout.EscapeHdr.escapeCode = VBOXESC_SCREENLAYOUT;
+
+    pMon->hGdi32 = LoadLibraryW(L"gdi32.dll");
+    if (pMon->hGdi32 != NULL)
+    {
+        bool bSupported = true;
+        pMon->pfnD3DKMTOpenAdapterFromHdc = (PFND3DKMT_OPENADAPTERFROMHDC)GetProcAddress(pMon->hGdi32, "D3DKMTOpenAdapterFromHdc");
+        Log((__FUNCTION__"pfnD3DKMTOpenAdapterFromHdc = %p\n", pMon->pfnD3DKMTOpenAdapterFromHdc));
+        bSupported &= !!(pMon->pfnD3DKMTOpenAdapterFromHdc);
+
+        pMon->pfnD3DKMTOpenAdapterFromGdiDisplayName = (PFND3DKMT_OPENADAPTERFROMGDIDISPLAYNAME)GetProcAddress(pMon->hGdi32, "D3DKMTOpenAdapterFromGdiDisplayName");
+        Log((__FUNCTION__": pfnD3DKMTOpenAdapterFromGdiDisplayName = %p\n", pMon->pfnD3DKMTOpenAdapterFromGdiDisplayName));
+        bSupported &= !!(pMon->pfnD3DKMTOpenAdapterFromGdiDisplayName);
+
+        pMon->pfnD3DKMTCloseAdapter = (PFND3DKMT_CLOSEADAPTER)GetProcAddress(pMon->hGdi32, "D3DKMTCloseAdapter");
+        Log((__FUNCTION__": pfnD3DKMTCloseAdapter = %p\n", pMon->pfnD3DKMTCloseAdapter));
+        bSupported &= !!(pMon->pfnD3DKMTCloseAdapter);
+
+        pMon->pfnD3DKMTEscape = (PFND3DKMT_ESCAPE)GetProcAddress(pMon->hGdi32, "D3DKMTEscape");
+        Log((__FUNCTION__": pfnD3DKMTEscape = %p\n", pMon->pfnD3DKMTEscape));
+        bSupported &= !!(pMon->pfnD3DKMTCloseAdapter);
+
+        Assert(bSupported);
+        if (bSupported)
+        {
+            hr = vboxScreenMonWndCreate(&pMon->hWnd);
+            Assert(hr == S_OK);
+            if (hr == S_OK)
+                return S_OK;
+        }
+        else
+        {
+            Log((__FUNCTION__": one of pfnD3DKMT function pointers failed to initialize\n"));
+            hr = VBOX_E_NOT_SUPPORTED;
+        }
+
+        FreeLibrary(pMon->hGdi32);
+    }
+    else
+    {
+        DWORD winEr = GetLastError();
+        hr = HRESULT_FROM_WIN32(winEr);
+        Assert(0);
+        Assert(hr != S_OK);
+        Assert(hr != S_FALSE);
+        if (hr == S_OK || hr == S_FALSE)
+            hr = E_FAIL;
+    }
+
+    return hr;
+}
+
+//HRESULT vboxScreenMonTerm(PVBOXSCREENMON pMon)
+HRESULT vboxScreenMonTerm()
+{
+    PVBOXSCREENMON pMon = &g_VBoxScreenMon;
+    HRESULT tmpHr = vboxScreenMonWndDestroy(pMon->hWnd);
+    Assert(tmpHr == S_OK);
+
+    FreeLibrary(pMon->hGdi32);
+
+    pMon->bInited = FALSE;
+    return S_OK;
+}
+
+HRESULT vboxScreenMonRun()
+{
+    PVBOXSCREENMON pMon = &g_VBoxScreenMon;
+    MSG Msg;
+
+    HRESULT hr = S_FALSE;
+
+    Assert(0);
+
+    if (!pMon->bInited)
+    {
+        PeekMessage(&Msg,
+            NULL /* HWND hWnd */,
+            WM_USER /* UINT wMsgFilterMin */,
+            WM_USER /* UINT wMsgFilterMax */,
+            PM_NOREMOVE);
+
+        pMon->bInited = TRUE;
+    }
+
+    BOOL bCheck = TRUE;
+    do
+    {
+        if (bCheck)
+        {
+            hr = vboxScreenMonCheckUpdateChange();
+            Assert(hr == S_OK);
+
+            bCheck = FALSE;
+        }
+
+        BOOL bResult = GetMessage(&Msg,
+            0 /*HWND hWnd*/,
+            0 /*UINT wMsgFilterMin*/,
+            0 /*UINT wMsgFilterMax*/
+            );
+
+        if(!bResult) /* WM_QUIT was posted */
+        {
+            hr = S_FALSE;
+            break;
+        }
+
+        if(bResult == -1) /* error occured */
+        {
+            DWORD winEr = GetLastError();
+            hr = HRESULT_FROM_WIN32(winEr);
+            Assert(0);
+            /* just ensure we never return success in this case */
+            Assert(hr != S_OK);
+            Assert(hr != S_FALSE);
+            if (hr == S_OK || hr == S_FALSE)
+                hr = E_FAIL;
+            break;
+        }
+
+        switch (Msg.message)
+        {
+            case WM_DISPLAYCHANGE:
+                bCheck = TRUE;
+            default:
+                TranslateMessage(&Msg);
+                DispatchMessage(&Msg);
+                break;
+        }
+    } while (1);
+    return 0;
+}
+
+static DWORD WINAPI vboxScreenMRunnerThread(void *pvUser)
+{
+    PVBOXSCREENMONRUNNER pRunner = (PVBOXSCREENMONRUNNER)pvUser;
+
+    HRESULT hr = vboxScreenMonInit();
+    Assert(hr == S_OK);
+    if (hr == S_OK)
+    {
+        hr = vboxScreenMonRun();
+        Assert(hr == S_OK);
+
+        vboxScreenMonTerm();
+    }
+    return 0;
+}
+
+HRESULT VBoxScreenMRunnerStart(PVBOXSCREENMONRUNNER pMon)
+{
+    HRESULT hr = E_FAIL;
+    memset(pMon, 0, sizeof (VBOXSCREENMONRUNNER));
+
+    pMon->hThread = CreateThread(NULL /* LPSECURITY_ATTRIBUTES lpThreadAttributes */,
+                                          0 /* SIZE_T dwStackSize */,
+                                          vboxScreenMRunnerThread,
+                                          pMon,
+                                          0 /* DWORD dwCreationFlags */,
+                                          &pMon->idThread);
+    if (pMon->hThread)
+        return S_OK;
+
+    DWORD winErr = GetLastError();
+    Log((__FUNCTION__": CreateThread failed, winErr = (%d)", winErr));
+    hr = HRESULT_FROM_WIN32(winErr);
+    Assert(0);
+    Assert(hr != S_OK);
+
+    return hr;
+}
+
+HRESULT VBoxScreenMRunnerStop(PVBOXSCREENMONRUNNER pMon)
+{
+    if (!pMon->hThread)
+        return S_OK;
+
+    BOOL bResult = PostThreadMessage(pMon->idThread, WM_QUIT, 0, 0);
+    HRESULT hr = S_OK;
+    if (bResult)
+    {
+        DWORD dwErr = WaitForSingleObject(pMon->hThread, INFINITE);
+        if (dwErr != WAIT_OBJECT_0)
+        {
+            DWORD winErr = GetLastError();
+            hr = HRESULT_FROM_WIN32(winErr);
+            Assert(0);
+        }
+    }
+    else
+    {
+        DWORD winErr = GetLastError();
+        hr = HRESULT_FROM_WIN32(winErr);
+        Assert(0);
+    }
+
+    return hr;
+}
+
Index: trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxScreen.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxScreen.h	(revision 31687)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxScreen.h	(revision 31687)
@@ -0,0 +1,61 @@
+/** @file
+ *
+ * VBoxVideo Display D3D User mode dll
+ *
+ * Copyright (C) 2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+#include <windows.h>
+#include <d3dkmthk.h>
+
+#include <iprt/cdefs.h>
+#include <iprt/ctype.h>
+
+#include <VBox/VBoxVideo.h>
+
+#include "../../Miniport/wddm/VBoxVideoIf.h"
+
+typedef struct VBOXDISPIFESCAPE_SCREENLAYOUT_DATA
+{
+    VBOXDISPIFESCAPE_SCREENLAYOUT ScreenLayout;
+    POINT buffer[VBOX_VIDEO_MAX_SCREENS];
+} VBOXDISPIFESCAPE_SCREENLAYOUT_DATA, *PVBOXDISPIFESCAPE_SCREENLAYOUT_DATA;
+
+typedef struct VBOXSCREENMON
+{
+    BOOL bInited;
+
+    HMODULE hGdi32;
+
+    HWND hWnd;
+
+    /* open adapter */
+    PFND3DKMT_OPENADAPTERFROMHDC pfnD3DKMTOpenAdapterFromHdc;
+    PFND3DKMT_OPENADAPTERFROMGDIDISPLAYNAME pfnD3DKMTOpenAdapterFromGdiDisplayName;
+    /* close adapter */
+    PFND3DKMT_CLOSEADAPTER pfnD3DKMTCloseAdapter;
+    /* escape */
+    PFND3DKMT_ESCAPE pfnD3DKMTEscape;
+
+    VBOXDISPIFESCAPE_SCREENLAYOUT_DATA LoData;
+} VBOXSCREENMON, *PVBOXSCREENMON;
+
+typedef DECLCALLBACK(HRESULT) FNVBOXDISPESCAPECB(void * pvBuffer, uint32_t cbBuffer, void *pvContext);
+typedef FNVBOXDISPESCAPECB *PFNVBOXDISPESCAPECB;
+
+typedef struct VBOXSCREENMONRUNNER
+{
+//    VBOXSCREENMON Screen;
+    HANDLE hThread;
+    DWORD idThread;
+} VBOXSCREENMONRUNNER, *PVBOXSCREENMONRUNNER;
+
+HRESULT VBoxScreenMRunnerStart(PVBOXSCREENMONRUNNER pMon);
+HRESULT VBoxScreenMRunnerStop(PVBOXSCREENMONRUNNER pMon);
Index: trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h	(revision 31661)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h	(revision 31687)
@@ -178,4 +178,5 @@
     VBOXWDDM_VHWA Vhwa;
 #endif
+    POINT VScreenPos;
     VBOXWDDM_POINTER_INFO PointerInfo;
 } VBOXWDDM_SOURCE, *PVBOXWDDM_SOURCE;
Index: trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoIf.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoIf.h	(revision 31661)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoIf.h	(revision 31687)
@@ -239,4 +239,22 @@
 } VBOXDISPIFESCAPE_DBGPRINT, *PVBOXDISPIFESCAPE_DBGPRINT;
 AssertCompile(RT_OFFSETOF(VBOXDISPIFESCAPE_DBGPRINT, EscapeHdr) == 0);
+
+typedef struct VBOXSCREENLAYOUT_ELEMENT
+{
+    D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
+    POINT pos;
+} VBOXSCREENLAYOUT_ELEMENT, *PVBOXSCREENLAYOUT_ELEMENT;
+
+typedef struct VBOXSCREENLAYOUT
+{
+    uint32_t cScreens;
+    VBOXSCREENLAYOUT_ELEMENT aScreens[1];
+} VBOXSCREENLAYOUT, *PVBOXSCREENLAYOUT;
+
+typedef struct VBOXDISPIFESCAPE_SCREENLAYOUT
+{
+    VBOXDISPIFESCAPE EscapeHdr;
+    VBOXSCREENLAYOUT ScreenLayout;
+} VBOXDISPIFESCAPE_SCREENLAYOUT, *PVBOXDISPIFESCAPE_SCREENLAYOUT;
 
 /* query info func */
Index: trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVdma.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVdma.cpp	(revision 31661)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVdma.cpp	(revision 31687)
@@ -562,4 +562,5 @@
                     {
                         PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pCF->VidPnSourceId];
+                        vboxWddmRectTranslate(&UnionRect, pSource->VScreenPos.x, pSource->VScreenPos.y);
                         VBOXVBVA_OP_WITHLOCK(ReportDirtyRect, pDevExt, &pSource->Vbva, &UnionRect);
                     }
Index: trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp	(revision 31661)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp	(revision 31687)
@@ -87,5 +87,5 @@
 }
 
-NTSTATUS vboxWddmGhDisplayPostInfoScreen (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation)
+NTSTATUS vboxWddmGhDisplayPostInfoScreen (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation, POINT * pVScreenPos)
 {
     VBOXVIDEOOFFSET offVram = pAllocation->offVram;
@@ -105,6 +105,6 @@
 
         pScreen->u32ViewIndex    = pAllocation->SurfDesc.VidPnSourceId;
-        pScreen->i32OriginX      = 0;
-        pScreen->i32OriginY      = 0;
+        pScreen->i32OriginX      = pVScreenPos->x;
+        pScreen->i32OriginY      = pVScreenPos->y;
         pScreen->u32StartOffset  = 0; //(uint32_t)offVram; /* we pretend the view is located at the start of each framebuffer */
         pScreen->u32LineSize     = pAllocation->SurfDesc.pitch;
@@ -169,13 +169,21 @@
 }
 
+NTSTATUS vboxWddmGhDisplayUpdateScreenPos(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource, POINT *pVScreenPos)
+{
+    if (pSource->VScreenPos.x == pVScreenPos->x
+            && pSource->VScreenPos.y == pVScreenPos->y)
+        return STATUS_SUCCESS;
+
+    pSource->VScreenPos = *pVScreenPos;
+
+    PVBOXWDDM_ALLOCATION pAllocation = VBOXWDDM_FB_ALLOCATION(pSource);
+    NTSTATUS Status = vboxWddmGhDisplayPostInfoScreen(pDevExt, pAllocation, &pSource->VScreenPos);
+    Assert(Status == STATUS_SUCCESS);
+    return Status;
+}
 
 NTSTATUS vboxWddmGhDisplaySetInfo(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource)
 {
-
-#ifndef VBOXWDDM_RENDER_FROM_SHADOW
-    PVBOXWDDM_ALLOCATION pAllocation = pSource->pPrimaryAllocation;
-#else
-    PVBOXWDDM_ALLOCATION pAllocation = pSource->pShadowAllocation;
-#endif
+    PVBOXWDDM_ALLOCATION pAllocation = VBOXWDDM_FB_ALLOCATION(pSource);
     VBOXVIDEOOFFSET offVram = vboxWddmValidatePrimary(pAllocation);
     Assert(offVram != VBOXVIDEOOFFSET_VOID);
@@ -194,5 +202,5 @@
         if (Status == STATUS_SUCCESS)
         {
-            Status = vboxWddmGhDisplayPostInfoScreen(pDevExt, pAllocation);
+            Status = vboxWddmGhDisplayPostInfoScreen(pDevExt, pAllocation, &pSource->VScreenPos);
             Assert(Status == STATUS_SUCCESS);
             if (Status != STATUS_SUCCESS)
@@ -1699,5 +1707,5 @@
     DXGKARG_DESCRIBEALLOCATION*  pDescribeAllocation)
 {
-//    dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
+    dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
 
     vboxVDbgBreakFv();
@@ -1712,5 +1720,5 @@
     pDescribeAllocation->PrivateDriverFormatAttribute = 0;
 
-//    dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
+    dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
 
     return STATUS_SUCCESS;
@@ -2058,5 +2066,5 @@
 }
 
-static void vboxWddmSubmitBltCmd(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_CONTEXT pContext, PVBOXWDDM_DMA_PRESENT_BLT pBlt)
+static void vboxWddmSubmitBltCmd(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource, PVBOXWDDM_CONTEXT pContext, PVBOXWDDM_DMA_PRESENT_BLT pBlt)
 {
     PVBOXVDMAPIPE_CMD_RECTSINFO pRectsCmd = (PVBOXVDMAPIPE_CMD_RECTSINFO)vboxVdmaGgCmdCreate(&pDevExt->u.primary.Vdma.DmaGg, VBOXVDMAPIPE_CMD_TYPE_RECTSINFO, RT_OFFSETOF(VBOXVDMAPIPE_CMD_RECTSINFO, ContextsRects.UpdateRects.aRects[pBlt->DstRects.UpdateRects.cRects]));
@@ -2066,4 +2074,9 @@
         pRectsCmd->pContext = pContext;
         memcpy(&pRectsCmd->ContextsRects, &pBlt->DstRects, RT_OFFSETOF(VBOXVDMAPIPE_RECTS, UpdateRects.aRects[pBlt->DstRects.UpdateRects.cRects]));
+        vboxWddmRectTranslate(&pRectsCmd->ContextsRects.ContextRect, pSource->VScreenPos.x, pSource->VScreenPos.y);
+        for (UINT i = 0; i < pRectsCmd->ContextsRects.UpdateRects.cRects; ++i)
+        {
+            vboxWddmRectTranslate(&pRectsCmd->ContextsRects.UpdateRects.aRects[i], pSource->VScreenPos.x, pSource->VScreenPos.y);
+        }
         NTSTATUS tmpStatus = vboxVdmaGgCmdSubmit(&pDevExt->u.primary.Vdma.DmaGg, &pRectsCmd->Hdr);
         Assert(tmpStatus == STATUS_SUCCESS);
@@ -2111,4 +2124,5 @@
             vboxWddmCheckUpdateShadowAddress(pDevExt, pSource, pPrivateData->SrcAllocInfo.segmentIdAlloc, pPrivateData->SrcAllocInfo.offAlloc);
             PVBOXWDDM_DMA_PRESENT_RENDER_FROM_SHADOW pRFS = (PVBOXWDDM_DMA_PRESENT_RENDER_FROM_SHADOW)pPrivateData;
+            vboxWddmRectTranslate(&pRFS->rect, pSource->VScreenPos.x, pSource->VScreenPos.y);
             uint32_t cDMACmdsOutstanding = ASMAtomicReadU32(&pDevExt->cDMACmdsOutstanding);
             if (!cDMACmdsOutstanding)
@@ -2163,4 +2177,6 @@
                                     rect = pBlt->DstRects.ContextRect;
 
+                                vboxWddmRectTranslate(&rect, pSource->VScreenPos.x, pSource->VScreenPos.y);
+
                                 uint32_t cDMACmdsOutstanding = ASMAtomicReadU32(&pDevExt->cDMACmdsOutstanding);
                                 if (!cDMACmdsOutstanding)
@@ -2171,5 +2187,5 @@
                                     VBOXVBVA_OP_WITHLOCK_ATDPC(ReportDirtyRect, pDevExt, &pSource->Vbva, &rect);
                                 }
-                                vboxWddmSubmitBltCmd(pDevExt, pContext, pBlt);
+                                vboxWddmSubmitBltCmd(pDevExt, pSource, pContext, pBlt);
                                 break;
                             }
@@ -2180,5 +2196,5 @@
                                 if (pSrcAlloc->fRcFlags.RenderTarget)
                                 {
-                                    vboxWddmSubmitBltCmd(pDevExt, pContext, pBlt);
+                                    vboxWddmSubmitBltCmd(pDevExt, pSource, pContext, pBlt);
                                 }
                                 break;
@@ -2222,10 +2238,11 @@
             {
                 PVBOXWDDM_ALLOCATION pAlloc = pPrivateData->SrcAllocInfo.pAlloc;
+                VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pPrivateData->SrcAllocInfo.srcId];
                 pRectsCmd->pContext = pContext;
                 RECT r;
-                r.top = 0;
-                r.left = 0;
-                r.right = pAlloc->SurfDesc.width;
-                r.bottom = pAlloc->SurfDesc.height;
+                r.left = pSource->VScreenPos.x;
+                r.top = pSource->VScreenPos.y;
+                r.right = pAlloc->SurfDesc.width + pSource->VScreenPos.x;
+                r.bottom = pAlloc->SurfDesc.height + pSource->VScreenPos.y;
                 pRectsCmd->ContextsRects.ContextRect = r;
                 pRectsCmd->ContextsRects.UpdateRects.cRects = 1;
@@ -2843,4 +2860,33 @@
                 Status = STATUS_SUCCESS;
                 break;
+            case VBOXESC_SCREENLAYOUT:
+            {
+                Assert(pEscape->PrivateDriverDataSize >= sizeof (VBOXDISPIFESCAPE_SCREENLAYOUT));
+                if (pEscape->PrivateDriverDataSize >= sizeof (VBOXDISPIFESCAPE_SCREENLAYOUT))
+                {
+                    PVBOXDISPIFESCAPE_SCREENLAYOUT pLo = (PVBOXDISPIFESCAPE_SCREENLAYOUT)pEscapeHdr;
+                    Assert(pLo->ScreenLayout.cScreens <= (UINT)pDevExt->u.primary.cDisplays);
+                    for (UINT i = 0; i < pLo->ScreenLayout.cScreens; ++i)
+                    {
+                        PVBOXSCREENLAYOUT_ELEMENT pEl = &pLo->ScreenLayout.aScreens[i];
+                        Assert(pEl->VidPnSourceId < (UINT)pDevExt->u.primary.cDisplays);
+                        if (pEl->VidPnSourceId < (UINT)pDevExt->u.primary.cDisplays)
+                        {
+                            PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pEl->VidPnSourceId];
+                            NTSTATUS tmpStatus = vboxWddmGhDisplayUpdateScreenPos(pDevExt, pSource, &pEl->pos);
+                            Assert(tmpStatus == STATUS_SUCCESS);
+                        }
+                    }
+                    Status = STATUS_SUCCESS;
+                    break;
+                }
+                else
+                {
+                    drprintf((__FUNCTION__": VBOXESC_SCREENLAYOUT: incorrect buffer size (%d) < sizeof (VBOXDISPIFESCAPE_SCREENLAYOUT) (%d)\n",
+                            pEscape->PrivateDriverDataSize, sizeof (VBOXDISPIFESCAPE_SCREENLAYOUT)));
+                    AssertBreakpoint();
+                    Status = STATUS_INVALID_PARAMETER;
+                }
+            }
             case VBOXESC_REINITVIDEOMODES:
                 VBoxWddmInvalidateModesTable(pDevExt);
@@ -2925,5 +2971,5 @@
     PAGED_CODE();
 
-//    dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
+    dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
 
     vboxVDbgBreakFv();
@@ -3016,5 +3062,5 @@
     pIsSupportedVidPnArg->IsVidPnSupported = bSupported;
 
-//    dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
+    dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
 
     return Status;
@@ -3133,5 +3179,5 @@
     PAGED_CODE();
 
-//    dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
+    dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
 
     vboxVDbgBreakFv();
@@ -3180,5 +3226,5 @@
         drprintf((__FUNCTION__ ": DxgkCbQueryVidPnInterface failed Status(0x%x)\n", Status));
 
-//    dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
+    dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
 
     return Status;
@@ -3485,5 +3531,5 @@
     DXGKARG_GETSCANLINE*  pGetScanLine)
 {
-//    dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
+    dfprintf(("==> "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
 
     PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)hAdapter;
@@ -3513,5 +3559,5 @@
     }
 
-//    dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
+    dfprintf(("<== "__FUNCTION__ ", hAdapter(0x%x)\n", hAdapter));
 
     return STATUS_SUCCESS;
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/Makefile.kmk
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/Makefile.kmk	(revision 31661)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/Makefile.kmk	(revision 31687)
@@ -126,5 +126,5 @@
     LIB_TO_DATADIR=\"\" \
     BIN_TO_DATADIR=\"\"
-if "$(KBUILD_TYPE)" != "debug" || !defined(DEBUG_misha)
+if "$(KBUILD_TYPE)" != "debug" || defined(DEBUG_misha)
  wined3d_DEFS        += WINE_NO_DEBUG_MSGS
 endif
@@ -183,5 +183,5 @@
     LIB_TO_DATADIR=\"\" \
     BIN_TO_DATADIR=\"\"
-if "$(KBUILD_TYPE)" != "debug" || !defined(DEBUG_misha)
+if "$(KBUILD_TYPE)" != "debug" || defined(DEBUG_misha)
  VBoxD3D8_DEFS       += WINE_NO_DEBUG_MSGS
 endif
@@ -220,5 +220,5 @@
     LIB_TO_DATADIR=\"\" \
     BIN_TO_DATADIR=\"\"
-if "$(KBUILD_TYPE)" != "debug" || !defined(DEBUG_misha)
+if "$(KBUILD_TYPE)" != "debug" || defined(DEBUG_misha)
  VBoxD3D9_DEFS       += WINE_NO_DEBUG_MSGS
 endif
Index: trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.cpp	(revision 31661)
+++ trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.cpp	(revision 31687)
@@ -113,5 +113,5 @@
     D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME OpenAdapterData = {0};
     wcsncpy(OpenAdapterData.DeviceName, pDevName, RT_ELEMENTS(OpenAdapterData.DeviceName) - 1 /* the last one is always \0 */);
-    DWORD err = ERROR_GEN_FAILURE;
+    DWORD err = NO_ERROR;
     NTSTATUS Status = pIf->modeData.wddm.pfnD3DKMTOpenAdapterFromGdiDisplayName(&OpenAdapterData);
     if (!Status)
@@ -133,5 +133,8 @@
     }
     else
+    {
         Log((__FUNCTION__": pfnD3DKMTOpenAdapterFromGdiDisplayName failed, Status (0x%x)\n", Status));
+        err = ERROR_GEN_FAILURE;
+    }
 
     return err;
Index: trunk/src/VBox/Additions/WINNT/include/VBoxDisplay.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/include/VBoxDisplay.h	(revision 31661)
+++ trunk/src/VBox/Additions/WINNT/include/VBoxDisplay.h	(revision 31687)
@@ -25,4 +25,5 @@
 # define VBOXESC_GETVBOXVIDEOCMCMD          0xABCD9004
 # define VBOXESC_DBGPRINT                   0xABCD9005
+# define VBOXESC_SCREENLAYOUT               0xABCD9006
 
 typedef struct
