Changeset 81768 in vbox for trunk/src/VBox/Additions/WINNT/VBoxTray
- Timestamp:
- Nov 11, 2019 4:36:41 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp
r81559 r81768 352 352 { 353 353 const uint32_t cbPrealloc = _4K; 354 uint32_t cb= 0;354 uint32_t cb = 0; 355 355 356 356 /* Preallocate a buffer, most of small text transfers will fit into it. */ 357 357 HANDLE hMem = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, cbPrealloc); 358 LogFlowFunc(("Preallocated handle hMem = %p\n", hMem));359 360 358 if (hMem) 361 359 { 362 360 void *pMem = GlobalLock(hMem); 363 LogFlowFunc(("Locked pMem = %p, GlobalSize = %ld\n", pMem, GlobalSize(hMem)));364 365 361 if (pMem) 366 362 { 363 SHCLDATABLOCK dataBlock; 364 RT_ZERO(dataBlock); 365 366 dataBlock.cbData = cbPrealloc; 367 dataBlock.pvData = pMem; 368 dataBlock.uFormat = fFormat; 369 367 370 /* Read the host data to the preallocated buffer. */ 368 int rc = VbglR3ClipboardReadData(pCtx->CmdCtx.uClientID, fFormat, pMem, cbPrealloc, &cb); 369 LogFlowFunc(("VbglR3ClipboardReadData returned with rc = %Rrc\n", rc)); 370 371 int rc = VbglR3ClipboardReadDataEx(&pCtx->CmdCtx, &dataBlock, &cb); 371 372 if (RT_SUCCESS(rc)) 372 373 { … … 384 385 GlobalUnlock(hMem); 385 386 387 LogRel2(("Shared Clipboard: Buffer too small (%RU32), needs %RU32 bytes\n", cbPrealloc, cb)); 388 386 389 /* The preallocated buffer is too small, adjust the size. */ 387 390 hMem = GlobalReAlloc(hMem, cb, 0); 388 LogFlowFunc(("Reallocated hMem = %p\n", hMem));389 390 391 if (hMem) 391 392 { 392 393 pMem = GlobalLock(hMem); 393 LogFlowFunc(("Locked pMem = %p, GlobalSize = %ld\n", pMem, GlobalSize(hMem)));394 395 394 if (pMem) 396 395 { 396 dataBlock.cbData = cb; 397 dataBlock.pvData = pMem; 398 397 399 /* Read the host data to the preallocated buffer. */ 398 400 uint32_t cbNew = 0; 399 rc = VbglR3ClipboardReadData(pCtx->CmdCtx.uClientID, fFormat, pMem, cb, &cbNew); 400 LogFlowFunc(("VbglR3ClipboardReadData returned with rc = %Rrc, cb = %d, cbNew = %d\n", 401 rc, cb, cbNew)); 402 403 if (RT_SUCCESS(rc) 401 rc = VbglR3ClipboardReadDataEx(&pCtx->CmdCtx, &dataBlock, &cbNew); 402 if ( RT_SUCCESS(rc) 404 403 && cbNew <= cb) 405 404 { … … 408 407 else 409 408 { 409 LogRel(("Shared Clipboard: Receiving host data failed with %Rrc\n", rc)); 410 410 411 GlobalUnlock(hMem); 411 412 GlobalFree(hMem); … … 415 416 else 416 417 { 418 LogRel(("Shared Clipboard: Error locking reallocated host data buffer\n")); 419 417 420 GlobalFree(hMem); 418 421 hMem = NULL; 419 422 } 420 423 } 424 else 425 LogRel(("Shared Clipboard: No memory for reallocating host data buffer\n")); 421 426 } 422 427 … … 433 438 if (FAILED(hrc)) 434 439 { 440 LogRel(("Shared Clipboard: Received host data is invalid (%RU32 vs. %zu)\n", 441 cb, cbActual)); 442 435 443 /* Discard invalid data. */ 436 444 GlobalUnlock(hMem); … … 453 461 454 462 hMem = GlobalReAlloc(hMem, cb, 0); 455 LogFlowFunc(("Reallocated hMem = %p\n", hMem));456 457 463 if (hMem) 458 464 { … … 460 466 * size is 'cb' and format is 'format'. */ 461 467 HANDLE hClip = SetClipboardData(cfFormat, hMem); 462 LogFlowFunc(("WM_RENDERFORMAT hClip = %p\n", hClip));463 464 468 if (hClip) 465 469 { … … 467 471 break; 468 472 } 473 else 474 LogRel(("Shared Clipboard: Setting host data buffer to clipboard failed with %ld\n", 475 GetLastError())); 469 476 470 477 /* Cleanup follows. */ 471 478 } 479 else 480 LogRel(("Shared Clipboard: No memory for allocating final host data buffer\n")); 472 481 } 473 482 } 483 474 484 if (hMem) 475 485 GlobalUnlock(hMem); 476 486 } 487 else 488 LogRel(("Shared Clipboard: No memory for allocating host data buffer\n")); 489 477 490 if (hMem) 478 491 GlobalFree(hMem); … … 629 642 /* Requested clipboard format is not available, send empty data. */ 630 643 VbglR3ClipboardWriteData(pCtx->CmdCtx.uClientID, VBOX_SHCL_FMT_NONE, NULL, 0); 631 #ifdef DEBUG_andy632 AssertFailed();633 #endif634 644 } 635 645 … … 983 993 PVBGLR3CLIPBOARDEVENT pEvent = NULL; 984 994 985 LogFlowFunc(("Waiting for host message (fHostFeatures=%#RX64) ...\n", pCtx->CmdCtx.fHostFeatures)); 995 LogFlowFunc(("Waiting for host message (fUseLegacyProtocol=%RTbool, fHostFeatures=%#RX64) ...\n", 996 pCtx->CmdCtx.fUseLegacyProtocol, pCtx->CmdCtx.fHostFeatures)); 986 997 987 998 if (pCtx->CmdCtx.fUseLegacyProtocol) … … 1025 1036 rc = VERR_NOT_SUPPORTED; 1026 1037 break; 1038 } 1039 1040 if (RT_SUCCESS(rc)) 1041 { 1042 /* Copy over our command context to the event. */ 1043 pEvent->cmdCtx = pCtx->CmdCtx; 1027 1044 } 1028 1045 }
Note:
See TracChangeset
for help on using the changeset viewer.