1 | /* $Id: clipboard-common.cpp 82477 2019-12-06 23:54:16Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Shared Clipboard: Some helper function for converting between the various eol.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Includes contributions from François Revol
|
---|
8 | *
|
---|
9 | * Copyright (C) 2006-2019 Oracle Corporation
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | * available from http://www.alldomusa.eu.org. This file is free software;
|
---|
13 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | * General Public License (GPL) as published by the Free Software
|
---|
15 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | */
|
---|
19 |
|
---|
20 | #define LOG_GROUP LOG_GROUP_SHARED_CLIPBOARD
|
---|
21 |
|
---|
22 | #include <iprt/alloc.h>
|
---|
23 | #include <iprt/assert.h>
|
---|
24 | #include <iprt/semaphore.h>
|
---|
25 | #include <iprt/path.h>
|
---|
26 | #include <iprt/rand.h>
|
---|
27 |
|
---|
28 | #include <iprt/errcore.h>
|
---|
29 | #include <VBox/log.h>
|
---|
30 | #include <VBox/GuestHost/clipboard-helper.h>
|
---|
31 | #include <VBox/HostServices/VBoxClipboardSvc.h>
|
---|
32 |
|
---|
33 |
|
---|
34 | /**
|
---|
35 | * Allocates a new event payload.
|
---|
36 | *
|
---|
37 | * @returns VBox status code.
|
---|
38 | * @param uID Payload ID to set for this payload. Useful for consequtive payloads.
|
---|
39 | * @param pvData Data block to associate to this payload.
|
---|
40 | * @param cbData Size (in bytes) of data block to associate.
|
---|
41 | * @param ppPayload Where to store the allocated event payload on success.
|
---|
42 | */
|
---|
43 | int ShClPayloadAlloc(uint32_t uID, const void *pvData, uint32_t cbData,
|
---|
44 | PSHCLEVENTPAYLOAD *ppPayload)
|
---|
45 | {
|
---|
46 | AssertPtrReturn(pvData, VERR_INVALID_POINTER);
|
---|
47 | AssertReturn(cbData > 0, VERR_INVALID_PARAMETER);
|
---|
48 |
|
---|
49 | PSHCLEVENTPAYLOAD pPayload = (PSHCLEVENTPAYLOAD)RTMemAlloc(sizeof(SHCLEVENTPAYLOAD));
|
---|
50 | if (pPayload)
|
---|
51 | {
|
---|
52 | pPayload->pvData = RTMemDup(pvData, cbData);
|
---|
53 | if (pPayload->pvData)
|
---|
54 | {
|
---|
55 | pPayload->cbData = cbData;
|
---|
56 | pPayload->uID = uID;
|
---|
57 |
|
---|
58 | *ppPayload = pPayload;
|
---|
59 | return VINF_SUCCESS;
|
---|
60 | }
|
---|
61 |
|
---|
62 | RTMemFree(pPayload);
|
---|
63 | }
|
---|
64 | return VERR_NO_MEMORY;
|
---|
65 | }
|
---|
66 |
|
---|
67 | /**
|
---|
68 | * Frees an event payload.
|
---|
69 | *
|
---|
70 | * @returns VBox status code.
|
---|
71 | * @param pPayload Event payload to free.
|
---|
72 | */
|
---|
73 | void ShClPayloadFree(PSHCLEVENTPAYLOAD pPayload)
|
---|
74 | {
|
---|
75 | if (!pPayload)
|
---|
76 | return;
|
---|
77 |
|
---|
78 | if (pPayload->pvData)
|
---|
79 | {
|
---|
80 | Assert(pPayload->cbData);
|
---|
81 | RTMemFree(pPayload->pvData);
|
---|
82 | pPayload->pvData = NULL;
|
---|
83 | }
|
---|
84 |
|
---|
85 | pPayload->cbData = 0;
|
---|
86 | pPayload->uID = UINT32_MAX;
|
---|
87 |
|
---|
88 | RTMemFree(pPayload);
|
---|
89 | }
|
---|
90 |
|
---|
91 | /**
|
---|
92 | * Creates (initializes) an event.
|
---|
93 | *
|
---|
94 | * @returns VBox status code.
|
---|
95 | * @param pEvent Event to initialize.
|
---|
96 | * @param uID Event ID to use.
|
---|
97 | */
|
---|
98 | int ShClEventCreate(PSHCLEVENT pEvent, SHCLEVENTID uID)
|
---|
99 | {
|
---|
100 | AssertPtrReturn(pEvent, VERR_INVALID_POINTER);
|
---|
101 |
|
---|
102 | LogFlowFunc(("Event %RU32\n", uID));
|
---|
103 |
|
---|
104 | int rc = RTSemEventCreate(&pEvent->hEventSem);
|
---|
105 | if (RT_SUCCESS(rc))
|
---|
106 | {
|
---|
107 | pEvent->uID = uID;
|
---|
108 | pEvent->pPayload = NULL;
|
---|
109 | }
|
---|
110 |
|
---|
111 | return rc;
|
---|
112 | }
|
---|
113 |
|
---|
114 | /**
|
---|
115 | * Destroys an event.
|
---|
116 | *
|
---|
117 | * @param pEvent Event to destroy.
|
---|
118 | */
|
---|
119 | void ShClEventDestroy(PSHCLEVENT pEvent)
|
---|
120 | {
|
---|
121 | if (!pEvent)
|
---|
122 | return;
|
---|
123 |
|
---|
124 | LogFlowFunc(("Event %RU32\n", pEvent->uID));
|
---|
125 |
|
---|
126 | if (pEvent->hEventSem != NIL_RTSEMEVENT)
|
---|
127 | {
|
---|
128 | RTSemEventDestroy(pEvent->hEventSem);
|
---|
129 | pEvent->hEventSem = NIL_RTSEMEVENT;
|
---|
130 | }
|
---|
131 |
|
---|
132 | ShClPayloadFree(pEvent->pPayload);
|
---|
133 |
|
---|
134 | pEvent->uID = 0;
|
---|
135 | }
|
---|
136 |
|
---|
137 | /**
|
---|
138 | * Creates a new event source.
|
---|
139 | *
|
---|
140 | * @returns VBox status code.
|
---|
141 | * @param pSource Event source to create.
|
---|
142 | * @param uID ID to use for event source.
|
---|
143 | */
|
---|
144 | int ShClEventSourceCreate(PSHCLEVENTSOURCE pSource, SHCLEVENTSOURCEID uID)
|
---|
145 | {
|
---|
146 | LogFlowFunc(("pSource=%p, uID=%RU16\n", pSource, uID));
|
---|
147 | AssertPtrReturn(pSource, VERR_INVALID_POINTER);
|
---|
148 |
|
---|
149 | RTListInit(&pSource->lstEvents);
|
---|
150 |
|
---|
151 | pSource->uID = uID;
|
---|
152 | /* Choose a random event ID starting point. */
|
---|
153 | pSource->uEventIDNext = RTRandU32() % VBOX_SHCL_MAX_EVENTS;
|
---|
154 |
|
---|
155 | LogFlowFuncLeaveRC(VINF_SUCCESS);
|
---|
156 | return VINF_SUCCESS;
|
---|
157 | }
|
---|
158 |
|
---|
159 | /**
|
---|
160 | * Destroys an event source.
|
---|
161 | *
|
---|
162 | * @param pSource Event source to destroy.
|
---|
163 | */
|
---|
164 | void ShClEventSourceDestroy(PSHCLEVENTSOURCE pSource)
|
---|
165 | {
|
---|
166 | if (!pSource)
|
---|
167 | return;
|
---|
168 |
|
---|
169 | LogFlowFunc(("ID=%RU32\n", pSource->uID));
|
---|
170 |
|
---|
171 | ShClEventSourceReset(pSource);
|
---|
172 |
|
---|
173 | pSource->uID = UINT16_MAX;
|
---|
174 | pSource->uEventIDNext = UINT32_MAX;
|
---|
175 | }
|
---|
176 |
|
---|
177 | /**
|
---|
178 | * Resets an event source.
|
---|
179 | *
|
---|
180 | * @param pSource Event source to reset.
|
---|
181 | */
|
---|
182 | void ShClEventSourceReset(PSHCLEVENTSOURCE pSource)
|
---|
183 | {
|
---|
184 | LogFlowFunc(("ID=%RU32\n", pSource->uID));
|
---|
185 |
|
---|
186 | PSHCLEVENT pEvIt;
|
---|
187 | PSHCLEVENT pEvItNext;
|
---|
188 | RTListForEachSafe(&pSource->lstEvents, pEvIt, pEvItNext, SHCLEVENT, Node)
|
---|
189 | {
|
---|
190 | RTListNodeRemove(&pEvIt->Node);
|
---|
191 |
|
---|
192 | ShClEventDestroy(pEvIt);
|
---|
193 |
|
---|
194 | RTMemFree(pEvIt);
|
---|
195 | pEvIt = NULL;
|
---|
196 | }
|
---|
197 | }
|
---|
198 |
|
---|
199 | /**
|
---|
200 | * Generates a new event ID for a specific event source.
|
---|
201 | *
|
---|
202 | * @returns New event ID generated, or 0 on error.
|
---|
203 | * @param pSource Event source to generate event for.
|
---|
204 | */
|
---|
205 | SHCLEVENTID ShClEventIDGenerate(PSHCLEVENTSOURCE pSource)
|
---|
206 | {
|
---|
207 | AssertPtrReturn(pSource, 0);
|
---|
208 |
|
---|
209 | LogFlowFunc(("uSource=%RU16: New event: %RU32\n", pSource->uID, pSource->uEventIDNext));
|
---|
210 |
|
---|
211 | pSource->uEventIDNext++;
|
---|
212 | if (pSource->uEventIDNext == VBOX_SHCL_MAX_EVENTS)
|
---|
213 | pSource->uEventIDNext = 0;
|
---|
214 |
|
---|
215 | return pSource->uEventIDNext;
|
---|
216 | }
|
---|
217 |
|
---|
218 | /**
|
---|
219 | * Returns a specific event of a event source.
|
---|
220 | *
|
---|
221 | * @returns Pointer to event if found, or NULL if not found.
|
---|
222 | * @param pSource Event source to get event from.
|
---|
223 | * @param uID Event ID to get.
|
---|
224 | */
|
---|
225 | inline PSHCLEVENT shclEventGet(PSHCLEVENTSOURCE pSource, SHCLEVENTID uID)
|
---|
226 | {
|
---|
227 | PSHCLEVENT pEvIt;
|
---|
228 | RTListForEach(&pSource->lstEvents, pEvIt, SHCLEVENT, Node)
|
---|
229 | {
|
---|
230 | if (pEvIt->uID == uID)
|
---|
231 | return pEvIt;
|
---|
232 | }
|
---|
233 |
|
---|
234 | return NULL;
|
---|
235 | }
|
---|
236 |
|
---|
237 | /**
|
---|
238 | * Returns the last (newest) event ID which has been registered for an event source.
|
---|
239 | *
|
---|
240 | * @returns Last registered event ID, or 0 if not found.
|
---|
241 | * @param pSource Event source to get last registered event from.
|
---|
242 | */
|
---|
243 | SHCLEVENTID ShClEventGetLast(PSHCLEVENTSOURCE pSource)
|
---|
244 | {
|
---|
245 | AssertPtrReturn(pSource, 0);
|
---|
246 | PSHCLEVENT pEvent = RTListGetLast(&pSource->lstEvents, SHCLEVENT, Node);
|
---|
247 | if (pEvent)
|
---|
248 | return pEvent->uID;
|
---|
249 |
|
---|
250 | return 0;
|
---|
251 | }
|
---|
252 |
|
---|
253 | /**
|
---|
254 | * Detaches a payload from an event, internal version.
|
---|
255 | *
|
---|
256 | * @param pEvent Event to detach payload for.
|
---|
257 | */
|
---|
258 | static void shclEventPayloadDetachInternal(PSHCLEVENT pEvent)
|
---|
259 | {
|
---|
260 | AssertPtrReturnVoid(pEvent);
|
---|
261 |
|
---|
262 | pEvent->pPayload = NULL;
|
---|
263 | }
|
---|
264 |
|
---|
265 | /**
|
---|
266 | * Registers an event.
|
---|
267 | *
|
---|
268 | * @returns VBox status code.
|
---|
269 | * @param pSource Event source to register event for.
|
---|
270 | * @param uID Event ID to register.
|
---|
271 | */
|
---|
272 | int ShClEventRegister(PSHCLEVENTSOURCE pSource, SHCLEVENTID uID)
|
---|
273 | {
|
---|
274 | AssertPtrReturn(pSource, VERR_INVALID_POINTER);
|
---|
275 |
|
---|
276 | int rc;
|
---|
277 |
|
---|
278 | LogFlowFunc(("uSource=%RU16, uEvent=%RU32\n", pSource->uID, uID));
|
---|
279 |
|
---|
280 | if (shclEventGet(pSource, uID) == NULL)
|
---|
281 | {
|
---|
282 | PSHCLEVENT pEvent
|
---|
283 | = (PSHCLEVENT)RTMemAllocZ(sizeof(SHCLEVENT));
|
---|
284 | if (pEvent)
|
---|
285 | {
|
---|
286 | rc = ShClEventCreate(pEvent, uID);
|
---|
287 | if (RT_SUCCESS(rc))
|
---|
288 | {
|
---|
289 | RTListAppend(&pSource->lstEvents, &pEvent->Node);
|
---|
290 |
|
---|
291 | LogFlowFunc(("Event %RU32\n", uID));
|
---|
292 | }
|
---|
293 | }
|
---|
294 | else
|
---|
295 | rc = VERR_NO_MEMORY;
|
---|
296 | }
|
---|
297 | else
|
---|
298 | rc = VERR_ALREADY_EXISTS;
|
---|
299 |
|
---|
300 | #ifdef DEBUG_andy
|
---|
301 | AssertRC(rc);
|
---|
302 | #endif
|
---|
303 |
|
---|
304 | LogFlowFuncLeaveRC(rc);
|
---|
305 | return rc;
|
---|
306 | }
|
---|
307 |
|
---|
308 | /**
|
---|
309 | * Unregisters an event.
|
---|
310 | *
|
---|
311 | * @returns VBox status code.
|
---|
312 | * @param pSource Event source to unregister event for.
|
---|
313 | * @param uID Event ID to unregister.
|
---|
314 | */
|
---|
315 | int ShClEventUnregister(PSHCLEVENTSOURCE pSource, SHCLEVENTID uID)
|
---|
316 | {
|
---|
317 | AssertPtrReturn(pSource, VERR_INVALID_POINTER);
|
---|
318 |
|
---|
319 | int rc;
|
---|
320 |
|
---|
321 | LogFlowFunc(("uSource=%RU16, uEvent=%RU32\n", pSource->uID, uID));
|
---|
322 |
|
---|
323 | PSHCLEVENT pEvent = shclEventGet(pSource, uID);
|
---|
324 | if (pEvent)
|
---|
325 | {
|
---|
326 | LogFlowFunc(("Event %RU32\n", pEvent->uID));
|
---|
327 |
|
---|
328 | RTListNodeRemove(&pEvent->Node);
|
---|
329 |
|
---|
330 | ShClEventDestroy(pEvent);
|
---|
331 |
|
---|
332 | RTMemFree(pEvent);
|
---|
333 | pEvent = NULL;
|
---|
334 |
|
---|
335 | rc = VINF_SUCCESS;
|
---|
336 | }
|
---|
337 | else
|
---|
338 | rc = VERR_NOT_FOUND;
|
---|
339 |
|
---|
340 | LogFlowFuncLeaveRC(rc);
|
---|
341 | return rc;
|
---|
342 | }
|
---|
343 |
|
---|
344 | /**
|
---|
345 | * Waits for an event to get signalled.
|
---|
346 | *
|
---|
347 | * @returns VBox status code.
|
---|
348 | * @param pSource Event source that contains the event to wait for.
|
---|
349 | * @param uID Event ID to wait for.
|
---|
350 | * @param uTimeoutMs Timeout (in ms) to wait.
|
---|
351 | * @param ppPayload Where to store the (allocated) event payload on success. Needs to be free'd with
|
---|
352 | * SharedClipboardPayloadFree(). Optional.
|
---|
353 | */
|
---|
354 | int ShClEventWait(PSHCLEVENTSOURCE pSource, SHCLEVENTID uID, RTMSINTERVAL uTimeoutMs,
|
---|
355 | PSHCLEVENTPAYLOAD* ppPayload)
|
---|
356 | {
|
---|
357 | AssertPtrReturn(pSource, VERR_INVALID_POINTER);
|
---|
358 | /** ppPayload is optional. */
|
---|
359 |
|
---|
360 | LogFlowFuncEnter();
|
---|
361 |
|
---|
362 | int rc;
|
---|
363 |
|
---|
364 | PSHCLEVENT pEvent = shclEventGet(pSource, uID);
|
---|
365 | if (pEvent)
|
---|
366 | {
|
---|
367 | rc = RTSemEventWait(pEvent->hEventSem, uTimeoutMs);
|
---|
368 | if (RT_SUCCESS(rc))
|
---|
369 | {
|
---|
370 | if (ppPayload)
|
---|
371 | {
|
---|
372 | *ppPayload = pEvent->pPayload;
|
---|
373 |
|
---|
374 | /* Make sure to detach payload here, as the caller now owns the data. */
|
---|
375 | shclEventPayloadDetachInternal(pEvent);
|
---|
376 | }
|
---|
377 | }
|
---|
378 | }
|
---|
379 | else
|
---|
380 | rc = VERR_NOT_FOUND;
|
---|
381 |
|
---|
382 | LogFlowFuncLeaveRC(rc);
|
---|
383 | return rc;
|
---|
384 | }
|
---|
385 |
|
---|
386 | /**
|
---|
387 | * Signals an event.
|
---|
388 | *
|
---|
389 | * @returns VBox status code.
|
---|
390 | * @param pSource Event source of event to signal.
|
---|
391 | * @param uID Event ID to signal.
|
---|
392 | * @param pPayload Event payload to associate. Takes ownership. Optional.
|
---|
393 | */
|
---|
394 | int ShClEventSignal(PSHCLEVENTSOURCE pSource, SHCLEVENTID uID,
|
---|
395 | PSHCLEVENTPAYLOAD pPayload)
|
---|
396 | {
|
---|
397 | AssertPtrReturn(pSource, VERR_INVALID_POINTER);
|
---|
398 |
|
---|
399 | int rc;
|
---|
400 |
|
---|
401 | LogFlowFunc(("uSource=%RU16, uEvent=%RU32\n", pSource->uID, uID));
|
---|
402 |
|
---|
403 | PSHCLEVENT pEvent = shclEventGet(pSource, uID);
|
---|
404 | if (pEvent)
|
---|
405 | {
|
---|
406 | Assert(pEvent->pPayload == NULL);
|
---|
407 |
|
---|
408 | pEvent->pPayload = pPayload;
|
---|
409 |
|
---|
410 | rc = RTSemEventSignal(pEvent->hEventSem);
|
---|
411 | }
|
---|
412 | else
|
---|
413 | rc = VERR_NOT_FOUND;
|
---|
414 |
|
---|
415 | LogFlowFuncLeaveRC(rc);
|
---|
416 | return rc;
|
---|
417 | }
|
---|
418 |
|
---|
419 | /**
|
---|
420 | * Detaches a payload from an event.
|
---|
421 | *
|
---|
422 | * @returns VBox status code.
|
---|
423 | * @param pSource Event source of event to detach payload for.
|
---|
424 | * @param uID Event ID to detach payload for.
|
---|
425 | */
|
---|
426 | void ShClEventPayloadDetach(PSHCLEVENTSOURCE pSource, SHCLEVENTID uID)
|
---|
427 | {
|
---|
428 | AssertPtrReturnVoid(pSource);
|
---|
429 |
|
---|
430 | LogFlowFunc(("uSource=%RU16, uEvent=%RU32\n", pSource->uID, uID));
|
---|
431 |
|
---|
432 | PSHCLEVENT pEvent = shclEventGet(pSource, uID);
|
---|
433 | if (pEvent)
|
---|
434 | {
|
---|
435 | shclEventPayloadDetachInternal(pEvent);
|
---|
436 | }
|
---|
437 | #ifdef DEBUG_andy
|
---|
438 | else
|
---|
439 | AssertMsgFailed(("uSource=%RU16, uEvent=%RU32\n", pSource->uID, uID));
|
---|
440 | #endif
|
---|
441 | }
|
---|
442 |
|
---|
443 | /** @todo Delinuxify the code (*Lin* -> *Host*); use AssertLogRel*. */
|
---|
444 |
|
---|
445 | int ShClUtf16GetWinSize(PCRTUTF16 pcwszSrc, size_t cwSrc, size_t *pcwDest)
|
---|
446 | {
|
---|
447 | size_t cwDest, i;
|
---|
448 |
|
---|
449 | LogFlowFunc(("pcwszSrc=%.*ls, cwSrc=%u\n", cwSrc, pcwszSrc, cwSrc));
|
---|
450 | AssertLogRelMsgReturn(pcwszSrc != NULL, ("vboxClipboardUtf16GetWinSize: received a null Utf16 string, returning VERR_INVALID_PARAMETER\n"), VERR_INVALID_PARAMETER);
|
---|
451 | if (cwSrc == 0)
|
---|
452 | {
|
---|
453 | *pcwDest = 0;
|
---|
454 | LogFlowFunc(("empty source string, returning\n"));
|
---|
455 | return VINF_SUCCESS;
|
---|
456 | }
|
---|
457 | /** @todo convert the remainder of the Assert stuff to AssertLogRel. */
|
---|
458 | /* We only take little endian Utf16 */
|
---|
459 | if (pcwszSrc[0] == VBOX_SHCL_UTF16BEMARKER)
|
---|
460 | {
|
---|
461 | LogRel(("Shared Clipboard: vboxClipboardUtf16GetWinSize: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n"));
|
---|
462 | AssertReturn(pcwszSrc[0] != VBOX_SHCL_UTF16BEMARKER, VERR_INVALID_PARAMETER);
|
---|
463 | }
|
---|
464 | cwDest = 0;
|
---|
465 | /* Calculate the size of the destination text string. */
|
---|
466 | /* Is this Utf16 or Utf16-LE? */
|
---|
467 | for (i = (pcwszSrc[0] == VBOX_SHCL_UTF16LEMARKER ? 1 : 0); i < cwSrc; ++i, ++cwDest)
|
---|
468 | {
|
---|
469 | /* Check for a single line feed */
|
---|
470 | if (pcwszSrc[i] == VBOX_SHCL_LINEFEED)
|
---|
471 | ++cwDest;
|
---|
472 | #ifdef RT_OS_DARWIN
|
---|
473 | /* Check for a single carriage return (MacOS) */
|
---|
474 | if (pcwszSrc[i] == VBOX_SHCL_CARRIAGERETURN)
|
---|
475 | ++cwDest;
|
---|
476 | #endif
|
---|
477 | if (pcwszSrc[i] == 0)
|
---|
478 | {
|
---|
479 | /* Don't count this, as we do so below. */
|
---|
480 | break;
|
---|
481 | }
|
---|
482 | }
|
---|
483 | /* Count the terminating null byte. */
|
---|
484 | ++cwDest;
|
---|
485 | LogFlowFunc(("returning VINF_SUCCESS, %d 16bit words\n", cwDest));
|
---|
486 | *pcwDest = cwDest;
|
---|
487 | return VINF_SUCCESS;
|
---|
488 | }
|
---|
489 |
|
---|
490 | int ShClUtf16LinToWin(PCRTUTF16 pcwszSrc, size_t cwSrc, PRTUTF16 pu16Dest, size_t cwDest)
|
---|
491 | {
|
---|
492 | size_t i, j;
|
---|
493 | LogFlowFunc(("pcwszSrc=%.*ls, cwSrc=%u\n", cwSrc, pcwszSrc, cwSrc));
|
---|
494 | if (!VALID_PTR(pcwszSrc) || !VALID_PTR(pu16Dest))
|
---|
495 | {
|
---|
496 | LogRel(("Shared Clipboard: vboxClipboardUtf16LinToWin: received an invalid pointer, returning VERR_INVALID_PARAMETER\n"));
|
---|
497 | AssertReturn(VALID_PTR(pcwszSrc) && VALID_PTR(pu16Dest), VERR_INVALID_PARAMETER);
|
---|
498 | }
|
---|
499 | if (cwSrc == 0)
|
---|
500 | {
|
---|
501 | if (cwDest == 0)
|
---|
502 | {
|
---|
503 | LogFlowFunc(("returning VERR_BUFFER_OVERFLOW\n"));
|
---|
504 | return VERR_BUFFER_OVERFLOW;
|
---|
505 | }
|
---|
506 | pu16Dest[0] = 0;
|
---|
507 | LogFlowFunc(("empty source string, returning\n"));
|
---|
508 | return VINF_SUCCESS;
|
---|
509 | }
|
---|
510 | /* We only take little endian Utf16 */
|
---|
511 | if (pcwszSrc[0] == VBOX_SHCL_UTF16BEMARKER)
|
---|
512 | {
|
---|
513 | LogRel(("Shared Clipboard: vboxClipboardUtf16LinToWin: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n"));
|
---|
514 | AssertReturn(pcwszSrc[0] != VBOX_SHCL_UTF16BEMARKER, VERR_INVALID_PARAMETER);
|
---|
515 | }
|
---|
516 | /* Don't copy the endian marker. */
|
---|
517 | for (i = (pcwszSrc[0] == VBOX_SHCL_UTF16LEMARKER ? 1 : 0), j = 0; i < cwSrc; ++i, ++j)
|
---|
518 | {
|
---|
519 | /* Don't copy the null byte, as we add it below. */
|
---|
520 | if (pcwszSrc[i] == 0)
|
---|
521 | break;
|
---|
522 | if (j == cwDest)
|
---|
523 | {
|
---|
524 | LogFlowFunc(("returning VERR_BUFFER_OVERFLOW\n"));
|
---|
525 | return VERR_BUFFER_OVERFLOW;
|
---|
526 | }
|
---|
527 | if (pcwszSrc[i] == VBOX_SHCL_LINEFEED)
|
---|
528 | {
|
---|
529 | pu16Dest[j] = VBOX_SHCL_CARRIAGERETURN;
|
---|
530 | ++j;
|
---|
531 | if (j == cwDest)
|
---|
532 | {
|
---|
533 | LogFlowFunc(("returning VERR_BUFFER_OVERFLOW\n"));
|
---|
534 | return VERR_BUFFER_OVERFLOW;
|
---|
535 | }
|
---|
536 | }
|
---|
537 | #ifdef RT_OS_DARWIN
|
---|
538 | /* Check for a single carriage return (MacOS) */
|
---|
539 | else if (pcwszSrc[i] == VBOX_SHCL_CARRIAGERETURN)
|
---|
540 | {
|
---|
541 | /* set cr */
|
---|
542 | pu16Dest[j] = VBOX_SHCL_CARRIAGERETURN;
|
---|
543 | ++j;
|
---|
544 | if (j == cwDest)
|
---|
545 | {
|
---|
546 | LogFlowFunc(("returning VERR_BUFFER_OVERFLOW\n"));
|
---|
547 | return VERR_BUFFER_OVERFLOW;
|
---|
548 | }
|
---|
549 | /* add the lf */
|
---|
550 | pu16Dest[j] = VBOX_SHCL_LINEFEED;
|
---|
551 | continue;
|
---|
552 | }
|
---|
553 | #endif
|
---|
554 | pu16Dest[j] = pcwszSrc[i];
|
---|
555 | }
|
---|
556 | /* Add the trailing null. */
|
---|
557 | if (j == cwDest)
|
---|
558 | {
|
---|
559 | LogFlowFunc(("returning VERR_BUFFER_OVERFLOW\n"));
|
---|
560 | return VERR_BUFFER_OVERFLOW;
|
---|
561 | }
|
---|
562 | pu16Dest[j] = 0;
|
---|
563 | LogFlowFunc(("rc=VINF_SUCCESS, pu16Dest=%ls\n", pu16Dest));
|
---|
564 | return VINF_SUCCESS;
|
---|
565 | }
|
---|
566 |
|
---|
567 | int ShClUtf16GetLinSize(PCRTUTF16 pcwszSrc, size_t cwSrc, size_t *pcwDest)
|
---|
568 | {
|
---|
569 | size_t cwDest;
|
---|
570 |
|
---|
571 | LogFlowFunc(("pcwszSrc=%.*ls, cwSrc=%u\n", cwSrc, pcwszSrc, cwSrc));
|
---|
572 | if (!VALID_PTR(pcwszSrc))
|
---|
573 | {
|
---|
574 | LogRel(("Shared Clipboard: vboxClipboardUtf16GetLinSize: received an invalid Utf16 string, returning VERR_INVALID_PARAMETER\n"));
|
---|
575 | AssertReturn(VALID_PTR(pcwszSrc), VERR_INVALID_PARAMETER);
|
---|
576 | }
|
---|
577 | if (cwSrc == 0)
|
---|
578 | {
|
---|
579 | LogFlowFunc(("empty source string, returning VINF_SUCCESS\n"));
|
---|
580 | *pcwDest = 0;
|
---|
581 | return VINF_SUCCESS;
|
---|
582 | }
|
---|
583 | /* We only take little endian Utf16 */
|
---|
584 | if (pcwszSrc[0] == VBOX_SHCL_UTF16BEMARKER)
|
---|
585 | {
|
---|
586 | LogRel(("Shared Clipboard: vboxClipboardUtf16GetLinSize: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n"));
|
---|
587 | AssertReturn(pcwszSrc[0] != VBOX_SHCL_UTF16BEMARKER, VERR_INVALID_PARAMETER);
|
---|
588 | }
|
---|
589 | /* Calculate the size of the destination text string. */
|
---|
590 | /* Is this Utf16 or Utf16-LE? */
|
---|
591 | if (pcwszSrc[0] == VBOX_SHCL_UTF16LEMARKER)
|
---|
592 | cwDest = 0;
|
---|
593 | else
|
---|
594 | cwDest = 1;
|
---|
595 | for (size_t i = 0; i < cwSrc; ++i, ++cwDest)
|
---|
596 | {
|
---|
597 | if ( (i + 1 < cwSrc)
|
---|
598 | && (pcwszSrc[i] == VBOX_SHCL_CARRIAGERETURN)
|
---|
599 | && (pcwszSrc[i + 1] == VBOX_SHCL_LINEFEED))
|
---|
600 | {
|
---|
601 | ++i;
|
---|
602 | }
|
---|
603 | if (pcwszSrc[i] == 0)
|
---|
604 | {
|
---|
605 | break;
|
---|
606 | }
|
---|
607 | }
|
---|
608 | /* Terminating zero */
|
---|
609 | ++cwDest;
|
---|
610 | LogFlowFunc(("returning %d\n", cwDest));
|
---|
611 | *pcwDest = cwDest;
|
---|
612 | return VINF_SUCCESS;
|
---|
613 | }
|
---|
614 |
|
---|
615 | int ShClUtf16WinToLin(PCRTUTF16 pcwszSrc, size_t cwSrc, PRTUTF16 pu16Dest, size_t cwDest)
|
---|
616 | {
|
---|
617 | size_t cwDestPos;
|
---|
618 |
|
---|
619 | LogFlowFunc(("pcwszSrc=%.*ls, cwSrc=%u, pu16Dest=%p, cwDest=%u\n",
|
---|
620 | cwSrc, pcwszSrc, cwSrc, pu16Dest, cwDest));
|
---|
621 | /* A buffer of size 0 may not be an error, but it is not a good idea either. */
|
---|
622 | Assert(cwDest > 0);
|
---|
623 | if (!VALID_PTR(pcwszSrc) || !VALID_PTR(pu16Dest))
|
---|
624 | {
|
---|
625 | LogRel(("Shared Clipboard: vboxClipboardUtf16WinToLin: received an invalid pointer, returning VERR_INVALID_PARAMETER\n"));
|
---|
626 | AssertReturn(VALID_PTR(pcwszSrc) && VALID_PTR(pu16Dest), VERR_INVALID_PARAMETER);
|
---|
627 | }
|
---|
628 | /* We only take little endian Utf16 */
|
---|
629 | if (pcwszSrc[0] == VBOX_SHCL_UTF16BEMARKER)
|
---|
630 | {
|
---|
631 | LogRel(("Shared Clipboard: vboxClipboardUtf16WinToLin: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n"));
|
---|
632 | AssertMsgFailedReturn(("received a big endian string\n"), VERR_INVALID_PARAMETER);
|
---|
633 | }
|
---|
634 | if (cwDest == 0)
|
---|
635 | {
|
---|
636 | LogFlowFunc(("returning VERR_BUFFER_OVERFLOW\n"));
|
---|
637 | return VERR_BUFFER_OVERFLOW;
|
---|
638 | }
|
---|
639 | if (cwSrc == 0)
|
---|
640 | {
|
---|
641 | pu16Dest[0] = 0;
|
---|
642 | LogFlowFunc(("received empty string. Returning VINF_SUCCESS\n"));
|
---|
643 | return VINF_SUCCESS;
|
---|
644 | }
|
---|
645 | /* Prepend the Utf16 byte order marker if it is missing. */
|
---|
646 | if (pcwszSrc[0] == VBOX_SHCL_UTF16LEMARKER)
|
---|
647 | {
|
---|
648 | cwDestPos = 0;
|
---|
649 | }
|
---|
650 | else
|
---|
651 | {
|
---|
652 | pu16Dest[0] = VBOX_SHCL_UTF16LEMARKER;
|
---|
653 | cwDestPos = 1;
|
---|
654 | }
|
---|
655 | for (size_t i = 0; i < cwSrc; ++i, ++cwDestPos)
|
---|
656 | {
|
---|
657 | if (pcwszSrc[i] == 0)
|
---|
658 | {
|
---|
659 | break;
|
---|
660 | }
|
---|
661 | if (cwDestPos == cwDest)
|
---|
662 | {
|
---|
663 | LogFlowFunc(("returning VERR_BUFFER_OVERFLOW\n"));
|
---|
664 | return VERR_BUFFER_OVERFLOW;
|
---|
665 | }
|
---|
666 | if ( (i + 1 < cwSrc)
|
---|
667 | && (pcwszSrc[i] == VBOX_SHCL_CARRIAGERETURN)
|
---|
668 | && (pcwszSrc[i + 1] == VBOX_SHCL_LINEFEED))
|
---|
669 | {
|
---|
670 | ++i;
|
---|
671 | }
|
---|
672 | pu16Dest[cwDestPos] = pcwszSrc[i];
|
---|
673 | }
|
---|
674 | /* Terminating zero */
|
---|
675 | if (cwDestPos == cwDest)
|
---|
676 | {
|
---|
677 | LogFlowFunc(("returning VERR_BUFFER_OVERFLOW\n"));
|
---|
678 | return VERR_BUFFER_OVERFLOW;
|
---|
679 | }
|
---|
680 | pu16Dest[cwDestPos] = 0;
|
---|
681 | LogFlowFunc(("set string %ls. Returning\n", pu16Dest + 1));
|
---|
682 | return VINF_SUCCESS;
|
---|
683 | }
|
---|
684 |
|
---|
685 | int ShClDibToBmp(const void *pvSrc, size_t cbSrc, void **ppvDest, size_t *pcbDest)
|
---|
686 | {
|
---|
687 | size_t cb = sizeof(BMFILEHEADER) + cbSrc;
|
---|
688 | PBMFILEHEADER pFileHeader = NULL;
|
---|
689 | void *pvDest = NULL;
|
---|
690 | size_t offPixel = 0;
|
---|
691 |
|
---|
692 | AssertPtrReturn(pvSrc, VERR_INVALID_PARAMETER);
|
---|
693 | AssertPtrReturn(ppvDest, VERR_INVALID_PARAMETER);
|
---|
694 | AssertPtrReturn(pcbDest, VERR_INVALID_PARAMETER);
|
---|
695 |
|
---|
696 | PBMINFOHEADER pBitmapInfoHeader = (PBMINFOHEADER)pvSrc;
|
---|
697 | /** @todo Support all the many versions of the DIB headers. */
|
---|
698 | if ( cbSrc < sizeof(BMINFOHEADER)
|
---|
699 | || RT_LE2H_U32(pBitmapInfoHeader->uSize) < sizeof(BMINFOHEADER)
|
---|
700 | || RT_LE2H_U32(pBitmapInfoHeader->uSize) != sizeof(BMINFOHEADER))
|
---|
701 | {
|
---|
702 | Log(("vboxClipboardDibToBmp: invalid or unsupported bitmap data\n"));
|
---|
703 | return VERR_INVALID_PARAMETER;
|
---|
704 | }
|
---|
705 |
|
---|
706 | offPixel = sizeof(BMFILEHEADER)
|
---|
707 | + RT_LE2H_U32(pBitmapInfoHeader->uSize)
|
---|
708 | + RT_LE2H_U32(pBitmapInfoHeader->uClrUsed) * sizeof(uint32_t);
|
---|
709 | if (cbSrc < offPixel)
|
---|
710 | {
|
---|
711 | Log(("vboxClipboardDibToBmp: invalid bitmap data\n"));
|
---|
712 | return VERR_INVALID_PARAMETER;
|
---|
713 | }
|
---|
714 |
|
---|
715 | pvDest = RTMemAlloc(cb);
|
---|
716 | if (!pvDest)
|
---|
717 | {
|
---|
718 | Log(("writeToPasteboard: cannot allocate memory for bitmap\n"));
|
---|
719 | return VERR_NO_MEMORY;
|
---|
720 | }
|
---|
721 |
|
---|
722 | pFileHeader = (PBMFILEHEADER)pvDest;
|
---|
723 | pFileHeader->uType = BITMAPHEADERMAGIC;
|
---|
724 | pFileHeader->uSize = (uint32_t)RT_H2LE_U32(cb);
|
---|
725 | pFileHeader->uReserved1 = pFileHeader->uReserved2 = 0;
|
---|
726 | pFileHeader->uOffBits = (uint32_t)RT_H2LE_U32(offPixel);
|
---|
727 | memcpy((uint8_t *)pvDest + sizeof(BMFILEHEADER), pvSrc, cbSrc);
|
---|
728 | *ppvDest = pvDest;
|
---|
729 | *pcbDest = cb;
|
---|
730 | return VINF_SUCCESS;
|
---|
731 | }
|
---|
732 |
|
---|
733 | int ShClBmpGetDib(const void *pvSrc, size_t cbSrc, const void **ppvDest, size_t *pcbDest)
|
---|
734 | {
|
---|
735 | AssertPtrReturn(pvSrc, VERR_INVALID_PARAMETER);
|
---|
736 | AssertPtrReturn(ppvDest, VERR_INVALID_PARAMETER);
|
---|
737 | AssertPtrReturn(pcbDest, VERR_INVALID_PARAMETER);
|
---|
738 |
|
---|
739 | PBMFILEHEADER pFileHeader = (PBMFILEHEADER)pvSrc;
|
---|
740 | if ( cbSrc < sizeof(BMFILEHEADER)
|
---|
741 | || pFileHeader->uType != BITMAPHEADERMAGIC
|
---|
742 | || RT_LE2H_U32(pFileHeader->uSize) != cbSrc)
|
---|
743 | {
|
---|
744 | Log(("vboxClipboardBmpGetDib: invalid bitmap data\n"));
|
---|
745 | return VERR_INVALID_PARAMETER;
|
---|
746 | }
|
---|
747 |
|
---|
748 | *ppvDest = ((uint8_t *)pvSrc) + sizeof(BMFILEHEADER);
|
---|
749 | *pcbDest = cbSrc - sizeof(BMFILEHEADER);
|
---|
750 | return VINF_SUCCESS;
|
---|
751 | }
|
---|
752 |
|
---|
753 | #ifdef LOG_ENABLED
|
---|
754 | int ShClDbgDumpHtml(const char *pcszSrc, size_t cbSrc)
|
---|
755 | {
|
---|
756 | size_t cchIgnored = 0;
|
---|
757 | int rc = RTStrNLenEx(pcszSrc, cbSrc, &cchIgnored);
|
---|
758 | if (RT_SUCCESS(rc))
|
---|
759 | {
|
---|
760 | char *pszBuf = (char *)RTMemAllocZ(cbSrc + 1);
|
---|
761 | if (pszBuf)
|
---|
762 | {
|
---|
763 | rc = RTStrCopy(pszBuf, cbSrc + 1, (const char *)pcszSrc);
|
---|
764 | if (RT_SUCCESS(rc))
|
---|
765 | {
|
---|
766 | for (size_t i = 0; i < cbSrc; ++i)
|
---|
767 | if (pszBuf[i] == '\n' || pszBuf[i] == '\r')
|
---|
768 | pszBuf[i] = ' ';
|
---|
769 | }
|
---|
770 | else
|
---|
771 | LogFunc(("Error in copying string\n"));
|
---|
772 | LogFunc(("Removed \\r\\n: %s\n", pszBuf));
|
---|
773 | RTMemFree(pszBuf);
|
---|
774 | }
|
---|
775 | else
|
---|
776 | rc = VERR_NO_MEMORY;
|
---|
777 | }
|
---|
778 |
|
---|
779 | return rc;
|
---|
780 | }
|
---|
781 |
|
---|
782 | void ShClDbgDumpData(const void *pv, size_t cb, SHCLFORMAT uFormat)
|
---|
783 | {
|
---|
784 | if (uFormat & VBOX_SHCL_FMT_UNICODETEXT)
|
---|
785 | {
|
---|
786 | LogFunc(("VBOX_SHCL_FMT_UNICODETEXT:\n"));
|
---|
787 | if (pv && cb)
|
---|
788 | LogFunc(("%ls\n", pv));
|
---|
789 | else
|
---|
790 | LogFunc(("%p %zu\n", pv, cb));
|
---|
791 | }
|
---|
792 | else if (uFormat & VBOX_SHCL_FMT_BITMAP)
|
---|
793 | LogFunc(("VBOX_SHCL_FMT_BITMAP\n"));
|
---|
794 | else if (uFormat & VBOX_SHCL_FMT_HTML)
|
---|
795 | {
|
---|
796 | LogFunc(("VBOX_SHCL_FMT_HTML:\n"));
|
---|
797 | if (pv && cb)
|
---|
798 | {
|
---|
799 | LogFunc(("%s\n", pv));
|
---|
800 |
|
---|
801 | //size_t cb = RTStrNLen(pv, );
|
---|
802 | char *pszBuf = (char *)RTMemAllocZ(cb + 1);
|
---|
803 | RTStrCopy(pszBuf, cb + 1, (const char *)pv);
|
---|
804 | for (size_t off = 0; off < cb; ++off)
|
---|
805 | {
|
---|
806 | if (pszBuf[off] == '\n' || pszBuf[off] == '\r')
|
---|
807 | pszBuf[off] = ' ';
|
---|
808 | }
|
---|
809 |
|
---|
810 | LogFunc(("%s\n", pszBuf));
|
---|
811 | RTMemFree(pszBuf);
|
---|
812 | }
|
---|
813 | else
|
---|
814 | LogFunc(("%p %zu\n", pv, cb));
|
---|
815 | }
|
---|
816 | else
|
---|
817 | LogFunc(("Invalid format %02X\n", uFormat));
|
---|
818 | }
|
---|
819 | #endif /* LOG_ENABLED */
|
---|
820 |
|
---|
821 | /**
|
---|
822 | * Translates a Shared Clipboard host function number to a string.
|
---|
823 | *
|
---|
824 | * @returns Function ID string name.
|
---|
825 | * @param uFn The function to translate.
|
---|
826 | */
|
---|
827 | const char *ShClHostFunctionToStr(uint32_t uFn)
|
---|
828 | {
|
---|
829 | switch (uFn)
|
---|
830 | {
|
---|
831 | RT_CASE_RET_STR(VBOX_SHCL_HOST_FN_SET_MODE);
|
---|
832 | RT_CASE_RET_STR(VBOX_SHCL_HOST_FN_SET_TRANSFER_MODE);
|
---|
833 | RT_CASE_RET_STR(VBOX_SHCL_HOST_FN_SET_HEADLESS);
|
---|
834 | RT_CASE_RET_STR(VBOX_SHCL_HOST_FN_CANCEL);
|
---|
835 | RT_CASE_RET_STR(VBOX_SHCL_HOST_FN_ERROR);
|
---|
836 | RT_CASE_RET_STR(VBOX_SHCL_HOST_FN_AREA_REGISTER);
|
---|
837 | RT_CASE_RET_STR(VBOX_SHCL_HOST_FN_AREA_UNREGISTER);
|
---|
838 | RT_CASE_RET_STR(VBOX_SHCL_HOST_FN_AREA_ATTACH);
|
---|
839 | RT_CASE_RET_STR(VBOX_SHCL_HOST_FN_AREA_DETACH);
|
---|
840 | }
|
---|
841 | return "Unknown";
|
---|
842 | }
|
---|
843 |
|
---|
844 | /**
|
---|
845 | * Translates a Shared Clipboard host message enum to a string.
|
---|
846 | *
|
---|
847 | * @returns Message ID string name.
|
---|
848 | * @param uMsg The message to translate.
|
---|
849 | */
|
---|
850 | const char *ShClHostMsgToStr(uint32_t uMsg)
|
---|
851 | {
|
---|
852 | switch (uMsg)
|
---|
853 | {
|
---|
854 | RT_CASE_RET_STR(VBOX_SHCL_HOST_MSG_QUIT);
|
---|
855 | RT_CASE_RET_STR(VBOX_SHCL_HOST_MSG_READ_DATA);
|
---|
856 | RT_CASE_RET_STR(VBOX_SHCL_HOST_MSG_FORMATS_REPORT);
|
---|
857 | RT_CASE_RET_STR(VBOX_SHCL_HOST_MSG_TRANSFER_STATUS);
|
---|
858 | RT_CASE_RET_STR(VBOX_SHCL_HOST_MSG_TRANSFER_ROOT_LIST_HDR_READ);
|
---|
859 | RT_CASE_RET_STR(VBOX_SHCL_HOST_MSG_TRANSFER_ROOT_LIST_HDR_WRITE);
|
---|
860 | RT_CASE_RET_STR(VBOX_SHCL_HOST_MSG_TRANSFER_ROOT_LIST_ENTRY_READ);
|
---|
861 | RT_CASE_RET_STR(VBOX_SHCL_HOST_MSG_TRANSFER_ROOT_LIST_ENTRY_WRITE);
|
---|
862 | RT_CASE_RET_STR(VBOX_SHCL_HOST_MSG_TRANSFER_LIST_OPEN);
|
---|
863 | RT_CASE_RET_STR(VBOX_SHCL_HOST_MSG_TRANSFER_LIST_CLOSE);
|
---|
864 | RT_CASE_RET_STR(VBOX_SHCL_HOST_MSG_TRANSFER_LIST_HDR_READ);
|
---|
865 | RT_CASE_RET_STR(VBOX_SHCL_HOST_MSG_TRANSFER_LIST_HDR_WRITE);
|
---|
866 | RT_CASE_RET_STR(VBOX_SHCL_HOST_MSG_TRANSFER_LIST_ENTRY_READ);
|
---|
867 | RT_CASE_RET_STR(VBOX_SHCL_HOST_MSG_TRANSFER_LIST_ENTRY_WRITE);
|
---|
868 | RT_CASE_RET_STR(VBOX_SHCL_HOST_MSG_TRANSFER_OBJ_OPEN);
|
---|
869 | RT_CASE_RET_STR(VBOX_SHCL_HOST_MSG_TRANSFER_OBJ_CLOSE);
|
---|
870 | RT_CASE_RET_STR(VBOX_SHCL_HOST_MSG_TRANSFER_OBJ_READ);
|
---|
871 | RT_CASE_RET_STR(VBOX_SHCL_HOST_MSG_TRANSFER_OBJ_WRITE);
|
---|
872 | RT_CASE_RET_STR(VBOX_SHCL_HOST_MSG_TRANSFER_CANCEL);
|
---|
873 | RT_CASE_RET_STR(VBOX_SHCL_HOST_MSG_TRANSFER_ERROR);
|
---|
874 | }
|
---|
875 | return "Unknown";
|
---|
876 | }
|
---|
877 |
|
---|
878 | /**
|
---|
879 | * Translates a Shared Clipboard guest message enum to a string.
|
---|
880 | *
|
---|
881 | * @returns Message ID string name.
|
---|
882 | * @param uMsg The message to translate.
|
---|
883 | */
|
---|
884 | const char *ShClGuestMsgToStr(uint32_t uMsg)
|
---|
885 | {
|
---|
886 | switch (uMsg)
|
---|
887 | {
|
---|
888 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_GET_HOST_MSG_OLD);
|
---|
889 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_FORMATS_REPORT);
|
---|
890 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_DATA_READ);
|
---|
891 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_DATA_WRITE);
|
---|
892 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_CONNECT);
|
---|
893 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_REPORT_FEATURES);
|
---|
894 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_QUERY_FEATURES);
|
---|
895 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_MSG_PEEK_NOWAIT);
|
---|
896 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_MSG_PEEK_WAIT);
|
---|
897 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_MSG_GET);
|
---|
898 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_REPLY);
|
---|
899 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_ROOT_LIST_HDR_READ);
|
---|
900 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_ROOT_LIST_HDR_WRITE);
|
---|
901 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_ROOT_LIST_ENTRY_READ);
|
---|
902 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_ROOT_LIST_ENTRY_WRITE);
|
---|
903 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_LIST_OPEN);
|
---|
904 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_LIST_CLOSE);
|
---|
905 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_LIST_HDR_READ);
|
---|
906 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_LIST_HDR_WRITE);
|
---|
907 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_LIST_ENTRY_READ);
|
---|
908 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_LIST_ENTRY_WRITE);
|
---|
909 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_OBJ_OPEN);
|
---|
910 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_OBJ_CLOSE);
|
---|
911 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_OBJ_READ);
|
---|
912 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_OBJ_WRITE);
|
---|
913 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_CANCEL);
|
---|
914 | RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_ERROR);
|
---|
915 | }
|
---|
916 | return "Unknown";
|
---|
917 | }
|
---|