Index: trunk/src/VBox/Runtime/r3/win/fileio-win.cpp
===================================================================
--- trunk/src/VBox/Runtime/r3/win/fileio-win.cpp	(revision 69535)
+++ trunk/src/VBox/Runtime/r3/win/fileio-win.cpp	(revision 69536)
@@ -496,5 +496,5 @@
     if (cbToWrite <= 0)
         return VINF_SUCCESS;
-    ULONG cbToWriteAdj = (ULONG)cbToWrite;
+    ULONG const cbToWriteAdj = (ULONG)cbToWrite;
     AssertReturn(cbToWriteAdj == cbToWrite, VERR_NUMBER_TOO_BIG);
 
@@ -504,9 +504,9 @@
         if (pcbWritten)
             /* Caller can handle partial writes. */
-            *pcbWritten = cbWritten;
+            *pcbWritten = RT_MIN(cbWritten, cbToWriteAdj); /* paranoia^3 */
         else
         {
             /* Caller expects everything to be written. */
-            while (cbToWriteAdj > cbWritten)
+            while (cbWritten < cbToWriteAdj)
             {
                 ULONG cbWrittenPart = 0;
@@ -543,5 +543,5 @@
 
         cbWritten = 0;
-        while (cbToWriteAdj > cbWritten)
+        while (cbWritten < cbToWriteAdj)
         {
             ULONG cbToWrite     = RT_MIN(cbChunk, cbToWriteAdj - cbWritten);
@@ -570,5 +570,5 @@
             if (pcbWritten)
             {
-                *pcbWritten = cbWritten;
+                *pcbWritten = RT_MIN(cbWritten, cbToWriteAdj); /* paranoia^3 */
                 break;
             }
Index: trunk/src/VBox/Runtime/r3/win/localipc-win.cpp
===================================================================
--- trunk/src/VBox/Runtime/r3/win/localipc-win.cpp	(revision 69535)
+++ trunk/src/VBox/Runtime/r3/win/localipc-win.cpp	(revision 69536)
@@ -1392,7 +1392,6 @@
                     RTCritSectLeave(&pThis->CritSect);
 
-                    fRc = WriteFile(pThis->hNmPipe, pvBuf,
-                                    cbToWrite <= ~(DWORD)0 ? (DWORD)cbToWrite : ~(DWORD)0,
-                                    &cbWritten, &pThis->Write.OverlappedIO);
+                    DWORD const cbToWriteInThisIteration = cbToWrite <= ~(DWORD)0 ? (DWORD)cbToWrite : ~(DWORD)0;
+                    fRc = WriteFile(pThis->hNmPipe, pvBuf, cbToWriteInThisIteration, &cbWritten, &pThis->Write.OverlappedIO);
                     if (fRc)
                         rc = VINF_SUCCESS;
@@ -1423,4 +1422,7 @@
                     }
 
+                    if (cbWritten > cbToWriteInThisIteration) /* paranoia^3 */
+                        cbWritten = cbToWriteInThisIteration;
+
                     RTCritSectEnter(&pThis->CritSect);
                     if (RT_FAILURE(rc))
Index: trunk/src/VBox/Runtime/r3/win/pipe-win.cpp
===================================================================
--- trunk/src/VBox/Runtime/r3/win/pipe-win.cpp	(revision 69535)
+++ trunk/src/VBox/Runtime/r3/win/pipe-win.cpp	(revision 69536)
@@ -797,5 +797,5 @@
                                   &cbWritten, &pThis->Overlapped))
                     {
-                        *pcbWritten = cbWritten;
+                        *pcbWritten = RT_MIN(cbWritten, cbToWrite); /* paranoia^3 */
                         rc = VINF_SUCCESS;
                     }
@@ -879,7 +879,6 @@
 
                     DWORD cbWritten = 0;
-                    if (WriteFile(pThis->hPipe, pvBuf,
-                                  cbToWrite <= ~(DWORD)0 ? (DWORD)cbToWrite : ~(DWORD)0,
-                                  &cbWritten, &pThis->Overlapped))
+                    DWORD const cbToWriteInThisIteration = cbToWrite <= ~(DWORD)0 ? (DWORD)cbToWrite : ~(DWORD)0;
+                    if (WriteFile(pThis->hPipe, pvBuf, cbToWriteInThisIteration, &cbWritten, &pThis->Overlapped))
                         rc = VINF_SUCCESS;
                     else if (GetLastError() == ERROR_IO_PENDING)
@@ -902,4 +901,6 @@
 
                     /* advance */
+                    if (cbWritten > cbToWriteInThisIteration) /* paranoia^3 */
+                        cbWritten = cbToWriteInThisIteration;
                     pvBuf           = (char const *)pvBuf + cbWritten;
                     cbTotalWritten += cbWritten;
