VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedFolders/VBoxSharedFoldersSvc.cpp@ 78018

Last change on this file since 78018 was 77852, checked in by vboxsync, 6 years ago

SharedFoldersSvc: Fixed parameter validation bug in SHFL_CPARMS_COPY_FILE_PART. bugref:9172

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 85.1 KB
Line 
1/* $Id: VBoxSharedFoldersSvc.cpp 77852 2019-03-22 20:51:48Z vboxsync $ */
2/** @file
3 * Shared Folders - Host service entry points.
4 */
5
6/*
7 * Copyright (C) 2006-2019 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
19/*********************************************************************************************************************************
20* Header Files *
21*********************************************************************************************************************************/
22#define LOG_GROUP LOG_GROUP_SHARED_FOLDERS
23#include <VBox/shflsvc.h>
24
25#include "shfl.h"
26#include "mappings.h"
27#include "shflhandle.h"
28#include "vbsf.h"
29#include <iprt/alloc.h>
30#include <iprt/string.h>
31#include <iprt/assert.h>
32#include <VBox/AssertGuest.h>
33#include <VBox/vmm/ssm.h>
34#include <VBox/vmm/pdmifs.h>
35
36
37/*********************************************************************************************************************************
38* Defined Constants And Macros *
39*********************************************************************************************************************************/
40#define SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16 2
41#define SHFL_SAVED_STATE_VERSION_PRE_AUTO_MOUNT_POINT 3
42#define SHFL_SAVED_STATE_VERSION 4
43
44
45/*********************************************************************************************************************************
46* Global Variables *
47*********************************************************************************************************************************/
48PVBOXHGCMSVCHELPERS g_pHelpers;
49static PPDMLED g_pStatusLed = NULL;
50
51/** @name Shared folder statistics.
52 * @{ */
53static STAMPROFILE g_StatQueryMappings;
54static STAMPROFILE g_StatQueryMappingsFail;
55static STAMPROFILE g_StatQueryMapName;
56static STAMPROFILE g_StatCreate;
57static STAMPROFILE g_StatCreateFail;
58static STAMPROFILE g_StatLookup;
59static STAMPROFILE g_StatLookupFail;
60static STAMPROFILE g_StatClose;
61static STAMPROFILE g_StatCloseFail;
62static STAMPROFILE g_StatRead;
63static STAMPROFILE g_StatReadFail;
64static STAMPROFILE g_StatWrite;
65static STAMPROFILE g_StatWriteFail;
66static STAMPROFILE g_StatLock;
67static STAMPROFILE g_StatLockFail;
68static STAMPROFILE g_StatList;
69static STAMPROFILE g_StatListFail;
70static STAMPROFILE g_StatReadLink;
71static STAMPROFILE g_StatReadLinkFail;
72static STAMPROFILE g_StatMapFolderOld;
73static STAMPROFILE g_StatMapFolder;
74static STAMPROFILE g_StatMapFolderFail;
75static STAMPROFILE g_StatUnmapFolder;
76static STAMPROFILE g_StatUnmapFolderFail;
77static STAMPROFILE g_StatInformationFail;
78static STAMPROFILE g_StatInformationSetFile;
79static STAMPROFILE g_StatInformationSetFileFail;
80static STAMPROFILE g_StatInformationSetSize;
81static STAMPROFILE g_StatInformationSetSizeFail;
82static STAMPROFILE g_StatInformationGetFile;
83static STAMPROFILE g_StatInformationGetFileFail;
84static STAMPROFILE g_StatInformationGetVolume;
85static STAMPROFILE g_StatInformationGetVolumeFail;
86static STAMPROFILE g_StatRemove;
87static STAMPROFILE g_StatRemoveFail;
88static STAMPROFILE g_StatRename;
89static STAMPROFILE g_StatRenameFail;
90static STAMPROFILE g_StatFlush;
91static STAMPROFILE g_StatFlushFail;
92static STAMPROFILE g_StatSetUtf8;
93static STAMPROFILE g_StatSetFileSize;
94static STAMPROFILE g_StatSetFileSizeFail;
95static STAMPROFILE g_StatSymlink;
96static STAMPROFILE g_StatSymlinkFail;
97static STAMPROFILE g_StatSetSymlinks;
98static STAMPROFILE g_StatQueryMapInfo;
99static STAMPROFILE g_StatQueryFeatures;
100static STAMPROFILE g_StatCopyFile;
101static STAMPROFILE g_StatCopyFileFail;
102static STAMPROFILE g_StatCopyFilePart;
103static STAMPROFILE g_StatCopyFilePartFail;
104static STAMPROFILE g_StatWaitForMappingsChanges;
105static STAMPROFILE g_StatWaitForMappingsChangesFail;
106static STAMPROFILE g_StatCancelMappingsChangesWait;
107static STAMPROFILE g_StatUnknown;
108static STAMPROFILE g_StatMsgStage1;
109/** @} */
110
111
112/** @page pg_shfl_svc Shared Folders Host Service
113 *
114 * Shared Folders map a host file system to guest logical filesystem.
115 * A mapping represents 'host name'<->'guest name' translation and a root
116 * identifier to be used to access this mapping.
117 * Examples: "C:\WINNT"<->"F:", "C:\WINNT\System32"<->"/mnt/host/system32".
118 *
119 * Therefore, host name and guest name are strings interpreted
120 * only by host service and guest client respectively. Host name is
121 * passed to guest only for informational purpose. Guest may for example
122 * display the string or construct volume label out of the string.
123 *
124 * Root identifiers are unique for whole guest life,
125 * that is until next guest reset/fresh start.
126 * 32 bit value incremented for each new mapping is used.
127 *
128 * Mapping strings are taken from VM XML configuration on VM startup.
129 * The service DLL takes mappings during initialization. There is
130 * also API for changing mappings at runtime.
131 *
132 * Current mappings and root identifiers are saved when VM is saved.
133 *
134 * Guest may use any of these mappings. Full path information
135 * about an object on a mapping consists of the root identifier and
136 * a full path of object.
137 *
138 * Guest IFS connects to the service and calls SHFL_FN_QUERY_MAP
139 * function which returns current mappings. For guest convenience,
140 * removed mappings also returned with REMOVED flag and new mappings
141 * are marked with NEW flag.
142 *
143 * To access host file system guest just forwards file system calls
144 * to the service, and specifies full paths or handles for objects.
145 *
146 *
147 */
148
149
150
151static DECLCALLBACK(int) svcUnload (void *)
152{
153 int rc = VINF_SUCCESS;
154
155 Log(("svcUnload\n"));
156 vbsfFreeHandleTable();
157
158 if (g_pHelpers)
159 HGCMSvcHlpStamDeregister(g_pHelpers, "/HGCM/VBoxSharedFolders/*");
160 return rc;
161}
162
163static DECLCALLBACK(int) svcConnect (void *, uint32_t u32ClientID, void *pvClient, uint32_t fRequestor, bool fRestoring)
164{
165 RT_NOREF(u32ClientID, fRequestor, fRestoring);
166 SHFLCLIENTDATA *pClient = (SHFLCLIENTDATA *)pvClient;
167 Log(("SharedFolders host service: connected, u32ClientID = %u\n", u32ClientID));
168
169 pClient->fHasMappingCounts = true;
170 return VINF_SUCCESS;
171}
172
173static DECLCALLBACK(int) svcDisconnect (void *, uint32_t u32ClientID, void *pvClient)
174{
175 RT_NOREF1(u32ClientID);
176 int rc = VINF_SUCCESS;
177 SHFLCLIENTDATA *pClient = (SHFLCLIENTDATA *)pvClient;
178
179 Log(("SharedFolders host service: disconnected, u32ClientID = %u\n", u32ClientID));
180
181 vbsfDisconnect(pClient);
182 return rc;
183}
184
185/** @note We only save as much state as required to access the shared folder again after restore.
186 * All I/O requests pending at the time of saving will never be completed or result in errors.
187 * (file handles no longer valid etc)
188 * This works as designed at the moment. A full state save would be difficult and not always possible
189 * as the contents of a shared folder might change in between save and restore.
190 */
191static DECLCALLBACK(int) svcSaveState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM)
192{
193#ifndef UNITTEST /* Read this as not yet tested */
194 RT_NOREF1(u32ClientID);
195 SHFLCLIENTDATA *pClient = (SHFLCLIENTDATA *)pvClient;
196
197 Log(("SharedFolders host service: saving state, u32ClientID = %u\n", u32ClientID));
198
199 int rc = SSMR3PutU32(pSSM, SHFL_SAVED_STATE_VERSION);
200 AssertRCReturn(rc, rc);
201
202 rc = SSMR3PutU32(pSSM, SHFL_MAX_MAPPINGS);
203 AssertRCReturn(rc, rc);
204
205 /* Save client structure length & contents */
206 rc = SSMR3PutU32(pSSM, sizeof(*pClient));
207 AssertRCReturn(rc, rc);
208
209 rc = SSMR3PutMem(pSSM, pClient, sizeof(*pClient));
210 AssertRCReturn(rc, rc);
211
212 /* Save all the active mappings. */
213 for (int i=0;i<SHFL_MAX_MAPPINGS;i++)
214 {
215 /* Mapping are saved in the order of increasing root handle values. */
216 MAPPING *pFolderMapping = vbsfMappingGetByRoot(i);
217
218 rc = SSMR3PutU32(pSSM, pFolderMapping? pFolderMapping->cMappings: 0);
219 AssertRCReturn(rc, rc);
220
221 rc = SSMR3PutBool(pSSM, pFolderMapping? pFolderMapping->fValid: false);
222 AssertRCReturn(rc, rc);
223
224 if (pFolderMapping && pFolderMapping->fValid)
225 {
226 uint32_t len = (uint32_t)strlen(pFolderMapping->pszFolderName);
227 SSMR3PutU32(pSSM, len);
228 SSMR3PutStrZ(pSSM, pFolderMapping->pszFolderName);
229
230 len = ShflStringSizeOfBuffer(pFolderMapping->pMapName);
231 SSMR3PutU32(pSSM, len);
232 SSMR3PutMem(pSSM, pFolderMapping->pMapName, len);
233
234 SSMR3PutBool(pSSM, pFolderMapping->fHostCaseSensitive);
235
236 SSMR3PutBool(pSSM, pFolderMapping->fGuestCaseSensitive);
237
238 len = ShflStringSizeOfBuffer(pFolderMapping->pAutoMountPoint);
239 SSMR3PutU32(pSSM, len);
240 rc = SSMR3PutMem(pSSM, pFolderMapping->pAutoMountPoint, len);
241 AssertRCReturn(rc, rc);
242 }
243 }
244
245#else
246 RT_NOREF3(u32ClientID, pvClient, pSSM);
247#endif
248 return VINF_SUCCESS;
249}
250
251static DECLCALLBACK(int) svcLoadState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM, uint32_t uVersion)
252{
253#ifndef UNITTEST /* Read this as not yet tested */
254 RT_NOREF(u32ClientID, uVersion);
255 uint32_t nrMappings;
256 SHFLCLIENTDATA *pClient = (SHFLCLIENTDATA *)pvClient;
257 uint32_t len, version;
258
259 Log(("SharedFolders host service: loading state, u32ClientID = %u\n", u32ClientID));
260
261 int rc = SSMR3GetU32(pSSM, &version);
262 AssertRCReturn(rc, rc);
263
264 if ( version > SHFL_SAVED_STATE_VERSION
265 || version < SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16)
266 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
267
268 rc = SSMR3GetU32(pSSM, &nrMappings);
269 AssertRCReturn(rc, rc);
270 if (nrMappings != SHFL_MAX_MAPPINGS)
271 return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
272
273 /* Restore the client data (flags + path delimiter + mapping counts (new) at the moment) */
274 rc = SSMR3GetU32(pSSM, &len);
275 AssertRCReturn(rc, rc);
276
277 if (len == RT_UOFFSETOF(SHFLCLIENTDATA, acMappings))
278 pClient->fHasMappingCounts = false;
279 else if (len != sizeof(*pClient))
280 return SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
281 "Saved SHFLCLIENTDATA size %u differs from current %u!\n", len, sizeof(*pClient));
282
283 rc = SSMR3GetMem(pSSM, pClient, len);
284 AssertRCReturn(rc, rc);
285
286 /* We don't actually (fully) restore the state; we simply check if the current state is as we it expect it to be. */
287 for (int i=0;i<SHFL_MAX_MAPPINGS;i++)
288 {
289 /* Load the saved mapping description and try to find it in the mappings. */
290 MAPPING mapping;
291 RT_ZERO(mapping);
292
293 /* restore the folder mapping counter. */
294 rc = SSMR3GetU32(pSSM, &mapping.cMappings);
295 AssertRCReturn(rc, rc);
296
297 rc = SSMR3GetBool(pSSM, &mapping.fValid);
298 AssertRCReturn(rc, rc);
299
300 if (mapping.fValid)
301 {
302 uint32_t cb;
303
304 /* Load the host path name. */
305 rc = SSMR3GetU32(pSSM, &cb);
306 AssertRCReturn(rc, rc);
307
308 char *pszFolderName;
309 if (version == SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16)
310 {
311 AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1),
312 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad folder name size: %#x\n", cb));
313 PSHFLSTRING pFolderName = (PSHFLSTRING)RTMemAlloc(cb);
314 AssertReturn(pFolderName != NULL, VERR_NO_MEMORY);
315
316 rc = SSMR3GetMem(pSSM, pFolderName, cb);
317 AssertRCReturn(rc, rc);
318 AssertReturn(pFolderName->u16Size < cb && pFolderName->u16Length < pFolderName->u16Size,
319 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
320 "Bad folder name string: %#x/%#x cb=%#x\n",
321 pFolderName->u16Size, pFolderName->u16Length, cb));
322
323 rc = RTUtf16ToUtf8(pFolderName->String.ucs2, &pszFolderName);
324 RTMemFree(pFolderName);
325 AssertRCReturn(rc, rc);
326 }
327 else
328 {
329 pszFolderName = (char *)RTStrAlloc(cb + 1);
330 AssertReturn(pszFolderName, VERR_NO_MEMORY);
331
332 rc = SSMR3GetStrZ(pSSM, pszFolderName, cb + 1);
333 AssertRCReturn(rc, rc);
334 mapping.pszFolderName = pszFolderName;
335 }
336
337 /* Load the map name. */
338 rc = SSMR3GetU32(pSSM, &cb);
339 AssertRCReturn(rc, rc);
340 AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1),
341 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad map name size: %#x\n", cb));
342
343 PSHFLSTRING pMapName = (PSHFLSTRING)RTMemAlloc(cb);
344 AssertReturn(pMapName != NULL, VERR_NO_MEMORY);
345
346 rc = SSMR3GetMem(pSSM, pMapName, cb);
347 AssertRCReturn(rc, rc);
348 AssertReturn(pMapName->u16Size < cb && pMapName->u16Length < pMapName->u16Size,
349 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
350 "Bad map name string: %#x/%#x cb=%#x\n",
351 pMapName->u16Size, pMapName->u16Length, cb));
352
353 /* Load case sensitivity config. */
354 rc = SSMR3GetBool(pSSM, &mapping.fHostCaseSensitive);
355 AssertRCReturn(rc, rc);
356
357 rc = SSMR3GetBool(pSSM, &mapping.fGuestCaseSensitive);
358 AssertRCReturn(rc, rc);
359
360 /* Load the auto mount point. */
361 PSHFLSTRING pAutoMountPoint;
362 if (version > SHFL_SAVED_STATE_VERSION_PRE_AUTO_MOUNT_POINT)
363 {
364 rc = SSMR3GetU32(pSSM, &cb);
365 AssertRCReturn(rc, rc);
366 AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1),
367 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad auto mount point size: %#x\n", cb));
368
369 pAutoMountPoint = (PSHFLSTRING)RTMemAlloc(cb);
370 AssertReturn(pAutoMountPoint != NULL, VERR_NO_MEMORY);
371
372 rc = SSMR3GetMem(pSSM, pAutoMountPoint, cb);
373 AssertRCReturn(rc, rc);
374 AssertReturn(pAutoMountPoint->u16Size < cb && pAutoMountPoint->u16Length < pAutoMountPoint->u16Size,
375 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
376 "Bad auto mount point string: %#x/%#x cb=%#x\n",
377 pAutoMountPoint->u16Size, pAutoMountPoint->u16Length, cb));
378
379 }
380 else
381 {
382 pAutoMountPoint = ShflStringDupUtf8("");
383 AssertReturn(pAutoMountPoint, VERR_NO_MEMORY);
384 }
385
386 mapping.pszFolderName = pszFolderName;
387 mapping.pMapName = pMapName;
388 mapping.pAutoMountPoint = pAutoMountPoint;
389
390 /* 'i' is the root handle of the saved mapping. */
391 rc = vbsfMappingLoaded (&mapping, i);
392 if (RT_FAILURE(rc))
393 {
394 LogRel(("SharedFolders host service: %Rrc loading %d [%ls] -> [%s]\n",
395 rc, i, pMapName->String.ucs2, pszFolderName));
396 }
397
398 RTMemFree(pAutoMountPoint);
399 RTMemFree(pMapName);
400 RTStrFree(pszFolderName);
401
402 AssertRCReturn(rc, rc);
403 }
404 }
405 Log(("SharedFolders host service: successfully loaded state\n"));
406#else
407 RT_NOREF(u32ClientID, pvClient, pSSM, uVersion);
408#endif
409 return VINF_SUCCESS;
410}
411
412static DECLCALLBACK(void) svcCall (void *, VBOXHGCMCALLHANDLE callHandle, uint32_t u32ClientID, void *pvClient,
413 uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM paParms[], uint64_t tsArrival)
414{
415 RT_NOREF(u32ClientID, tsArrival);
416#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
417 uint64_t tsStart;
418 STAM_GET_TS(tsStart);
419 STAM_REL_PROFILE_ADD_PERIOD(&g_StatMsgStage1, tsStart - tsArrival);
420#endif
421 Log(("SharedFolders host service: svcCall: u32ClientID = %u, fn = %u, cParms = %u, pparms = %p\n", u32ClientID, u32Function, cParms, paParms));
422
423 SHFLCLIENTDATA *pClient = (SHFLCLIENTDATA *)pvClient;
424
425 bool fAsynchronousProcessing = false;
426
427#ifdef LOG_ENABLED
428 for (uint32_t i = 0; i < cParms; i++)
429 {
430 /** @todo parameters other than 32 bit */
431 Log((" pparms[%d]: type %u, value %u\n", i, paParms[i].type, paParms[i].u.uint32));
432 }
433#endif
434
435 int rc = VINF_SUCCESS;
436 PSTAMPROFILE pStat, pStatFail;
437 switch (u32Function)
438 {
439 case SHFL_FN_QUERY_MAPPINGS:
440 {
441 pStat = &g_StatQueryMappings;
442 pStatFail = &g_StatQueryMappingsFail;
443 Log(("SharedFolders host service: svcCall: SHFL_FN_QUERY_MAPPINGS\n"));
444
445 /* Verify parameter count and types. */
446 if (cParms != SHFL_CPARMS_QUERY_MAPPINGS)
447 {
448 rc = VERR_INVALID_PARAMETER;
449 }
450 else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* flags */
451 || paParms[1].type != VBOX_HGCM_SVC_PARM_32BIT /* numberOfMappings */
452 || paParms[2].type != VBOX_HGCM_SVC_PARM_PTR /* mappings */
453 )
454 {
455 rc = VERR_INVALID_PARAMETER;
456 }
457 else
458 {
459 /* Fetch parameters. */
460 uint32_t fu32Flags = paParms[0].u.uint32;
461 uint32_t cMappings = paParms[1].u.uint32;
462 SHFLMAPPING *pMappings = (SHFLMAPPING *)paParms[2].u.pointer.addr;
463 uint32_t cbMappings = paParms[2].u.pointer.size;
464
465 /* Verify parameters values. */
466 if ( (fu32Flags & ~SHFL_MF_MASK) != 0
467 || cbMappings / sizeof (SHFLMAPPING) != cMappings
468 )
469 {
470 rc = VERR_INVALID_PARAMETER;
471 }
472 else
473 {
474 /* Execute the function. */
475 if (fu32Flags & SHFL_MF_UTF8)
476 pClient->fu32Flags |= SHFL_CF_UTF8;
477 /// @todo r=bird: Someone please explain this amusing code (r63916):
478 //if (fu32Flags & SHFL_MF_AUTOMOUNT)
479 // pClient->fu32Flags |= SHFL_MF_AUTOMOUNT;
480 //
481 //rc = vbsfMappingsQuery(pClient, pMappings, &cMappings);
482
483 rc = vbsfMappingsQuery(pClient, RT_BOOL(fu32Flags & SHFL_MF_AUTOMOUNT), pMappings, &cMappings);
484 if (RT_SUCCESS(rc))
485 {
486 /* Report that there are more mappings to get if
487 * handed in buffer is too small. */
488 if (paParms[1].u.uint32 < cMappings)
489 rc = VINF_BUFFER_OVERFLOW;
490
491 /* Update parameters. */
492 paParms[1].u.uint32 = cMappings;
493 }
494 }
495 }
496
497
498 } break;
499
500 case SHFL_FN_QUERY_MAP_NAME:
501 {
502 pStatFail = pStat = &g_StatQueryMapName;
503 Log(("SharedFolders host service: svcCall: SHFL_FN_QUERY_MAP_NAME\n"));
504
505 /* Verify parameter count and types. */
506 if (cParms != SHFL_CPARMS_QUERY_MAP_NAME)
507 {
508 rc = VERR_INVALID_PARAMETER;
509 }
510 else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* Root. */
511 || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR /* Name. */
512 )
513 {
514 rc = VERR_INVALID_PARAMETER;
515 }
516 else
517 {
518 /* Fetch parameters. */
519 SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
520 SHFLSTRING *pString = (SHFLSTRING *)paParms[1].u.pointer.addr;
521
522 /* Verify parameters values. */
523 if (!ShflStringIsValidOut(pString, paParms[1].u.pointer.size))
524 {
525 rc = VERR_INVALID_PARAMETER;
526 }
527 else
528 {
529 /* Execute the function. */
530 rc = vbsfMappingsQueryName(pClient, root, pString);
531
532 if (RT_SUCCESS(rc))
533 {
534 /* Update parameters.*/
535 ; /* None. */
536 }
537 }
538 }
539
540 } break;
541
542 case SHFL_FN_CREATE:
543 {
544 pStat = &g_StatCreate;
545 pStatFail = &g_StatCreateFail;
546 Log(("SharedFolders host service: svcCall: SHFL_FN_CREATE\n"));
547
548 /* Verify parameter count and types. */
549 if (cParms != SHFL_CPARMS_CREATE)
550 {
551 rc = VERR_INVALID_PARAMETER;
552 }
553 else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
554 || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR /* path */
555 || paParms[2].type != VBOX_HGCM_SVC_PARM_PTR /* parms */
556 )
557 {
558 Log(("SharedFolders host service: Invalid parameters types\n"));
559 rc = VERR_INVALID_PARAMETER;
560 }
561 else
562 {
563 /* Fetch parameters. */
564 SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
565 SHFLSTRING *pPath = (SHFLSTRING *)paParms[1].u.pointer.addr;
566 uint32_t cbPath = paParms[1].u.pointer.size;
567 SHFLCREATEPARMS *pParms = (SHFLCREATEPARMS *)paParms[2].u.pointer.addr;
568 uint32_t cbParms = paParms[2].u.pointer.size;
569
570 /* Verify parameters values. */
571 if ( !ShflStringIsValidIn(pPath, cbPath, RT_BOOL(pClient->fu32Flags & SHFL_CF_UTF8))
572 || (cbParms != sizeof (SHFLCREATEPARMS))
573 )
574 {
575 AssertMsgFailed (("Invalid parameters cbPath or cbParms (%x, %x - expected >=%x, %x)\n",
576 cbPath, cbParms, sizeof(SHFLSTRING), sizeof (SHFLCREATEPARMS)));
577 rc = VERR_INVALID_PARAMETER;
578 }
579 else
580 {
581 if (pParms->CreateFlags & SHFL_CF_LOOKUP)
582 {
583 pStat = &g_StatLookup;
584 pStatFail = &g_StatLookupFail;
585 }
586
587 /* Execute the function. */
588 rc = vbsfCreate (pClient, root, pPath, cbPath, pParms);
589
590 if (RT_SUCCESS(rc))
591 {
592 /* Update parameters.*/
593 ; /* none */
594 }
595 }
596 }
597 break;
598 }
599
600 case SHFL_FN_CLOSE:
601 {
602 pStat = &g_StatClose;
603 pStatFail = &g_StatCloseFail;
604 Log(("SharedFolders host service: svcCall: SHFL_FN_CLOSE\n"));
605
606 /* Verify parameter count and types. */
607 if (cParms != SHFL_CPARMS_CLOSE)
608 {
609 rc = VERR_INVALID_PARAMETER;
610 }
611 else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
612 || paParms[1].type != VBOX_HGCM_SVC_PARM_64BIT /* handle */
613 )
614 {
615 rc = VERR_INVALID_PARAMETER;
616 }
617 else
618 {
619 /* Fetch parameters. */
620 SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
621 SHFLHANDLE Handle = paParms[1].u.uint64;
622
623 /* Verify parameters values. */
624 if (Handle == SHFL_HANDLE_ROOT)
625 {
626 rc = VERR_INVALID_PARAMETER;
627 }
628 else
629 if (Handle == SHFL_HANDLE_NIL)
630 {
631 AssertMsgFailed(("Invalid handle!\n"));
632 rc = VERR_INVALID_HANDLE;
633 }
634 else
635 {
636 /* Execute the function. */
637 rc = vbsfClose (pClient, root, Handle);
638
639 if (RT_SUCCESS(rc))
640 {
641 /* Update parameters.*/
642 ; /* none */
643 }
644 }
645 }
646 break;
647
648 }
649
650 /* Read object content. */
651 case SHFL_FN_READ:
652 {
653 pStat = &g_StatRead;
654 pStatFail = &g_StatReadFail;
655 Log(("SharedFolders host service: svcCall: SHFL_FN_READ\n"));
656 /* Verify parameter count and types. */
657 ASSERT_GUEST_STMT_BREAK(cParms == SHFL_CPARMS_READ, rc = VERR_WRONG_PARAMETER_COUNT);
658 ASSERT_GUEST_STMT_BREAK(paParms[0].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* root */
659 ASSERT_GUEST_STMT_BREAK(paParms[1].type == VBOX_HGCM_SVC_PARM_64BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* handle */
660 ASSERT_GUEST_STMT_BREAK(paParms[2].type == VBOX_HGCM_SVC_PARM_64BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* offset */
661 ASSERT_GUEST_STMT_BREAK(paParms[3].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* count */
662 ASSERT_GUEST_STMT_BREAK( paParms[4].type == VBOX_HGCM_SVC_PARM_PTR
663 || paParms[4].type == VBOX_HGCM_SVC_PARM_PAGES, rc = VERR_WRONG_PARAMETER_TYPE); /* buffer */
664
665 /* Fetch parameters. */
666 SHFLROOT const idRoot = (SHFLROOT)paParms[0].u.uint32;
667 SHFLHANDLE const hFile = paParms[1].u.uint64;
668 uint64_t const offFile = paParms[2].u.uint64;
669 uint32_t cbRead = paParms[3].u.uint32;
670
671 /* Verify parameters values. */
672 ASSERT_GUEST_STMT_BREAK(hFile != SHFL_HANDLE_ROOT, rc = VERR_INVALID_PARAMETER);
673 ASSERT_GUEST_STMT_BREAK(hFile != SHFL_HANDLE_NIL, rc = VERR_INVALID_HANDLE);
674 if (paParms[4].type == VBOX_HGCM_SVC_PARM_PTR)
675 ASSERT_GUEST_STMT_BREAK(cbRead <= paParms[4].u.pointer.size, rc = VERR_INVALID_HANDLE);
676 else
677 ASSERT_GUEST_STMT_BREAK(cbRead <= paParms[4].u.Pages.cb, rc = VERR_OUT_OF_RANGE);
678
679 /* Execute the function. */
680 if (g_pStatusLed)
681 {
682 Assert(g_pStatusLed->u32Magic == PDMLED_MAGIC);
683 g_pStatusLed->Asserted.s.fReading = g_pStatusLed->Actual.s.fReading = 1;
684 }
685
686 if (paParms[4].type == VBOX_HGCM_SVC_PARM_PTR)
687 rc = vbsfRead(pClient, idRoot, hFile, offFile, &cbRead, (uint8_t *)paParms[4].u.pointer.addr);
688 else
689 rc = vbsfReadPages(pClient, idRoot, hFile, offFile, &cbRead, &paParms[4].u.Pages);
690
691 if (g_pStatusLed)
692 g_pStatusLed->Actual.s.fReading = 0;
693
694 /* Update parameters.*/
695 paParms[3].u.uint32 = RT_SUCCESS(rc) ? cbRead : 0 /* nothing read */;
696 break;
697 }
698
699 /* Write new object content. */
700 case SHFL_FN_WRITE:
701 {
702 pStat = &g_StatWrite;
703 pStatFail = &g_StatWriteFail;
704 Log(("SharedFolders host service: svcCall: SHFL_FN_WRITE\n"));
705
706 /* Verify parameter count and types. */
707 ASSERT_GUEST_STMT_BREAK(cParms == SHFL_CPARMS_WRITE, rc = VERR_WRONG_PARAMETER_COUNT);
708 ASSERT_GUEST_STMT_BREAK(paParms[0].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* root */
709 ASSERT_GUEST_STMT_BREAK(paParms[1].type == VBOX_HGCM_SVC_PARM_64BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* handle */
710 ASSERT_GUEST_STMT_BREAK(paParms[2].type == VBOX_HGCM_SVC_PARM_64BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* offset */
711 ASSERT_GUEST_STMT_BREAK(paParms[3].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* count */
712 ASSERT_GUEST_STMT_BREAK( paParms[4].type == VBOX_HGCM_SVC_PARM_PTR
713 || paParms[4].type == VBOX_HGCM_SVC_PARM_PAGES, rc = VERR_WRONG_PARAMETER_TYPE); /* buffer */
714 /* Fetch parameters. */
715 SHFLROOT const idRoot = (SHFLROOT)paParms[0].u.uint32;
716 SHFLHANDLE const hFile = paParms[1].u.uint64;
717 uint64_t offFile = paParms[2].u.uint64;
718 uint32_t cbWrite = paParms[3].u.uint32;
719
720 /* Verify parameters values. */
721 ASSERT_GUEST_STMT_BREAK(hFile != SHFL_HANDLE_ROOT, rc = VERR_INVALID_PARAMETER);
722 ASSERT_GUEST_STMT_BREAK(hFile != SHFL_HANDLE_NIL, rc = VERR_INVALID_HANDLE);
723 if (paParms[4].type == VBOX_HGCM_SVC_PARM_PTR)
724 ASSERT_GUEST_STMT_BREAK(cbWrite <= paParms[4].u.pointer.size, rc = VERR_INVALID_HANDLE);
725 else
726 ASSERT_GUEST_STMT_BREAK(cbWrite <= paParms[4].u.Pages.cb, rc = VERR_OUT_OF_RANGE);
727
728 /* Execute the function. */
729 if (g_pStatusLed)
730 {
731 Assert(g_pStatusLed->u32Magic == PDMLED_MAGIC);
732 g_pStatusLed->Asserted.s.fWriting = g_pStatusLed->Actual.s.fWriting = 1;
733 }
734
735 if (paParms[4].type == VBOX_HGCM_SVC_PARM_PTR)
736 rc = vbsfWrite(pClient, idRoot, hFile, &offFile, &cbWrite, (uint8_t *)paParms[4].u.pointer.addr);
737 else
738 rc = vbsfWritePages(pClient, idRoot, hFile, &offFile, &cbWrite, &paParms[4].u.Pages);
739
740 if (g_pStatusLed)
741 g_pStatusLed->Actual.s.fWriting = 0;
742
743 /* Update parameters.*/
744 if (RT_SUCCESS(rc))
745 {
746 paParms[3].u.uint32 = cbWrite;
747 paParms[4].u.uint64 = offFile;
748 }
749 else
750 paParms[3].u.uint32 = 0;
751 break;
752 }
753
754 /* Lock/unlock a range in the object. */
755 case SHFL_FN_LOCK:
756 pStat = &g_StatLock;
757 pStatFail = &g_StatLockFail;
758 Log(("SharedFolders host service: svcCall: SHFL_FN_LOCK\n"));
759
760 /* Verify parameter count and types. */
761 if (cParms != SHFL_CPARMS_LOCK)
762 {
763 rc = VERR_INVALID_PARAMETER;
764 }
765 else
766 if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
767 || paParms[1].type != VBOX_HGCM_SVC_PARM_64BIT /* handle */
768 || paParms[2].type != VBOX_HGCM_SVC_PARM_64BIT /* offset */
769 || paParms[3].type != VBOX_HGCM_SVC_PARM_64BIT /* length */
770 || paParms[4].type != VBOX_HGCM_SVC_PARM_32BIT /* flags */
771 )
772 {
773 rc = VERR_INVALID_PARAMETER;
774 }
775 else
776 {
777 /* Fetch parameters. */
778 SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
779 SHFLHANDLE Handle = paParms[1].u.uint64;
780 uint64_t offset = paParms[2].u.uint64;
781 uint64_t length = paParms[3].u.uint64;
782 uint32_t flags = paParms[4].u.uint32;
783
784 /* Verify parameters values. */
785 if (Handle == SHFL_HANDLE_ROOT)
786 {
787 rc = VERR_INVALID_PARAMETER;
788 }
789 else
790 if (Handle == SHFL_HANDLE_NIL)
791 {
792 AssertMsgFailed(("Invalid handle!\n"));
793 rc = VERR_INVALID_HANDLE;
794 }
795 else if (flags & SHFL_LOCK_WAIT)
796 {
797 /** @todo This should be properly implemented by the shared folders service.
798 * The service thread must never block. If an operation requires
799 * blocking, it must be processed by another thread and when it is
800 * completed, the another thread must call
801 *
802 * g_pHelpers->pfnCallComplete (callHandle, rc);
803 *
804 * The operation is async.
805 * fAsynchronousProcessing = true;
806 */
807
808 /* Here the operation must be posted to another thread. At the moment it is not implemented.
809 * Until it is implemented, try to perform the operation without waiting.
810 */
811 flags &= ~SHFL_LOCK_WAIT;
812
813 /* Execute the function. */
814 if ((flags & SHFL_LOCK_MODE_MASK) == SHFL_LOCK_CANCEL)
815 rc = vbsfUnlock(pClient, root, Handle, offset, length, flags);
816 else
817 rc = vbsfLock(pClient, root, Handle, offset, length, flags);
818
819 if (RT_SUCCESS(rc))
820 {
821 /* Update parameters.*/
822 /* none */
823 }
824 }
825 else
826 {
827 /* Execute the function. */
828 if ((flags & SHFL_LOCK_MODE_MASK) == SHFL_LOCK_CANCEL)
829 rc = vbsfUnlock(pClient, root, Handle, offset, length, flags);
830 else
831 rc = vbsfLock(pClient, root, Handle, offset, length, flags);
832
833 if (RT_SUCCESS(rc))
834 {
835 /* Update parameters.*/
836 /* none */
837 }
838 }
839 }
840 break;
841
842 /* List object content. */
843 case SHFL_FN_LIST:
844 {
845 pStat = &g_StatList;
846 pStatFail = &g_StatListFail;
847 Log(("SharedFolders host service: svcCall: SHFL_FN_LIST\n"));
848
849 /* Verify parameter count and types. */
850 if (cParms != SHFL_CPARMS_LIST)
851 {
852 rc = VERR_INVALID_PARAMETER;
853 }
854 else
855 if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
856 || paParms[1].type != VBOX_HGCM_SVC_PARM_64BIT /* handle */
857 || paParms[2].type != VBOX_HGCM_SVC_PARM_32BIT /* flags */
858 || paParms[3].type != VBOX_HGCM_SVC_PARM_32BIT /* cb */
859 || paParms[4].type != VBOX_HGCM_SVC_PARM_PTR /* pPath */
860 || paParms[5].type != VBOX_HGCM_SVC_PARM_PTR /* buffer */
861 || paParms[6].type != VBOX_HGCM_SVC_PARM_32BIT /* resumePoint */
862 || paParms[7].type != VBOX_HGCM_SVC_PARM_32BIT /* cFiles (out) */
863 )
864 {
865 rc = VERR_INVALID_PARAMETER;
866 }
867 else
868 {
869 /* Fetch parameters. */
870 SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
871 SHFLHANDLE Handle = paParms[1].u.uint64;
872 uint32_t flags = paParms[2].u.uint32;
873 uint32_t length = paParms[3].u.uint32;
874 SHFLSTRING *pPath = (paParms[4].u.pointer.size == 0) ? 0 : (SHFLSTRING *)paParms[4].u.pointer.addr;
875 uint8_t *pBuffer = (uint8_t *)paParms[5].u.pointer.addr;
876 uint32_t resumePoint = paParms[6].u.uint32;
877 uint32_t cFiles = 0;
878
879 /* Verify parameters values. */
880 if ( (length < sizeof (SHFLDIRINFO))
881 || length > paParms[5].u.pointer.size
882 || !ShflStringIsValidOrNullIn(pPath, paParms[4].u.pointer.size, RT_BOOL(pClient->fu32Flags & SHFL_CF_UTF8))
883 )
884 {
885 rc = VERR_INVALID_PARAMETER;
886 }
887 else
888 {
889 if (g_pStatusLed)
890 {
891 Assert(g_pStatusLed->u32Magic == PDMLED_MAGIC);
892 g_pStatusLed->Asserted.s.fReading = g_pStatusLed->Actual.s.fReading = 1;
893 }
894
895 /* Execute the function. */
896 rc = vbsfDirList (pClient, root, Handle, pPath, flags, &length, pBuffer, &resumePoint, &cFiles);
897
898 if (g_pStatusLed)
899 g_pStatusLed->Actual.s.fReading = 0;
900
901 if (rc == VERR_NO_MORE_FILES && cFiles != 0)
902 rc = VINF_SUCCESS; /* Successfully return these files. */
903
904 if (RT_SUCCESS(rc))
905 {
906 /* Update parameters.*/
907 paParms[3].u.uint32 = length;
908 paParms[6].u.uint32 = resumePoint;
909 paParms[7].u.uint32 = cFiles;
910 }
911 else
912 {
913 paParms[3].u.uint32 = 0; /* nothing read */
914 paParms[6].u.uint32 = 0;
915 paParms[7].u.uint32 = cFiles;
916 }
917 }
918 }
919 break;
920 }
921
922 /* Read symlink destination */
923 case SHFL_FN_READLINK:
924 {
925 pStat = &g_StatReadLink;
926 pStatFail = &g_StatReadLinkFail;
927 Log(("SharedFolders host service: svcCall: SHFL_FN_READLINK\n"));
928
929 /* Verify parameter count and types. */
930 if (cParms != SHFL_CPARMS_READLINK)
931 {
932 rc = VERR_INVALID_PARAMETER;
933 }
934 else
935 if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
936 || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR /* path */
937 || paParms[2].type != VBOX_HGCM_SVC_PARM_PTR /* buffer */
938 )
939 {
940 rc = VERR_INVALID_PARAMETER;
941 }
942 else
943 {
944 /* Fetch parameters. */
945 SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
946 SHFLSTRING *pPath = (SHFLSTRING *)paParms[1].u.pointer.addr;
947 uint32_t cbPath = paParms[1].u.pointer.size;
948 uint8_t *pBuffer = (uint8_t *)paParms[2].u.pointer.addr;
949 uint32_t cbBuffer = paParms[2].u.pointer.size;
950
951 /* Verify parameters values. */
952 if (!ShflStringIsValidOrNullIn(pPath, paParms[1].u.pointer.size, RT_BOOL(pClient->fu32Flags & SHFL_CF_UTF8)))
953 {
954 rc = VERR_INVALID_PARAMETER;
955 }
956 else
957 {
958 /* Execute the function. */
959 rc = vbsfReadLink (pClient, root, pPath, cbPath, pBuffer, cbBuffer);
960
961 if (RT_SUCCESS(rc))
962 {
963 /* Update parameters.*/
964 ; /* none */
965 }
966 }
967 }
968
969 break;
970 }
971
972 /* Legacy interface */
973 case SHFL_FN_MAP_FOLDER_OLD:
974 {
975 pStatFail = pStat = &g_StatMapFolderOld;
976 Log(("SharedFolders host service: svcCall: SHFL_FN_MAP_FOLDER_OLD\n"));
977
978 /* Verify parameter count and types. */
979 if (cParms != SHFL_CPARMS_MAP_FOLDER_OLD)
980 {
981 rc = VERR_INVALID_PARAMETER;
982 }
983 else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_PTR /* path */
984 || paParms[1].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
985 || paParms[2].type != VBOX_HGCM_SVC_PARM_32BIT /* delimiter */
986 )
987 {
988 rc = VERR_INVALID_PARAMETER;
989 }
990 else
991 {
992 /* Fetch parameters. */
993 PSHFLSTRING pszMapName = (PSHFLSTRING)paParms[0].u.pointer.addr;
994 SHFLROOT root = (SHFLROOT)paParms[1].u.uint32;
995 RTUTF16 delimiter = (RTUTF16)paParms[2].u.uint32;
996
997 /* Verify parameters values. */
998 if (!ShflStringIsValidIn(pszMapName, paParms[0].u.pointer.size, RT_BOOL(pClient->fu32Flags & SHFL_CF_UTF8)))
999 {
1000 rc = VERR_INVALID_PARAMETER;
1001 }
1002 else
1003 {
1004 /* Execute the function. */
1005 rc = vbsfMapFolder (pClient, pszMapName, delimiter, false, &root);
1006
1007 if (RT_SUCCESS(rc))
1008 {
1009 /* Update parameters.*/
1010 paParms[1].u.uint32 = root;
1011 }
1012 }
1013 }
1014 break;
1015 }
1016
1017 case SHFL_FN_MAP_FOLDER:
1018 {
1019 pStat = &g_StatMapFolder;
1020 pStatFail = &g_StatMapFolderFail;
1021 Log(("SharedFolders host service: svcCall: SHFL_FN_MAP_FOLDER\n"));
1022 if (BIT_FLAG(pClient->fu32Flags, SHFL_CF_UTF8))
1023 Log(("SharedFolders host service: request to map folder '%s'\n",
1024 ((PSHFLSTRING)paParms[0].u.pointer.addr)->String.utf8));
1025 else
1026 Log(("SharedFolders host service: request to map folder '%ls'\n",
1027 ((PSHFLSTRING)paParms[0].u.pointer.addr)->String.ucs2));
1028
1029 /* Verify parameter count and types. */
1030 if (cParms != SHFL_CPARMS_MAP_FOLDER)
1031 {
1032 rc = VERR_INVALID_PARAMETER;
1033 }
1034 else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_PTR /* path */
1035 || paParms[1].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
1036 || paParms[2].type != VBOX_HGCM_SVC_PARM_32BIT /* delimiter */
1037 || paParms[3].type != VBOX_HGCM_SVC_PARM_32BIT /* fCaseSensitive */
1038 )
1039 {
1040 rc = VERR_INVALID_PARAMETER;
1041 }
1042 else
1043 {
1044 /* Fetch parameters. */
1045 PSHFLSTRING pszMapName = (PSHFLSTRING)paParms[0].u.pointer.addr;
1046 SHFLROOT root = (SHFLROOT)paParms[1].u.uint32;
1047 RTUTF16 delimiter = (RTUTF16)paParms[2].u.uint32;
1048 bool fCaseSensitive = !!paParms[3].u.uint32;
1049
1050 /* Verify parameters values. */
1051 if (ShflStringIsValidIn(pszMapName, paParms[0].u.pointer.size, RT_BOOL(pClient->fu32Flags & SHFL_CF_UTF8)))
1052 {
1053 rc = VINF_SUCCESS;
1054 }
1055 else
1056 {
1057 rc = VERR_INVALID_PARAMETER;
1058
1059 /* Fudge for windows GAs getting the length wrong by one char. */
1060 if ( !(pClient->fu32Flags & SHFL_CF_UTF8)
1061 && paParms[0].u.pointer.size >= sizeof(SHFLSTRING)
1062 && pszMapName->u16Length >= 2
1063 && pszMapName->String.ucs2[pszMapName->u16Length / 2 - 1] == 0x0000)
1064 {
1065 pszMapName->u16Length -= 2;
1066 if (ShflStringIsValidIn(pszMapName, paParms[0].u.pointer.size, false /*fUtf8Not16*/))
1067 rc = VINF_SUCCESS;
1068 else
1069 pszMapName->u16Length += 2;
1070 }
1071 }
1072
1073 /* Execute the function. */
1074 if (RT_SUCCESS(rc))
1075 rc = vbsfMapFolder (pClient, pszMapName, delimiter, fCaseSensitive, &root);
1076
1077 if (RT_SUCCESS(rc))
1078 {
1079 /* Update parameters.*/
1080 paParms[1].u.uint32 = root;
1081 }
1082 }
1083 Log(("SharedFolders host service: map operation result %Rrc\n", rc));
1084 if (RT_SUCCESS(rc))
1085 Log(("SharedFolders host service: mapped to handle %d\n", paParms[1].u.uint32));
1086 break;
1087 }
1088
1089 case SHFL_FN_UNMAP_FOLDER:
1090 {
1091 pStat = &g_StatUnmapFolder;
1092 pStatFail = &g_StatUnmapFolderFail;
1093 Log(("SharedFolders host service: svcCall: SHFL_FN_UNMAP_FOLDER\n"));
1094 Log(("SharedFolders host service: request to unmap folder handle %u\n",
1095 paParms[0].u.uint32));
1096
1097 /* Verify parameter count and types. */
1098 if (cParms != SHFL_CPARMS_UNMAP_FOLDER)
1099 {
1100 rc = VERR_INVALID_PARAMETER;
1101 }
1102 else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
1103 )
1104 {
1105 rc = VERR_INVALID_PARAMETER;
1106 }
1107 else
1108 {
1109 /* Fetch parameters. */
1110 SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
1111
1112 /* Execute the function. */
1113 rc = vbsfUnmapFolder (pClient, root);
1114
1115 if (RT_SUCCESS(rc))
1116 {
1117 /* Update parameters.*/
1118 /* nothing */
1119 }
1120 }
1121 Log(("SharedFolders host service: unmap operation result %Rrc\n", rc));
1122 break;
1123 }
1124
1125 /* Query/set object information. */
1126 case SHFL_FN_INFORMATION:
1127 {
1128 pStatFail = pStat = &g_StatInformationFail;
1129 Log(("SharedFolders host service: svcCall: SHFL_FN_INFORMATION\n"));
1130
1131 /* Verify parameter count and types. */
1132 if (cParms != SHFL_CPARMS_INFORMATION)
1133 {
1134 rc = VERR_INVALID_PARAMETER;
1135 }
1136 else
1137 if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
1138 || paParms[1].type != VBOX_HGCM_SVC_PARM_64BIT /* handle */
1139 || paParms[2].type != VBOX_HGCM_SVC_PARM_32BIT /* flags */
1140 || paParms[3].type != VBOX_HGCM_SVC_PARM_32BIT /* cb */
1141 || paParms[4].type != VBOX_HGCM_SVC_PARM_PTR /* buffer */
1142 )
1143 {
1144 rc = VERR_INVALID_PARAMETER;
1145 }
1146 else
1147 {
1148 /* Fetch parameters. */
1149 SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
1150 SHFLHANDLE Handle = paParms[1].u.uint64;
1151 uint32_t flags = paParms[2].u.uint32;
1152 uint32_t length = paParms[3].u.uint32;
1153 uint8_t *pBuffer = (uint8_t *)paParms[4].u.pointer.addr;
1154
1155 /* Verify parameters values. */
1156 if (length > paParms[4].u.pointer.size)
1157 {
1158 rc = VERR_INVALID_PARAMETER;
1159 }
1160 else
1161 {
1162 /* Execute the function. */
1163 if (flags & SHFL_INFO_SET)
1164 {
1165 rc = vbsfSetFSInfo (pClient, root, Handle, flags, &length, pBuffer);
1166
1167 if (flags & SHFL_INFO_FILE)
1168 {
1169 pStat = &g_StatInformationSetFile;
1170 pStatFail = &g_StatInformationSetFileFail;
1171 }
1172 else if (flags & SHFL_INFO_SIZE)
1173 {
1174 pStat = &g_StatInformationSetSize;
1175 pStatFail = &g_StatInformationSetSizeFail;
1176 }
1177 }
1178 else /* SHFL_INFO_GET */
1179 {
1180 rc = vbsfQueryFSInfo (pClient, root, Handle, flags, &length, pBuffer);
1181
1182 if (flags & SHFL_INFO_FILE)
1183 {
1184 pStat = &g_StatInformationGetFile;
1185 pStatFail = &g_StatInformationGetFileFail;
1186 }
1187 else if (flags & SHFL_INFO_VOLUME)
1188 {
1189 pStat = &g_StatInformationGetVolume;
1190 pStatFail = &g_StatInformationGetVolumeFail;
1191 }
1192 }
1193
1194 if (RT_SUCCESS(rc))
1195 {
1196 /* Update parameters.*/
1197 paParms[3].u.uint32 = length;
1198 }
1199 else
1200 {
1201 paParms[3].u.uint32 = 0; /* nothing read */
1202 }
1203 }
1204 }
1205 break;
1206 }
1207
1208 /* Remove or rename object */
1209 case SHFL_FN_REMOVE:
1210 {
1211 pStat = &g_StatRemove;
1212 pStatFail = &g_StatRemoveFail;
1213 Log(("SharedFolders host service: svcCall: SHFL_FN_REMOVE\n"));
1214
1215 /* Verify parameter count and types. */
1216 if (cParms != SHFL_CPARMS_REMOVE)
1217 {
1218 rc = VERR_INVALID_PARAMETER;
1219 }
1220 else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
1221 || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR /* path */
1222 || paParms[2].type != VBOX_HGCM_SVC_PARM_32BIT /* flags */
1223 )
1224 {
1225 rc = VERR_INVALID_PARAMETER;
1226 }
1227 else
1228 {
1229 /* Fetch parameters. */
1230 SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
1231 SHFLSTRING *pPath = (SHFLSTRING *)paParms[1].u.pointer.addr;
1232 uint32_t cbPath = paParms[1].u.pointer.size;
1233 uint32_t flags = paParms[2].u.uint32;
1234
1235 /* Verify parameters values. */
1236 if (!ShflStringIsValidIn(pPath, cbPath, RT_BOOL(pClient->fu32Flags & SHFL_CF_UTF8)))
1237 {
1238 rc = VERR_INVALID_PARAMETER;
1239 }
1240 else
1241 {
1242 /* Execute the function. */
1243 rc = vbsfRemove (pClient, root, pPath, cbPath, flags);
1244 if (RT_SUCCESS(rc))
1245 {
1246 /* Update parameters.*/
1247 ; /* none */
1248 }
1249 }
1250 }
1251 break;
1252 }
1253
1254 case SHFL_FN_RENAME:
1255 {
1256 pStat = &g_StatRename;
1257 pStatFail = &g_StatRenameFail;
1258 Log(("SharedFolders host service: svcCall: SHFL_FN_RENAME\n"));
1259
1260 /* Verify parameter count and types. */
1261 if (cParms != SHFL_CPARMS_RENAME)
1262 {
1263 rc = VERR_INVALID_PARAMETER;
1264 }
1265 else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
1266 || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR /* src */
1267 || paParms[2].type != VBOX_HGCM_SVC_PARM_PTR /* dest */
1268 || paParms[3].type != VBOX_HGCM_SVC_PARM_32BIT /* flags */
1269 )
1270 {
1271 rc = VERR_INVALID_PARAMETER;
1272 }
1273 else
1274 {
1275 /* Fetch parameters. */
1276 SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
1277 SHFLSTRING *pSrc = (SHFLSTRING *)paParms[1].u.pointer.addr;
1278 SHFLSTRING *pDest = (SHFLSTRING *)paParms[2].u.pointer.addr;
1279 uint32_t flags = paParms[3].u.uint32;
1280
1281 /* Verify parameters values. */
1282 if ( !ShflStringIsValidIn(pSrc, paParms[1].u.pointer.size, RT_BOOL(pClient->fu32Flags & SHFL_CF_UTF8))
1283 || !ShflStringIsValidIn(pDest, paParms[2].u.pointer.size, RT_BOOL(pClient->fu32Flags & SHFL_CF_UTF8))
1284 )
1285 {
1286 rc = VERR_INVALID_PARAMETER;
1287 }
1288 else
1289 {
1290 /* Execute the function. */
1291 rc = vbsfRename (pClient, root, pSrc, pDest, flags);
1292 if (RT_SUCCESS(rc))
1293 {
1294 /* Update parameters.*/
1295 ; /* none */
1296 }
1297 }
1298 }
1299 break;
1300 }
1301
1302 case SHFL_FN_FLUSH:
1303 {
1304 pStat = &g_StatFlush;
1305 pStatFail = &g_StatFlushFail;
1306 Log(("SharedFolders host service: svcCall: SHFL_FN_FLUSH\n"));
1307
1308 /* Verify parameter count and types. */
1309 if (cParms != SHFL_CPARMS_FLUSH)
1310 {
1311 rc = VERR_INVALID_PARAMETER;
1312 }
1313 else
1314 if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
1315 || paParms[1].type != VBOX_HGCM_SVC_PARM_64BIT /* handle */
1316 )
1317 {
1318 rc = VERR_INVALID_PARAMETER;
1319 }
1320 else
1321 {
1322 /* Fetch parameters. */
1323 SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
1324 SHFLHANDLE Handle = paParms[1].u.uint64;
1325
1326 /* Verify parameters values. */
1327 if (Handle == SHFL_HANDLE_ROOT)
1328 {
1329 rc = VERR_INVALID_PARAMETER;
1330 }
1331 else
1332 if (Handle == SHFL_HANDLE_NIL)
1333 {
1334 AssertMsgFailed(("Invalid handle!\n"));
1335 rc = VERR_INVALID_HANDLE;
1336 }
1337 else
1338 {
1339 /* Execute the function. */
1340
1341 rc = vbsfFlush (pClient, root, Handle);
1342
1343 if (RT_SUCCESS(rc))
1344 {
1345 /* Nothing to do */
1346 }
1347 }
1348 }
1349 } break;
1350
1351 case SHFL_FN_SET_UTF8:
1352 {
1353 pStatFail = pStat = &g_StatSetUtf8;
1354
1355 pClient->fu32Flags |= SHFL_CF_UTF8;
1356 rc = VINF_SUCCESS;
1357 break;
1358 }
1359
1360 case SHFL_FN_SYMLINK:
1361 {
1362 pStat = &g_StatSymlink;
1363 pStatFail = &g_StatSymlinkFail;
1364 Log(("SharedFolders host service: svnCall: SHFL_FN_SYMLINK\n"));
1365
1366 /* Verify parameter count and types. */
1367 if (cParms != SHFL_CPARMS_SYMLINK)
1368 {
1369 rc = VERR_INVALID_PARAMETER;
1370 }
1371 else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
1372 || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR /* newPath */
1373 || paParms[2].type != VBOX_HGCM_SVC_PARM_PTR /* oldPath */
1374 || paParms[3].type != VBOX_HGCM_SVC_PARM_PTR /* info */
1375 )
1376 {
1377 rc = VERR_INVALID_PARAMETER;
1378 }
1379 else
1380 {
1381 /* Fetch parameters. */
1382 SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
1383 SHFLSTRING *pNewPath = (SHFLSTRING *)paParms[1].u.pointer.addr;
1384 SHFLSTRING *pOldPath = (SHFLSTRING *)paParms[2].u.pointer.addr;
1385 SHFLFSOBJINFO *pInfo = (SHFLFSOBJINFO *)paParms[3].u.pointer.addr;
1386 uint32_t cbInfo = paParms[3].u.pointer.size;
1387
1388 /* Verify parameters values. */
1389 if ( !ShflStringIsValidIn(pNewPath, paParms[1].u.pointer.size, RT_BOOL(pClient->fu32Flags & SHFL_CF_UTF8))
1390 || !ShflStringIsValidIn(pOldPath, paParms[2].u.pointer.size, RT_BOOL(pClient->fu32Flags & SHFL_CF_UTF8))
1391 || (cbInfo != sizeof(SHFLFSOBJINFO))
1392 )
1393 {
1394 rc = VERR_INVALID_PARAMETER;
1395 }
1396 else
1397 {
1398 /* Execute the function. */
1399 rc = vbsfSymlink (pClient, root, pNewPath, pOldPath, pInfo);
1400 if (RT_SUCCESS(rc))
1401 {
1402 /* Update parameters.*/
1403 ; /* none */
1404 }
1405 }
1406 }
1407 }
1408 break;
1409
1410 case SHFL_FN_SET_SYMLINKS:
1411 {
1412 pStatFail = pStat = &g_StatSetSymlinks;
1413
1414 pClient->fu32Flags |= SHFL_CF_SYMLINKS;
1415 rc = VINF_SUCCESS;
1416 break;
1417 }
1418
1419 case SHFL_FN_QUERY_MAP_INFO:
1420 {
1421 pStatFail = pStat = &g_StatQueryMapInfo;
1422 Log(("SharedFolders host service: svnCall: SHFL_FN_QUERY_MAP_INFO\n"));
1423
1424 /* Validate input: */
1425 rc = VERR_INVALID_PARAMETER;
1426 ASSERT_GUEST_BREAK(cParms == SHFL_CPARMS_QUERY_MAP_INFO);
1427 ASSERT_GUEST_BREAK(paParms[0].type == VBOX_HGCM_SVC_PARM_32BIT); /* root */
1428 ASSERT_GUEST_BREAK(paParms[1].type == VBOX_HGCM_SVC_PARM_PTR); /* name */
1429 PSHFLSTRING pNameBuf = (PSHFLSTRING)paParms[1].u.pointer.addr;
1430 ASSERT_GUEST_BREAK(ShflStringIsValidOut(pNameBuf, paParms[1].u.pointer.size));
1431 ASSERT_GUEST_BREAK(paParms[2].type == VBOX_HGCM_SVC_PARM_PTR); /* mountPoint */
1432 PSHFLSTRING pMntPtBuf = (PSHFLSTRING)paParms[2].u.pointer.addr;
1433 ASSERT_GUEST_BREAK(ShflStringIsValidOut(pMntPtBuf, paParms[2].u.pointer.size));
1434 ASSERT_GUEST_BREAK(paParms[3].type == VBOX_HGCM_SVC_PARM_64BIT); /* flags */
1435 ASSERT_GUEST_BREAK(!(paParms[3].u.uint64 & ~(SHFL_MIQF_DRIVE_LETTER | SHFL_MIQF_PATH))); /* flags */
1436 ASSERT_GUEST_BREAK(paParms[4].type == VBOX_HGCM_SVC_PARM_32BIT); /* version */
1437
1438 /* Execute the function: */
1439 rc = vbsfMappingsQueryInfo(pClient, paParms[0].u.uint32, pNameBuf, pMntPtBuf,
1440 &paParms[3].u.uint64, &paParms[4].u.uint32);
1441 break;
1442 }
1443
1444 case SHFL_FN_WAIT_FOR_MAPPINGS_CHANGES:
1445 {
1446 pStat = &g_StatWaitForMappingsChanges;
1447 pStatFail = &g_StatWaitForMappingsChangesFail;
1448 Log(("SharedFolders host service: svnCall: SHFL_FN_WAIT_FOR_MAPPINGS_CHANGES\n"));
1449
1450 /* Validate input: */
1451 rc = VERR_INVALID_PARAMETER;
1452 ASSERT_GUEST_BREAK(cParms == SHFL_CPARMS_WAIT_FOR_MAPPINGS_CHANGES);
1453 ASSERT_GUEST_BREAK(paParms[0].type == VBOX_HGCM_SVC_PARM_32BIT); /* uFolderMappingsVersion */
1454
1455 /* Execute the function: */
1456 rc = vbsfMappingsWaitForChanges(pClient, callHandle, paParms, g_pHelpers->pfnIsCallRestored(callHandle));
1457 fAsynchronousProcessing = rc == VINF_HGCM_ASYNC_EXECUTE;
1458 break;
1459 }
1460
1461 case SHFL_FN_CANCEL_MAPPINGS_CHANGES_WAITS:
1462 {
1463 pStatFail = pStat = &g_StatCancelMappingsChangesWait;
1464 Log(("SharedFolders host service: svnCall: SHFL_FN_CANCEL_WAIT_FOR_CHANGES\n"));
1465
1466 /* Validate input: */
1467 rc = VERR_INVALID_PARAMETER;
1468 ASSERT_GUEST_BREAK(cParms == SHFL_CPARMS_CANCEL_MAPPINGS_CHANGES_WAITS);
1469
1470 /* Execute the function: */
1471 rc = vbsfMappingsCancelChangesWaits(pClient);
1472 break;
1473 }
1474
1475 case SHFL_FN_SET_FILE_SIZE:
1476 {
1477 pStat = &g_StatSetFileSize;
1478 pStatFail = &g_StatSetFileSizeFail;
1479 Log(("SharedFolders host service: svcCall: SHFL_FN_SET_FILE_SIZE\n"));
1480
1481 /* Validate input: */
1482 ASSERT_GUEST_STMT_BREAK(cParms == SHFL_CPARMS_SET_FILE_SIZE, rc = VERR_WRONG_PARAMETER_COUNT);
1483 ASSERT_GUEST_STMT_BREAK(paParms[0].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* id32Root */
1484 ASSERT_GUEST_STMT_BREAK(paParms[1].type == VBOX_HGCM_SVC_PARM_64BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* u64Handle */
1485 ASSERT_GUEST_STMT_BREAK(paParms[2].type == VBOX_HGCM_SVC_PARM_64BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* cb64NewSize */
1486
1487 /* Execute the function: */
1488 rc = vbsfSetFileSize(pClient, paParms[0].u.uint32, paParms[1].u.uint64, paParms[2].u.uint64);
1489 break;
1490 }
1491
1492 case SHFL_FN_QUERY_FEATURES:
1493 {
1494 pStat = pStatFail = &g_StatQueryFeatures;
1495
1496 /* Validate input: */
1497 ASSERT_GUEST_STMT_BREAK(cParms == SHFL_CPARMS_QUERY_FEATURES, rc = VERR_WRONG_PARAMETER_COUNT);
1498 ASSERT_GUEST_STMT_BREAK(paParms[0].type == VBOX_HGCM_SVC_PARM_64BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* f64Features */
1499 ASSERT_GUEST_STMT_BREAK(paParms[1].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* u32LastFunction */
1500
1501 /* Execute the function: */
1502 paParms[0].u.uint64 = SHFL_FEATURE_WRITE_UPDATES_OFFSET;
1503 paParms[1].u.uint32 = SHFL_FN_LAST;
1504 rc = VINF_SUCCESS;
1505 break;
1506 }
1507
1508 case SHFL_FN_COPY_FILE:
1509 {
1510 pStat = &g_StatCopyFile;
1511 pStatFail = &g_StatCopyFileFail;
1512
1513 /* Validate input: */
1514 ASSERT_GUEST_STMT_BREAK(cParms == SHFL_CPARMS_COPY_FILE, rc = VERR_WRONG_PARAMETER_COUNT);
1515 ASSERT_GUEST_STMT_BREAK(paParms[0].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* i32RootSrc */
1516 ASSERT_GUEST_STMT_BREAK(paParms[1].type == VBOX_HGCM_SVC_PARM_PTR, rc = VERR_WRONG_PARAMETER_TYPE); /* pStrPathSrc */
1517 PCSHFLSTRING pStrPathSrc = (PCSHFLSTRING)paParms[1].u.pointer.addr;
1518 ASSERT_GUEST_STMT_BREAK(ShflStringIsValidIn(pStrPathSrc, paParms[1].u.pointer.size,
1519 RT_BOOL(pClient->fu32Flags & SHFL_CF_UTF8)),
1520 rc = VERR_INVALID_PARAMETER);
1521 ASSERT_GUEST_STMT_BREAK(paParms[2].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* i32RootDst */
1522 ASSERT_GUEST_STMT_BREAK(paParms[3].type == VBOX_HGCM_SVC_PARM_PTR, rc = VERR_WRONG_PARAMETER_TYPE); /* pStrPathDst */
1523 PCSHFLSTRING pStrPathDst = (PCSHFLSTRING)paParms[3].u.pointer.addr;
1524 ASSERT_GUEST_STMT_BREAK(ShflStringIsValidIn(pStrPathDst, paParms[3].u.pointer.size,
1525 RT_BOOL(pClient->fu32Flags & SHFL_CF_UTF8)),
1526 rc = VERR_INVALID_PARAMETER);
1527 ASSERT_GUEST_STMT_BREAK(paParms[4].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* f32Flags */
1528 ASSERT_GUEST_STMT_BREAK(paParms[4].u.uint32 == 0, rc = VERR_INVALID_FLAGS);
1529
1530 /* Execute the function: */
1531 rc = vbsfCopyFile(pClient, paParms[0].u.uint32, pStrPathSrc, paParms[2].u.uint64, pStrPathDst, paParms[3].u.uint32);
1532 break;
1533 }
1534
1535
1536 case SHFL_FN_COPY_FILE_PART:
1537 {
1538 pStat = &g_StatCopyFilePart;
1539 pStatFail = &g_StatCopyFilePartFail;
1540
1541 /* Validate input: */
1542 ASSERT_GUEST_STMT_BREAK(cParms == SHFL_CPARMS_COPY_FILE_PART, rc = VERR_WRONG_PARAMETER_COUNT);
1543 ASSERT_GUEST_STMT_BREAK(paParms[0].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* i32RootSrc */
1544 ASSERT_GUEST_STMT_BREAK(paParms[1].type == VBOX_HGCM_SVC_PARM_64BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* u64HandleSrc */
1545 ASSERT_GUEST_STMT_BREAK(paParms[2].type == VBOX_HGCM_SVC_PARM_64BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* off64Src */
1546 ASSERT_GUEST_STMT_BREAK((int64_t)paParms[2].u.uint64 >= 0, rc = VERR_NEGATIVE_SEEK);
1547 ASSERT_GUEST_STMT_BREAK(paParms[3].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* i32RootDst */
1548 ASSERT_GUEST_STMT_BREAK(paParms[4].type == VBOX_HGCM_SVC_PARM_64BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* u64HandleDst */
1549 ASSERT_GUEST_STMT_BREAK(paParms[5].type == VBOX_HGCM_SVC_PARM_64BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* off64Dst */
1550 ASSERT_GUEST_STMT_BREAK((int64_t)paParms[5].u.uint64 >= 0, rc = VERR_NEGATIVE_SEEK);
1551 ASSERT_GUEST_STMT_BREAK(paParms[6].type == VBOX_HGCM_SVC_PARM_64BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* cb64ToCopy */
1552 ASSERT_GUEST_STMT_BREAK(paParms[6].u.uint64 < _1E, rc = VERR_OUT_OF_RANGE);
1553 ASSERT_GUEST_STMT_BREAK(paParms[7].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* f32Flags */
1554 ASSERT_GUEST_STMT_BREAK(paParms[7].u.uint32 == 0, rc = VERR_INVALID_FLAGS);
1555
1556 /* Execute the function: */
1557 rc = vbsfCopyFilePart(pClient,
1558 paParms[0].u.uint32, paParms[1].u.uint64, paParms[2].u.uint64,
1559 paParms[3].u.uint32, paParms[4].u.uint64, paParms[5].u.uint64,
1560 &paParms[6].u.uint64, paParms[7].u.uint64);
1561 break;
1562 }
1563
1564 default:
1565 {
1566 pStatFail = pStat = &g_StatUnknown;
1567 rc = VERR_NOT_IMPLEMENTED;
1568 break;
1569 }
1570 }
1571
1572 LogFlow(("SharedFolders host service: svcCall: rc=%Rrc\n", rc));
1573
1574 if ( !fAsynchronousProcessing
1575 || RT_FAILURE (rc))
1576 {
1577 /* Complete the operation if it was unsuccessful or
1578 * it was processed synchronously.
1579 */
1580 g_pHelpers->pfnCallComplete (callHandle, rc);
1581 }
1582
1583#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
1584 /* Statistics: */
1585 uint64_t cTicks;
1586 STAM_GET_TS(cTicks);
1587 cTicks -= tsStart;
1588 if (RT_SUCCESS(rc))
1589 STAM_REL_PROFILE_ADD_PERIOD(pStat, cTicks);
1590 else
1591 STAM_REL_PROFILE_ADD_PERIOD(pStatFail, cTicks);
1592#endif
1593
1594 LogFlow(("\n")); /* Add a new line to differentiate between calls more easily. */
1595}
1596
1597/*
1598 * We differentiate between a function handler for the guest (svcCall) and one
1599 * for the host. The guest is not allowed to add or remove mappings for obvious
1600 * security reasons.
1601 */
1602static DECLCALLBACK(int) svcHostCall (void *, uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM paParms[])
1603{
1604 int rc = VINF_SUCCESS;
1605
1606 Log(("svcHostCall: fn = %d, cParms = %d, pparms = %d\n", u32Function, cParms, paParms));
1607
1608#ifdef DEBUG
1609 uint32_t i;
1610
1611 for (i = 0; i < cParms; i++)
1612 {
1613 /** @todo parameters other than 32 bit */
1614 Log((" pparms[%d]: type %d value %d\n", i, paParms[i].type, paParms[i].u.uint32));
1615 }
1616#endif
1617
1618 switch (u32Function)
1619 {
1620 case SHFL_FN_ADD_MAPPING:
1621 {
1622 Log(("SharedFolders host service: svcCall: SHFL_FN_ADD_MAPPING\n"));
1623 LogRel(("SharedFolders host service: Adding host mapping\n"));
1624 /* Verify parameter count and types. */
1625 if ( (cParms != SHFL_CPARMS_ADD_MAPPING)
1626 )
1627 {
1628 rc = VERR_INVALID_PARAMETER;
1629 }
1630 else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_PTR /* host folder path */
1631 || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR /* map name */
1632 || paParms[2].type != VBOX_HGCM_SVC_PARM_32BIT /* fFlags */
1633 || paParms[3].type != VBOX_HGCM_SVC_PARM_PTR /* auto mount point */
1634 )
1635 {
1636 rc = VERR_INVALID_PARAMETER;
1637 }
1638 else
1639 {
1640 /* Fetch parameters. */
1641 SHFLSTRING *pHostPath = (SHFLSTRING *)paParms[0].u.pointer.addr;
1642 SHFLSTRING *pMapName = (SHFLSTRING *)paParms[1].u.pointer.addr;
1643 uint32_t fFlags = paParms[2].u.uint32;
1644 SHFLSTRING *pAutoMountPoint = (SHFLSTRING *)paParms[3].u.pointer.addr;
1645
1646 /* Verify parameters values. */
1647 if ( !ShflStringIsValidIn(pHostPath, paParms[0].u.pointer.size, false /*fUtf8Not16*/)
1648 || !ShflStringIsValidIn(pMapName, paParms[1].u.pointer.size, false /*fUtf8Not16*/)
1649 || !ShflStringIsValidIn(pAutoMountPoint, paParms[3].u.pointer.size, false /*fUtf8Not16*/)
1650 )
1651 {
1652 rc = VERR_INVALID_PARAMETER;
1653 }
1654 else
1655 {
1656 LogRel((" Host path '%ls', map name '%ls', %s, automount=%s, automntpnt=%s, create_symlinks=%s, missing=%s\n",
1657 pHostPath->String.utf16, pMapName->String.utf16,
1658 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_WRITABLE) ? "writable" : "read-only",
1659 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_AUTOMOUNT) ? "true" : "false",
1660 pAutoMountPoint->String.utf16,
1661 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_CREATE_SYMLINKS) ? "true" : "false",
1662 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_MISSING) ? "true" : "false"));
1663
1664 char *pszHostPath;
1665 rc = RTUtf16ToUtf8(pHostPath->String.ucs2, &pszHostPath);
1666 if (RT_SUCCESS(rc))
1667 {
1668 /* Execute the function. */
1669 rc = vbsfMappingsAdd(pszHostPath, pMapName,
1670 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_WRITABLE),
1671 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_AUTOMOUNT),
1672 pAutoMountPoint,
1673 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_CREATE_SYMLINKS),
1674 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_MISSING),
1675 /* fPlaceholder = */ false);
1676 if (RT_SUCCESS(rc))
1677 {
1678 /* Update parameters.*/
1679 ; /* none */
1680 }
1681 RTStrFree(pszHostPath);
1682 }
1683 }
1684 }
1685 if (RT_FAILURE(rc))
1686 LogRel(("SharedFolders host service: Adding host mapping failed with rc=%Rrc\n", rc));
1687 break;
1688 }
1689
1690 case SHFL_FN_REMOVE_MAPPING:
1691 {
1692 Log(("SharedFolders host service: svcCall: SHFL_FN_REMOVE_MAPPING\n"));
1693 LogRel(("SharedFolders host service: Removing host mapping '%ls'\n",
1694 ((SHFLSTRING *)paParms[0].u.pointer.addr)->String.ucs2));
1695
1696 /* Verify parameter count and types. */
1697 if (cParms != SHFL_CPARMS_REMOVE_MAPPING)
1698 {
1699 rc = VERR_INVALID_PARAMETER;
1700 }
1701 else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_PTR /* folder name */
1702 )
1703 {
1704 rc = VERR_INVALID_PARAMETER;
1705 }
1706 else
1707 {
1708 /* Fetch parameters. */
1709 SHFLSTRING *pString = (SHFLSTRING *)paParms[0].u.pointer.addr;
1710
1711 /* Verify parameters values. */
1712 if (!ShflStringIsValidIn(pString, paParms[0].u.pointer.size, false /*fUtf8Not16*/))
1713 {
1714 rc = VERR_INVALID_PARAMETER;
1715 }
1716 else
1717 {
1718 /* Execute the function. */
1719 rc = vbsfMappingsRemove (pString);
1720
1721 if (RT_SUCCESS(rc))
1722 {
1723 /* Update parameters.*/
1724 ; /* none */
1725 }
1726 }
1727 }
1728 if (RT_FAILURE(rc))
1729 LogRel(("SharedFolders host service: Removing host mapping failed with rc=%Rrc\n", rc));
1730 break;
1731 }
1732
1733 case SHFL_FN_SET_STATUS_LED:
1734 {
1735 Log(("SharedFolders host service: svcCall: SHFL_FN_SET_STATUS_LED\n"));
1736
1737 /* Verify parameter count and types. */
1738 if (cParms != SHFL_CPARMS_SET_STATUS_LED)
1739 {
1740 rc = VERR_INVALID_PARAMETER;
1741 }
1742 else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_PTR /* folder name */
1743 )
1744 {
1745 rc = VERR_INVALID_PARAMETER;
1746 }
1747 else
1748 {
1749 /* Fetch parameters. */
1750 PPDMLED pLed = (PPDMLED)paParms[0].u.pointer.addr;
1751 uint32_t cbLed = paParms[0].u.pointer.size;
1752
1753 /* Verify parameters values. */
1754 if ( (cbLed != sizeof (PDMLED))
1755 )
1756 {
1757 rc = VERR_INVALID_PARAMETER;
1758 }
1759 else
1760 {
1761 /* Execute the function. */
1762 g_pStatusLed = pLed;
1763 rc = VINF_SUCCESS;
1764 }
1765 }
1766 break;
1767 }
1768
1769 default:
1770 rc = VERR_NOT_IMPLEMENTED;
1771 break;
1772 }
1773
1774 LogFlow(("SharedFolders host service: svcHostCall ended with rc=%Rrc\n", rc));
1775 return rc;
1776}
1777
1778extern "C" DECLCALLBACK(DECLEXPORT(int)) VBoxHGCMSvcLoad (VBOXHGCMSVCFNTABLE *ptable)
1779{
1780 int rc = VINF_SUCCESS;
1781
1782 Log(("SharedFolders host service: VBoxHGCMSvcLoad: ptable = %p\n", ptable));
1783
1784 if (!VALID_PTR(ptable))
1785 {
1786 LogRelFunc(("SharedFolders host service: Bad value of ptable (%p)\n", ptable));
1787 rc = VERR_INVALID_PARAMETER;
1788 }
1789 else
1790 {
1791 Log(("SharedFolders host service: VBoxHGCMSvcLoad: ptable->cbSize = %u, ptable->u32Version = 0x%08X\n",
1792 ptable->cbSize, ptable->u32Version));
1793
1794 if ( ptable->cbSize != sizeof (VBOXHGCMSVCFNTABLE)
1795 || ptable->u32Version != VBOX_HGCM_SVC_VERSION)
1796 {
1797 LogRelFunc(("SharedFolders host service: Version mismatch while loading: ptable->cbSize = %u (should be %u), ptable->u32Version = 0x%08X (should be 0x%08X)\n",
1798 ptable->cbSize, sizeof (VBOXHGCMSVCFNTABLE), ptable->u32Version, VBOX_HGCM_SVC_VERSION));
1799 rc = VERR_VERSION_MISMATCH;
1800 }
1801 else
1802 {
1803 g_pHelpers = ptable->pHelpers;
1804
1805 ptable->cbClient = sizeof (SHFLCLIENTDATA);
1806
1807 ptable->pfnUnload = svcUnload;
1808 ptable->pfnConnect = svcConnect;
1809 ptable->pfnDisconnect = svcDisconnect;
1810 ptable->pfnCall = svcCall;
1811 ptable->pfnHostCall = svcHostCall;
1812 ptable->pfnSaveState = svcSaveState;
1813 ptable->pfnLoadState = svcLoadState;
1814 ptable->pfnNotify = NULL;
1815 ptable->pvService = NULL;
1816 }
1817
1818 /* Init handle table */
1819 rc = vbsfInitHandleTable();
1820 AssertRC(rc);
1821
1822 vbsfMappingInit();
1823
1824 /* Finally, register statistics if everything went well: */
1825 if (RT_SUCCESS(rc))
1826 {
1827 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatQueryMappings, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_QUERY_MAPPINGS successes", "/HGCM/VBoxSharedFolders/FnQueryMappings");
1828 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatQueryMappingsFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_QUERY_MAPPINGS failures", "/HGCM/VBoxSharedFolders/FnQueryMappingsFail");
1829 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatQueryMapName, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_QUERY_MAP_NAME", "/HGCM/VBoxSharedFolders/FnQueryMapName");
1830 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatCreate, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_CREATE/CREATE successes", "/HGCM/VBoxSharedFolders/FnCreate");
1831 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatCreateFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_CREATE/CREATE failures", "/HGCM/VBoxSharedFolders/FnCreateFail");
1832 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatLookup, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_CREATE/LOOKUP successes", "/HGCM/VBoxSharedFolders/FnLookup");
1833 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatLookupFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_CREATE/LOOKUP failures", "/HGCM/VBoxSharedFolders/FnLookupFail");
1834 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatClose, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_CLOSE successes", "/HGCM/VBoxSharedFolders/FnClose");
1835 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatCloseFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_CLOSE failures", "/HGCM/VBoxSharedFolders/FnCloseFail");
1836 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatRead, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_READ successes", "/HGCM/VBoxSharedFolders/FnRead");
1837 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatReadFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_READ failures", "/HGCM/VBoxSharedFolders/FnReadFail");
1838 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatWrite, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_WRITE successes", "/HGCM/VBoxSharedFolders/FnWrite");
1839 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatWriteFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_WRITE failures", "/HGCM/VBoxSharedFolders/FnWriteFail");
1840 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatLock, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_LOCK successes", "/HGCM/VBoxSharedFolders/FnLock");
1841 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatLockFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_LOCK failures", "/HGCM/VBoxSharedFolders/FnLockFail");
1842 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatList, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_LIST successes", "/HGCM/VBoxSharedFolders/FnList");
1843 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatListFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_LIST failures", "/HGCM/VBoxSharedFolders/FnListFail");
1844 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatReadLink, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_READLINK successes", "/HGCM/VBoxSharedFolders/FnReadLink");
1845 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatReadLinkFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_READLINK failures", "/HGCM/VBoxSharedFolders/FnReadLinkFail");
1846 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatMapFolderOld, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_MAP_FOLDER_OLD", "/HGCM/VBoxSharedFolders/FnMapFolderOld");
1847 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatMapFolder, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_MAP_FOLDER successes", "/HGCM/VBoxSharedFolders/FnMapFolder");
1848 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatMapFolderFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_MAP_FOLDER failures", "/HGCM/VBoxSharedFolders/FnMapFolderFail");
1849 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatUnmapFolder, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_UNMAP_FOLDER successes", "/HGCM/VBoxSharedFolders/FnUnmapFolder");
1850 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatUnmapFolderFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_UNMAP_FOLDER failures", "/HGCM/VBoxSharedFolders/FnUnmapFolderFail");
1851 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatInformationFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_INFORMATION early failures", "/HGCM/VBoxSharedFolders/FnInformationFail");
1852 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatInformationSetFile, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_INFORMATION/SET/FILE successes", "/HGCM/VBoxSharedFolders/FnInformationSetFile");
1853 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatInformationSetFileFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_INFORMATION/SET/FILE failures", "/HGCM/VBoxSharedFolders/FnInformationSetFileFail");
1854 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatInformationSetSize, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_INFORMATION/SET/SIZE successes", "/HGCM/VBoxSharedFolders/FnInformationSetSize");
1855 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatInformationSetSizeFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_INFORMATION/SET/SIZE failures", "/HGCM/VBoxSharedFolders/FnInformationSetSizeFail");
1856 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatInformationGetFile, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_INFORMATION/GET/FILE successes", "/HGCM/VBoxSharedFolders/FnInformationGetFile");
1857 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatInformationGetFileFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_INFORMATION/GET/FILE failures", "/HGCM/VBoxSharedFolders/FnInformationGetFileFail");
1858 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatInformationGetVolume, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_INFORMATION/GET/VOLUME successes", "/HGCM/VBoxSharedFolders/FnInformationGetVolume");
1859 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatInformationGetVolumeFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_INFORMATION/GET/VOLUME failures", "/HGCM/VBoxSharedFolders/FnInformationGetVolumeFail");
1860 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatRemove, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_REMOVE successes", "/HGCM/VBoxSharedFolders/FnRemove");
1861 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatRemoveFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_REMOVE failures", "/HGCM/VBoxSharedFolders/FnRemoveFail");
1862 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatRename, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_RENAME successes", "/HGCM/VBoxSharedFolders/FnRename");
1863 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatRenameFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_RENAME failures", "/HGCM/VBoxSharedFolders/FnRenameFail");
1864 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatFlush, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_FLUSH successes", "/HGCM/VBoxSharedFolders/FnFlush");
1865 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatFlushFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_FLUSH failures", "/HGCM/VBoxSharedFolders/FnFlushFail");
1866 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatSetUtf8, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_SET_UTF8", "/HGCM/VBoxSharedFolders/FnSetUtf8");
1867 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatSymlink, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_SYMLINK successes", "/HGCM/VBoxSharedFolders/FnSymlink");
1868 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatSymlinkFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_SYMLINK failures", "/HGCM/VBoxSharedFolders/FnSymlinkFail");
1869 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatSetSymlinks, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_SET_SYMLINKS", "/HGCM/VBoxSharedFolders/FnSetSymlink");
1870 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatQueryMapInfo, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_QUERY_MAP_INFO", "/HGCM/VBoxSharedFolders/FnQueryMapInfo");
1871 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatQueryFeatures, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_QUERY_FEATURES", "/HGCM/VBoxSharedFolders/FnQueryFeatures");
1872 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatCopyFile, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_COPY_FILE successes", "/HGCM/VBoxSharedFolders/FnCopyFile");
1873 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatCopyFileFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_COPY_FILE failures", "/HGCM/VBoxSharedFolders/FnCopyFileFail");
1874 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatCopyFilePart, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_COPY_FILE_PART successes", "/HGCM/VBoxSharedFolders/FnCopyFilePart");
1875 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatCopyFilePartFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_COPY_FILE_PART failures", "/HGCM/VBoxSharedFolders/FnCopyFilePartFail");
1876 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatWaitForMappingsChanges, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_WAIT_FOR_MAPPINGS_CHANGES successes", "/HGCM/VBoxSharedFolders/FnWaitForMappingsChanges");
1877 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatWaitForMappingsChangesFail,STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_WAIT_FOR_MAPPINGS_CHANGES failures","/HGCM/VBoxSharedFolders/FnWaitForMappingsChangesFail");
1878 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatCancelMappingsChangesWait, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_CANCEL_MAPPINGS_CHANGES_WAITS", "/HGCM/VBoxSharedFolders/FnCancelMappingsChangesWaits");
1879 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatUnknown, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_???", "/HGCM/VBoxSharedFolders/FnUnknown");
1880 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatMsgStage1, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "Time from VMMDev arrival to worker thread.","/HGCM/VBoxSharedFolders/MsgStage1");
1881 }
1882 }
1883
1884 return rc;
1885}
1886
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