Index: /trunk/include/VBox/VBoxGuest.h
===================================================================
--- /trunk/include/VBox/VBoxGuest.h	(revision 38854)
+++ /trunk/include/VBox/VBoxGuest.h	(revision 38855)
@@ -350,4 +350,8 @@
 /** Get the pointer to the first HGCM parameter in a 32-bit request.  */
 # define VBOXGUEST_HGCM_CALL_PARMS32(a)           ( (HGCMFunctionParameter32 *)((uint8_t *)(a) + sizeof(VBoxGuestHGCMCallInfo)) )
+
+/** IOCTL to VBoxGuest to make a connect to the clipboard service.
+ * @todo Seems this is no longer is use. Try remove it. */
+# define VBOXGUEST_IOCTL_CLIPBOARD_CONNECT        VBOXGUEST_IOCTL_CODE_(19, sizeof(uint32_t))
 
 #endif /* VBOX_WITH_HGCM */
Index: /trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp	(revision 38854)
+++ /trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp	(revision 38855)
@@ -713,4 +713,5 @@
     pDevExt->u32MousePosChangedSeq = 0;
     pDevExt->SessionSpinlock = NIL_RTSPINLOCK;
+    pDevExt->u32ClipboardClientId = 0;
     pDevExt->MemBalloon.hMtx = NIL_RTSEMFASTMUTEX;
     pDevExt->MemBalloon.cChunks = 0;
@@ -1826,4 +1827,72 @@
 }
 
+
+/**
+ * @returns VBox status code. Unlike the other HGCM IOCtls this will combine
+ *          the VbglHGCMConnect/Disconnect return code with the Info.result.
+ *
+ * @param   pDevExt             The device extension.
+ * @param   pu32ClientId        The client id.
+ * @param   pcbDataReturned     Where to store the amount of returned data. Can
+ *                              be NULL.
+ */
+static int VBoxGuestCommonIOCtl_HGCMClipboardReConnect(PVBOXGUESTDEVEXT pDevExt, uint32_t *pu32ClientId, size_t *pcbDataReturned)
+{
+    int                         rc;
+    VBoxGuestHGCMConnectInfo    CnInfo;
+
+    Log(("VBoxGuestCommonIOCtl: CLIPBOARD_CONNECT: Current u32ClientId=%RX32\n", pDevExt->u32ClipboardClientId));
+
+    /*
+     * If there is an old client, try disconnect it first.
+     */
+    if (pDevExt->u32ClipboardClientId != 0)
+    {
+        VBoxGuestHGCMDisconnectInfo DiInfo;
+        DiInfo.result = VERR_WRONG_ORDER;
+        DiInfo.u32ClientID = pDevExt->u32ClipboardClientId;
+        rc = VbglR0HGCMInternalDisconnect(&DiInfo, VBoxGuestHGCMAsyncWaitCallback, pDevExt, RT_INDEFINITE_WAIT);
+        if (RT_SUCCESS(rc))
+        {
+            LogRel(("VBoxGuestCommonIOCtl: CLIPBOARD_CONNECT: failed to disconnect old client. VbglHGCMDisconnect -> rc=%Rrc\n", rc));
+            return rc;
+        }
+        if (RT_FAILURE((int32_t)DiInfo.result))
+        {
+            Log(("VBoxGuestCommonIOCtl: CLIPBOARD_CONNECT: failed to disconnect old client. DiInfo.result=%Rrc\n", DiInfo.result));
+            return DiInfo.result;
+        }
+        pDevExt->u32ClipboardClientId = 0;
+    }
+
+    /*
+     * Try connect.
+     */
+    CnInfo.Loc.type = VMMDevHGCMLoc_LocalHost_Existing;
+    strcpy(CnInfo.Loc.u.host.achName, "VBoxSharedClipboard");
+    CnInfo.u32ClientID = 0;
+    CnInfo.result = VERR_WRONG_ORDER;
+
+    rc = VbglR0HGCMInternalConnect(&CnInfo, VBoxGuestHGCMAsyncWaitCallback, pDevExt, RT_INDEFINITE_WAIT);
+    if (RT_FAILURE(rc))
+    {
+        LogRel(("VBoxGuestCommonIOCtl: CLIPBOARD_CONNECT: VbglHGCMConnected -> rc=%Rrc\n", rc));
+        return rc;
+    }
+    if (RT_FAILURE(CnInfo.result))
+    {
+        LogRel(("VBoxGuestCommonIOCtl: CLIPBOARD_CONNECT: VbglHGCMConnected -> rc=%Rrc\n", rc));
+        return rc;
+    }
+
+    Log(("VBoxGuestCommonIOCtl: CLIPBOARD_CONNECT: connected successfully u32ClientId=%RX32\n", CnInfo.u32ClientID));
+
+    pDevExt->u32ClipboardClientId = CnInfo.u32ClientID;
+    *pu32ClientId = CnInfo.u32ClientID;
+    if (pcbDataReturned)
+        *pcbDataReturned = sizeof(uint32_t);
+
+    return VINF_SUCCESS;
+}
 
 #endif /* VBOX_WITH_HGCM */
@@ -2350,4 +2419,9 @@
                 rc = VBoxGuestCommonIOCtl_HGCMDisconnect(pDevExt, pSession, (VBoxGuestHGCMDisconnectInfo *)pvData, pcbDataReturned);
                 break;
+
+            case VBOXGUEST_IOCTL_CLIPBOARD_CONNECT:
+                CHECKRET_MIN_SIZE("CLIPBOARD_CONNECT", sizeof(uint32_t));
+                rc = VBoxGuestCommonIOCtl_HGCMClipboardReConnect(pDevExt, (uint32_t *)pvData, pcbDataReturned);
+                break;
 #endif /* VBOX_WITH_HGCM */
 
Index: /trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h	(revision 38854)
+++ /trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h	(revision 38855)
@@ -145,4 +145,8 @@
     /** Spinlock various items in the VBOXGUESTSESSION. */
     RTSPINLOCK                  SessionSpinlock;
+
+    /** The current clipboard client ID, 0 if no client.
+     * For implementing the VBOXGUEST_IOCTL_CLIPBOARD_CONNECT interface. */
+    uint32_t                    u32ClipboardClientId;
 #ifdef VBOX_WITH_VRDP_SESSION_HANDLING
     BOOL                        fVRDPEnabled;
@@ -167,9 +171,5 @@
      *          following it (to grow into and align the struct size).
      */
-#ifdef VBOXGUEST_USE_DEFERRED_WAKE_UP
-    uint8_t abAlignment1[HC_ARCH_BITS == 32 ? 144 : 60];
-#else
-    uint8_t abAlignment1[HC_ARCH_BITS == 32 ? 88 : 12];
-#endif
+    uint8_t abAlignment1[HC_ARCH_BITS == 32 ? 20 : 0];
 
     /** Windows part. */
@@ -186,10 +186,5 @@
 typedef VBOXGUESTDEVEXT *PVBOXGUESTDEVEXT;
 
-#ifdef VBOXGUEST_USE_DEFERRED_WAKE_UP
-AssertCompileMemberOffset(VBOXGUESTDEVEXT, win, 384);
-#else
-AssertCompileMemberOffset(VBOXGUESTDEVEXT, win, 320);
-#endif
-AssertCompileMemberAlignment(VBOXGUESTDEVEXT, win, 64);
+AssertCompileMemberSizeAlignment(VBOXGUESTDEVEXT, win, 64);
 
 /**
