VirtualBox

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

Last change on this file since 85915 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

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