Changeset 86889 in vbox for trunk/src/VBox/HostServices
- Timestamp:
- Nov 16, 2020 2:23:04 PM (4 years ago)
- Location:
- trunk/src/VBox/HostServices/SharedClipboard
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-darwin.cpp
r85989 r86889 261 261 262 262 int rc = readFromPasteboard(pClient->State.pCtx->hPasteboard, fFormat, pvData, cbData, pcbActual); 263 if (RT_FAILURE(rc)) 264 LogRel(("Shared Clipboard: Error reading host clipboard data from macOS, rc=%Rrc\n", rc)); 263 265 264 266 ShClSvcUnlock(); -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp
r86247 r86889 67 67 68 68 /** @todo Someone please explain the protocol wrt overflows... */ 69 static void vboxClipboardSvcWinGetData(uint32_t u32Format, const void *pvSrc, uint32_t cbSrc, 70 void *pvDst, uint32_t cbDst, uint32_t *pcbActualDst) 71 { 69 static int vboxClipboardSvcWinDataGet(uint32_t u32Format, const void *pvSrc, uint32_t cbSrc, 70 void *pvDst, uint32_t cbDst, uint32_t *pcbActualDst) 71 { 72 AssertPtrReturn(pvSrc, VERR_INVALID_POINTER); 73 AssertReturn (cbSrc, VERR_INVALID_PARAMETER); 74 AssertPtrReturn(pvDst, VERR_INVALID_POINTER); 75 AssertReturn (cbDst, VERR_INVALID_PARAMETER); 76 AssertPtrReturn(pcbActualDst, VERR_INVALID_POINTER); 77 72 78 LogFlowFunc(("cbSrc = %d, cbDst = %d\n", cbSrc, cbDst)); 73 79 … … 96 102 else 97 103 { 98 *pcbActualDst = cbSrc; 104 *pcbActualDst = cbSrc; /* Tell the caller how much space we need. */ 99 105 100 106 if (cbSrc > cbDst) 101 { 102 /* Do not copy data. The dst buffer is not enough. */ 103 return; 104 } 107 return VERR_BUFFER_OVERFLOW; 105 108 106 109 memcpy(pvDst, pvSrc, cbSrc); … … 111 114 #endif 112 115 113 return; 114 } 115 116 return VINF_SUCCESS; 117 } 118 119 /** 120 * Sets (places) clipboard data into the Windows clipboard. 121 * 122 * @returns VBox status code. 123 * @param pCtx Shared Clipboard context to use. 124 * @param cfFormat Windows clipboard format to set data for. 125 * @param pvData Pointer to actual clipboard data to set. 126 * @param cbData Size (in bytes) of actual clipboard data to set. 127 * @note 128 */ 116 129 static int vboxClipboardSvcWinDataSet(PSHCLCONTEXT pCtx, UINT cfFormat, void *pvData, uint32_t cbData) 117 130 { … … 163 176 rc = RTErrConvertFromWin32(GetLastError()); 164 177 178 if (RT_FAILURE(rc)) 179 LogRel(("Shared Clipboard: Setting clipboard data for Windows host failed with %Rrc\n", rc)); 180 165 181 LogFlowFuncLeaveRC(rc); 166 182 return rc; … … 174 190 if (fFormat == VBOX_SHCL_FMT_NONE) 175 191 { 176 LogRel2(("Shared Clipb aord: Windows format %u not supported, ingoring\n", uFormat));192 LogRel2(("Shared Clipboard: Windows format %u not supported, ignoring\n", uFormat)); 177 193 return VERR_NOT_SUPPORTED; 178 194 } … … 193 209 ShClEventUnregister(&pCtx->pClient->EventSrc, idEvent); 194 210 } 211 212 if (RT_FAILURE(rc)) 213 LogRel(("Shared Clipboard: Reading guest clipboard data for Windows host failed with %Rrc\n", rc)); 195 214 196 215 LogFlowFuncLeaveRC(rc); … … 340 359 /* Announce available formats. Do not insert data -- will be inserted in WM_RENDERFORMAT (or via IDataObject). */ 341 360 SHCLFORMATS fFormats = (uint32_t)lParam; 342 LogFunc(("SHCL_WIN_WM_REPORT_FORMATS: fFormats= 0x%x\n", fFormats));361 LogFunc(("SHCL_WIN_WM_REPORT_FORMATS: fFormats=%#xn", fFormats)); 343 362 344 363 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS … … 373 392 SharedClipboardWinClose(); 374 393 } 394 395 if (RT_FAILURE(rc)) 396 LogRel(("Shared Clipboard: Reporting clipboard formats %#x to Windows host failed with %Rrc\n", fFormats, rc)); 397 375 398 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 376 399 } … … 714 737 715 738 int ShClBackendReadData(PSHCLCLIENT pClient, PSHCLCLIENTCMDCTX pCmdCtx, 716 SHCLFORMAT uF ormat, void *pvData, uint32_t cbData, uint32_t *pcbActual)739 SHCLFORMAT uFmt, void *pvData, uint32_t cbData, uint32_t *pcbActual) 717 740 { 718 741 AssertPtrReturn(pClient, VERR_INVALID_POINTER); … … 725 748 AssertPtrReturn(pClient->State.pCtx, VERR_INVALID_POINTER); 726 749 727 LogFlowFunc(("uF ormat=%02X\n", uFormat));750 LogFlowFunc(("uFmt=%#x\n", uFmt)); 728 751 729 752 HANDLE hClip = NULL; … … 737 760 if (RT_SUCCESS(rc)) 738 761 { 739 LogFunc(("Clipboard opened\n")); 740 741 if (uFormat & VBOX_SHCL_FMT_BITMAP) 742 { 762 if (uFmt & VBOX_SHCL_FMT_BITMAP) 763 { 764 LogFunc(("CF_DIB\n")); 743 765 hClip = GetClipboardData(CF_DIB); 744 766 if (hClip != NULL) 745 767 { 746 768 LPVOID lp = GlobalLock(hClip); 747 748 769 if (lp != NULL) 749 770 { 750 LogFunc(("CF_DIB\n")); 751 752 vboxClipboardSvcWinGetData(VBOX_SHCL_FMT_BITMAP, lp, GlobalSize(hClip), 753 pvData, cbData, pcbActual); 754 771 rc = vboxClipboardSvcWinDataGet(VBOX_SHCL_FMT_BITMAP, lp, GlobalSize(hClip), 772 pvData, cbData, pcbActual); 755 773 GlobalUnlock(hClip); 756 774 } … … 761 779 } 762 780 } 763 else if (uFormat & VBOX_SHCL_FMT_UNICODETEXT) 764 { 781 else if (uFmt & VBOX_SHCL_FMT_UNICODETEXT) 782 { 783 LogFunc(("CF_UNICODETEXT\n")); 765 784 hClip = GetClipboardData(CF_UNICODETEXT); 766 785 if (hClip != NULL) 767 786 { 768 787 LPWSTR uniString = (LPWSTR)GlobalLock(hClip); 769 770 788 if (uniString != NULL) 771 789 { 772 LogFunc(("CF_UNICODETEXT\n")); 773 774 vboxClipboardSvcWinGetData(VBOX_SHCL_FMT_UNICODETEXT, uniString, (lstrlenW(uniString) + 1) * 2, 775 pvData, cbData, pcbActual); 776 790 rc = vboxClipboardSvcWinDataGet(VBOX_SHCL_FMT_UNICODETEXT, uniString, (lstrlenW(uniString) + 1) * 2, 791 pvData, cbData, pcbActual); 777 792 GlobalUnlock(hClip); 778 793 } … … 783 798 } 784 799 } 785 else if (uFormat & VBOX_SHCL_FMT_HTML) 786 { 787 UINT format = RegisterClipboardFormat(SHCL_WIN_REGFMT_HTML); 788 if (format != 0) 789 { 790 hClip = GetClipboardData(format); 800 else if (uFmt & VBOX_SHCL_FMT_HTML) 801 { 802 LogFunc(("SHCL_WIN_REGFMT_HTML\n")); 803 UINT uRegFmt = RegisterClipboardFormat(SHCL_WIN_REGFMT_HTML); 804 if (uRegFmt != 0) 805 { 806 hClip = GetClipboardData(uRegFmt); 791 807 if (hClip != NULL) 792 808 { … … 794 810 if (lp != NULL) 795 811 { 796 /** @todo r=andy Add data overflow handling. */ 797 vboxClipboardSvcWinGetData(VBOX_SHCL_FMT_HTML, lp, GlobalSize(hClip), 798 pvData, cbData, pcbActual); 812 rc = vboxClipboardSvcWinDataGet(VBOX_SHCL_FMT_HTML, lp, GlobalSize(hClip), 813 pvData, cbData, pcbActual); 799 814 #ifdef LOG_ENABLED 800 LogFlowFunc(("Raw HTML clipboard data from host:")); 801 ShClDbgDumpHtml((char *)pvData, cbData); 815 if (RT_SUCCESS(rc)) 816 { 817 LogFlowFunc(("Raw HTML clipboard data from host:\n")); 818 ShClDbgDumpHtml((char *)pvData, cbData); 819 } 802 820 #endif 803 821 GlobalUnlock(hClip); … … 811 829 } 812 830 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 813 else if (uF ormat & VBOX_SHCL_FMT_URI_LIST)831 else if (uFmt & VBOX_SHCL_FMT_URI_LIST) 814 832 { 815 833 AssertFailed(); /** @todo */ … … 819 837 } 820 838 821 if (hClip == NULL) 839 if (hClip == NULL) /* Empty data is not fatal. */ 822 840 { 823 841 /* Reply with empty data. */ 824 vboxClipboardSvcWinGetData(0, NULL, 0, pvData, cbData, pcbActual); 825 } 842 vboxClipboardSvcWinDataGet(0, NULL, 0, pvData, cbData, pcbActual); 843 } 844 845 if (RT_FAILURE(rc)) 846 LogRel(("Shared Clipboard: Error reading host clipboard data in format %#x from Windows, rc=%Rrc\n", uFmt, rc)); 826 847 827 848 LogFlowFuncLeaveRC(rc); -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp
r86691 r86889 230 230 rc = VERR_NO_MEMORY; 231 231 232 if (RT_FAILURE(rc)) 233 LogRel(("Shared Clipboard: Error reading host clipboard data from X11, rc=%Rrc\n", rc)); 234 232 235 LogFlowFuncLeaveRC(rc); 233 236 return rc; … … 287 290 { 288 291 AssertPtrReturnVoid(pCtx); 289 RT_NOREF(rcCompletion);290 292 AssertPtrReturnVoid(pReq); 291 293 … … 316 318 if (pReq) 317 319 RTMemFree(pReq); 320 321 LogRel2(("Shared Clipboard: Request for clipboard data from X11 host completed with %Rrc\n", rcCompletion)); 318 322 } 319 323 … … 376 380 } 377 381 382 if (RT_FAILURE(rc)) 383 LogRel(("Shared Clipboard: Requesting data in format %#x for X11 host failed with %Rrc\n", fFormat, rc)); 384 378 385 LogFlowFuncLeaveRC(rc); 379 386 return rc; -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp
r86363 r86889 1332 1332 } 1333 1333 1334 if (RT_FAILURE(rc)) 1335 LogRel(("Shared Clipboard: Requesting data in formats %#x from guest failed with %Rrc\n", fFormats, rc)); 1336 1334 1337 LogFlowFuncLeaveRC(rc); 1335 1338 return rc; … … 1337 1340 1338 1341 /** 1339 * Signals th at clipboard data from the guest has been received.1342 * Signals the host that clipboard data from the guest has been received. 1340 1343 * 1341 1344 * @returns VBox status code. Returns VERR_NOT_FOUND when related event ID was not found. … … 1389 1392 } 1390 1393 1394 if (RT_FAILURE(rc)) 1395 LogRel(("Shared Clipboard: Signalling of guest clipboard data to the host failed with %Rrc\n", rc)); 1396 1391 1397 LogFlowFuncLeaveRC(rc); 1392 1398 return rc; … … 1403 1409 int ShClSvcHostReportFormats(PSHCLCLIENT pClient, SHCLFORMATS fFormats) 1404 1410 { 1411 AssertPtrReturn(pClient, VERR_INVALID_POINTER); 1412 1405 1413 LogFlowFunc(("fFormats=%#x\n", fFormats)); 1406 AssertPtrReturn(pClient, VERR_INVALID_POINTER);1407 1414 1408 1415 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS … … 1453 1460 else 1454 1461 rc = VERR_NO_MEMORY; 1462 1463 if (RT_FAILURE(rc)) 1464 LogRel(("Shared Clipboard: Reporting formats %#x to guest failed with %Rrc\n", fFormats, rc)); 1455 1465 1456 1466 LogFlowFuncLeaveRC(rc); … … 1527 1537 } 1528 1538 else 1539 { 1529 1540 rc = ShClBackendFormatAnnounce(pClient, fFormats); 1541 if (RT_FAILURE(rc)) 1542 LogRel(("Shared Clipboard: Reporting guest clipboard formats to the host failed with %Rrc\n", rc)); 1543 } 1530 1544 } 1531 1545 } … … 1535 1549 1536 1550 /** 1537 * Handles the VBOX_SHCL_GUEST_FN_DATA_READ message from the guest. 1551 * Called when the guest wants to read host clipboard data. 1552 * Handles the VBOX_SHCL_GUEST_FN_DATA_READ message. 1553 * 1554 * @returns VBox status code. 1555 * @retval VINF_BUFFER_OVERFLOW if the guest supplied a smaller buffer than needed in order to read the host clipboard data. 1556 * @param pClient Client that wants to read host clipboard data. 1557 * @param cParms Number of HGCM parameters supplied in \a paParms. 1558 * @param paParms Array of HGCM parameters. 1538 1559 */ 1539 1560 static int shClSvcClientReadData(PSHCLCLIENT pClient, uint32_t cParms, VBOXHGCMSVCPARM paParms[]) … … 1637 1658 /* Read clipboard data from the extension. */ 1638 1659 rc = g_ExtState.pfnExtension(g_ExtState.pvExtension, VBOX_CLIPBOARD_EXT_FN_DATA_READ, &parms, sizeof(parms)); 1639 LogRelFlowFunc(("Shared Clipboard: DATA/Ext: fDelayedAnnouncement=%RTbool fDelayedFormats=%#x cbData=%RU32->%RU32 rc=%Rrc\n", 1640 g_ExtState.fDelayedAnnouncement, g_ExtState.fDelayedFormats, cbData, parms.cbData, rc)); 1660 1661 LogRel2(("Shared Clipboard: Read extension clipboard data (fDelayedAnnouncement=%RTbool, fDelayedFormats=%#x, max %RU32 bytes), got %RU32 bytes: rc=%Rrc\n", 1662 g_ExtState.fDelayedAnnouncement, g_ExtState.fDelayedFormats, cbData, parms.cbData, rc)); 1641 1663 1642 1664 /* Did the extension send the clipboard formats yet? … … 1659 1681 { 1660 1682 rc = ShClBackendReadData(pClient, &cmdCtx, uFormat, pvData, cbData, &cbActual); 1661 LogRelFlowFunc(("Shared Clipboard: DATA/Host: cbData=%RU32->%RU32 rc=%Rrc\n", cbData, cbActual, rc)); 1683 if (RT_SUCCESS(rc)) 1684 { 1685 LogRel2(("Shared Clipboard: Read host clipboard data (max %RU32 bytes), got %RU32 bytes\n", cbData, cbActual)); 1686 } 1687 else 1688 LogRel(("Shared Clipboard: Reading host clipboard data failed with %Rrc\n", rc)); 1662 1689 } 1663 1690 … … 1679 1706 } 1680 1707 1708 /** 1709 * Called when the guest writes clipboard data to the host. 1710 * Handles the VBOX_SHCL_GUEST_FN_DATA_WRITE message. 1711 * 1712 * @returns VBox status code. 1713 * @param pClient Client that wants to read host clipboard data. 1714 * @param cParms Number of HGCM parameters supplied in \a paParms. 1715 * @param paParms Array of HGCM parameters. 1716 */ 1681 1717 int shClSvcClientWriteData(PSHCLCLIENT pClient, uint32_t cParms, VBOXHGCMSVCPARM paParms[]) 1682 1718 { … … 1811 1847 /* Let the backend implementation know. */ 1812 1848 rc = ShClBackendWriteData(pClient, &cmdCtx, uFormat, pvData, cbData); 1849 if (RT_FAILURE(rc)) 1850 LogRel(("Shared Clipboard: Writing guest clipboard data to the host failed with %Rrc\n", rc)); 1813 1851 1814 1852 int rc2; /* Don't return internals back to the guest. */ 1815 1853 rc2 = ShClSvcGuestDataSignal(pClient, &cmdCtx, uFormat, pvData, cbData); /* To complete pending events, if any. */ 1854 if (RT_FAILURE(rc2)) 1855 LogRel(("Shared Clipboard: Signalling host about guest clipboard data failed with %Rrc\n", rc2)); 1816 1856 AssertRC(rc2); 1817 1857 }
Note:
See TracChangeset
for help on using the changeset viewer.