Index: trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibClipboard.cpp
===================================================================
--- trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibClipboard.cpp	(revision 80301)
+++ trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibClipboard.cpp	(revision 80318)
@@ -270,5 +270,5 @@
                        VBOX_SHARED_CLIPBOARD_GUEST_FN_STATUS, VBOX_SHARED_CLIPBOARD_CPARMS_STATUS);
 
-    Msg.uContext.SetUInt32(0); /** @todo Context ID not used yet. */
+    Msg.uContext.SetUInt32(pCtx->uContextID);
     Msg.uStatus.SetUInt32(uStatus);
     Msg.cbPayload.SetUInt32(0);
@@ -399,5 +399,5 @@
                        VBOX_SHARED_CLIPBOARD_GUEST_FN_LIST_OPEN, VBOX_SHARED_CLIPBOARD_CPARMS_LIST_OPEN);
 
-    Msg.uContext.SetUInt32(0); /** @todo Context ID not used yet. */
+    Msg.uContext.SetUInt32(pCtx->uContextID);
     Msg.fList.SetUInt32(0);
     Msg.cbFilter.SetUInt32(pOpenParms->cbFilter);
@@ -438,5 +438,7 @@
     if (RT_SUCCESS(rc))
     {
-        rc = Msg.fList.GetUInt32(&pOpenParms->fList);
+        rc = Msg.uContext.GetUInt32(&pCtx->uContextID);
+        if (RT_SUCCESS(rc))
+            rc = Msg.fList.GetUInt32(&pOpenParms->fList);
         if (RT_SUCCESS(rc))
             rc = Msg.cbFilter.GetUInt32(&pOpenParms->cbFilter);
@@ -459,5 +461,5 @@
                        VBOX_SHARED_CLIPBOARD_GUEST_FN_REPLY, 6);
 
-    Msg.uContext.SetUInt32(0); /** @todo Context ID not used yet. */
+    Msg.uContext.SetUInt32(pCtx->uContextID);
     Msg.enmType.SetUInt32(VBOX_SHAREDCLIPBOARD_REPLYMSGTYPE_LIST_OPEN);
     Msg.rc.SetUInt32((uint32_t)rcReply); /** int vs. uint32_t */
@@ -490,5 +492,7 @@
     if (RT_SUCCESS(rc))
     {
-        rc = Msg.uHandle.GetUInt64(phList); AssertRC(rc);
+        rc = Msg.uContext.GetUInt32(&pCtx->uContextID);
+        if (RT_SUCCESS(rc))
+            rc = Msg.uHandle.GetUInt64(phList); AssertRC(rc);
     }
 
@@ -507,5 +511,5 @@
                        VBOX_SHARED_CLIPBOARD_GUEST_FN_REPLY, 6);
 
-    Msg.uContext.SetUInt32(0); /** @todo Context ID not used yet. */
+    Msg.uContext.SetUInt32(pCtx->uContextID);
     Msg.enmType.SetUInt32(VBOX_SHAREDCLIPBOARD_REPLYMSGTYPE_LIST_CLOSE);
     Msg.rc.SetUInt32((uint32_t)rcReply); /** int vs. uint32_t */
@@ -531,5 +535,5 @@
                        VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_CLOSE, VBOX_SHARED_CLIPBOARD_CPARMS_LIST_CLOSE);
 
-    Msg.uContext.SetUInt32(0); /** @todo Context ID not used yet. */
+    Msg.uContext.SetUInt32(pCtx->uContextID);
     Msg.uHandle.SetUInt64(hList);
 
@@ -553,5 +557,5 @@
                        VBOX_SHARED_CLIPBOARD_GUEST_FN_LIST_HDR_READ, VBOX_SHARED_CLIPBOARD_CPARMS_LIST_HDR);
 
-    Msg.ReqParms.uContext.SetUInt32(0); /** @todo Context ID not used yet. */
+    Msg.ReqParms.uContext.SetUInt32(pCtx->uContextID);
     Msg.ReqParms.uHandle.SetUInt64(hList);
     Msg.ReqParms.fFlags.SetUInt32(fFlags);
@@ -601,4 +605,5 @@
     if (RT_SUCCESS(rc))
     {
+        rc = Msg.ReqParms.uContext.GetUInt32(&pCtx->uContextID);
         if (RT_SUCCESS(rc))
             rc = Msg.ReqParms.uHandle.GetUInt64(phList);
@@ -623,5 +628,5 @@
                        VBOX_SHARED_CLIPBOARD_GUEST_FN_LIST_HDR_WRITE, VBOX_SHARED_CLIPBOARD_CPARMS_LIST_HDR);
 
-    Msg.ReqParms.uContext.SetUInt32(0);
+    Msg.ReqParms.uContext.SetUInt32(pCtx->uContextID);
     Msg.ReqParms.uHandle.SetUInt64(hList);
     Msg.ReqParms.fFlags.SetUInt32(0);
@@ -652,5 +657,5 @@
                        VBOX_SHARED_CLIPBOARD_GUEST_FN_LIST_ENTRY_READ, VBOX_SHARED_CLIPBOARD_CPARMS_LIST_ENTRY);
 
-    Msg.ReqParms.uContext.SetUInt32(0); /** @todo Context ID not used yet. */
+    Msg.ReqParms.uContext.SetUInt32(pCtx->uContextID);
     Msg.ReqParms.uHandle.SetUInt64(hList);
     Msg.ReqParms.fInfo.SetUInt32(0);
@@ -689,5 +694,7 @@
     if (RT_SUCCESS(rc))
     {
-        rc = Msg.ReqParms.uHandle.GetUInt64(phList); AssertRC(rc);
+        rc = Msg.ReqParms.uContext.GetUInt32(&pCtx->uContextID);
+        if (RT_SUCCESS(rc))
+            rc = Msg.ReqParms.uHandle.GetUInt64(phList); AssertRC(rc);
         if (RT_SUCCESS(rc))
             rc = Msg.ReqParms.fInfo.GetUInt32(pfInfo); AssertRC(rc);
@@ -710,5 +717,5 @@
                        VBOX_SHARED_CLIPBOARD_GUEST_FN_LIST_ENTRY_WRITE, VBOX_SHARED_CLIPBOARD_CPARMS_LIST_ENTRY);
 
-    Msg.ReqParms.uContext.SetUInt32(0); /** @todo Context ID not used yet. */
+    Msg.ReqParms.uContext.SetUInt32(pCtx->uContextID);
     Msg.ReqParms.uHandle.SetUInt64(hList);
     Msg.ReqParms.fInfo.SetUInt32(pListEntry->fInfo);
@@ -744,5 +751,7 @@
     if (RT_SUCCESS(rc))
     {
-        rc = Msg.cbPath.GetUInt32(&pCreateParms->cbPath);
+        rc = Msg.uContext.GetUInt32(&pCtx->uContextID);
+        if (RT_SUCCESS(rc))
+            rc = Msg.cbPath.GetUInt32(&pCreateParms->cbPath);
         if (RT_SUCCESS(rc))
             rc = Msg.fCreate.GetUInt32(&pCreateParms->fCreate);
@@ -763,5 +772,5 @@
                        VBOX_SHARED_CLIPBOARD_GUEST_FN_REPLY, 6);
 
-    Msg.uContext.SetUInt32(0); /** @todo Context ID not used yet. */
+    Msg.uContext.SetUInt32(pCtx->uContextID);
     Msg.enmType.SetUInt32(VBOX_SHAREDCLIPBOARD_REPLYMSGTYPE_OBJ_OPEN);
     Msg.rc.SetUInt32((uint32_t)rcReply); /** int vs. uint32_t */
@@ -790,5 +799,5 @@
                        VBOX_SHARED_CLIPBOARD_GUEST_FN_OBJ_OPEN, VBOX_SHARED_CLIPBOARD_CPARMS_OBJ_OPEN);
 
-    Msg.uContext.SetUInt32(0); /** @todo Context ID not used yet. */
+    Msg.uContext.SetUInt32(pCtx->uContextID);
     Msg.uHandle.SetUInt64(0);
     Msg.cbPath.SetUInt32(pCreateParms->cbPath);
@@ -824,5 +833,7 @@
     if (RT_SUCCESS(rc))
     {
-        rc = Msg.uHandle.GetUInt64(phObj);
+        rc = Msg.uContext.GetUInt32(&pCtx->uContextID);
+        if (RT_SUCCESS(rc))
+            rc = Msg.uHandle.GetUInt64(phObj);
     }
 
@@ -841,5 +852,5 @@
                        VBOX_SHARED_CLIPBOARD_GUEST_FN_REPLY, 6);
 
-    Msg.uContext.SetUInt32(0); /** @todo Context ID not used yet. */
+    Msg.uContext.SetUInt32(pCtx->uContextID);
     Msg.enmType.SetUInt32(VBOX_SHAREDCLIPBOARD_REPLYMSGTYPE_OBJ_CLOSE);
     Msg.rc.SetUInt32((uint32_t)rcReply); /** int vs. uint32_t */
@@ -865,5 +876,5 @@
                        VBOX_SHARED_CLIPBOARD_GUEST_FN_OBJ_CLOSE, VBOX_SHARED_CLIPBOARD_CPARMS_OBJ_CLOSE);
 
-    Msg.uContext.SetUInt32(0); /** @todo Context ID not used yet. */
+    Msg.uContext.SetUInt32(pCtx->uContextID);
     Msg.uHandle.SetUInt64(hObj);
 
@@ -896,5 +907,7 @@
     if (RT_SUCCESS(rc))
     {
-        rc = Msg.ReqParms.uHandle.GetUInt64(phObj);
+        rc = Msg.ReqParms.uContext.GetUInt32(&pCtx->uContextID);
+        if (RT_SUCCESS(rc))
+            rc = Msg.ReqParms.uHandle.GetUInt64(phObj);
         if (RT_SUCCESS(rc))
             rc = Msg.ReqParms.cbToRead.GetUInt32(pcbToRead);
@@ -920,5 +933,5 @@
     VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, VBOX_SHARED_CLIPBOARD_GUEST_FN_OBJ_READ, VBOX_SHARED_CLIPBOARD_CPARMS_OBJ_READ);
 
-    Msg.uContext.SetUInt32(0);
+    Msg.uContext.SetUInt32(pCtx->uContextID);
     Msg.uHandle.SetUInt64(hObj);
     Msg.pvData.SetPtr(pvData, cbData);
@@ -958,5 +971,5 @@
     VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, VBOX_SHARED_CLIPBOARD_GUEST_FN_OBJ_WRITE, VBOX_SHARED_CLIPBOARD_CPARMS_OBJ_WRITE);
 
-    Msg.uContext.SetUInt32(0);
+    Msg.uContext.SetUInt32(pCtx->uContextID);
     Msg.uHandle.SetUInt64(hObj);
     Msg.pvData.SetPtr(pvData, cbData);
@@ -1053,7 +1066,7 @@
                         int rc2 = VbglR3ClipboardListOpenReply(pCtx, rc, hList);
                         AssertRC(rc2);
-
-                        SharedClipboardURIListOpenParmsDestroy(&openParmsList);
                     }
+
+                    SharedClipboardURIListOpenParmsDestroy(&openParmsList);
                 }
 
@@ -1251,5 +1264,5 @@
         /* Report error back to the host. */
         int rc2 = VbglR3ClipboardWriteError(pCtx->uClientID, rc);
-        Assert(rc2);
+        AssertRC(rc2);
 
         VbglR3ClipboardEventFree(pEvent);
