- Timestamp:
- Sep 2, 2020 2:38:09 PM (4 years ago)
- Location:
- trunk/src/VBox/HostServices/SharedClipboard
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-internal.h
r85980 r85999 99 99 100 100 /** 101 * Strucutre for keeping legacy state, required for keeping backwards compatibility 102 * to old(er) Guest Additions. 103 */ 104 typedef struct SHCLCLIENTLEGACYSTATE 105 { 106 /** Context ID required for an incoming VBOX_SHCL_GUEST_FN_DATA_WRITE call. Set to UINT64_MAX if not in use. 107 * Required for: 108 * - Guest Additions < 6.1. */ 109 uint64_t idCtxWriteData; 110 } SHCLCLIENTLEGACYSTATE; 111 112 /** 101 113 * Structure for keeping generic client state data within the Shared Clipboard host service. 102 114 * This structure needs to be serializable by SSM (must be a POD type). … … 123 135 /** Client state flags of type SHCLCLIENTSTATE_FLAGS_. */ 124 136 uint32_t fFlags; 137 /** Legacy cruft we have to keep to support old(er) Guest Additions. */ 138 SHCLCLIENTLEGACYSTATE Legacy; 125 139 /** POD (plain old data) state. */ 126 140 SHCLCLIENTPODSTATE POD; … … 149 163 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 150 164 /** Transfer contextdata. */ 151 SHCLTRANSFERCTX TransferCtx;165 SHCLTRANSFERCTX TransferCtx; 152 166 #endif 153 167 /** Structure for keeping the client's pending (deferred return) state. -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp
r85987 r85999 1243 1243 LogFlowFunc(("fFormats=%#x -> fFormat=%#x, idEvent=%#x\n", fFormats, fFormat, idEvent)); 1244 1244 1245 /* 1246 * Format the message. 1247 */ 1248 if (pMsg->idMsg == VBOX_SHCL_HOST_MSG_READ_DATA_CID) 1249 HGCMSvcSetU64(&pMsg->aParms[0], 1250 VBOX_SHCL_CONTEXTID_MAKE(pClient->State.uSessionID, pClient->EventSrc.uID, idEvent)); 1251 else 1252 HGCMSvcSetU32(&pMsg->aParms[0], VBOX_SHCL_HOST_MSG_READ_DATA); 1253 HGCMSvcSetU32(&pMsg->aParms[1], fFormat); 1254 1255 shClSvcMsgAdd(pClient, pMsg, true /* fAppend */); 1245 const uint64_t uCID = VBOX_SHCL_CONTEXTID_MAKE(pClient->State.uSessionID, pClient->EventSrc.uID, idEvent); 1256 1246 1257 1247 rc = VINF_SUCCESS; 1248 1249 /* Save the context ID in our legacy cruft if we have to deal with old(er) Guest Additions (< 6.1.). */ 1250 if (!(pClient->State.fGuestFeatures0 & VBOX_SHCL_GF_0_CONTEXT_ID)) 1251 { 1252 /* Only one data request at a time is supported. */ 1253 AssertStmt(pClient->State.Legacy.idCtxWriteData == UINT64_MAX, rc = VERR_WRONG_ORDER); 1254 if (RT_SUCCESS(rc)) 1255 pClient->State.Legacy.idCtxWriteData = uCID; 1256 } 1257 1258 if (RT_SUCCESS(rc)) 1259 { 1260 /* 1261 * Format the message. 1262 */ 1263 if (pMsg->idMsg == VBOX_SHCL_HOST_MSG_READ_DATA_CID) 1264 HGCMSvcSetU64(&pMsg->aParms[0], uCID); 1265 else 1266 HGCMSvcSetU32(&pMsg->aParms[0], VBOX_SHCL_HOST_MSG_READ_DATA); 1267 HGCMSvcSetU32(&pMsg->aParms[1], fFormat); 1268 1269 shClSvcMsgAdd(pClient, pMsg, true /* fAppend */); 1270 } 1258 1271 } 1259 1272 else … … 1261 1274 1262 1275 RTCritSectLeave(&pClient->CritSect); 1276 1277 if (RT_FAILURE(rc)) 1278 shClSvcMsgFree(pClient, pMsg); 1263 1279 } 1264 1280 else … … 1311 1327 LogFlowFuncEnter(); 1312 1328 1313 SHCLEVENTID idEvent; 1314 if (!(pClient->State.fGuestFeatures0 & VBOX_SHCL_GF_0_CONTEXT_ID)) /* Legacy, Guest Additions < 6.1. */ 1315 { 1316 /* Older Guest Additions (<= VBox 6.0) did not have any context ID handling, so we ASSUME that the last event registered 1317 * is the one we want to handle (as this all was a synchronous protocol anyway). */ 1318 idEvent = ShClEventGetLast(&pClient->EventSrc); 1319 } 1320 else 1321 idEvent = VBOX_SHCL_CONTEXTID_GET_EVENT(pCmdCtx->uContextID); 1322 1323 if (idEvent == NIL_SHCLEVENTID) /* Event not found? Bail out early. */ 1324 return VERR_NOT_FOUND; 1329 const SHCLEVENTID idEvent = VBOX_SHCL_CONTEXTID_GET_EVENT(pCmdCtx->uContextID); 1330 1331 AssertMsgReturn(idEvent != NIL_SHCLEVENTID, 1332 ("Event %RU64 empty within supplied context ID\n", idEvent), VERR_WRONG_ORDER); 1333 #ifdef VBOX_STRICT 1334 AssertMsgReturn(ShClEventGet(&pClient->EventSrc, idEvent) != NULL, 1335 ("Event %RU64 not found, even if context ID was around\n", idEvent), VERR_NOT_FOUND); 1336 #endif 1325 1337 1326 1338 int rc = VINF_SUCCESS; … … 1670 1682 ASSERT_GUEST_RETURN(paParms[iParm].type == VBOX_HGCM_SVC_PARM_64BIT, VERR_WRONG_PARAMETER_TYPE); 1671 1683 cmdCtx.uContextID = paParms[iParm].u.uint64; 1672 uint64_t const idCtxExpected = VBOX_SHCL_CONTEXTID_MAKE(pClient->State.uSessionID, pClient->EventSrc.uID,1673 VBOX_SHCL_CONTEXTID_GET_EVENT(cmdCtx.uContextID));1674 ASSERT_GUEST_MSG_RETURN(cmdCtx.uContextID == idCtxExpected,1675 ("Wrong context ID: %#RX64, expected %#RX64\n", cmdCtx.uContextID, idCtxExpected),1676 VERR_INVALID_CONTEXT);1677 1684 iParm++; 1678 1685 } 1679 else 1680 { 1681 /** @todo supply CID from client state? Setting it in ShClSvcGuestDataRequest? */ 1682 } 1686 else /* Older Guest Additions (< 6.1) did not supply a context ID. Dig it out of our legacy cruft. */ 1687 { 1688 cmdCtx.uContextID = pClient->State.Legacy.idCtxWriteData; 1689 pClient->State.Legacy.idCtxWriteData = UINT64_MAX; /* Reset. */ 1690 } 1691 1692 uint64_t const idCtxExpected = VBOX_SHCL_CONTEXTID_MAKE(pClient->State.uSessionID, pClient->EventSrc.uID, 1693 VBOX_SHCL_CONTEXTID_GET_EVENT(cmdCtx.uContextID)); 1694 ASSERT_GUEST_MSG_RETURN(cmdCtx.uContextID == idCtxExpected, 1695 ("Wrong context ID: %#RX64, expected %#RX64\n", cmdCtx.uContextID, idCtxExpected), 1696 VERR_INVALID_CONTEXT); 1697 1683 1698 if (cParms == VBOX_SHCL_CPARMS_DATA_WRITE_61B) 1684 1699 { … … 2110 2125 #endif 2111 2126 2112 2127 pClientState->Legacy.idCtxWriteData = UINT64_MAX; 2113 2128 } 2114 2129
Note:
See TracChangeset
for help on using the changeset viewer.