VirtualBox

source: vbox/trunk/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp@ 93399

Last change on this file since 93399 was 93399, checked in by vboxsync, 3 years ago

SharedClipboard/win: scm fix. bugref:10160

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 40.5 KB
Line 
1/* $Id: clipboard-win.cpp 93399 2022-01-21 14:20:57Z vboxsync $ */
2/** @file
3 * Shared Clipboard: Windows-specific functions for clipboard handling.
4 */
5
6/*
7 * Copyright (C) 2006-2022 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#define LOG_GROUP LOG_GROUP_SHARED_CLIPBOARD
19#include <VBox/GuestHost/SharedClipboard.h>
20
21#include <iprt/assert.h>
22#include <iprt/errcore.h>
23#include <iprt/ldr.h>
24#include <iprt/mem.h>
25#include <iprt/thread.h>
26#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
27# include <iprt/win/windows.h>
28# include <iprt/win/shlobj.h> /* For CFSTR_FILEDESCRIPTORXXX + CFSTR_FILECONTENTS. */
29# include <iprt/utf16.h>
30#endif
31
32#include <VBox/log.h>
33
34#include <VBox/HostServices/VBoxClipboardSvc.h>
35#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
36# include <VBox/GuestHost/SharedClipboard-transfers.h>
37#endif
38#include <VBox/GuestHost/SharedClipboard-win.h>
39#include <VBox/GuestHost/clipboard-helper.h>
40
41
42/**
43 * Opens the clipboard of a specific window.
44 *
45 * @returns VBox status code.
46 * @param hWnd Handle of window to open clipboard for.
47 */
48int SharedClipboardWinOpen(HWND hWnd)
49{
50 /* "OpenClipboard fails if another window has the clipboard open."
51 * So try a few times and wait up to 1 second.
52 */
53 BOOL fOpened = FALSE;
54
55 LogFlowFunc(("hWnd=%p\n", hWnd));
56
57 int i = 0;
58 for (;;)
59 {
60 if (OpenClipboard(hWnd))
61 {
62 fOpened = TRUE;
63 break;
64 }
65
66 if (i >= 10) /* sleep interval = [1..512] ms */
67 break;
68
69 RTThreadSleep(1 << i);
70 ++i;
71 }
72
73#ifdef LOG_ENABLED
74 if (i > 0)
75 LogFlowFunc(("%d times tried to open clipboard\n", i + 1));
76#endif
77
78 int rc;
79 if (fOpened)
80 rc = VINF_SUCCESS;
81 else
82 {
83 const DWORD dwLastErr = GetLastError();
84 rc = RTErrConvertFromWin32(dwLastErr);
85 LogRel(("Failed to open clipboard, rc=%Rrc (0x%x)\n", rc, dwLastErr));
86 }
87
88 return rc;
89}
90
91/**
92 * Closes the clipboard for the current thread.
93 *
94 * @returns VBox status code.
95 */
96int SharedClipboardWinClose(void)
97{
98 int rc;
99
100 const BOOL fRc = CloseClipboard();
101 if (RT_UNLIKELY(!fRc))
102 {
103 const DWORD dwLastErr = GetLastError();
104 if (dwLastErr == ERROR_CLIPBOARD_NOT_OPEN)
105 {
106 rc = VINF_SUCCESS; /* Not important, so just report success instead. */
107 }
108 else
109 {
110 rc = RTErrConvertFromWin32(dwLastErr);
111 LogFunc(("Failed with %Rrc (0x%x)\n", rc, dwLastErr));
112 }
113 }
114 else
115 rc = VINF_SUCCESS;
116
117 LogFlowFuncLeaveRC(rc);
118 return rc;
119}
120
121/**
122 * Clears the clipboard for the current thread.
123 *
124 * @returns VBox status code.
125 */
126int SharedClipboardWinClear(void)
127{
128 LogFlowFuncEnter();
129 if (EmptyClipboard())
130 return VINF_SUCCESS;
131
132 const DWORD dwLastErr = GetLastError();
133 AssertReturn(dwLastErr != ERROR_CLIPBOARD_NOT_OPEN, VERR_INVALID_STATE);
134
135 int rc = RTErrConvertFromWin32(dwLastErr);
136 LogFunc(("Failed with %Rrc (0x%x)\n", rc, dwLastErr));
137 return rc;
138}
139
140/**
141 * Initializes a Shared Clipboard Windows context.
142 *
143 * @returns VBox status code.
144 * @param pWinCtx Shared Clipboard Windows context to initialize.
145 */
146int SharedClipboardWinCtxInit(PSHCLWINCTX pWinCtx)
147{
148 int rc = RTCritSectInit(&pWinCtx->CritSect);
149 if (RT_SUCCESS(rc))
150 {
151 /* Check that new Clipboard API is available. */
152 SharedClipboardWinCheckAndInitNewAPI(&pWinCtx->newAPI);
153 /* Do *not* check the rc, as the call might return VERR_SYMBOL_NOT_FOUND is the new API isn't available. */
154
155 pWinCtx->hWnd = NULL;
156 pWinCtx->hWndClipboardOwnerUs = NULL;
157 pWinCtx->hWndNextInChain = NULL;
158 }
159
160 LogFlowFuncLeaveRC(rc);
161 return rc;
162}
163
164/**
165 * Destroys a Shared Clipboard Windows context.
166 *
167 * @param pWinCtx Shared Clipboard Windows context to destroy.
168 */
169void SharedClipboardWinCtxDestroy(PSHCLWINCTX pWinCtx)
170{
171 if (!pWinCtx)
172 return;
173
174 LogFlowFuncEnter();
175
176 if (RTCritSectIsInitialized(&pWinCtx->CritSect))
177 {
178 int rc2 = RTCritSectDelete(&pWinCtx->CritSect);
179 AssertRC(rc2);
180 }
181}
182
183/**
184 * Checks and initializes function pointer which are required for using
185 * the new clipboard API.
186 *
187 * @returns VBox status code, or VERR_SYMBOL_NOT_FOUND if the new API is not available.
188 * @param pAPI Where to store the retrieved function pointers.
189 * Will be set to NULL if the new API is not available.
190 */
191int SharedClipboardWinCheckAndInitNewAPI(PSHCLWINAPINEW pAPI)
192{
193 RTLDRMOD hUser32 = NIL_RTLDRMOD;
194 int rc = RTLdrLoadSystem("User32.dll", /* fNoUnload = */ true, &hUser32);
195 if (RT_SUCCESS(rc))
196 {
197 rc = RTLdrGetSymbol(hUser32, "AddClipboardFormatListener", (void **)&pAPI->pfnAddClipboardFormatListener);
198 if (RT_SUCCESS(rc))
199 {
200 rc = RTLdrGetSymbol(hUser32, "RemoveClipboardFormatListener", (void **)&pAPI->pfnRemoveClipboardFormatListener);
201 }
202
203 RTLdrClose(hUser32);
204 }
205
206 if (RT_SUCCESS(rc))
207 {
208 LogRel(("Shared Clipboard: New Clipboard API enabled\n"));
209 }
210 else
211 {
212 RT_BZERO(pAPI, sizeof(SHCLWINAPINEW));
213 LogRel(("Shared Clipboard: New Clipboard API not available (%Rrc)\n", rc));
214 }
215
216 LogFlowFuncLeaveRC(rc);
217 return rc;
218}
219
220/**
221 * Returns if the new clipboard API is available or not.
222 *
223 * @returns @c true if the new API is available, or @c false if not.
224 * @param pAPI Structure used for checking if the new clipboard API is available or not.
225 */
226bool SharedClipboardWinIsNewAPI(PSHCLWINAPINEW pAPI)
227{
228 if (!pAPI)
229 return false;
230 return pAPI->pfnAddClipboardFormatListener != NULL;
231}
232
233/**
234 * Adds ourselves into the chain of cliboard listeners.
235 *
236 * @returns VBox status code.
237 * @param pCtx Windows clipboard context to use to add ourselves.
238 */
239int SharedClipboardWinChainAdd(PSHCLWINCTX pCtx)
240{
241 const PSHCLWINAPINEW pAPI = &pCtx->newAPI;
242
243 BOOL fRc;
244 if (SharedClipboardWinIsNewAPI(pAPI))
245 fRc = pAPI->pfnAddClipboardFormatListener(pCtx->hWnd);
246 else
247 {
248 SetLastError(NO_ERROR);
249 pCtx->hWndNextInChain = SetClipboardViewer(pCtx->hWnd);
250 fRc = pCtx->hWndNextInChain != NULL || GetLastError() == NO_ERROR;
251 }
252
253 int rc = VINF_SUCCESS;
254
255 if (!fRc)
256 {
257 const DWORD dwLastErr = GetLastError();
258 rc = RTErrConvertFromWin32(dwLastErr);
259 LogFunc(("Failed with %Rrc (0x%x)\n", rc, dwLastErr));
260 }
261
262 return rc;
263}
264
265/**
266 * Remove ourselves from the chain of cliboard listeners
267 *
268 * @returns VBox status code.
269 * @param pCtx Windows clipboard context to use to remove ourselves.
270 */
271int SharedClipboardWinChainRemove(PSHCLWINCTX pCtx)
272{
273 if (!pCtx->hWnd)
274 return VINF_SUCCESS;
275
276 const PSHCLWINAPINEW pAPI = &pCtx->newAPI;
277
278 BOOL fRc;
279 if (SharedClipboardWinIsNewAPI(pAPI))
280 {
281 fRc = pAPI->pfnRemoveClipboardFormatListener(pCtx->hWnd);
282 }
283 else
284 {
285 fRc = ChangeClipboardChain(pCtx->hWnd, pCtx->hWndNextInChain);
286 if (fRc)
287 pCtx->hWndNextInChain = NULL;
288 }
289
290 int rc = VINF_SUCCESS;
291
292 if (!fRc)
293 {
294 const DWORD dwLastErr = GetLastError();
295 rc = RTErrConvertFromWin32(dwLastErr);
296 LogFunc(("Failed with %Rrc (0x%x)\n", rc, dwLastErr));
297 }
298
299 return rc;
300}
301
302/**
303 * Callback which is invoked when we have successfully pinged ourselves down the
304 * clipboard chain. We simply unset a boolean flag to say that we are responding.
305 * There is a race if a ping returns after the next one is initiated, but nothing
306 * very bad is likely to happen.
307 *
308 * @param hWnd Window handle to use for this callback. Not used currently.
309 * @param uMsg Message to handle. Not used currently.
310 * @param dwData Pointer to user-provided data. Contains our Windows clipboard context.
311 * @param lResult Additional data to pass. Not used currently.
312 */
313VOID CALLBACK SharedClipboardWinChainPingProc(HWND hWnd, UINT uMsg, ULONG_PTR dwData, LRESULT lResult) RT_NOTHROW_DEF
314{
315 RT_NOREF(hWnd);
316 RT_NOREF(uMsg);
317 RT_NOREF(lResult);
318
319 /** @todo r=andy Why not using SetWindowLongPtr for keeping the context? */
320 PSHCLWINCTX pCtx = (PSHCLWINCTX)dwData;
321 AssertPtrReturnVoid(pCtx);
322
323 pCtx->oldAPI.fCBChainPingInProcess = FALSE;
324}
325
326/**
327 * Passes a window message to the next window in the clipboard chain.
328 *
329 * @returns LRESULT
330 * @param pWinCtx Window context to use.
331 * @param msg Window message to pass.
332 * @param wParam WPARAM to pass.
333 * @param lParam LPARAM to pass.
334 */
335LRESULT SharedClipboardWinChainPassToNext(PSHCLWINCTX pWinCtx,
336 UINT msg, WPARAM wParam, LPARAM lParam)
337{
338 LogFlowFuncEnter();
339
340 LRESULT lresultRc = 0;
341
342 if (pWinCtx->hWndNextInChain)
343 {
344 LogFunc(("hWndNextInChain=%p\n", pWinCtx->hWndNextInChain));
345
346 /* Pass the message to next window in the clipboard chain. */
347 DWORD_PTR dwResult;
348 lresultRc = SendMessageTimeout(pWinCtx->hWndNextInChain, msg, wParam, lParam, 0,
349 SHCL_WIN_CBCHAIN_TIMEOUT_MS, &dwResult);
350 if (!lresultRc)
351 lresultRc = dwResult;
352 }
353
354 LogFlowFunc(("lresultRc=%ld\n", lresultRc));
355 return lresultRc;
356}
357
358/**
359 * Converts a (registered or standard) Windows clipboard format to a VBox clipboard format.
360 *
361 * @returns Converted VBox clipboard format, or VBOX_SHCL_FMT_NONE if not found.
362 * @param uFormat Windows clipboard format to convert.
363 */
364SHCLFORMAT SharedClipboardWinClipboardFormatToVBox(UINT uFormat)
365{
366 /* Insert the requested clipboard format data into the clipboard. */
367 SHCLFORMAT vboxFormat = VBOX_SHCL_FMT_NONE;
368
369 switch (uFormat)
370 {
371 case CF_UNICODETEXT:
372 vboxFormat = VBOX_SHCL_FMT_UNICODETEXT;
373 break;
374
375 case CF_DIB:
376 vboxFormat = VBOX_SHCL_FMT_BITMAP;
377 break;
378
379#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
380 /* CF_HDROP handles file system entries which are locally present
381 * on source for transferring to the target.
382 *
383 * This does *not* invoke any IDataObject / IStream implementations! */
384 case CF_HDROP:
385 vboxFormat = VBOX_SHCL_FMT_URI_LIST;
386 break;
387#endif
388
389 default:
390 if (uFormat >= 0xC000) /** Formats registered with RegisterClipboardFormat() start at this index. */
391 {
392 TCHAR szFormatName[256]; /** @todo r=andy Do we need Unicode support here as well? */
393 int cActual = GetClipboardFormatName(uFormat, szFormatName, sizeof(szFormatName) / sizeof(TCHAR));
394 if (cActual)
395 {
396 LogFlowFunc(("uFormat=%u -> szFormatName=%s\n", uFormat, szFormatName));
397
398 if (RTStrCmp(szFormatName, SHCL_WIN_REGFMT_HTML) == 0)
399 vboxFormat = VBOX_SHCL_FMT_HTML;
400#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
401 /* These types invoke our IDataObject / IStream implementations. */
402 else if ( (RTStrCmp(szFormatName, CFSTR_FILEDESCRIPTORA) == 0)
403 || (RTStrCmp(szFormatName, CFSTR_FILECONTENTS) == 0))
404 vboxFormat = VBOX_SHCL_FMT_URI_LIST;
405 /** @todo Do we need to handle CFSTR_FILEDESCRIPTORW here as well? */
406#endif
407 }
408 }
409 break;
410 }
411
412 LogFlowFunc(("uFormat=%u -> vboxFormat=0x%x\n", uFormat, vboxFormat));
413 return vboxFormat;
414}
415
416/**
417 * Retrieves all supported clipboard formats of a specific clipboard.
418 *
419 * @returns VBox status code.
420 * @param pCtx Windows clipboard context to retrieve formats for.
421 * @param pfFormats Where to store the retrieved formats.
422 */
423int SharedClipboardWinGetFormats(PSHCLWINCTX pCtx, PSHCLFORMATS pfFormats)
424{
425 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
426 AssertPtrReturn(pfFormats, VERR_INVALID_POINTER);
427
428 SHCLFORMATS fFormats = VBOX_SHCL_FMT_NONE;
429
430 /* Query list of available formats and report to host. */
431 int rc = SharedClipboardWinOpen(pCtx->hWnd);
432 if (RT_SUCCESS(rc))
433 {
434 UINT uCurFormat = 0; /* Must be set to zero for EnumClipboardFormats(). */
435 while ((uCurFormat = EnumClipboardFormats(uCurFormat)) != 0)
436 fFormats |= SharedClipboardWinClipboardFormatToVBox(uCurFormat);
437
438 int rc2 = SharedClipboardWinClose();
439 AssertRC(rc2);
440 LogFlowFunc(("fFormats=%#x\n", fFormats));
441 }
442 else
443 LogFunc(("Failed with rc=%Rrc (fFormats=%#x)\n", rc, fFormats));
444
445 *pfFormats = fFormats;
446 return rc;
447}
448
449/**
450 * Extracts a field value from CF_HTML data.
451 *
452 * @returns VBox status code.
453 * @param pszSrc source in CF_HTML format.
454 * @param pszOption Name of CF_HTML field.
455 * @param puValue Where to return extracted value of CF_HTML field.
456 */
457int SharedClipboardWinGetCFHTMLHeaderValue(const char *pszSrc, const char *pszOption, uint32_t *puValue)
458{
459 AssertPtrReturn(pszSrc, VERR_INVALID_POINTER);
460 AssertPtrReturn(pszOption, VERR_INVALID_POINTER);
461
462 int rc = VERR_INVALID_PARAMETER;
463
464 const char *pszOptionValue = RTStrStr(pszSrc, pszOption);
465 if (pszOptionValue)
466 {
467 size_t cchOption = strlen(pszOption);
468 Assert(cchOption);
469
470 rc = RTStrToUInt32Ex(pszOptionValue + cchOption, NULL, 10, puValue);
471 }
472 return rc;
473}
474
475/**
476 * Check that the source string contains CF_HTML struct.
477 *
478 * @returns @c true if the @a pszSource string is in CF_HTML format.
479 * @param pszSource Source string to check.
480 */
481bool SharedClipboardWinIsCFHTML(const char *pszSource)
482{
483 return RTStrStr(pszSource, "Version:") != NULL
484 && RTStrStr(pszSource, "StartHTML:") != NULL;
485}
486
487/**
488 * Converts clipboard data from CF_HTML format to MIME clipboard format.
489 *
490 * Returns allocated buffer that contains html converted to text/html mime type
491 *
492 * @returns VBox status code.
493 * @param pszSource The input.
494 * @param cch The length of the input.
495 * @param ppszOutput Where to return the result. Free using RTMemFree.
496 * @param pcbOutput Where to the return length of the result (bytes/chars).
497 */
498int SharedClipboardWinConvertCFHTMLToMIME(const char *pszSource, const uint32_t cch, char **ppszOutput, uint32_t *pcbOutput)
499{
500 Assert(pszSource);
501 Assert(cch);
502 Assert(ppszOutput);
503 Assert(pcbOutput);
504
505 uint32_t offStart;
506 int rc = SharedClipboardWinGetCFHTMLHeaderValue(pszSource, "StartFragment:", &offStart);
507 if (RT_SUCCESS(rc))
508 {
509 uint32_t offEnd;
510 rc = SharedClipboardWinGetCFHTMLHeaderValue(pszSource, "EndFragment:", &offEnd);
511 if (RT_SUCCESS(rc))
512 {
513 if ( offStart > 0
514 && offEnd > 0
515 && offEnd > offStart
516 && offEnd <= cch)
517 {
518 uint32_t cchSubStr = offEnd - offStart;
519 char *pszResult = (char *)RTMemAlloc(cchSubStr + 1);
520 if (pszResult)
521 {
522 rc = RTStrCopyEx(pszResult, cchSubStr + 1, pszSource + offStart, cchSubStr);
523 if (RT_SUCCESS(rc))
524 {
525 *ppszOutput = pszResult;
526 *pcbOutput = (uint32_t)(cchSubStr + 1);
527 rc = VINF_SUCCESS;
528 }
529 else
530 {
531 LogRelFlowFunc(("Error: Unknown CF_HTML format. Expected EndFragment. rc = %Rrc\n", rc));
532 RTMemFree(pszResult);
533 }
534 }
535 else
536 {
537 LogRelFlowFunc(("Error: Unknown CF_HTML format. Expected EndFragment\n"));
538 rc = VERR_NO_MEMORY;
539 }
540 }
541 else
542 {
543 LogRelFlowFunc(("Error: CF_HTML out of bounds - offStart=%#x offEnd=%#x cch=%#x\n", offStart, offEnd, cch));
544 rc = VERR_INVALID_PARAMETER;
545 }
546 }
547 else
548 {
549 LogRelFlowFunc(("Error: Unknown CF_HTML format. Expected EndFragment. rc = %Rrc\n", rc));
550 rc = VERR_INVALID_PARAMETER;
551 }
552 }
553 else
554 {
555 LogRelFlowFunc(("Error: Unknown CF_HTML format. Expected StartFragment. rc = %Rrc\n", rc));
556 rc = VERR_INVALID_PARAMETER;
557 }
558
559 return rc;
560}
561
562/**
563 * Converts source UTF-8 MIME HTML clipboard data to UTF-8 CF_HTML format.
564 *
565 * This is just encapsulation work, slapping a header on the data.
566 *
567 * It allocates [..]
568 *
569 * Calculations:
570 * Header length = format Length + (2*(10 - 5('%010d'))('digits')) - 2('%s') = format length + 8
571 * EndHtml = Header length + fragment length
572 * StartHtml = 105(constant)
573 * StartFragment = 141(constant) may vary if the header html content will be extended
574 * EndFragment = Header length + fragment length - 38(ending length)
575 *
576 * For more format details, check out:
577 * https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767917(v=vs.85)
578 *
579 * @returns VBox status code.
580 * @param pszSource Source buffer that contains utf-16 string in mime html format
581 * @param cb Size of source buffer in bytes
582 * @param ppszOutput Where to return the allocated output buffer to put converted UTF-8
583 * CF_HTML clipboard data. This function allocates memory for this.
584 * @param pcbOutput Where to return the size of allocated result buffer in bytes/chars, including zero terminator
585 *
586 * @note output buffer should be free using RTMemFree()
587 * @note Everything inside of fragment can be UTF8. Windows allows it. Everything in header should be Latin1.
588 */
589int SharedClipboardWinConvertMIMEToCFHTML(const char *pszSource, size_t cb, char **ppszOutput, uint32_t *pcbOutput)
590{
591 Assert(ppszOutput);
592 Assert(pcbOutput);
593 Assert(pszSource);
594 Assert(cb);
595
596 /* construct CF_HTML formatted string */
597
598 /* Check that input is zero terminated. */
599 /** @todo r=bird: Check that it's valid UTF-8 encoded too. */
600 size_t cchFragment;
601 int rc = RTStrNLenEx(pszSource, cb, &cchFragment);
602 if (!RT_SUCCESS(rc))
603 {
604 LogRelFlowFunc(("Error: invalid source fragment. rc = %Rrc\n", rc));
605 return VERR_INVALID_PARAMETER;
606 }
607
608 /*
609 @StartHtml - pos before <html>
610 @EndHtml - whole size of text excluding ending zero char
611 @StartFragment - pos after <!--StartFragment-->
612 @EndFragment - pos before <!--EndFragment-->
613 @note: all values includes CR\LF inserted into text
614 Calculations:
615 Header length = format Length + (3*6('digits')) - 2('%s') = format length + 16 (control value - 183)
616 EndHtml = Header length + fragment length
617 StartHtml = 105(constant)
618 StartFragment = 143(constant)
619 EndFragment = Header length + fragment length - 40(ending length)
620 */
621 static const char s_szFormatSample[] =
622 /* 0: */ "Version:1.0\r\n"
623 /* 13: */ "StartHTML:000000101\r\n"
624 /* 34: */ "EndHTML:%0000009u\r\n" // END HTML = Header length + fragment length
625 /* 53: */ "StartFragment:000000137\r\n"
626 /* 78: */ "EndFragment:%0000009u\r\n"
627 /* 101: */ "<html>\r\n"
628 /* 109: */ "<body>\r\n"
629 /* 117: */ "<!--StartFragment-->"
630 /* 137: */ "%s"
631 /* 137+2: */ "<!--EndFragment-->\r\n"
632 /* 157+2: */ "</body>\r\n"
633 /* 166+2: */ "</html>\r\n";
634 /* 175+2: */
635 AssertCompile(sizeof(s_szFormatSample) == 175 + 2 + 1);
636
637 /* calculate parameters of CF_HTML header */
638 size_t cchHeader = sizeof(s_szFormatSample) - 1;
639 size_t offEndHtml = cchHeader + cchFragment;
640 size_t offEndFragment = cchHeader + cchFragment - 38; /* 175-137 = 38 */
641 char *pszResult = (char *)RTMemAlloc(offEndHtml + 1);
642 if (pszResult == NULL)
643 {
644 LogRelFlowFunc(("Error: Cannot allocate memory for result buffer. rc = %Rrc\n"));
645 return VERR_NO_MEMORY;
646 }
647
648 /* format result CF_HTML string */
649 size_t cchFormatted = RTStrPrintf(pszResult, offEndHtml + 1,
650 s_szFormatSample, offEndHtml, offEndFragment, pszSource);
651 Assert(offEndHtml == cchFormatted);
652
653#ifdef VBOX_STRICT
654 /* Control calculations. check consistency.*/
655 static const char s_szStartFragment[] = "<!--StartFragment-->";
656 static const char s_szEndFragment[] = "<!--EndFragment-->";
657
658 /* check 'StartFragment:' value */
659 const char *pszRealStartFragment = RTStrStr(pszResult, s_szStartFragment);
660 Assert(&pszRealStartFragment[sizeof(s_szStartFragment) - 1] - pszResult == 137);
661
662 /* check 'EndFragment:' value */
663 const char *pszRealEndFragment = RTStrStr(pszResult, s_szEndFragment);
664 Assert((size_t)(pszRealEndFragment - pszResult) == offEndFragment);
665#endif
666
667 *ppszOutput = pszResult;
668 *pcbOutput = (uint32_t)cchFormatted + 1;
669 Assert(*pcbOutput == cchFormatted + 1);
670
671 return VINF_SUCCESS;
672}
673
674/**
675 * Handles the WM_CHANGECBCHAIN code.
676 *
677 * @returns LRESULT
678 * @param pWinCtx Windows context to use.
679 * @param hWnd Window handle to use.
680 * @param msg Message ID to pass on.
681 * @param wParam wParam to pass on
682 * @param lParam lParam to pass on.
683 */
684LRESULT SharedClipboardWinHandleWMChangeCBChain(PSHCLWINCTX pWinCtx,
685 HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
686{
687 LRESULT lresultRc = 0;
688
689 LogFlowFuncEnter();
690
691 if (SharedClipboardWinIsNewAPI(&pWinCtx->newAPI))
692 {
693 lresultRc = DefWindowProc(hWnd, msg, wParam, lParam);
694 }
695 else /* Old API */
696 {
697 HWND hwndRemoved = (HWND)wParam;
698 HWND hwndNext = (HWND)lParam;
699
700 if (hwndRemoved == pWinCtx->hWndNextInChain)
701 {
702 /* The window that was next to our in the chain is being removed.
703 * Relink to the new next window.
704 */
705 pWinCtx->hWndNextInChain = hwndNext;
706 }
707 else
708 {
709 if (pWinCtx->hWndNextInChain)
710 {
711 /* Pass the message further. */
712 DWORD_PTR dwResult;
713 lresultRc = SendMessageTimeout(pWinCtx->hWndNextInChain, WM_CHANGECBCHAIN, wParam, lParam, 0,
714 SHCL_WIN_CBCHAIN_TIMEOUT_MS,
715 &dwResult);
716 if (!lresultRc)
717 lresultRc = (LRESULT)dwResult;
718 }
719 }
720 }
721
722 LogFlowFunc(("lresultRc=%ld\n", lresultRc));
723 return lresultRc;
724}
725
726/**
727 * Handles the WM_DESTROY code.
728 *
729 * @returns VBox status code.
730 * @param pWinCtx Windows context to use.
731 */
732int SharedClipboardWinHandleWMDestroy(PSHCLWINCTX pWinCtx)
733{
734 LogFlowFuncEnter();
735
736 int rc = VINF_SUCCESS;
737
738 /* MS recommends to remove from Clipboard chain in this callback. */
739 SharedClipboardWinChainRemove(pWinCtx);
740
741 if (pWinCtx->oldAPI.timerRefresh)
742 {
743 Assert(pWinCtx->hWnd);
744 KillTimer(pWinCtx->hWnd, 0);
745 }
746
747 LogFlowFuncLeaveRC(rc);
748 return rc;
749}
750
751/**
752 * Handles the WM_RENDERALLFORMATS message.
753 *
754 * @returns VBox status code.
755 * @param pWinCtx Windows context to use.
756 * @param hWnd Window handle to use.
757 */
758int SharedClipboardWinHandleWMRenderAllFormats(PSHCLWINCTX pWinCtx, HWND hWnd)
759{
760 RT_NOREF(pWinCtx);
761
762 LogFlowFuncEnter();
763
764 /* Do nothing. The clipboard formats will be unavailable now, because the
765 * windows is to be destroyed and therefore the guest side becomes inactive.
766 */
767 int rc = SharedClipboardWinOpen(hWnd);
768 if (RT_SUCCESS(rc))
769 {
770 SharedClipboardWinClear();
771 SharedClipboardWinClose();
772 }
773
774 LogFlowFuncLeaveRC(rc);
775 return rc;
776}
777
778/**
779 * Handles the WM_TIMER code, which is needed if we're running with the so-called "old" Windows clipboard API.
780 * Does nothing if we're running with the "new" Windows API.
781 *
782 * @returns VBox status code.
783 * @param pWinCtx Windows context to use.
784 */
785int SharedClipboardWinHandleWMTimer(PSHCLWINCTX pWinCtx)
786{
787 int rc = VINF_SUCCESS;
788
789 if (!SharedClipboardWinIsNewAPI(&pWinCtx->newAPI)) /* Only run when using the "old" Windows API. */
790 {
791 LogFlowFuncEnter();
792
793 HWND hViewer = GetClipboardViewer();
794
795 /* Re-register ourselves in the clipboard chain if our last ping
796 * timed out or there seems to be no valid chain. */
797 if (!hViewer || pWinCtx->oldAPI.fCBChainPingInProcess)
798 {
799 SharedClipboardWinChainRemove(pWinCtx);
800 SharedClipboardWinChainAdd(pWinCtx);
801 }
802
803 /* Start a new ping by passing a dummy WM_CHANGECBCHAIN to be
804 * processed by ourselves to the chain. */
805 pWinCtx->oldAPI.fCBChainPingInProcess = TRUE;
806
807 hViewer = GetClipboardViewer();
808 if (hViewer)
809 SendMessageCallback(hViewer, WM_CHANGECBCHAIN, (WPARAM)pWinCtx->hWndNextInChain, (LPARAM)pWinCtx->hWndNextInChain,
810 SharedClipboardWinChainPingProc, (ULONG_PTR)pWinCtx);
811 }
812
813 LogFlowFuncLeaveRC(rc);
814 return rc;
815}
816
817/**
818 * Announces a clipboard format to the Windows clipboard.
819 *
820 * The actual rendering (setting) of the clipboard data will be done later with
821 * a separate WM_RENDERFORMAT message.
822 *
823 * @returns VBox status code. VERR_NOT_SUPPORTED if the format is not supported / handled.
824 * @param pWinCtx Windows context to use.
825 * @param fFormats Clipboard format(s) to announce.
826 */
827static int sharedClipboardWinAnnounceFormats(PSHCLWINCTX pWinCtx, SHCLFORMATS fFormats)
828{
829 LogFunc(("fFormats=0x%x\n", fFormats));
830
831 /*
832 * Set the clipboard formats.
833 */
834 static struct
835 {
836 uint32_t fVBoxFormat;
837 UINT uWinFormat;
838 const char *pszWinFormat;
839 const char *pszLog;
840 } s_aFormats[] =
841 {
842 { VBOX_SHCL_FMT_UNICODETEXT, CF_UNICODETEXT, NULL, "CF_UNICODETEXT" },
843 { VBOX_SHCL_FMT_BITMAP, CF_DIB, NULL, "CF_DIB" },
844 { VBOX_SHCL_FMT_HTML, 0, SHCL_WIN_REGFMT_HTML, "SHCL_WIN_REGFMT_HTML" },
845 };
846 unsigned cSuccessfullySet = 0;
847 SHCLFORMATS fFormatsLeft = fFormats;
848 int rc = VINF_SUCCESS;
849 for (uintptr_t i = 0; i < RT_ELEMENTS(s_aFormats) && fFormatsLeft != 0; i++)
850 {
851 if (fFormatsLeft & s_aFormats[i].fVBoxFormat)
852 {
853 LogFunc(("%s\n", s_aFormats[i].pszLog));
854 fFormatsLeft &= ~s_aFormats[i].fVBoxFormat;
855
856 /* Reg format if needed: */
857 UINT uWinFormat = s_aFormats[i].uWinFormat;
858 if (!uWinFormat)
859 {
860 uWinFormat = RegisterClipboardFormat(s_aFormats[i].pszWinFormat);
861 AssertContinue(uWinFormat != 0);
862 }
863
864 /* Tell the clipboard we've got data upon a request. We check the
865 last error here as hClip will be NULL even on success (despite
866 what MSDN says). */
867 SetLastError(NO_ERROR);
868 HANDLE hClip = SetClipboardData(uWinFormat, NULL);
869 DWORD dwErr = GetLastError();
870 if (dwErr == NO_ERROR || hClip != NULL)
871 cSuccessfullySet++;
872 else
873 {
874 AssertMsgFailed(("%s/%u: %u\n", s_aFormats[i].pszLog, uWinFormat, dwErr));
875 rc = RTErrConvertFromWin32(dwErr);
876 }
877 }
878 }
879
880 /*
881 * Consider setting anything a success, converting any error into
882 * informational status. Unsupport error only happens if all formats
883 * were unsupported.
884 */
885 if (cSuccessfullySet > 0)
886 {
887 pWinCtx->hWndClipboardOwnerUs = GetClipboardOwner();
888 if (RT_FAILURE(rc))
889 rc = -rc;
890 }
891 else if (RT_SUCCESS(rc) && fFormatsLeft != 0)
892 {
893 LogFunc(("Unsupported formats: %#x (%#x)\n", fFormatsLeft, fFormats));
894 rc = VERR_NOT_SUPPORTED;
895 }
896
897 LogFlowFuncLeaveRC(rc);
898 return rc;
899}
900
901/**
902 * Opens the clipboard, clears it, announces @a fFormats and closes it.
903 *
904 * The actual rendering (setting) of the clipboard data will be done later with
905 * a separate WM_RENDERFORMAT message.
906 *
907 * @returns VBox status code. VERR_NOT_SUPPORTED if the format is not supported / handled.
908 * @param pWinCtx Windows context to use.
909 * @param fFormats Clipboard format(s) to announce.
910 * @param hWnd The window handle to use as owner.
911 */
912int SharedClipboardWinClearAndAnnounceFormats(PSHCLWINCTX pWinCtx, SHCLFORMATS fFormats, HWND hWnd)
913{
914 int rc = SharedClipboardWinOpen(hWnd);
915 if (RT_SUCCESS(rc))
916 {
917 SharedClipboardWinClear();
918
919 rc = sharedClipboardWinAnnounceFormats(pWinCtx, fFormats);
920 Assert(pWinCtx->hWndClipboardOwnerUs == hWnd || pWinCtx->hWndClipboardOwnerUs == NULL);
921
922 SharedClipboardWinClose();
923 }
924 return rc;
925}
926
927#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
928
929/**
930 * Creates an Shared Clipboard transfer by announcing transfer data (via IDataObject) to Windows.
931 *
932 * This creates the necessary IDataObject + IStream implementations and initiates the actual transfers required for getting
933 * the meta data. Whether or not the actual (file++) transfer(s) are happening is up to the user (at some point) later then.
934 *
935 * @returns VBox status code.
936 * @param pWinCtx Windows context to use.
937 * @param pTransferCtxCtx Transfer contextto use.
938 * @param pTransfer Shared Clipboard transfer to use.
939 */
940int SharedClipboardWinTransferCreate(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer)
941{
942 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);
943
944 LogFlowFunc(("pWinCtx=%p\n", pWinCtx));
945
946 AssertReturn(pTransfer->pvUser == NULL, VERR_WRONG_ORDER);
947
948 /* Make sure to enter the critical section before setting the clipboard data, as otherwise WM_CLIPBOARDUPDATE
949 * might get called *before* we had the opportunity to set pWinCtx->hWndClipboardOwnerUs below. */
950 int rc = RTCritSectEnter(&pWinCtx->CritSect);
951 if (RT_SUCCESS(rc))
952 {
953 SharedClipboardWinTransferCtx *pWinURITransferCtx = new SharedClipboardWinTransferCtx();
954 if (pWinURITransferCtx)
955 {
956 pTransfer->pvUser = pWinURITransferCtx;
957 pTransfer->cbUser = sizeof(SharedClipboardWinTransferCtx);
958
959 pWinURITransferCtx->pDataObj = new SharedClipboardWinDataObject(pTransfer);
960 if (pWinURITransferCtx->pDataObj)
961 {
962 rc = pWinURITransferCtx->pDataObj->Init();
963 if (RT_SUCCESS(rc))
964 {
965 SharedClipboardWinClose();
966 /* Note: Clipboard must be closed first before calling OleSetClipboard(). */
967
968 /** @todo There is a potential race between SharedClipboardWinClose() and OleSetClipboard(),
969 * where another application could own the clipboard (open), and thus the call to
970 * OleSetClipboard() will fail. Needs (better) fixing. */
971 HRESULT hr = S_OK;
972
973 for (unsigned uTries = 0; uTries < 3; uTries++)
974 {
975 hr = OleSetClipboard(pWinURITransferCtx->pDataObj);
976 if (SUCCEEDED(hr))
977 {
978 Assert(OleIsCurrentClipboard(pWinURITransferCtx->pDataObj) == S_OK); /* Sanity. */
979
980 /*
981 * Calling OleSetClipboard() changed the clipboard owner, which in turn will let us receive
982 * a WM_CLIPBOARDUPDATE message. To not confuse ourselves with our own clipboard owner changes,
983 * save a new window handle and deal with it in WM_CLIPBOARDUPDATE.
984 */
985 pWinCtx->hWndClipboardOwnerUs = GetClipboardOwner();
986
987 LogFlowFunc(("hWndClipboardOwnerUs=%p\n", pWinCtx->hWndClipboardOwnerUs));
988 break;
989 }
990
991 LogFlowFunc(("Failed with %Rhrc (try %u/3)\n", hr, uTries + 1));
992 RTThreadSleep(500); /* Wait a bit. */
993 }
994
995 if (FAILED(hr))
996 {
997 rc = VERR_ACCESS_DENIED; /** @todo Fudge; fix this. */
998 LogRel(("Shared Clipboard: Failed with %Rhrc when setting data object to clipboard\n", hr));
999 }
1000 }
1001 }
1002 else
1003 rc = VERR_NO_MEMORY;
1004 }
1005 else
1006 rc = VERR_NO_MEMORY;
1007
1008 int rc2 = RTCritSectLeave(&pWinCtx->CritSect);
1009 AssertRC(rc2);
1010 }
1011
1012 LogFlowFuncLeaveRC(rc);
1013 return rc;
1014}
1015
1016/**
1017 * Destroys implementation-specific data for an Shared Clipboard transfer.
1018 *
1019 * @param pWinCtx Windows context to use.
1020 * @param pTransfer Shared Clipboard transfer to create implementation-specific data for.
1021 */
1022void SharedClipboardWinTransferDestroy(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer)
1023{
1024 RT_NOREF(pWinCtx);
1025
1026 if (!pTransfer)
1027 return;
1028
1029 LogFlowFuncEnter();
1030
1031 if (pTransfer->pvUser)
1032 {
1033 Assert(pTransfer->cbUser == sizeof(SharedClipboardWinTransferCtx));
1034 SharedClipboardWinTransferCtx *pWinURITransferCtx = (SharedClipboardWinTransferCtx *)pTransfer->pvUser;
1035 Assert(pWinURITransferCtx);
1036
1037 if (pWinURITransferCtx->pDataObj)
1038 {
1039 delete pWinURITransferCtx->pDataObj;
1040 pWinURITransferCtx->pDataObj = NULL;
1041 }
1042
1043 delete pWinURITransferCtx;
1044
1045 pTransfer->pvUser = NULL;
1046 pTransfer->cbUser = 0;
1047 }
1048}
1049
1050/**
1051 * Retrieves the roots for a transfer by opening the clipboard and getting the clipboard data
1052 * as string list (CF_HDROP), assigning it to the transfer as roots then.
1053 *
1054 * @returns VBox status code.
1055 * @param pWinCtx Windows context to use.
1056 * @param pTransfer Transfer to get roots for.
1057 */
1058int SharedClipboardWinGetRoots(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer)
1059{
1060 AssertPtrReturn(pWinCtx, VERR_INVALID_POINTER);
1061 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);
1062
1063 Assert(ShClTransferGetSource(pTransfer) == SHCLSOURCE_LOCAL); /* Sanity. */
1064
1065 int rc = SharedClipboardWinOpen(pWinCtx->hWnd);
1066 if (RT_SUCCESS(rc))
1067 {
1068 /* The data data in CF_HDROP format, as the files are locally present and don't need to be
1069 * presented as a IDataObject or IStream. */
1070 HANDLE hClip = hClip = GetClipboardData(CF_HDROP);
1071 if (hClip)
1072 {
1073 HDROP hDrop = (HDROP)GlobalLock(hClip);
1074 if (hDrop)
1075 {
1076 char *papszList = NULL;
1077 uint32_t cbList;
1078 rc = SharedClipboardWinDropFilesToStringList((DROPFILES *)hDrop, &papszList, &cbList);
1079
1080 GlobalUnlock(hClip);
1081
1082 if (RT_SUCCESS(rc))
1083 {
1084 rc = ShClTransferRootsSet(pTransfer,
1085 papszList, cbList + 1 /* Include termination */);
1086 RTStrFree(papszList);
1087 }
1088 }
1089 else
1090 LogRel(("Shared Clipboard: Unable to lock clipboard data, last error: %ld\n", GetLastError()));
1091 }
1092 else
1093 LogRel(("Shared Clipboard: Unable to retrieve clipboard data from clipboard (CF_HDROP), last error: %ld\n",
1094 GetLastError()));
1095
1096 SharedClipboardWinClose();
1097 }
1098
1099 LogFlowFuncLeaveRC(rc);
1100 return rc;
1101}
1102
1103/**
1104 * Converts a DROPFILES (HDROP) structure to a string list, separated by \r\n.
1105 * Does not do any locking on the input data.
1106 *
1107 * @returns VBox status code.
1108 * @param pDropFiles Pointer to DROPFILES structure to convert.
1109 * @param papszList Where to store the allocated string list.
1110 * @param pcbList Where to store the size (in bytes) of the allocated string list.
1111 */
1112int SharedClipboardWinDropFilesToStringList(DROPFILES *pDropFiles, char **papszList, uint32_t *pcbList)
1113{
1114 AssertPtrReturn(pDropFiles, VERR_INVALID_POINTER);
1115 AssertPtrReturn(papszList, VERR_INVALID_POINTER);
1116 AssertPtrReturn(pcbList, VERR_INVALID_POINTER);
1117
1118 /* Do we need to do Unicode stuff? */
1119 const bool fUnicode = RT_BOOL(pDropFiles->fWide);
1120
1121 /* Get the offset of the file list. */
1122 Assert(pDropFiles->pFiles >= sizeof(DROPFILES));
1123
1124 /* Note: This is *not* pDropFiles->pFiles! DragQueryFile only
1125 * will work with the plain storage medium pointer! */
1126 HDROP hDrop = (HDROP)(pDropFiles);
1127
1128 int rc = VINF_SUCCESS;
1129
1130 /* First, get the file count. */
1131 /** @todo Does this work on Windows 2000 / NT4? */
1132 char *pszFiles = NULL;
1133 uint32_t cchFiles = 0;
1134 UINT cFiles = DragQueryFile(hDrop, UINT32_MAX /* iFile */, NULL /* lpszFile */, 0 /* cchFile */);
1135
1136 LogFlowFunc(("Got %RU16 file(s), fUnicode=%RTbool\n", cFiles, fUnicode));
1137
1138 for (UINT i = 0; i < cFiles; i++)
1139 {
1140 UINT cchFile = DragQueryFile(hDrop, i /* File index */, NULL /* Query size first */, 0 /* cchFile */);
1141 Assert(cchFile);
1142
1143 if (RT_FAILURE(rc))
1144 break;
1145
1146 char *pszFileUtf8 = NULL; /* UTF-8 version. */
1147 UINT cchFileUtf8 = 0;
1148 if (fUnicode)
1149 {
1150 /* Allocate enough space (including terminator). */
1151 WCHAR *pwszFile = (WCHAR *)RTMemAlloc((cchFile + 1) * sizeof(WCHAR));
1152 if (pwszFile)
1153 {
1154 const UINT cwcFileUtf16 = DragQueryFileW(hDrop, i /* File index */,
1155 pwszFile, cchFile + 1 /* Include terminator */);
1156
1157 AssertMsg(cwcFileUtf16 == cchFile, ("cchFileUtf16 (%RU16) does not match cchFile (%RU16)\n",
1158 cwcFileUtf16, cchFile));
1159 RT_NOREF(cwcFileUtf16);
1160
1161 rc = RTUtf16ToUtf8(pwszFile, &pszFileUtf8);
1162 if (RT_SUCCESS(rc))
1163 {
1164 cchFileUtf8 = (UINT)strlen(pszFileUtf8);
1165 Assert(cchFileUtf8);
1166 }
1167
1168 RTMemFree(pwszFile);
1169 }
1170 else
1171 rc = VERR_NO_MEMORY;
1172 }
1173 else /* ANSI */
1174 {
1175 /* Allocate enough space (including terminator). */
1176 char *pszFileANSI = (char *)RTMemAlloc((cchFile + 1) * sizeof(char));
1177 UINT cchFileANSI = 0;
1178 if (pszFileANSI)
1179 {
1180 cchFileANSI = DragQueryFileA(hDrop, i /* File index */,
1181 pszFileANSI, cchFile + 1 /* Include terminator */);
1182
1183 AssertMsg(cchFileANSI == cchFile, ("cchFileANSI (%RU16) does not match cchFile (%RU16)\n",
1184 cchFileANSI, cchFile));
1185
1186 /* Convert the ANSI codepage to UTF-8. */
1187 rc = RTStrCurrentCPToUtf8(&pszFileUtf8, pszFileANSI);
1188 if (RT_SUCCESS(rc))
1189 {
1190 cchFileUtf8 = (UINT)strlen(pszFileUtf8);
1191 }
1192 }
1193 else
1194 rc = VERR_NO_MEMORY;
1195 }
1196
1197 if (RT_SUCCESS(rc))
1198 {
1199 LogFlowFunc(("\tFile: %s (cchFile=%RU16)\n", pszFileUtf8, cchFileUtf8));
1200
1201 LogRel2(("Shared Clipboard: Adding file '%s' to transfer\n", pszFileUtf8));
1202
1203 rc = RTStrAAppendExN(&pszFiles, 1 /* cPairs */, pszFileUtf8, strlen(pszFileUtf8));
1204 cchFiles += (uint32_t)strlen(pszFileUtf8);
1205 }
1206
1207 if (pszFileUtf8)
1208 RTStrFree(pszFileUtf8);
1209
1210 if (RT_FAILURE(rc))
1211 {
1212 LogFunc(("Error handling file entry #%u, rc=%Rrc\n", i, rc));
1213 break;
1214 }
1215
1216 /* Add separation between filenames.
1217 * Note: Also do this for the last element of the list. */
1218 rc = RTStrAAppendExN(&pszFiles, 1 /* cPairs */, "\r\n", 2 /* Bytes */);
1219 if (RT_SUCCESS(rc))
1220 cchFiles += 2; /* Include \r\n */
1221 }
1222
1223 if (RT_SUCCESS(rc))
1224 {
1225 cchFiles += 1; /* Add string termination. */
1226 uint32_t cbFiles = cchFiles * sizeof(char); /* UTF-8. */
1227
1228 LogFlowFunc(("cFiles=%u, cchFiles=%RU32, cbFiles=%RU32, pszFiles=0x%p\n",
1229 cFiles, cchFiles, cbFiles, pszFiles));
1230
1231 *papszList = pszFiles;
1232 *pcbList = cbFiles;
1233 }
1234 else
1235 {
1236 if (pszFiles)
1237 RTStrFree(pszFiles);
1238 }
1239
1240 LogFlowFuncLeaveRC(rc);
1241 return rc;
1242}
1243
1244#endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */
1245
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette