Changeset 81768 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Nov 11, 2019 4:36:41 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 134559
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibClipboard.cpp
r81559 r81768 211 211 212 212 /** 213 * Receives a host request to read clipboard data requestfrom the guest.213 * Receives a host request to read clipboard data from the guest. 214 214 * 215 215 * @returns VBox status code. … … 225 225 226 226 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, 227 VBOX_SHCL_GUEST_FN_MSG_GET, VBOX_SHCL_CPARMS_READ_DATA );227 VBOX_SHCL_GUEST_FN_MSG_GET, VBOX_SHCL_CPARMS_READ_DATA_REQ); 228 228 229 229 Msg.uContext.SetUInt64(VBOX_SHCL_HOST_MSG_READ_DATA); 230 Msg.fFlags.SetUInt32(0); 230 231 Msg.uFormat.SetUInt32(0); 231 232 Msg.cbSize.SetUInt32(0); … … 290 291 * Reads data from the host clipboard. 291 292 * 293 * Legacy function, do not use anymore. 294 * 292 295 * @returns VBox status code. 293 296 * @retval VINF_BUFFER_OVERFLOW If there is more data available than the caller provided buffer space for. … … 295 298 * @param idClient The client id returned by VbglR3ClipboardConnect(). 296 299 * @param fFormat The format we're requesting the data in. 297 * @param pv Where to store the data. 298 * @param cb The size of the buffer pointed to by pv. 299 * @param pcb The actual size of the host clipboard data. May be larger than cb. 300 */ 301 VBGLR3DECL(int) VbglR3ClipboardReadData(HGCMCLIENTID idClient, uint32_t fFormat, void *pv, uint32_t cb, uint32_t *pcb) 300 * @param pvData Where to store the data. 301 * @param cbData The size of the buffer pointed to by \a pvData. 302 * @param pcbRead The actual size of the host clipboard data. May be larger than \a cbData. 303 */ 304 VBGLR3DECL(int) VbglR3ClipboardReadData(HGCMCLIENTID idClient, uint32_t fFormat, void *pvData, uint32_t cbData, 305 uint32_t *pcbRead) 302 306 { 303 307 VBoxShClReadDataMsg Msg; 304 308 305 VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, VBOX_SHCL_GUEST_FN_DATA_READ, VBOX_SHCL_CPARMS_READ_DATA); 306 VbglHGCMParmUInt32Set(&Msg.format, fFormat); 307 VbglHGCMParmPtrSet(&Msg.ptr, pv, cb); 308 VbglHGCMParmUInt32Set(&Msg.size, 0); 309 310 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 311 if (RT_SUCCESS(rc)) 312 { 313 uint32_t cbActual; 314 int rc2 = VbglHGCMParmUInt32Get(&Msg.size, &cbActual); 315 if (RT_SUCCESS(rc2)) 316 { 317 *pcb = cbActual; 318 if (cbActual > cb) 319 return VINF_BUFFER_OVERFLOW; 320 return rc; 321 } 322 rc = rc2; 323 } 309 LogFlowFuncEnter(); 310 311 VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, VBOX_SHCL_GUEST_FN_DATA_READ, 3); 312 313 VbglHGCMParmUInt32Set(&Msg.u.v0.format, fFormat); 314 VbglHGCMParmPtrSet(&Msg.u.v0.ptr, pvData, cbData); 315 VbglHGCMParmUInt32Set(&Msg.u.v0.size, 0); 316 317 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg.hdr) + sizeof(Msg.u.v0)); 318 if (RT_SUCCESS(rc)) 319 { 320 uint32_t cbRead; 321 rc = VbglHGCMParmUInt32Get(&Msg.u.v0.size, &cbRead); 322 if (RT_SUCCESS(rc)) 323 { 324 LogFlowFunc(("cbRead=%RU32\n", cbRead)); 325 326 if (cbRead > cbData) 327 rc = VINF_BUFFER_OVERFLOW; 328 329 *pcbRead = cbRead; 330 } 331 } 332 333 LogFlowFuncLeaveRC(rc); 334 return rc; 335 } 336 337 /** 338 * Reads clipboard data from the host clipboard. 339 * 340 * @returns VBox status code. 341 * @retval VINF_BUFFER_OVERFLOW If there is more data available than the caller provided buffer space for. 342 * 343 * @param pCtx The command context returned by VbglR3ClipboardConnectEx(). 344 * @param pData Where to store the clipboard data read. 345 * @param pcbRead The actual size of the host clipboard data. 346 */ 347 VBGLR3DECL(int) VbglR3ClipboardReadDataEx(PVBGLR3SHCLCMDCTX pCtx, PSHCLDATABLOCK pData, uint32_t *pcbRead) 348 { 349 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 350 AssertPtrReturn(pData, VERR_INVALID_POINTER); 351 352 int rc; 353 354 LogFlowFuncEnter(); 355 356 if (pCtx->fUseLegacyProtocol) 357 { 358 rc = VbglR3ClipboardReadData(pCtx->uClientID, pData->uFormat, pData->pvData, pData->cbData, pcbRead); 359 } 360 else 361 { 362 VBoxShClReadDataMsg Msg; 363 364 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, VBOX_SHCL_GUEST_FN_DATA_READ, VBOX_SHCL_CPARMS_READ_DATA); 365 366 VbglHGCMParmUInt64Set(&Msg.u.v1.uContext, pCtx->uContextID); 367 VbglHGCMParmUInt32Set(&Msg.u.v1.fFlags, 0); 368 VbglHGCMParmUInt32Set(&Msg.u.v1.uFormat, pData->uFormat); 369 VbglHGCMParmUInt32Set(&Msg.u.v1.cbData, pData->cbData); 370 VbglHGCMParmPtrSet(&Msg.u.v1.pvData, pData->pvData, pData->cbData); 371 372 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg.hdr) + sizeof(Msg.u.v1)); 373 if (RT_SUCCESS(rc)) 374 { 375 uint32_t cbRead; 376 rc = VbglHGCMParmUInt32Get(&Msg.u.v1.cbData, &cbRead); 377 if (RT_SUCCESS(rc)) 378 { 379 LogFlowFunc(("cbRead=%RU32\n", cbRead)); 380 381 if (cbRead > pData->cbData) 382 rc = VINF_BUFFER_OVERFLOW; 383 384 *pcbRead = cbRead; 385 } 386 } 387 } 388 389 LogFlowFuncLeaveRC(rc); 324 390 return rc; 325 391 } … … 2340 2406 VbglHGCMParmUInt32Set(&Msg.u.v0.uFormats, fFormats); 2341 2407 2342 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg.hdr) + sizeof(Msg.u.v0)); 2343 } 2344 2345 /** 2346 * Sends guest clipboard data to the host. Legacy function kept for compatibility, do not use anymore. 2408 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg.hdr) + sizeof(Msg.u.v0)); 2409 2410 LogFlowFuncLeaveRC(rc); 2411 return rc; 2412 } 2413 2414 /** 2415 * Sends guest clipboard data to the host. 2416 * 2417 * Legacy function kept for compatibility, do not use anymore. 2347 2418 * 2348 2419 * This is usually called in reply to a VBOX_SHCL_HOST_MSG_READ_DATA message … … 2357 2428 VBGLR3DECL(int) VbglR3ClipboardWriteData(HGCMCLIENTID idClient, uint32_t fFormat, void *pv, uint32_t cb) 2358 2429 { 2359 AssertReturn (idClient, VERR_INVALID_PARAMETER); 2360 AssertPtrReturn(pv, VERR_INVALID_POINTER); 2361 AssertReturn (cb, VERR_INVALID_PARAMETER); 2430 LogFlowFuncEnter(); 2362 2431 2363 2432 VBoxShClWriteDataMsg Msg; … … 2393 2462 int rc; 2394 2463 2464 LogFlowFuncEnter(); 2465 2395 2466 if (pCtx->fUseLegacyProtocol) 2396 2467 { … … 2409 2480 Msg.u.v1.uContext.SetUInt64(pCtx->uContextID); 2410 2481 Msg.u.v1.uFormat.SetUInt32(pData->uFormat); 2482 Msg.u.v1.fFlags.SetUInt32(0); 2411 2483 Msg.u.v1.cbData.SetUInt32(pData->cbData); 2412 2484 Msg.u.v1.pvData.SetPtr(pData->pvData, pData->cbData);
Note:
See TracChangeset
for help on using the changeset viewer.