Index: /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp	(revision 78170)
+++ /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp	(revision 78171)
@@ -20,5 +20,5 @@
 *   Header Files                                                                                                                 *
 *********************************************************************************************************************************/
-# define LOG_GROUP LOG_GROUP_SHARED_CLIPBOARD
+#define LOG_GROUP LOG_GROUP_SHARED_CLIPBOARD
 #include "VBoxTray.h"
 #include "VBoxHelpers.h"
@@ -69,418 +69,429 @@
         case WM_CLIPBOARDUPDATE:
         {
-            Log(("WM_CLIPBOARDUPDATE\n"));
-
-            if (GetClipboardOwner() != hwnd)
-            {
-                /* Clipboard was updated by another application. */
-                uint32_t uFormats;
-                int vboxrc = VBoxClipboardWinGetFormats(&pCtx->Win, &uFormats);
-                if (RT_SUCCESS(vboxrc))
-                    vboxrc = VbglR3ClipboardReportFormats(pCtx->u32ClientID, uFormats);
-            }
-        } break;
+           Log(("WM_CLIPBOARDUPDATE\n"));
+
+           if (GetClipboardOwner() != hwnd)
+           {
+               /* Clipboard was updated by another application. */
+               uint32_t uFormats;
+               int vboxrc = VBoxClipboardWinGetFormats(&pCtx->Win, &uFormats);
+               if (RT_SUCCESS(vboxrc))
+                   vboxrc = VbglR3ClipboardReportFormats(pCtx->u32ClientID, uFormats);
+           }
+        }
+        break;
 
         case WM_CHANGECBCHAIN:
         {
-            if (VBoxClipboardWinIsNewAPI(&pWinCtx->newAPI))
-            {
-                rc = DefWindowProc(hwnd, msg, wParam, lParam);
-                break;
-            }
-
-            HWND hWndRemoved = (HWND)wParam;
-            HWND hWndNext    = (HWND)lParam;
-
-            LogFlowFunc(("WM_CHANGECBCHAIN: hWndRemoved=%p, hWndNext=%p, hWnd=%p\n", hWndRemoved, hWndNext, pWinCtx->hWnd));
-
-            if (hWndRemoved == pWinCtx->hWndNextInChain)
-            {
-                /* The window that was next to our in the chain is being removed.
-                 * Relink to the new next window. */
-                pWinCtx->hWndNextInChain = hWndNext;
-            }
-            else
-            {
-                if (pWinCtx->hWndNextInChain)
-                {
-                    /* Pass the message further. */
-                    DWORD_PTR dwResult;
-                    rc = SendMessageTimeout(pWinCtx->hWndNextInChain, WM_CHANGECBCHAIN, wParam, lParam, 0,
-                                            VBOX_CLIPBOARD_CBCHAIN_TIMEOUT_MS, &dwResult);
-                    if (!rc)
-                        rc = (LRESULT) dwResult;
-                }
-            }
-        } break;
+           if (VBoxClipboardWinIsNewAPI(&pWinCtx->newAPI))
+           {
+               rc = DefWindowProc(hwnd, msg, wParam, lParam);
+               break;
+           }
+
+           HWND hWndRemoved = (HWND)wParam;
+           HWND hWndNext    = (HWND)lParam;
+
+           LogFlowFunc(("WM_CHANGECBCHAIN: hWndRemoved=%p, hWndNext=%p, hWnd=%p\n", hWndRemoved, hWndNext, pWinCtx->hWnd));
+
+           if (hWndRemoved == pWinCtx->hWndNextInChain)
+           {
+               /* The window that was next to our in the chain is being removed.
+                * Relink to the new next window. */
+               pWinCtx->hWndNextInChain = hWndNext;
+           }
+           else
+           {
+               if (pWinCtx->hWndNextInChain)
+               {
+                   /* Pass the message further. */
+                   DWORD_PTR dwResult;
+                   rc = SendMessageTimeout(pWinCtx->hWndNextInChain, WM_CHANGECBCHAIN, wParam, lParam, 0,
+                                           VBOX_CLIPBOARD_CBCHAIN_TIMEOUT_MS, &dwResult);
+                   if (!rc)
+                       rc = (LRESULT)dwResult;
+               }
+           }
+        }
+        break;
 
         case WM_DRAWCLIPBOARD:
         {
-            LogFlowFunc(("WM_DRAWCLIPBOARD, hwnd %p\n", pWinCtx->hWnd));
-
-            if (GetClipboardOwner() != hwnd)
-            {
-                /* Clipboard was updated by another application. */
-                /* WM_DRAWCLIPBOARD always expects a return code of 0, so don't change "rc" here. */
-                uint32_t uFormats;
-                int vboxrc = VBoxClipboardWinGetFormats(pWinCtx, &uFormats);
-                if (RT_SUCCESS(vboxrc))
-                    vboxrc = VbglR3ClipboardReportFormats(pCtx->u32ClientID, uFormats);
-            }
-
-            if (pWinCtx->hWndNextInChain)
-            {
-                /* Pass the message to next windows in the clipboard chain. */
-                SendMessageTimeout(pWinCtx->hWndNextInChain, msg, wParam, lParam, 0, VBOX_CLIPBOARD_CBCHAIN_TIMEOUT_MS, NULL);
-            }
-        } break;
+           LogFlowFunc(("WM_DRAWCLIPBOARD, hwnd %p\n", pWinCtx->hWnd));
+
+           if (GetClipboardOwner() != hwnd)
+           {
+               /* Clipboard was updated by another application. */
+               /* WM_DRAWCLIPBOARD always expects a return code of 0, so don't change "rc" here. */
+               uint32_t uFormats;
+               int vboxrc = VBoxClipboardWinGetFormats(pWinCtx, &uFormats);
+               if (RT_SUCCESS(vboxrc))
+                   vboxrc = VbglR3ClipboardReportFormats(pCtx->u32ClientID, uFormats);
+           }
+
+           if (pWinCtx->hWndNextInChain)
+           {
+               /* Pass the message to next windows in the clipboard chain. */
+               SendMessageTimeout(pWinCtx->hWndNextInChain, msg, wParam, lParam, 0, VBOX_CLIPBOARD_CBCHAIN_TIMEOUT_MS, NULL);
+           }
+        }
+        break;
 
         case WM_TIMER:
         {
-            if (VBoxClipboardWinIsNewAPI(&pWinCtx->newAPI))
-                break;
-
-            HWND hViewer = GetClipboardViewer();
-
-            /* Re-register ourselves in the clipboard chain if our last ping
-             * timed out or there seems to be no valid chain. */
-            if (!hViewer || pWinCtx->oldAPI.fCBChainPingInProcess)
-            {
-                VBoxClipboardWinRemoveFromCBChain(pWinCtx);
-                VBoxClipboardWinAddToCBChain(pWinCtx);
-            }
-
-            /* Start a new ping by passing a dummy WM_CHANGECBCHAIN to be
-             * processed by ourselves to the chain. */
-            pWinCtx->oldAPI.fCBChainPingInProcess = TRUE;
-
-            hViewer = GetClipboardViewer();
-            if (hViewer)
-                SendMessageCallback(hViewer, WM_CHANGECBCHAIN, (WPARAM)pWinCtx->hWndNextInChain, (LPARAM)pWinCtx->hWndNextInChain,
-                                    VBoxClipboardWinChainPingProc, (ULONG_PTR)pWinCtx);
-        } break;
+           if (VBoxClipboardWinIsNewAPI(&pWinCtx->newAPI))
+               break;
+
+           HWND hViewer = GetClipboardViewer();
+
+           /* Re-register ourselves in the clipboard chain if our last ping
+            * timed out or there seems to be no valid chain. */
+           if (!hViewer || pWinCtx->oldAPI.fCBChainPingInProcess)
+           {
+               VBoxClipboardWinRemoveFromCBChain(pWinCtx);
+               VBoxClipboardWinAddToCBChain(pWinCtx);
+           }
+
+           /* Start a new ping by passing a dummy WM_CHANGECBCHAIN to be
+            * processed by ourselves to the chain. */
+           pWinCtx->oldAPI.fCBChainPingInProcess = TRUE;
+
+           hViewer = GetClipboardViewer();
+           if (hViewer)
+               SendMessageCallback(hViewer, WM_CHANGECBCHAIN, (WPARAM)pWinCtx->hWndNextInChain, (LPARAM)pWinCtx->hWndNextInChain,
+                                   VBoxClipboardWinChainPingProc, (ULONG_PTR)pWinCtx);
+        }
+        break;
 
         case WM_CLOSE:
         {
-            /* Do nothing. Ignore the message. */
-        } break;
+           /* Do nothing. Ignore the message. */
+        }
+        break;
 
         case WM_RENDERFORMAT:
         {
-            /* Insert the requested clipboard format data into the clipboard. */
-            uint32_t u32Format = 0;
-            UINT format = (UINT)wParam;
-
-            LogFlowFunc(("WM_RENDERFORMAT, format = %x\n", format));
-            switch (format)
-            {
-                case CF_UNICODETEXT:
-                    u32Format |= VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT;
-                    break;
-
-                case CF_DIB:
-                    u32Format |= VBOX_SHARED_CLIPBOARD_FMT_BITMAP;
-                    break;
-
-                default:
-                    if (format >= 0xC000)
-                    {
-                        TCHAR szFormatName[256];
-
-                        int cActual = GetClipboardFormatName(format, szFormatName, sizeof(szFormatName)/sizeof (TCHAR));
-                        if (cActual)
-                        {
-                            if (strcmp (szFormatName, "HTML Format") == 0)
-                            {
-                                u32Format |= VBOX_SHARED_CLIPBOARD_FMT_HTML;
-                            }
-                        }
-                    }
-                    break;
-            }
-
-            if (u32Format == 0)
-            {
-                /* Unsupported clipboard format is requested. */
-                LogFlowFunc(("Unsupported clipboard format requested: %ld\n", u32Format));
-                VBoxClipboardWinClear();
-            }
-            else
-            {
-                const uint32_t cbPrealloc = 4096; /** @todo r=andy Make it dynamic for supporting larger text buffers! */
-                uint32_t cb = 0;
-
-                /* Preallocate a buffer, most of small text transfers will fit into it. */
-                HANDLE hMem = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, cbPrealloc);
-                LogFlowFunc(("Preallocated handle hMem = %p\n", hMem));
-
-                if (hMem)
-                {
-                    void *pMem = GlobalLock(hMem);
-                    LogFlowFunc(("Locked pMem = %p, GlobalSize = %ld\n", pMem, GlobalSize(hMem)));
-
-                    if (pMem)
-                    {
-                        /* Read the host data to the preallocated buffer. */
-                        int vboxrc = VbglR3ClipboardReadData(pCtx->u32ClientID, u32Format, pMem, cbPrealloc, &cb);
-                        LogFlowFunc(("VbglR3ClipboardReadData returned with rc = %Rrc\n",  vboxrc));
-
-                        if (RT_SUCCESS(vboxrc))
-                        {
-                            if (cb == 0)
-                            {
-                                /* 0 bytes returned means the clipboard is empty.
-                                 * Deallocate the memory and set hMem to NULL to get to
-                                 * the clipboard empty code path. */
-                                GlobalUnlock(hMem);
-                                GlobalFree(hMem);
-                                hMem = NULL;
-                            }
-                            else if (cb > cbPrealloc)
-                            {
-                                GlobalUnlock(hMem);
-
-                                /* The preallocated buffer is too small, adjust the size. */
-                                hMem = GlobalReAlloc(hMem, cb, 0);
-                                LogFlowFunc(("Reallocated hMem = %p\n", hMem));
-
-                                if (hMem)
-                                {
-                                    pMem = GlobalLock(hMem);
-                                    LogFlowFunc(("Locked pMem = %p, GlobalSize = %ld\n", pMem, GlobalSize(hMem)));
-
-                                    if (pMem)
-                                    {
-                                        /* Read the host data to the preallocated buffer. */
-                                        uint32_t cbNew = 0;
-                                        vboxrc = VbglR3ClipboardReadData(pCtx->u32ClientID, u32Format, pMem, cb, &cbNew);
-                                        LogFlowFunc(("VbglR3ClipboardReadData returned with rc = %Rrc, cb = %d, cbNew = %d\n", vboxrc, cb, cbNew));
-
-                                        if (RT_SUCCESS (vboxrc) && cbNew <= cb)
-                                        {
-                                            cb = cbNew;
-                                        }
-                                        else
-                                        {
-                                            GlobalUnlock(hMem);
-                                            GlobalFree(hMem);
-                                            hMem = NULL;
-                                        }
-                                    }
-                                    else
-                                    {
-                                        GlobalFree(hMem);
-                                        hMem = NULL;
-                                    }
-                                }
-                            }
-
-                            if (hMem)
-                            {
-                                /* pMem is the address of the data. cb is the size of returned data. */
-                                /* Verify the size of returned text, the memory block for clipboard
-                                 * must have the exact string size.
-                                 */
-                                if (u32Format == VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
-                                {
-                                    size_t cbActual = 0;
-                                    HRESULT hrc = StringCbLengthW((LPWSTR)pMem, cb, &cbActual);
-                                    if (FAILED (hrc))
-                                    {
-                                        /* Discard invalid data. */
-                                        GlobalUnlock(hMem);
-                                        GlobalFree(hMem);
-                                        hMem = NULL;
-                                    }
-                                    else
-                                    {
-                                        /* cbActual is the number of bytes, excluding those used
-                                         * for the terminating null character.
-                                         */
-                                        cb = (uint32_t)(cbActual + 2);
-                                    }
-                                }
-                            }
-
-                            if (hMem)
-                            {
-                                GlobalUnlock(hMem);
-
-                                hMem = GlobalReAlloc(hMem, cb, 0);
-                                LogFlowFunc(("Reallocated hMem = %p\n", hMem));
-
-                                if (hMem)
-                                {
-                                    /* 'hMem' contains the host clipboard data.
-                                     * size is 'cb' and format is 'format'. */
-                                    HANDLE hClip = SetClipboardData(format, hMem);
-                                    LogFlowFunc(("WM_RENDERFORMAT hClip = %p\n", hClip));
-
-                                    if (hClip)
-                                    {
-                                        /* The hMem ownership has gone to the system. Finish the processing. */
-                                        break;
-                                    }
-
-                                    /* Cleanup follows. */
-                                }
-                            }
-                        }
-                        if (hMem)
-                            GlobalUnlock(hMem);
-                    }
-                    if (hMem)
-                        GlobalFree(hMem);
-                }
-
-                /* Something went wrong. */
-                VBoxClipboardWinClear();
-            }
-        } break;
+           /* Insert the requested clipboard format data into the clipboard. */
+           uint32_t u32Format = 0;
+           UINT format = (UINT)wParam;
+
+           LogFlowFunc(("WM_RENDERFORMAT, format = %x\n", format));
+           switch (format)
+           {
+              case CF_UNICODETEXT:
+                  u32Format |= VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT;
+                  break;
+
+              case CF_DIB:
+                  u32Format |= VBOX_SHARED_CLIPBOARD_FMT_BITMAP;
+                  break;
+
+              default:
+                  if (format >= 0xC000)
+                  {
+                      TCHAR szFormatName[256];
+
+                      int cActual = GetClipboardFormatName(format, szFormatName, sizeof(szFormatName) / sizeof(TCHAR));
+                      if (cActual)
+                      {
+                          if (strcmp(szFormatName, "HTML Format") == 0)
+                          {
+                              u32Format |= VBOX_SHARED_CLIPBOARD_FMT_HTML;
+                          }
+                      }
+                  }
+                  break;
+           }
+
+           if (u32Format == 0)
+           {
+               /* Unsupported clipboard format is requested. */
+               LogFlowFunc(("Unsupported clipboard format requested: %ld\n", u32Format));
+               VBoxClipboardWinClear();
+           }
+           else
+           {
+               const uint32_t cbPrealloc = 4096; /** @todo r=andy Make it dynamic for supporting larger text buffers! */
+               uint32_t cb = 0;
+
+               /* Preallocate a buffer, most of small text transfers will fit into it. */
+               HANDLE hMem = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, cbPrealloc);
+               LogFlowFunc(("Preallocated handle hMem = %p\n", hMem));
+
+               if (hMem)
+               {
+                   void *pMem = GlobalLock(hMem);
+                   LogFlowFunc(("Locked pMem = %p, GlobalSize = %ld\n", pMem, GlobalSize(hMem)));
+
+                   if (pMem)
+                   {
+                       /* Read the host data to the preallocated buffer. */
+                       int vboxrc = VbglR3ClipboardReadData(pCtx->u32ClientID, u32Format, pMem, cbPrealloc, &cb);
+                       LogFlowFunc(("VbglR3ClipboardReadData returned with rc = %Rrc\n",  vboxrc));
+
+                       if (RT_SUCCESS(vboxrc))
+                       {
+                           if (cb == 0)
+                           {
+                               /* 0 bytes returned means the clipboard is empty.
+                                * Deallocate the memory and set hMem to NULL to get to
+                                * the clipboard empty code path. */
+                               GlobalUnlock(hMem);
+                               GlobalFree(hMem);
+                               hMem = NULL;
+                           }
+                           else if (cb > cbPrealloc)
+                           {
+                               GlobalUnlock(hMem);
+
+                               /* The preallocated buffer is too small, adjust the size. */
+                               hMem = GlobalReAlloc(hMem, cb, 0);
+                               LogFlowFunc(("Reallocated hMem = %p\n", hMem));
+
+                               if (hMem)
+                               {
+                                   pMem = GlobalLock(hMem);
+                                   LogFlowFunc(("Locked pMem = %p, GlobalSize = %ld\n", pMem, GlobalSize(hMem)));
+
+                                   if (pMem)
+                                   {
+                                       /* Read the host data to the preallocated buffer. */
+                                       uint32_t cbNew = 0;
+                                       vboxrc = VbglR3ClipboardReadData(pCtx->u32ClientID, u32Format, pMem, cb, &cbNew);
+                                       LogFlowFunc(("VbglR3ClipboardReadData returned with rc = %Rrc, cb = %d, cbNew = %d\n", vboxrc, cb, cbNew));
+
+                                       if (RT_SUCCESS(vboxrc) && cbNew <= cb)
+                                       {
+                                           cb = cbNew;
+                                       }
+                                       else
+                                       {
+                                           GlobalUnlock(hMem);
+                                           GlobalFree(hMem);
+                                           hMem = NULL;
+                                       }
+                                   }
+                                   else
+                                   {
+                                       GlobalFree(hMem);
+                                       hMem = NULL;
+                                   }
+                               }
+                           }
+
+                           if (hMem)
+                           {
+                               /* pMem is the address of the data. cb is the size of returned data. */
+                               /* Verify the size of returned text, the memory block for clipboard
+                                * must have the exact string size.
+                                */
+                               if (u32Format == VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
+                               {
+                                   size_t cbActual = 0;
+                                   HRESULT hrc = StringCbLengthW((LPWSTR)pMem, cb, &cbActual);
+                                   if (FAILED(hrc))
+                                   {
+                                       /* Discard invalid data. */
+                                       GlobalUnlock(hMem);
+                                       GlobalFree(hMem);
+                                       hMem = NULL;
+                                   }
+                                   else
+                                   {
+                                       /* cbActual is the number of bytes, excluding those used
+                                        * for the terminating null character.
+                                        */
+                                       cb = (uint32_t)(cbActual + 2);
+                                   }
+                               }
+                           }
+
+                           if (hMem)
+                           {
+                               GlobalUnlock(hMem);
+
+                               hMem = GlobalReAlloc(hMem, cb, 0);
+                               LogFlowFunc(("Reallocated hMem = %p\n", hMem));
+
+                               if (hMem)
+                               {
+                                   /* 'hMem' contains the host clipboard data.
+                                    * size is 'cb' and format is 'format'. */
+                                   HANDLE hClip = SetClipboardData(format, hMem);
+                                   LogFlowFunc(("WM_RENDERFORMAT hClip = %p\n", hClip));
+
+                                   if (hClip)
+                                   {
+                                       /* The hMem ownership has gone to the system. Finish the processing. */
+                                       break;
+                                   }
+
+                                   /* Cleanup follows. */
+                               }
+                           }
+                       }
+                       if (hMem)
+                           GlobalUnlock(hMem);
+                   }
+                   if (hMem)
+                       GlobalFree(hMem);
+               }
+
+               /* Something went wrong. */
+               VBoxClipboardWinClear();
+           }
+        }
+        break;
 
         case WM_RENDERALLFORMATS:
         {
-            /* Do nothing. The clipboard formats will be unavailable now, because the
-             * windows is to be destroyed and therefore the guest side becomes inactive.
-             */
-            int vboxrc = VBoxClipboardWinOpen(hwnd);
-            if (RT_SUCCESS(vboxrc))
-            {
-                VBoxClipboardWinClear();
-                VBoxClipboardWinClose();
-            }
-        } break;
+           /* Do nothing. The clipboard formats will be unavailable now, because the
+            * windows is to be destroyed and therefore the guest side becomes inactive.
+            */
+           int vboxrc = VBoxClipboardWinOpen(hwnd);
+           if (RT_SUCCESS(vboxrc))
+           {
+               VBoxClipboardWinClear();
+               VBoxClipboardWinClose();
+           }
+        }
+        break;
 
         case VBOX_CLIPBOARD_WM_SET_FORMATS:
         {
-            /* Announce available formats. Do not insert data, they will be inserted in WM_RENDER*. */
-            uint32_t u32Formats = (uint32_t)lParam;
-
-            LogFlowFunc(("VBOX_WM_SHCLPB_SET_FORMATS: u32Formats=0x%x\n", u32Formats));
-
-            int vboxrc = VBoxClipboardWinOpen(hwnd);
-            if (RT_SUCCESS(vboxrc))
-            {
-                VBoxClipboardWinClear();
-
-                HANDLE hClip = NULL;
-
-                if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
-                    hClip = SetClipboardData(CF_UNICODETEXT, NULL);
-
-                if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_BITMAP)
-                    hClip = SetClipboardData(CF_DIB, NULL);
-
-                if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_HTML)
-                {
-                    UINT format = RegisterClipboardFormat ("HTML Format");
-                    if (format != 0)
-                        hClip = SetClipboardData(format, NULL);
-                }
-
-                VBoxClipboardWinClose();
-
-                LogFlowFunc(("VBOX_WM_SHCLPB_SET_FORMATS: hClip=%p, lastErr=%ld\n", hClip, GetLastError()));
-            }
-        } break;
+           /* Announce available formats. Do not insert data, they will be inserted in WM_RENDER*. */
+           uint32_t u32Formats = (uint32_t)lParam;
+
+           LogFlowFunc(("VBOX_WM_SHCLPB_SET_FORMATS: u32Formats=0x%x\n", u32Formats));
+
+           int vboxrc = VBoxClipboardWinOpen(hwnd);
+           if (RT_SUCCESS(vboxrc))
+           {
+               VBoxClipboardWinClear();
+
+               HANDLE hClip = NULL;
+
+               if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
+                   hClip = SetClipboardData(CF_UNICODETEXT, NULL);
+
+               if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_BITMAP)
+                   hClip = SetClipboardData(CF_DIB, NULL);
+
+               if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_HTML)
+               {
+                   UINT format = RegisterClipboardFormat("HTML Format");
+                   if (format != 0)
+                       hClip = SetClipboardData(format, NULL);
+               }
+
+               VBoxClipboardWinClose();
+
+               LogFlowFunc(("VBOX_WM_SHCLPB_SET_FORMATS: hClip=%p, lastErr=%ld\n", hClip, GetLastError()));
+           }
+        }
+        break;
 
         case VBOX_CLIPBOARD_WM_READ_DATA:
         {
-            /* Send data in the specified format to the host. */
-            uint32_t u32Formats = (uint32_t)lParam;
-            HANDLE hClip = NULL;
-
-            LogFlowFunc(("VBOX_WM_SHCLPB_READ_DATA: u32Formats=0x%x\n", u32Formats));
-
-            int vboxrc = VBoxClipboardWinOpen(hwnd);
-            if (RT_SUCCESS(vboxrc))
-            {
-                if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_BITMAP)
-                {
-                    hClip = GetClipboardData(CF_DIB);
-
-                    if (hClip != NULL)
-                    {
-                        LPVOID lp = GlobalLock(hClip);
-                        if (lp != NULL)
-                        {
-                            vboxrc = VbglR3ClipboardWriteData(pCtx->u32ClientID, VBOX_SHARED_CLIPBOARD_FMT_BITMAP,
-                                                              lp, GlobalSize(hClip));
-                            GlobalUnlock(hClip);
-                        }
-                        else
-                        {
-                            hClip = NULL;
-                        }
-                    }
-                }
-                else if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
-                {
-                    hClip = GetClipboardData(CF_UNICODETEXT);
-
-                    if (hClip != NULL)
-                    {
-                        LPWSTR uniString = (LPWSTR)GlobalLock(hClip);
-
-                        if (uniString != NULL)
-                        {
-                            vboxrc = VbglR3ClipboardWriteData(pCtx->u32ClientID, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT,
-                                                              uniString, (lstrlenW(uniString) + 1) * 2);
-                            GlobalUnlock(hClip);
-                        }
-                        else
-                        {
-                            hClip = NULL;
-                        }
-                    }
-                }
-                else if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_HTML)
-                {
-                    UINT format = RegisterClipboardFormat ("HTML Format");
-                    if (format != 0)
-                    {
-                        hClip = GetClipboardData(format);
-                        if (hClip != NULL)
-                        {
-                            LPVOID lp = GlobalLock(hClip);
-
-                            if (lp != NULL)
-                            {
-                                vboxrc = VbglR3ClipboardWriteData(pCtx->u32ClientID, VBOX_SHARED_CLIPBOARD_FMT_HTML,
-                                                                  lp, GlobalSize(hClip));
-                                GlobalUnlock(hClip);
-                            }
-                            else
-                            {
-                                hClip = NULL;
-                            }
-                        }
-                    }
-                }
-
-                VBoxClipboardWinClose();
-            }
-
-            if (hClip == NULL)
-            {
-                /* Requested clipboard format is not available, send empty data. */
-                VbglR3ClipboardWriteData(pCtx->u32ClientID, 0, NULL, 0);
-            }
-        } break;
+           /* Send data in the specified format to the host. */
+           uint32_t u32Formats = (uint32_t)lParam;
+           HANDLE hClip = NULL;
+
+           LogFlowFunc(("VBOX_WM_SHCLPB_READ_DATA: u32Formats=0x%x\n", u32Formats));
+
+           int vboxrc = VBoxClipboardWinOpen(hwnd);
+           if (RT_SUCCESS(vboxrc))
+           {
+               if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_BITMAP)
+               {
+                   hClip = GetClipboardData(CF_DIB);
+
+                   if (hClip != NULL)
+                   {
+                       LPVOID lp = GlobalLock(hClip);
+                       if (lp != NULL)
+                       {
+                           vboxrc = VbglR3ClipboardWriteData(pCtx->u32ClientID, VBOX_SHARED_CLIPBOARD_FMT_BITMAP,
+                                                             lp, GlobalSize(hClip));
+                           GlobalUnlock(hClip);
+                       }
+                       else
+                       {
+                           hClip = NULL;
+                       }
+                   }
+               }
+               else if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
+               {
+                   hClip = GetClipboardData(CF_UNICODETEXT);
+
+                   if (hClip != NULL)
+                   {
+                       LPWSTR uniString = (LPWSTR)GlobalLock(hClip);
+
+                       if (uniString != NULL)
+                       {
+                           vboxrc = VbglR3ClipboardWriteData(pCtx->u32ClientID, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT,
+                                                             uniString, (lstrlenW(uniString) + 1) * 2);
+                           GlobalUnlock(hClip);
+                       }
+                       else
+                       {
+                           hClip = NULL;
+                       }
+                   }
+               }
+               else if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_HTML)
+               {
+                   UINT format = RegisterClipboardFormat("HTML Format");
+                   if (format != 0)
+                   {
+                       hClip = GetClipboardData(format);
+                       if (hClip != NULL)
+                       {
+                           LPVOID lp = GlobalLock(hClip);
+
+                           if (lp != NULL)
+                           {
+                               vboxrc = VbglR3ClipboardWriteData(pCtx->u32ClientID, VBOX_SHARED_CLIPBOARD_FMT_HTML,
+                                                                 lp, GlobalSize(hClip));
+                               GlobalUnlock(hClip);
+                           }
+                           else
+                           {
+                               hClip = NULL;
+                           }
+                       }
+                   }
+               }
+
+               VBoxClipboardWinClose();
+           }
+
+           if (hClip == NULL)
+           {
+               /* Requested clipboard format is not available, send empty data. */
+               VbglR3ClipboardWriteData(pCtx->u32ClientID, 0, NULL, 0);
+           }
+        }
+        break;
 
         case WM_DESTROY:
         {
-            VBoxClipboardWinRemoveFromCBChain(pWinCtx);
-            if (pWinCtx->oldAPI.timerRefresh)
-                KillTimer(pWinCtx->hWnd, 0);
-            /*
-             * don't need to call PostQuitMessage cause
-             * the VBoxTray already finished a message loop
-             */
-        } break;
+           VBoxClipboardWinRemoveFromCBChain(pWinCtx);
+           if (pWinCtx->oldAPI.timerRefresh)
+               KillTimer(pWinCtx->hWnd, 0);
+           /*
+            * don't need to call PostQuitMessage cause
+            * the VBoxTray already finished a message loop
+            */
+        }
+        break;
 
         default:
         {
-            rc = DefWindowProc(hwnd, msg, wParam, lParam);
-        }
+           rc = DefWindowProc(hwnd, msg, wParam, lParam);
+        }
+        break;
     }
 
@@ -660,32 +671,36 @@
             switch (u32Msg)
             {
-                case VBOX_SHARED_CLIPBOARD_HOST_MSG_FORMATS:
-                {
-                    /* The host has announced available clipboard formats.
-                     * Forward the information to the window, so it can later
-                     * respond to WM_RENDERFORMAT message. */
-                    ::PostMessage(pWinCtx->hWnd, VBOX_CLIPBOARD_WM_SET_FORMATS, 0, u32Formats);
-                } break;
-
-                case VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA:
-                {
-                    /* The host needs data in the specified format. */
-                    ::PostMessage(pWinCtx->hWnd, VBOX_CLIPBOARD_WM_READ_DATA, 0, u32Formats);
-                } break;
-
-                case VBOX_SHARED_CLIPBOARD_HOST_MSG_QUIT:
-                {
-                    /* The host is terminating. */
-                    LogRel(("Clipboard: Terminating ...\n"));
-                    ASMAtomicXchgBool(pfShutdown, true);
-                } break;
-
-                default:
-                {
-                    LogFlowFunc(("Unsupported message from host, message=%RU32\n", u32Msg));
-
-                    /* Wait a bit before retrying. */
-                    RTThreadSleep(1000);
-                } break;
+               case VBOX_SHARED_CLIPBOARD_HOST_MSG_FORMATS:
+               {
+                   /* The host has announced available clipboard formats.
+                    * Forward the information to the window, so it can later
+                    * respond to WM_RENDERFORMAT message. */
+                   ::PostMessage(pWinCtx->hWnd, VBOX_CLIPBOARD_WM_SET_FORMATS, 0, u32Formats);
+               }
+                   break;
+
+               case VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA:
+               {
+                   /* The host needs data in the specified format. */
+                   ::PostMessage(pWinCtx->hWnd, VBOX_CLIPBOARD_WM_READ_DATA, 0, u32Formats);
+               }
+                   break;
+
+               case VBOX_SHARED_CLIPBOARD_HOST_MSG_QUIT:
+               {
+                   /* The host is terminating. */
+                   LogRel(("Clipboard: Terminating ...\n"));
+                   ASMAtomicXchgBool(pfShutdown, true);
+               }
+                   break;
+
+               default:
+               {
+                   LogFlowFunc(("Unsupported message from host, message=%RU32\n", u32Msg));
+
+                   /* Wait a bit before retrying. */
+                   RTThreadSleep(1000);
+               }
+                   break;
             }
         }
Index: /trunk/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp
===================================================================
--- /trunk/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp	(revision 78170)
+++ /trunk/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp	(revision 78171)
@@ -134,8 +134,8 @@
     if (RT_SUCCESS(rc))
     {
-        rc = RTLdrGetSymbol(hUser32, "AddClipboardFormatListener", (void**)&pAPI->pfnAddClipboardFormatListener);
+        rc = RTLdrGetSymbol(hUser32, "AddClipboardFormatListener", (void **)&pAPI->pfnAddClipboardFormatListener);
         if (RT_SUCCESS(rc))
         {
-            rc = RTLdrGetSymbol(hUser32, "RemoveClipboardFormatListener", (void**)&pAPI->pfnRemoveClipboardFormatListener);
+            rc = RTLdrGetSymbol(hUser32, "RemoveClipboardFormatListener", (void **)&pAPI->pfnRemoveClipboardFormatListener);
         }
 
Index: /trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp	(revision 78170)
+++ /trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp	(revision 78171)
@@ -103,14 +103,14 @@
 }
 #else  /* !LOG_ENABLED */
-# define vboxClipboardDump(__pv, __cb, __format) do { NOREF(__pv); NOREF(__cb); NOREF(__format); } while (0)
+#   define vboxClipboardDump(__pv, __cb, __format) do { NOREF(__pv); NOREF(__cb); NOREF(__format); } while (0)
 #endif /* !LOG_ENABLED */
 
 /** @todo Someone please explain the protocol wrt overflows...  */
-static void vboxClipboardGetData (uint32_t u32Format, const void *pvSrc, uint32_t cbSrc,
-                                  void *pvDst, uint32_t cbDst, uint32_t *pcbActualDst)
+static void vboxClipboardGetData(uint32_t u32Format, const void *pvSrc, uint32_t cbSrc,
+                                 void *pvDst, uint32_t cbDst, uint32_t *pcbActualDst)
 {
     LogFlow(("vboxClipboardGetData cbSrc = %d, cbDst = %d\n", cbSrc, cbDst));
 
-    if (   u32Format == VBOX_SHARED_CLIPBOARD_FMT_HTML
+    if (u32Format == VBOX_SHARED_CLIPBOARD_FMT_HTML
         && IsWindowsHTML((const char *)pvSrc))
     {
@@ -118,5 +118,5 @@
         char *pszBuf = NULL;
         uint32_t cbBuf = 0;
-        int rc = ConvertCFHtmlToMime((const char*)pvSrc, cbSrc, &pszBuf, &cbBuf);
+        int rc = ConvertCFHtmlToMime((const char *)pvSrc, cbSrc, &pszBuf, &cbBuf);
         if (RT_SUCCESS(rc))
         {
@@ -152,5 +152,5 @@
 }
 
-static int vboxClipboardReadDataFromClient (VBOXCLIPBOARDCONTEXT *pCtx, uint32_t u32Format)
+static int vboxClipboardReadDataFromClient(VBOXCLIPBOARDCONTEXT *pCtx, uint32_t u32Format)
 {
     Assert(pCtx->pClient);
@@ -160,7 +160,7 @@
     LogFlow(("vboxClipboardReadDataFromClient u32Format = %02X\n", u32Format));
 
-    ResetEvent (pCtx->hRenderEvent);
-
-    vboxSvcClipboardReportMsg (pCtx->pClient, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA, u32Format);
+    ResetEvent(pCtx->hRenderEvent);
+
+    vboxSvcClipboardReportMsg(pCtx->pClient, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA, u32Format);
 
     DWORD ret = WaitForSingleObject(pCtx->hRenderEvent, INFINITE);
@@ -475,5 +475,5 @@
 }
 
-DECLCALLBACK(int) VBoxClipboardThread (RTTHREAD hThreadSelf, void *pvUser)
+DECLCALLBACK(int) VBoxClipboardThread(RTTHREAD hThreadSelf, void *pvUser)
 {
     RT_NOREF2(hThreadSelf, pvUser);
@@ -508,8 +508,8 @@
     {
         /* Create the window. */
-        pWinCtx->hWnd = CreateWindowEx (WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT | WS_EX_TOPMOST,
-                                        s_szClipWndClassName, s_szClipWndClassName,
-                                        WS_POPUPWINDOW,
-                                        -200, -200, 100, 100, NULL, NULL, hInstance, NULL);
+        pWinCtx->hWnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT | WS_EX_TOPMOST,
+                                       s_szClipWndClassName, s_szClipWndClassName,
+                                       WS_POPUPWINDOW,
+                                       -200, -200, 100, 100, NULL, NULL, hInstance, NULL);
         if (pWinCtx->hWnd == NULL)
         {
@@ -547,5 +547,5 @@
     if (atomWindowClass != 0)
     {
-        UnregisterClass (s_szClipWndClassName, hInstance);
+        UnregisterClass(s_szClipWndClassName, hInstance);
         atomWindowClass = 0;
     }
@@ -579,5 +579,5 @@
  * Public platform dependent functions.
  */
-int vboxClipboardInit (void)
+int vboxClipboardInit(void)
 {
     int rc = VINF_SUCCESS;
@@ -590,10 +590,10 @@
     g_ctx.hRenderEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
 
-    rc = RTThreadCreate (&g_ctx.hThread, VBoxClipboardThread, NULL, 65536,
-                         RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "SHCLIP");
-
-    if (RT_FAILURE (rc))
-    {
-        CloseHandle (g_ctx.hRenderEvent);
+    rc = RTThreadCreate(&g_ctx.hThread, VBoxClipboardThread, NULL, 65536,
+                        RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "SHCLIP");
+
+    if (RT_FAILURE(rc))
+    {
+        CloseHandle(g_ctx.hRenderEvent);
     }
 
@@ -601,5 +601,5 @@
 }
 
-void vboxClipboardDestroy (void)
+void vboxClipboardDestroy(void)
 {
     Log(("vboxClipboardDestroy\n"));
@@ -607,16 +607,16 @@
     if (g_ctx.Win.hWnd)
     {
-        PostMessage (g_ctx.Win.hWnd, WM_CLOSE, 0, 0);
-    }
-
-    CloseHandle (g_ctx.hRenderEvent);
+        PostMessage(g_ctx.Win.hWnd, WM_CLOSE, 0, 0);
+    }
+
+    CloseHandle(g_ctx.hRenderEvent);
 
     /* Wait for the window thread to terminate. */
-    RTThreadWait (g_ctx.hThread, RT_INDEFINITE_WAIT, NULL);
+    RTThreadWait(g_ctx.hThread, RT_INDEFINITE_WAIT, NULL);
 
     g_ctx.hThread = NIL_RTTHREAD;
 }
 
-int vboxClipboardConnect (VBOXCLIPBOARDCLIENTDATA *pClient, bool fHeadless)
+int vboxClipboardConnect(VBOXCLIPBOARDCLIENTDATA *pClient, bool fHeadless)
 {
     NOREF(fHeadless);
@@ -634,10 +634,10 @@
 
     /* Sync the host clipboard content with the client. */
-    vboxClipboardSync (pClient);
+    vboxClipboardSync(pClient);
 
     return VINF_SUCCESS;
 }
 
-int vboxClipboardSync (VBOXCLIPBOARDCLIENTDATA *pClient)
+int vboxClipboardSync(VBOXCLIPBOARDCLIENTDATA *pClient)
 {
     /* Sync the host clipboard content with the client. */
@@ -645,5 +645,5 @@
 }
 
-void vboxClipboardDisconnect (VBOXCLIPBOARDCLIENTDATA *pClient)
+void vboxClipboardDisconnect(VBOXCLIPBOARDCLIENTDATA *pClient)
 {
     RT_NOREF1(pClient);
@@ -653,5 +653,5 @@
 }
 
-void vboxClipboardFormatAnnounce (VBOXCLIPBOARDCLIENTDATA *pClient, uint32_t u32Formats)
+void vboxClipboardFormatAnnounce(VBOXCLIPBOARDCLIENTDATA *pClient, uint32_t u32Formats)
 {
     AssertPtrReturnVoid(pClient);
@@ -661,5 +661,5 @@
      * The guest announces formats. Forward to the window thread.
      */
-    PostMessage (pClient->pCtx->Win.hWnd, WM_USER, 0, u32Formats);
+    PostMessage(pClient->pCtx->Win.hWnd, WM_USER, 0, u32Formats);
 }
 
@@ -694,5 +694,5 @@
 }
 
-int vboxClipboardReadData (VBOXCLIPBOARDCLIENTDATA *pClient, uint32_t u32Format, void *pv, uint32_t cb, uint32_t *pcbActual)
+int vboxClipboardReadData(VBOXCLIPBOARDCLIENTDATA *pClient, uint32_t u32Format, void *pv, uint32_t cb, uint32_t *pcbActual)
 {
     AssertPtrReturn(pClient,       VERR_INVALID_POINTER);
@@ -715,9 +715,9 @@
         if (u32Format & VBOX_SHARED_CLIPBOARD_FMT_BITMAP)
         {
-            hClip = GetClipboardData (CF_DIB);
+            hClip = GetClipboardData(CF_DIB);
 
             if (hClip != NULL)
             {
-                LPVOID lp = GlobalLock (hClip);
+                LPVOID lp = GlobalLock(hClip);
 
                 if (lp != NULL)
@@ -725,6 +725,6 @@
                     LogFunc(("CF_DIB\n"));
 
-                    vboxClipboardGetData (VBOX_SHARED_CLIPBOARD_FMT_BITMAP, lp, GlobalSize (hClip),
-                                          pv, cb, pcbActual);
+                    vboxClipboardGetData(VBOX_SHARED_CLIPBOARD_FMT_BITMAP, lp, GlobalSize(hClip),
+                                         pv, cb, pcbActual);
 
                     GlobalUnlock(hClip);
@@ -742,5 +742,5 @@
             if (hClip != NULL)
             {
-                LPWSTR uniString = (LPWSTR)GlobalLock (hClip);
+                LPWSTR uniString = (LPWSTR)GlobalLock(hClip);
 
                 if (uniString != NULL)
@@ -748,6 +748,6 @@
                     LogFunc(("CF_UNICODETEXT\n"));
 
-                    vboxClipboardGetData (VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT, uniString, (lstrlenW (uniString) + 1) * 2,
-                                          pv, cb, pcbActual);
+                    vboxClipboardGetData(VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT, uniString, (lstrlenW(uniString) + 1) * 2,
+                                         pv, cb, pcbActual);
 
                     GlobalUnlock(hClip);
@@ -761,13 +761,13 @@
         else if (u32Format & VBOX_SHARED_CLIPBOARD_FMT_HTML)
         {
-            UINT format = RegisterClipboardFormat ("HTML Format");
+            UINT format = RegisterClipboardFormat("HTML Format");
 
             if (format != 0)
             {
-                hClip = GetClipboardData (format);
+                hClip = GetClipboardData(format);
 
                 if (hClip != NULL)
                 {
-                    LPVOID lp = GlobalLock (hClip);
+                    LPVOID lp = GlobalLock(hClip);
 
                     if (lp != NULL)
@@ -775,8 +775,8 @@
                         LogFunc(("CF_HTML\n"));
 
-                        vboxClipboardGetData (VBOX_SHARED_CLIPBOARD_FMT_HTML, lp, GlobalSize (hClip),
-                                              pv, cb, pcbActual);
+                        vboxClipboardGetData(VBOX_SHARED_CLIPBOARD_FMT_HTML, lp, GlobalSize(hClip),
+                                             pv, cb, pcbActual);
                         LogRelFlowFunc(("Raw HTML clipboard data from host :"));
-                        DumpHtml((char*)pv, cb);
+                        DumpHtml((char *)pv, cb);
                         GlobalUnlock(hClip);
                     }
@@ -799,6 +799,6 @@
     {
         /* Reply with empty data. */
-        vboxClipboardGetData (0, NULL, 0,
-                              pv, cb, pcbActual);
+        vboxClipboardGetData(0, NULL, 0,
+                             pv, cb, pcbActual);
     }
 
@@ -806,5 +806,5 @@
 }
 
-void vboxClipboardWriteData (VBOXCLIPBOARDCLIENTDATA *pClient, void *pv, uint32_t cb, uint32_t u32Format)
+void vboxClipboardWriteData(VBOXCLIPBOARDCLIENTDATA *pClient, void *pv, uint32_t cb, uint32_t u32Format)
 {
     LogFlow(("vboxClipboardWriteData\n"));
@@ -888,6 +888,6 @@
 static bool IsWindowsHTML(const char *pszSource)
 {
-    return RTStrStr(pszSource, "Version:") != NULL
-        && RTStrStr(pszSource, "StartHTML:") != NULL;
+    return    RTStrStr(pszSource, "Version:") != NULL
+           && RTStrStr(pszSource, "StartHTML:") != NULL;
 }
 
@@ -1037,5 +1037,5 @@
     /* 166+2: */ "</html>\r\n";
     /* 175+2: */
-    AssertCompile(sizeof(s_szFormatSample) == 175+2+1);
+    AssertCompile(sizeof(s_szFormatSample) == 175 + 2 + 1);
 
     /* calculate parameters of CF_HTML header */
Index: /trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp	(revision 78170)
+++ /trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp	(revision 78171)
@@ -110,5 +110,5 @@
 
 
-static void VBoxHGCMParmUInt32Set (VBOXHGCMSVCPARM *pParm, uint32_t u32)
+static void VBoxHGCMParmUInt32Set(VBOXHGCMSVCPARM *pParm, uint32_t u32)
 {
     pParm->type = VBOX_HGCM_SVC_PARM_32BIT;
@@ -116,5 +116,5 @@
 }
 
-static int VBoxHGCMParmUInt32Get (VBOXHGCMSVCPARM *pParm, uint32_t *pu32)
+static int VBoxHGCMParmUInt32Get(VBOXHGCMSVCPARM *pParm, uint32_t *pu32)
 {
     if (pParm->type == VBOX_HGCM_SVC_PARM_32BIT)
@@ -136,5 +136,5 @@
 #endif
 
-static int VBoxHGCMParmPtrGet (VBOXHGCMSVCPARM *pParm, void **ppv, uint32_t *pcb)
+static int VBoxHGCMParmPtrGet(VBOXHGCMSVCPARM *pParm, void **ppv, uint32_t *pcb)
 {
     if (pParm->type == VBOX_HGCM_SVC_PARM_PTR)
@@ -149,5 +149,5 @@
 
 
-static uint32_t vboxSvcClipboardMode (void)
+static uint32_t vboxSvcClipboardMode(void)
 {
     return g_u32Mode;
@@ -168,5 +168,5 @@
 }
 
-static void vboxSvcClipboardModeSet (uint32_t u32Mode)
+static void vboxSvcClipboardModeSet(uint32_t u32Mode)
 {
     switch (u32Mode)
@@ -186,5 +186,5 @@
 bool VBoxSvcClipboardLock(void)
 {
-    return RT_SUCCESS(RTCritSectEnter (&critsect));
+    return RT_SUCCESS(RTCritSectEnter(&critsect));
 }
 
@@ -197,5 +197,5 @@
  * Executed under the clipboard lock.
  */
-static bool vboxSvcClipboardReturnMsg (VBOXCLIPBOARDCLIENTDATA *pClient, VBOXHGCMSVCPARM paParms[])
+static bool vboxSvcClipboardReturnMsg(VBOXCLIPBOARDCLIENTDATA *pClient, VBOXHGCMSVCPARM paParms[])
 {
     /* Message priority is taken into account. */
@@ -203,6 +203,6 @@
     {
         LogRelFlow(("vboxSvcClipboardReturnMsg: Quit\n"));
-        VBoxHGCMParmUInt32Set (&paParms[0], VBOX_SHARED_CLIPBOARD_HOST_MSG_QUIT);
-        VBoxHGCMParmUInt32Set (&paParms[1], 0);
+        VBoxHGCMParmUInt32Set(&paParms[0], VBOX_SHARED_CLIPBOARD_HOST_MSG_QUIT);
+        VBoxHGCMParmUInt32Set(&paParms[1], 0);
         pClient->fMsgQuit = false;
     }
@@ -221,6 +221,6 @@
             AssertStmt(pClient->u32RequestedFormat == 0, pClient->u32RequestedFormat = 0);
         pClient->u32RequestedFormat &= ~fFormat;
-        VBoxHGCMParmUInt32Set (&paParms[0], VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA);
-        VBoxHGCMParmUInt32Set (&paParms[1], fFormat);
+        VBoxHGCMParmUInt32Set(&paParms[0], VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA);
+        VBoxHGCMParmUInt32Set(&paParms[1], fFormat);
         if (pClient->u32RequestedFormat == 0)
             pClient->fMsgReadData = false;
@@ -229,6 +229,6 @@
     {
         LogRelFlow(("vboxSvcClipboardReturnMsg: Formats %02X\n", pClient->u32AvailableFormats));
-        VBoxHGCMParmUInt32Set (&paParms[0], VBOX_SHARED_CLIPBOARD_HOST_MSG_FORMATS);
-        VBoxHGCMParmUInt32Set (&paParms[1], pClient->u32AvailableFormats);
+        VBoxHGCMParmUInt32Set(&paParms[0], VBOX_SHARED_CLIPBOARD_HOST_MSG_FORMATS);
+        VBoxHGCMParmUInt32Set(&paParms[1], pClient->u32AvailableFormats);
         pClient->fMsgFormats = false;
     }
@@ -244,5 +244,5 @@
 }
 
-void vboxSvcClipboardReportMsg (VBOXCLIPBOARDCLIENTDATA *pClient, uint32_t u32Msg, uint32_t u32Formats)
+void vboxSvcClipboardReportMsg(VBOXCLIPBOARDCLIENTDATA *pClient, uint32_t u32Msg, uint32_t u32Formats)
 {
     AssertPtrReturnVoid(pClient);
@@ -293,5 +293,5 @@
         {
             /* The client waits for a response. */
-            bool fMessageReturned = vboxSvcClipboardReturnMsg (pClient, pClient->async.paParms);
+            bool fMessageReturned = vboxSvcClipboardReturnMsg(pClient, pClient->async.paParms);
 
             /* Make a copy of the handle. */
@@ -309,5 +309,5 @@
             {
                 LogRelFlow(("vboxSvcClipboardReportMsg: CallComplete\n"));
-                g_pHelpers->pfnCallComplete (callHandle, VINF_SUCCESS);
+                g_pHelpers->pfnCallComplete(callHandle, VINF_SUCCESS);
             }
         }
@@ -319,20 +319,20 @@
 }
 
-static int svcInit (void)
-{
-    int rc = RTCritSectInit (&critsect);
-
-    if (RT_SUCCESS (rc))
-    {
-        vboxSvcClipboardModeSet (VBOX_SHARED_CLIPBOARD_MODE_OFF);
-
-        rc = vboxClipboardInit ();
+static int svcInit(void)
+{
+    int rc = RTCritSectInit(&critsect);
+
+    if (RT_SUCCESS(rc))
+    {
+        vboxSvcClipboardModeSet(VBOX_SHARED_CLIPBOARD_MODE_OFF);
+
+        rc = vboxClipboardInit();
 
         /* Clean up on failure, because 'svnUnload' will not be called
          * if the 'svcInit' returns an error.
          */
-        if (RT_FAILURE (rc))
-        {
-            RTCritSectDelete (&critsect);
+        if (RT_FAILURE(rc))
+        {
+            RTCritSectDelete(&critsect);
         }
     }
@@ -341,8 +341,8 @@
 }
 
-static DECLCALLBACK(int) svcUnload (void *)
-{
-    vboxClipboardDestroy ();
-    RTCritSectDelete (&critsect);
+static DECLCALLBACK(int) svcUnload(void *)
+{
+    vboxClipboardDestroy();
+    RTCritSectDelete(&critsect);
     return VINF_SUCCESS;
 }
@@ -352,5 +352,5 @@
  * to the guest side.
  */
-static DECLCALLBACK(int) svcDisconnect (void *, uint32_t u32ClientID, void *pvClient)
+static DECLCALLBACK(int) svcDisconnect(void *, uint32_t u32ClientID, void *pvClient)
 {
     VBOXCLIPBOARDCLIENTDATA *pClient = (VBOXCLIPBOARDCLIENTDATA *)pvClient;
@@ -358,11 +358,11 @@
     LogRel2(("svcDisconnect: u32ClientID = %d\n", u32ClientID));
 
-    vboxSvcClipboardReportMsg (pClient, VBOX_SHARED_CLIPBOARD_HOST_MSG_QUIT, 0);
+    vboxSvcClipboardReportMsg(pClient, VBOX_SHARED_CLIPBOARD_HOST_MSG_QUIT, 0);
 
     vboxSvcClipboardCompleteReadData(pClient, VERR_NO_DATA, 0);
 
-    vboxClipboardDisconnect (pClient);
-
-    memset (pClient, 0, sizeof (*pClient));
+    vboxClipboardDisconnect(pClient);
+
+    memset(pClient, 0, sizeof(*pClient));
 
     g_pClient = NULL;
@@ -371,5 +371,5 @@
 }
 
-static DECLCALLBACK(int) svcConnect (void *, uint32_t u32ClientID, void *pvClient, uint32_t fRequestor, bool fRestoring)
+static DECLCALLBACK(int) svcConnect(void *, uint32_t u32ClientID, void *pvClient, uint32_t fRequestor, bool fRestoring)
 {
     RT_NOREF(fRequestor, fRestoring);
@@ -389,11 +389,11 @@
 
     /* Register the client. */
-    memset (pClient, 0, sizeof (*pClient));
+    memset(pClient, 0, sizeof(*pClient));
 
     pClient->u32ClientID = u32ClientID;
 
-    rc = vboxClipboardConnect (pClient, VBoxSvcClipboardGetHeadless());
-
-    if (RT_SUCCESS (rc))
+    rc = vboxClipboardConnect(pClient, VBoxSvcClipboardGetHeadless());
+
+    if (RT_SUCCESS(rc))
     {
         g_pClient = pClient;
@@ -405,12 +405,12 @@
 }
 
-static DECLCALLBACK(void) svcCall (void *,
-                                   VBOXHGCMCALLHANDLE callHandle,
-                                   uint32_t u32ClientID,
-                                   void *pvClient,
-                                   uint32_t u32Function,
-                                   uint32_t cParms,
-                                   VBOXHGCMSVCPARM paParms[],
-                                   uint64_t tsArrival)
+static DECLCALLBACK(void) svcCall(void *,
+                                  VBOXHGCMCALLHANDLE callHandle,
+                                  uint32_t u32ClientID,
+                                  void *pvClient,
+                                  uint32_t u32Function,
+                                  uint32_t cParms,
+                                  VBOXHGCMSVCPARM paParms[],
+                                  uint64_t tsArrival)
 {
     RT_NOREF_PV(tsArrival);
@@ -690,5 +690,5 @@
     if (!fAsynchronousProcessing)
     {
-        g_pHelpers->pfnCallComplete (callHandle, rc);
+        g_pHelpers->pfnCallComplete(callHandle, rc);
     }
 }
@@ -712,6 +712,6 @@
     if (fReadPending)
     {
-        VBoxHGCMParmUInt32Set (&paParms[2], cbActual);
-        g_pHelpers->pfnCallComplete (callHandle, rc);
+        VBoxHGCMParmUInt32Set(&paParms[2], cbActual);
+        g_pHelpers->pfnCallComplete(callHandle, rc);
     }
 }
@@ -720,13 +720,13 @@
  * We differentiate between a function handler for the guest and one for the host.
  */
-static DECLCALLBACK(int) svcHostCall (void *,
-                                      uint32_t u32Function,
-                                      uint32_t cParms,
-                                      VBOXHGCMSVCPARM paParms[])
+static DECLCALLBACK(int) svcHostCall(void *,
+                                     uint32_t u32Function,
+                                     uint32_t cParms,
+                                     VBOXHGCMSVCPARM paParms[])
 {
     int rc = VINF_SUCCESS;
 
     LogRel2(("svcHostCall: fn = %d, cParms = %d, pparms = %d\n",
-         u32Function, cParms, paParms));
+             u32Function, cParms, paParms));
 
     switch (u32Function)
@@ -802,5 +802,5 @@
      * Pending requests, if any, will be completed in svcDisconnect.
      */
-    LogRel2 (("svcSaveState: u32ClientID = %d\n", u32ClientID));
+    LogRel2(("svcSaveState: u32ClientID = %d\n", u32ClientID));
 
     VBOXCLIPBOARDCLIENTDATA *pClient = (VBOXCLIPBOARDCLIENTDATA *)pvClient;
@@ -808,7 +808,7 @@
     /* This field used to be the length. We're using it as a version field
        with the high bit set. */
-    SSMR3PutU32 (pSSM, UINT32_C (0x80000002));
-    int rc = SSMR3PutStructEx (pSSM, pClient, sizeof(*pClient), 0 /*fFlags*/, &g_aClipboardClientDataFields[0], NULL);
-    AssertRCReturn (rc, rc);
+    SSMR3PutU32(pSSM, UINT32_C(0x80000002));
+    int rc = SSMR3PutStructEx(pSSM, pClient, sizeof(*pClient), 0 /*fFlags*/, &g_aClipboardClientDataFields[0], NULL);
+    AssertRCReturn(rc, rc);
 
 #else  /* UNIT_TEST */
@@ -844,13 +844,15 @@
     bool fMsgFormats: 1;
 
-    struct {
+    struct
+    {
         VBOXHGCMCALLHANDLE callHandle;
         VBOXHGCMSVCPARM *paParms;
     } async;
 
-    struct {
-         void *pv;
-         uint32_t cb;
-         uint32_t u32Format;
+    struct
+    {
+        void *pv;
+        uint32_t cb;
+        uint32_t u32Format;
     } data;
 
@@ -864,10 +866,10 @@
 #ifndef UNIT_TEST
     RT_NOREF(uVersion);
-    LogRel2 (("svcLoadState: u32ClientID = %d\n", u32ClientID));
+    LogRel2(("svcLoadState: u32ClientID = %d\n", u32ClientID));
 
     VBOXCLIPBOARDCLIENTDATA *pClient = (VBOXCLIPBOARDCLIENTDATA *)pvClient;
 
     /* Existing client can not be in async state yet. */
-    Assert (!pClient->fAsync);
+    Assert(!pClient->fAsync);
 
     /* Save the client ID for data validation. */
@@ -877,12 +879,12 @@
     /* Restore the client data. */
     uint32_t lenOrVer;
-    int rc = SSMR3GetU32 (pSSM, &lenOrVer);
-    AssertRCReturn (rc, rc);
-    if (lenOrVer == UINT32_C (0x80000002))
-    {
-        rc = SSMR3GetStructEx (pSSM, pClient, sizeof(*pClient), 0 /*fFlags*/, &g_aClipboardClientDataFields[0], NULL);
-        AssertRCReturn (rc, rc);
-    }
-    else if (lenOrVer == (SSMR3HandleHostBits (pSSM) == 64 ? 72U : 48U))
+    int rc = SSMR3GetU32(pSSM, &lenOrVer);
+    AssertRCReturn(rc, rc);
+    if (lenOrVer == UINT32_C(0x80000002))
+    {
+        rc = SSMR3GetStructEx(pSSM, pClient, sizeof(*pClient), 0 /*fFlags*/, &g_aClipboardClientDataFields[0], NULL);
+        AssertRCReturn(rc, rc);
+    }
+    else if (lenOrVer == (SSMR3HandleHostBits(pSSM) == 64 ? 72U : 48U))
     {
         /**
@@ -907,8 +909,8 @@
 
         CLIPSAVEDSTATEDATA savedState;
-        RT_ZERO (savedState);
-        rc = SSMR3GetStructEx (pSSM, &savedState, sizeof(savedState), SSMSTRUCT_FLAGS_MEM_BAND_AID,
-                               &s_aClipSavedStateDataFields30[0], NULL);
-        AssertRCReturn (rc, rc);
+        RT_ZERO(savedState);
+        rc = SSMR3GetStructEx(pSSM, &savedState, sizeof(savedState), SSMSTRUCT_FLAGS_MEM_BAND_AID,
+                              &s_aClipSavedStateDataFields30[0], NULL);
+        AssertRCReturn(rc, rc);
 
         pClient->fMsgQuit           = savedState.fMsgQuit;
@@ -919,5 +921,5 @@
     else
     {
-        LogRel (("Client data size mismatch: got %#x\n", lenOrVer));
+        LogRel(("Client data size mismatch: got %#x\n", lenOrVer));
         return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
     }
@@ -926,5 +928,5 @@
     if (pClient->u32ClientID != u32ClientIDOld)
     {
-        LogRel (("Client ID mismatch: expected %d, got %d\n", u32ClientIDOld, pClient->u32ClientID));
+        LogRel(("Client ID mismatch: expected %d, got %d\n", u32ClientIDOld, pClient->u32ClientID));
         pClient->u32ClientID = u32ClientIDOld;
         return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
@@ -932,5 +934,5 @@
 
     /* Actual host data are to be reported to guest (SYNC). */
-    vboxClipboardSync (pClient);
+    vboxClipboardSync(pClient);
 
 #else  /* UNIT_TEST*/
@@ -940,5 +942,5 @@
 }
 
-static DECLCALLBACK(int) extCallback (uint32_t u32Function, uint32_t u32Format, void *pvData, uint32_t cbData)
+static DECLCALLBACK(int) extCallback(uint32_t u32Function, uint32_t u32Format, void *pvData, uint32_t cbData)
 {
     RT_NOREF2(pvData, cbData);
@@ -987,5 +989,5 @@
 
         parms.u.pfnCallback = extCallback;
-        g_pfnExtension (g_pvExtension, VBOX_CLIPBOARD_EXT_FN_SET_CALLBACK, &parms, sizeof (parms));
+        g_pfnExtension(g_pvExtension, VBOX_CLIPBOARD_EXT_FN_SET_CALLBACK, &parms, sizeof(parms));
     }
     else
@@ -994,5 +996,5 @@
         {
             parms.u.pfnCallback = NULL;
-            g_pfnExtension (g_pvExtension, VBOX_CLIPBOARD_EXT_FN_SET_CALLBACK, &parms, sizeof (parms));
+            g_pfnExtension(g_pvExtension, VBOX_CLIPBOARD_EXT_FN_SET_CALLBACK, &parms, sizeof(parms));
         }
 
@@ -1019,5 +1021,5 @@
         LogRel2(("VBoxHGCMSvcLoad: ptable->cbSize = %d, ptable->u32Version = 0x%08X\n", ptable->cbSize, ptable->u32Version));
 
-        if (   ptable->cbSize != sizeof (VBOXHGCMSVCFNTABLE)
+        if (   ptable->cbSize     != sizeof (VBOXHGCMSVCFNTABLE)
             || ptable->u32Version != VBOX_HGCM_SVC_VERSION)
         {
@@ -1028,5 +1030,5 @@
             g_pHelpers = ptable->pHelpers;
 
-            ptable->cbClient = sizeof (VBOXCLIPBOARDCLIENTDATA);
+            ptable->cbClient = sizeof(VBOXCLIPBOARDCLIENTDATA);
 
             ptable->pfnUnload     = svcUnload;
@@ -1042,5 +1044,5 @@
 
             /* Service specific initialization. */
-            rc = svcInit ();
+            rc = svcInit();
         }
     }
Index: /trunk/src/VBox/HostServices/SharedClipboard/testcase/tstClipboardServiceHost.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedClipboard/testcase/tstClipboardServiceHost.cpp	(revision 78170)
+++ /trunk/src/VBox/HostServices/SharedClipboard/testcase/tstClipboardServiceHost.cpp	(revision 78171)
@@ -121,6 +121,6 @@
                   2, parms, 0);
     RTTESTI_CHECK_RC(call.rc, VERR_TRY_AGAIN);  /* This should get updated only when the guest call completes. */
-    vboxSvcClipboardReportMsg (&g_Client, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA,
-                               VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
+    vboxSvcClipboardReportMsg(&g_Client, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA,
+                              VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
     RTTESTI_CHECK(parms[0].u.uint32 == VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA);
     RTTESTI_CHECK(parms[1].u.uint32 == VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
@@ -133,6 +133,6 @@
     RTTestISub("Testing FN_GET_HOST_MSG, one format, no waiting guest calls.");
     RT_ZERO(g_Client);
-    vboxSvcClipboardReportMsg (&g_Client, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA,
-                               VBOX_SHARED_CLIPBOARD_FMT_HTML);
+    vboxSvcClipboardReportMsg(&g_Client, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA,
+                              VBOX_SHARED_CLIPBOARD_FMT_HTML);
     HGCMSvcSetU32(&parms[0], 0);
     HGCMSvcSetU32(&parms[1], 0);
@@ -156,6 +156,6 @@
                   2, parms, 0);
     RTTESTI_CHECK_RC(call.rc, VERR_TRY_AGAIN);  /* This should get updated only when the guest call completes. */
-    vboxSvcClipboardReportMsg (&g_Client, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA,
-                               VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT | VBOX_SHARED_CLIPBOARD_FMT_HTML);
+    vboxSvcClipboardReportMsg(&g_Client, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA,
+                              VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT | VBOX_SHARED_CLIPBOARD_FMT_HTML);
     RTTESTI_CHECK(parms[0].u.uint32 == VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA);
     RTTESTI_CHECK(parms[1].u.uint32 == VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
@@ -174,6 +174,6 @@
     RTTestISub("Testing FN_GET_HOST_MSG, two formats, no waiting guest calls.");
     RT_ZERO(g_Client);
-    vboxSvcClipboardReportMsg (&g_Client, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA,
-                               VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT | VBOX_SHARED_CLIPBOARD_FMT_HTML);
+    vboxSvcClipboardReportMsg(&g_Client, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA,
+                              VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT | VBOX_SHARED_CLIPBOARD_FMT_HTML);
     HGCMSvcSetU32(&parms[0], 0);
     HGCMSvcSetU32(&parms[1], 0);
@@ -274,13 +274,13 @@
 
 int vboxClipboardInit() { return VINF_SUCCESS; }
-void vboxClipboardDestroy() {}
-void vboxClipboardDisconnect(_VBOXCLIPBOARDCLIENTDATA*) { AssertFailed(); }
-int vboxClipboardConnect(_VBOXCLIPBOARDCLIENTDATA*, bool)
+void vboxClipboardDestroy() { }
+void vboxClipboardDisconnect(_VBOXCLIPBOARDCLIENTDATA *) { AssertFailed(); }
+int vboxClipboardConnect(_VBOXCLIPBOARDCLIENTDATA *, bool)
 { AssertFailed(); return VERR_WRONG_ORDER; }
-void vboxClipboardFormatAnnounce(_VBOXCLIPBOARDCLIENTDATA*, unsigned int)
+void vboxClipboardFormatAnnounce(_VBOXCLIPBOARDCLIENTDATA *, unsigned int)
 { AssertFailed(); }
-int vboxClipboardReadData(_VBOXCLIPBOARDCLIENTDATA*, unsigned int, void*, unsigned int, unsigned int*)
+int vboxClipboardReadData(_VBOXCLIPBOARDCLIENTDATA *, unsigned int, void *, unsigned int, unsigned int *)
 { AssertFailed(); return VERR_WRONG_ORDER; }
-void vboxClipboardWriteData(_VBOXCLIPBOARDCLIENTDATA*, void*, unsigned int, unsigned int) { AssertFailed(); }
-int vboxClipboardSync(_VBOXCLIPBOARDCLIENTDATA*)
+void vboxClipboardWriteData(_VBOXCLIPBOARDCLIENTDATA *, void *, unsigned int, unsigned int) { AssertFailed(); }
+int vboxClipboardSync(_VBOXCLIPBOARDCLIENTDATA *)
 { AssertFailed(); return VERR_WRONG_ORDER; }
