Index: trunk/src/VBox/Additions/WINNT/Graphics/Display/dd.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Display/dd.c	(revision 5144)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Display/dd.c	(revision 5159)
@@ -649,5 +649,7 @@
 
         ShareMemory.ViewOffset = 0;
-        ShareMemory.ViewSize   = pDev->cyScreen * pDev->lDeltaScreen;
+
+        // We map down to the end of the frame buffer, including the offscreen heap.
+        ShareMemory.ViewSize   = pDev->layout.offVBVABuffer;
 
         DISPDBG((0, "ViewSize = %x\n", ShareMemory.ViewSize));
@@ -661,5 +663,5 @@
                        &ReturnedDataLength))
         {
-            DISPDBG((0, "Failed IOCTL_VIDEO_SHARE_MEMORY"));
+            DISPDBG((0, "Failed IOCTL_VIDEO_SHARE_MEMORY\n"));
 
             lpMapMemory->ddRVal = DDERR_GENERIC;
@@ -717,20 +719,30 @@
 {
     PPDEV pDev = (PPDEV)lpLock->lpDD->dhpdev;
-
-    DISPDBG((0, "%s: %p bHasRect = %d\n", __FUNCTION__, pDev, lpLock->bHasRect));
     
-    pDev->ddLock.bLocked = TRUE;
-    
-    if (lpLock->bHasRect)
-    {
-        DISPDBG((0, "%d,%d %dx%d\n", lpLock->rArea.left, lpLock->rArea.top, lpLock->rArea.right - lpLock->rArea.left, lpLock->rArea.bottom - lpLock->rArea.top));
-        pDev->ddLock.rArea = lpLock->rArea;
-    }
-    else
-    {
-        pDev->ddLock.rArea.left   = 0;
-        pDev->ddLock.rArea.top    = 0;
-        pDev->ddLock.rArea.right  = pDev->cxScreen;
-        pDev->ddLock.rArea.bottom = pDev->cyScreen;
+    PDD_SURFACE_LOCAL lpSurfaceLocal = lpLock->lpDDSurface;
+
+    DISPDBG((0, "%s: %p bHasRect = %d fpProcess = %p\n", __FUNCTION__, pDev, lpLock->bHasRect, lpLock->fpProcess));
+
+    if (lpSurfaceLocal->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
+    {
+        /* The updated rectangle must be reported only for the primary surface. */
+        pDev->ddLock.bLocked = TRUE;
+
+        if (lpLock->bHasRect)
+        {
+            DISPDBG((0, "%d,%d %dx%d\n", lpLock->rArea.left, lpLock->rArea.top, lpLock->rArea.right - lpLock->rArea.left, lpLock->rArea.bottom - lpLock->rArea.top));
+            pDev->ddLock.rArea = lpLock->rArea;
+        }
+        else
+        {
+            pDev->ddLock.rArea.left   = 0;
+            pDev->ddLock.rArea.top    = 0;
+            pDev->ddLock.rArea.right  = pDev->cxScreen;
+            pDev->ddLock.rArea.bottom = pDev->cyScreen;
+        }
+    }
+    else
+    {
+        DISPDBG((0, "%s: secondary surface.\n", __FUNCTION__));
     }
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Display/driver.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Display/driver.h	(revision 5144)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Display/driver.h	(revision 5159)
@@ -52,6 +52,6 @@
 
 /* VRAM
- *  |           |           |          |           |
- * 0+framebuffer+VBVA buffer+ddraw heap+displayinfo=cScreenSize
+ *  |           |          |           |           |
+ * 0+framebuffer+ddraw heap+VBVA buffer+displayinfo=cScreenSize
  */
 typedef struct _VRAMLAYOUT
@@ -62,9 +62,9 @@
     ULONG cbFrameBuffer;
     
+    ULONG offDDRAWHeap; //@todo
+    ULONG cbDDRAWHeap;
+    
     ULONG offVBVABuffer;
     ULONG cbVBVABuffer;
-    
-    ULONG offDDRAWHeap;
-    ULONG cbDDRAWHeap;
     
     ULONG offDisplayInformation;
Index: trunk/src/VBox/Additions/WINNT/Graphics/Display/screen.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Display/screen.c	(revision 5144)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Display/screen.c	(revision 5159)
@@ -94,10 +94,11 @@
             else
             {
-                ppdev->layout.offVBVABuffer = ppdev->layout.offFrameBuffer + ppdev->layout.cbFrameBuffer;
+                /* Now the offscreen heap followed by the VBVA buffer. */
+                ppdev->layout.offDDRAWHeap = ppdev->layout.offFrameBuffer + ppdev->layout.cbFrameBuffer;
                 
                 cbAvailable -= ppdev->layout.cbVBVABuffer;
+                ppdev->layout.cbDDRAWHeap = cbAvailable;
                 
-                ppdev->layout.offDDRAWHeap = ppdev->layout.offVBVABuffer + ppdev->layout.cbVBVABuffer;
-                ppdev->layout.cbDDRAWHeap  = cbAvailable;
+                ppdev->layout.offVBVABuffer = ppdev->layout.offDDRAWHeap + ppdev->layout.cbDDRAWHeap;
             }
         }
@@ -114,11 +115,11 @@
         ppdev->layout.cbFrameBuffer  = RT_ALIGN_32(pMemoryInformation->FrameBufferLength, 0x1000);
     
-        ppdev->layout.offVBVABuffer = ppdev->layout.offFrameBuffer + ppdev->layout.cbFrameBuffer;
+        ppdev->layout.offDDRAWHeap = ppdev->layout.offFrameBuffer + ppdev->layout.cbFrameBuffer;
+        ppdev->layout.cbDDRAWHeap  = ppdev->layout.cbVRAM - ppdev->layout.offDDRAWHeap;
+    
+        ppdev->layout.offVBVABuffer = ppdev->layout.offDDRAWHeap + ppdev->layout.cbDDRAWHeap;
         ppdev->layout.cbVBVABuffer  = 0;
     
-        ppdev->layout.offDDRAWHeap = ppdev->layout.offVBVABuffer + ppdev->layout.cbVBVABuffer;
-        ppdev->layout.cbDDRAWHeap  = ppdev->layout.cbVRAM - ppdev->layout.offDDRAWHeap;
-    
-        ppdev->layout.offDisplayInformation = ppdev->layout.offDDRAWHeap + ppdev->layout.cbDDRAWHeap;
+        ppdev->layout.offDisplayInformation = ppdev->layout.offVBVABuffer + ppdev->layout.cbVBVABuffer;
         ppdev->layout.cbDisplayInformation  = 0;
     }
@@ -128,8 +129,8 @@
                 "    offFrameBuffer = 0x%X\n"
                 "    cbFrameBuffer = 0x%X\n"
+                "    offDDRAWHeap = 0x%X\n"
+                "    cbDDRAWHeap = 0x%X\n"
                 "    offVBVABuffer = 0x%X\n"
                 "    cbVBVABuffer = 0x%X\n"
-                "    offDDRAWHeap = 0x%X\n"
-                "    cbDDRAWHeap = 0x%X\n"
                 "    offDisplayInformation = 0x%X\n"
                 "    cbDisplayInformation = 0x%X\n",
@@ -137,8 +138,8 @@
                 ppdev->layout.offFrameBuffer,
                 ppdev->layout.cbFrameBuffer,
+                ppdev->layout.offDDRAWHeap,
+                ppdev->layout.cbDDRAWHeap,
                 ppdev->layout.offVBVABuffer,
                 ppdev->layout.cbVBVABuffer,
-                ppdev->layout.offDDRAWHeap,
-                ppdev->layout.cbDDRAWHeap,
                 ppdev->layout.offDisplayInformation,
                 ppdev->layout.cbDisplayInformation
Index: trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp	(revision 5144)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp	(revision 5159)
@@ -1299,8 +1299,8 @@
             pShareMemory = (PVIDEO_SHARE_MEMORY)RequestPacket->InputBuffer;
 
-            if (    (pShareMemory->ViewOffset > pDevExt->ulFrameBufferSize) 
-                ||  ((pShareMemory->ViewOffset + pShareMemory->ViewSize) > pDevExt->ulFrameBufferSize) ) {
-
-                dprintf(("IOCTL_VIDEO_SHARE_VIDEO_MEMORY - ERROR_INVALID_PARAMETER %x:%x size %x\n", pShareMemory->ViewOffset, pShareMemory->ViewSize, pDevExt->ulFrameBufferSize));
+            if (    (pShareMemory->ViewOffset > pDevExt->pPrimary->u.primary.ulMaxFrameBufferSize) 
+                ||  ((pShareMemory->ViewOffset + pShareMemory->ViewSize) > pDevExt->pPrimary->u.primary.ulMaxFrameBufferSize) ) {
+
+                dprintf(("IOCTL_VIDEO_SHARE_VIDEO_MEMORY - ERROR_INVALID_PARAMETER %x:%x size %x\n", pShareMemory->ViewOffset, pShareMemory->ViewSize, pDevExt->pPrimary->u.primary.ulMaxFrameBufferSize));
                 RequestPacket->StatusBlock->Status = ERROR_INVALID_PARAMETER;
                 Result = FALSE;
