1 | /** @file
|
---|
2 | * Shared Folders: Host service entry points.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License as published by the Free Software Foundation,
|
---|
12 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
13 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
14 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | */
|
---|
16 |
|
---|
17 | #include <VBox/shflsvc.h>
|
---|
18 |
|
---|
19 |
|
---|
20 | #include "shfl.h"
|
---|
21 | #include "mappings.h"
|
---|
22 | #include "shflhandle.h"
|
---|
23 | #include "vbsf.h"
|
---|
24 | #include <iprt/alloc.h>
|
---|
25 | #include <iprt/string.h>
|
---|
26 | #include <iprt/assert.h>
|
---|
27 | #include <VBox/ssm.h>
|
---|
28 | #include <VBox/pdm.h>
|
---|
29 |
|
---|
30 | #define SHFL_SSM_VERSION 2
|
---|
31 |
|
---|
32 |
|
---|
33 | /* Shared Folders Host Service.
|
---|
34 | *
|
---|
35 | * Shared Folders map a host file system to guest logical filesystem.
|
---|
36 | * A mapping represents 'host name'<->'guest name' translation and a root
|
---|
37 | * identifier to be used to access this mapping.
|
---|
38 | * Examples: "C:\WINNT"<->"F:", "C:\WINNT\System32"<->"/mnt/host/system32".
|
---|
39 | *
|
---|
40 | * Therefore, host name and guest name are strings interpreted
|
---|
41 | * only by host service and guest client respectively. Host name is
|
---|
42 | * passed to guest only for informational purpose. Guest may for example
|
---|
43 | * display the string or construct volume label out of the string.
|
---|
44 | *
|
---|
45 | * Root identifiers are unique for whole guest life,
|
---|
46 | * that is until next guest reset/fresh start.
|
---|
47 | * 32 bit value incremented for each new mapping is used.
|
---|
48 | *
|
---|
49 | * Mapping strings are taken from VM XML configuration on VM startup.
|
---|
50 | * The service DLL takes mappings during initialization. There is
|
---|
51 | * also API for changing mappings at runtime.
|
---|
52 | *
|
---|
53 | * Current mappings and root identifiers are saved when VM is saved.
|
---|
54 | *
|
---|
55 | * Guest may use any of these mappings. Full path information
|
---|
56 | * about an object on a mapping consists of the root indentifier and
|
---|
57 | * a full path of object.
|
---|
58 | *
|
---|
59 | * Guest IFS connects to the service and calls SHFL_FN_QUERY_MAP
|
---|
60 | * function which returns current mappings. For guest convenience,
|
---|
61 | * removed mappings also returned with REMOVED flag and new mappings
|
---|
62 | * are marked with NEW flag.
|
---|
63 | *
|
---|
64 | * To access host file system guest just forwards file system calls
|
---|
65 | * to the service, and specifies full paths or handles for objects.
|
---|
66 | *
|
---|
67 | *
|
---|
68 | */
|
---|
69 |
|
---|
70 |
|
---|
71 | PVBOXHGCMSVCHELPERS g_pHelpers;
|
---|
72 | static PPDMLED pStatusLed = NULL;
|
---|
73 |
|
---|
74 | static DECLCALLBACK(int) svcUnload (void)
|
---|
75 | {
|
---|
76 | int rc = VINF_SUCCESS;
|
---|
77 |
|
---|
78 | Log(("svcUnload\n"));
|
---|
79 |
|
---|
80 | return rc;
|
---|
81 | }
|
---|
82 |
|
---|
83 | static DECLCALLBACK(int) svcConnect (uint32_t u32ClientID, void *pvClient)
|
---|
84 | {
|
---|
85 | int rc = VINF_SUCCESS;
|
---|
86 |
|
---|
87 | NOREF(u32ClientID);
|
---|
88 | NOREF(pvClient);
|
---|
89 |
|
---|
90 | Log(("svcConnect: u32ClientID = %d\n", u32ClientID));
|
---|
91 |
|
---|
92 | return rc;
|
---|
93 | }
|
---|
94 |
|
---|
95 | static DECLCALLBACK(int) svcDisconnect (uint32_t u32ClientID, void *pvClient)
|
---|
96 | {
|
---|
97 | int rc = VINF_SUCCESS;
|
---|
98 | SHFLCLIENTDATA *pClient = (SHFLCLIENTDATA *)pvClient;
|
---|
99 |
|
---|
100 | Log(("svcDisconnect: u32ClientID = %d\n", u32ClientID));
|
---|
101 |
|
---|
102 | vbsfDisconnect(pClient);
|
---|
103 | return rc;
|
---|
104 | }
|
---|
105 |
|
---|
106 | /** @note We only save as much state as required to access the shared folder again after restore.
|
---|
107 | * All I/O requests pending at the time of saving will never be completed or result in errors.
|
---|
108 | * (file handles no longer valid etc)
|
---|
109 | * This works as designed at the moment. A full state save would be difficult and not always possible
|
---|
110 | * as the contents of a shared folder might change in between save and restore.
|
---|
111 | */
|
---|
112 | static DECLCALLBACK(int) svcSaveState(uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM)
|
---|
113 | {
|
---|
114 | SHFLCLIENTDATA *pClient = (SHFLCLIENTDATA *)pvClient;
|
---|
115 |
|
---|
116 | Log(("svcSaveState: u32ClientID = %d\n", u32ClientID));
|
---|
117 |
|
---|
118 | int rc = SSMR3PutU32(pSSM, SHFL_SSM_VERSION);
|
---|
119 | AssertRCReturn(rc, rc);
|
---|
120 |
|
---|
121 | rc = SSMR3PutU32(pSSM, SHFL_MAX_MAPPINGS);
|
---|
122 | AssertRCReturn(rc, rc);
|
---|
123 |
|
---|
124 | /* Save client structure length & contents */
|
---|
125 | rc = SSMR3PutU32(pSSM, sizeof(*pClient));
|
---|
126 | AssertRCReturn(rc, rc);
|
---|
127 |
|
---|
128 | rc = SSMR3PutMem(pSSM, pClient, sizeof(*pClient));
|
---|
129 | AssertRCReturn(rc, rc);
|
---|
130 |
|
---|
131 | /* Save all the active mappings. */
|
---|
132 | for (int i=0;i<SHFL_MAX_MAPPINGS;i++)
|
---|
133 | {
|
---|
134 | rc = SSMR3PutU32(pSSM, FolderMapping[i].cMappings);
|
---|
135 | AssertRCReturn(rc, rc);
|
---|
136 |
|
---|
137 | rc = SSMR3PutBool(pSSM, FolderMapping[i].fValid);
|
---|
138 | AssertRCReturn(rc, rc);
|
---|
139 |
|
---|
140 | if (FolderMapping[i].fValid)
|
---|
141 | {
|
---|
142 | uint32_t len;
|
---|
143 |
|
---|
144 | len = ShflStringSizeOfBuffer(FolderMapping[i].pFolderName);
|
---|
145 | rc = SSMR3PutU32(pSSM, len);
|
---|
146 | AssertRCReturn(rc, rc);
|
---|
147 |
|
---|
148 | rc = SSMR3PutMem(pSSM, FolderMapping[i].pFolderName, len);
|
---|
149 | AssertRCReturn(rc, rc);
|
---|
150 |
|
---|
151 | len = ShflStringSizeOfBuffer(FolderMapping[i].pMapName);
|
---|
152 | rc = SSMR3PutU32(pSSM, len);
|
---|
153 | AssertRCReturn(rc, rc);
|
---|
154 |
|
---|
155 | rc = SSMR3PutMem(pSSM, FolderMapping[i].pMapName, len);
|
---|
156 | AssertRCReturn(rc, rc);
|
---|
157 |
|
---|
158 | rc = SSMR3PutBool(pSSM, FolderMapping[i].fHostCaseSensitive);
|
---|
159 | AssertRCReturn(rc, rc);
|
---|
160 |
|
---|
161 | rc = SSMR3PutBool(pSSM, FolderMapping[i].fGuestCaseSensitive);
|
---|
162 | AssertRCReturn(rc, rc);
|
---|
163 | }
|
---|
164 | }
|
---|
165 |
|
---|
166 | return VINF_SUCCESS;
|
---|
167 | }
|
---|
168 |
|
---|
169 | static DECLCALLBACK(int) svcLoadState(uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM)
|
---|
170 | {
|
---|
171 | uint32_t nrMappings;
|
---|
172 | SHFLCLIENTDATA *pClient = (SHFLCLIENTDATA *)pvClient;
|
---|
173 | uint32_t len, version;
|
---|
174 |
|
---|
175 | Log(("svcLoadState: u32ClientID = %d\n", u32ClientID));
|
---|
176 |
|
---|
177 | int rc = SSMR3GetU32(pSSM, &version);
|
---|
178 | AssertRCReturn(rc, rc);
|
---|
179 |
|
---|
180 | if (version != SHFL_SSM_VERSION)
|
---|
181 | return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
|
---|
182 |
|
---|
183 | rc = SSMR3GetU32(pSSM, &nrMappings);
|
---|
184 | AssertRCReturn(rc, rc);
|
---|
185 | if (nrMappings != SHFL_MAX_MAPPINGS)
|
---|
186 | return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
|
---|
187 |
|
---|
188 | /* Restore the client data (flags + path delimiter at the moment) */
|
---|
189 | rc = SSMR3GetU32(pSSM, &len);
|
---|
190 | AssertRCReturn(rc, rc);
|
---|
191 |
|
---|
192 | if (len != sizeof(*pClient))
|
---|
193 | return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
|
---|
194 |
|
---|
195 | rc = SSMR3GetMem(pSSM, pClient, sizeof(*pClient));
|
---|
196 | AssertRCReturn(rc, rc);
|
---|
197 |
|
---|
198 | /* We don't actually (fully) restore the state; we simply check if the current state is as we it expect it to be. */
|
---|
199 | for (int i=0;i<SHFL_MAX_MAPPINGS;i++)
|
---|
200 | {
|
---|
201 | bool fValid;
|
---|
202 |
|
---|
203 | /* restore the folder mapping counter. */
|
---|
204 | rc = SSMR3GetU32(pSSM, &FolderMapping[i].cMappings);
|
---|
205 | AssertRCReturn(rc, rc);
|
---|
206 |
|
---|
207 | rc = SSMR3GetBool(pSSM, &fValid);
|
---|
208 | AssertRCReturn(rc, rc);
|
---|
209 |
|
---|
210 | if (fValid != FolderMapping[i].fValid)
|
---|
211 | return VERR_SSM_UNEXPECTED_DATA;
|
---|
212 |
|
---|
213 | if (FolderMapping[i].fValid)
|
---|
214 | {
|
---|
215 | PSHFLSTRING pName;
|
---|
216 |
|
---|
217 | /* Check the host path name. */
|
---|
218 | rc = SSMR3GetU32(pSSM, &len);
|
---|
219 | AssertRCReturn(rc, rc);
|
---|
220 |
|
---|
221 | if (len != ShflStringSizeOfBuffer(FolderMapping[i].pFolderName))
|
---|
222 | return VERR_SSM_UNEXPECTED_DATA;
|
---|
223 |
|
---|
224 | pName = (PSHFLSTRING)RTMemAlloc(len);
|
---|
225 | Assert(pName);
|
---|
226 | if (pName == NULL)
|
---|
227 | return VERR_NO_MEMORY;
|
---|
228 |
|
---|
229 | rc = SSMR3GetMem(pSSM, pName, len);
|
---|
230 | AssertRCReturn(rc, rc);
|
---|
231 |
|
---|
232 | if (memcmp(FolderMapping[i].pFolderName, pName, len))
|
---|
233 | {
|
---|
234 | RTMemFree(pName);
|
---|
235 | return VERR_SSM_UNEXPECTED_DATA;
|
---|
236 | }
|
---|
237 | RTMemFree(pName);
|
---|
238 |
|
---|
239 | /* Check the map name. */
|
---|
240 | rc = SSMR3GetU32(pSSM, &len);
|
---|
241 | AssertRCReturn(rc, rc);
|
---|
242 |
|
---|
243 | if (len != ShflStringSizeOfBuffer(FolderMapping[i].pMapName))
|
---|
244 | return VERR_SSM_UNEXPECTED_DATA;
|
---|
245 |
|
---|
246 | pName = (PSHFLSTRING)RTMemAlloc(len);
|
---|
247 | Assert(pName);
|
---|
248 | if (pName == NULL)
|
---|
249 | return VERR_NO_MEMORY;
|
---|
250 |
|
---|
251 | rc = SSMR3GetMem(pSSM, pName, len);
|
---|
252 | AssertRCReturn(rc, rc);
|
---|
253 |
|
---|
254 | if (memcmp(FolderMapping[i].pMapName, pName, len))
|
---|
255 | {
|
---|
256 | RTMemFree(pName);
|
---|
257 | return VERR_SSM_UNEXPECTED_DATA;
|
---|
258 | }
|
---|
259 | RTMemFree(pName);
|
---|
260 |
|
---|
261 | bool fCaseSensitive;
|
---|
262 |
|
---|
263 | rc = SSMR3GetBool(pSSM, &fCaseSensitive);
|
---|
264 | AssertRCReturn(rc, rc);
|
---|
265 | if (FolderMapping[i].fHostCaseSensitive != fCaseSensitive)
|
---|
266 | return VERR_SSM_UNEXPECTED_DATA;
|
---|
267 |
|
---|
268 | rc = SSMR3GetBool(pSSM, &FolderMapping[i].fGuestCaseSensitive);
|
---|
269 | AssertRCReturn(rc, rc);
|
---|
270 | }
|
---|
271 | }
|
---|
272 | return VINF_SUCCESS;
|
---|
273 | }
|
---|
274 |
|
---|
275 | static DECLCALLBACK(void) svcCall (VBOXHGCMCALLHANDLE callHandle, uint32_t u32ClientID, void *pvClient, uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM paParms[])
|
---|
276 | {
|
---|
277 | int rc = VINF_SUCCESS;
|
---|
278 |
|
---|
279 | Log(("svcCall: u32ClientID = %d, fn = %d, cParms = %d, pparms = %d\n", u32ClientID, u32Function, cParms, paParms));
|
---|
280 |
|
---|
281 | SHFLCLIENTDATA *pClient = (SHFLCLIENTDATA *)pvClient;
|
---|
282 |
|
---|
283 | uint8_t AsynchronousProcessing = 0;
|
---|
284 |
|
---|
285 | #ifdef DEBUG
|
---|
286 | uint32_t i;
|
---|
287 |
|
---|
288 | for (i = 0; i < cParms; i++)
|
---|
289 | {
|
---|
290 | /** @todo parameters other than 32 bit */
|
---|
291 | Log((" pparms[%d]: type %d value %d\n", i, paParms[i].type, paParms[i].u.uint32));
|
---|
292 | }
|
---|
293 | #endif
|
---|
294 |
|
---|
295 | switch (u32Function)
|
---|
296 | {
|
---|
297 | case SHFL_FN_QUERY_MAPPINGS:
|
---|
298 | {
|
---|
299 | Log(("svcCall: SHFL_FN_QUERY_MAPPINGS\n"));
|
---|
300 |
|
---|
301 | /* Verify parameter count and types. */
|
---|
302 | if (cParms != SHFL_CPARMS_QUERY_MAPPINGS)
|
---|
303 | {
|
---|
304 | rc = VERR_INVALID_PARAMETER;
|
---|
305 | }
|
---|
306 | else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* flags */
|
---|
307 | || paParms[1].type != VBOX_HGCM_SVC_PARM_32BIT /* numberOfMappings */
|
---|
308 | || paParms[2].type != VBOX_HGCM_SVC_PARM_PTR /* mappings */
|
---|
309 | )
|
---|
310 | {
|
---|
311 | rc = VERR_INVALID_PARAMETER;
|
---|
312 | }
|
---|
313 | else
|
---|
314 | {
|
---|
315 | /* Fetch parameters. */
|
---|
316 | uint32_t fu32Flags = paParms[0].u.uint32;
|
---|
317 | uint32_t cMappings = paParms[1].u.uint32;
|
---|
318 | SHFLMAPPING *pMappings = (SHFLMAPPING *)paParms[2].u.pointer.addr;
|
---|
319 | uint32_t cbMappings = paParms[2].u.pointer.size;
|
---|
320 |
|
---|
321 | /* Verify parameters values. */
|
---|
322 | if ( (fu32Flags & ~SHFL_MF_UTF8) != 0
|
---|
323 | || (cbMappings < sizeof (SHFLMAPPING) * cMappings)
|
---|
324 | )
|
---|
325 | {
|
---|
326 | rc = VERR_INVALID_PARAMETER;
|
---|
327 | }
|
---|
328 | else
|
---|
329 | {
|
---|
330 | /* Execute the function. */
|
---|
331 | if (fu32Flags & SHFL_MF_UTF8)
|
---|
332 | {
|
---|
333 | pClient->fu32Flags |= SHFL_CF_UTF8;
|
---|
334 | }
|
---|
335 |
|
---|
336 | rc = vbsfMappingsQuery (pClient, pMappings, &cMappings);
|
---|
337 |
|
---|
338 | if (VBOX_SUCCESS(rc))
|
---|
339 | {
|
---|
340 | /* Update parameters.*/
|
---|
341 | paParms[1].u.uint32 = cMappings;
|
---|
342 | }
|
---|
343 | }
|
---|
344 | }
|
---|
345 |
|
---|
346 |
|
---|
347 | } break;
|
---|
348 |
|
---|
349 | case SHFL_FN_QUERY_MAP_NAME:
|
---|
350 | {
|
---|
351 | Log(("svcCall: SHFL_FN_QUERY_MAP_NAME\n"));
|
---|
352 |
|
---|
353 | /* Verify parameter count and types. */
|
---|
354 | if (cParms != SHFL_CPARMS_QUERY_MAP_NAME)
|
---|
355 | {
|
---|
356 | rc = VERR_INVALID_PARAMETER;
|
---|
357 | }
|
---|
358 | else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
|
---|
359 | || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR /* name */
|
---|
360 | )
|
---|
361 | {
|
---|
362 | rc = VERR_INVALID_PARAMETER;
|
---|
363 | }
|
---|
364 | else
|
---|
365 | {
|
---|
366 | /* Fetch parameters. */
|
---|
367 | SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
|
---|
368 | SHFLSTRING *pString = (SHFLSTRING *)paParms[1].u.pointer.addr;
|
---|
369 | uint32_t cbString = paParms[1].u.pointer.size;
|
---|
370 |
|
---|
371 | /* Verify parameters values. */
|
---|
372 | if ( (cbString < sizeof (SHFLSTRING))
|
---|
373 | || (cbString < pString->u16Size)
|
---|
374 | )
|
---|
375 | {
|
---|
376 | rc = VERR_INVALID_PARAMETER;
|
---|
377 | }
|
---|
378 | else
|
---|
379 | {
|
---|
380 | /* Execute the function. */
|
---|
381 | rc = vbsfMappingsQueryName (pClient, root, pString);
|
---|
382 |
|
---|
383 | if (VBOX_SUCCESS(rc))
|
---|
384 | {
|
---|
385 | /* Update parameters.*/
|
---|
386 | ; /* none */
|
---|
387 | }
|
---|
388 | }
|
---|
389 | }
|
---|
390 |
|
---|
391 | } break;
|
---|
392 |
|
---|
393 | case SHFL_FN_CREATE:
|
---|
394 | {
|
---|
395 | Log(("svcCall: SHFL_FN_CREATE\n"));
|
---|
396 |
|
---|
397 | /* Verify parameter count and types. */
|
---|
398 | if (cParms != SHFL_CPARMS_CREATE)
|
---|
399 | {
|
---|
400 | rc = VERR_INVALID_PARAMETER;
|
---|
401 | }
|
---|
402 | else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
|
---|
403 | || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR /* path */
|
---|
404 | || paParms[2].type != VBOX_HGCM_SVC_PARM_PTR /* parms */
|
---|
405 | )
|
---|
406 | {
|
---|
407 | Log(("Invalid parameters types\n"));
|
---|
408 | rc = VERR_INVALID_PARAMETER;
|
---|
409 | }
|
---|
410 | else
|
---|
411 | {
|
---|
412 | /* Fetch parameters. */
|
---|
413 | SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
|
---|
414 | SHFLSTRING *pPath = (SHFLSTRING *)paParms[1].u.pointer.addr;
|
---|
415 | uint32_t cbPath = paParms[1].u.pointer.size;
|
---|
416 | SHFLCREATEPARMS *pParms = (SHFLCREATEPARMS *)paParms[2].u.pointer.addr;
|
---|
417 | uint32_t cbParms = paParms[2].u.pointer.size;
|
---|
418 |
|
---|
419 | /* Verify parameters values. */
|
---|
420 | if ( (cbPath < sizeof (SHFLSTRING))
|
---|
421 | || (cbParms != sizeof (SHFLCREATEPARMS))
|
---|
422 | )
|
---|
423 | {
|
---|
424 | AssertMsgFailed (("Invalid parameters cbPath or cbParms (%x, %x - expected >=%x, %x)\n",
|
---|
425 | cbPath, cbParms, sizeof(SHFLSTRING), sizeof (SHFLCREATEPARMS)));
|
---|
426 | rc = VERR_INVALID_PARAMETER;
|
---|
427 | }
|
---|
428 | else
|
---|
429 | {
|
---|
430 | /* Execute the function. */
|
---|
431 |
|
---|
432 | rc = vbsfCreate (pClient, root, pPath, cbPath, pParms);
|
---|
433 |
|
---|
434 | if (VBOX_SUCCESS(rc))
|
---|
435 | {
|
---|
436 | /* Update parameters.*/
|
---|
437 | ; /* none */
|
---|
438 | }
|
---|
439 | }
|
---|
440 | }
|
---|
441 | break;
|
---|
442 | }
|
---|
443 |
|
---|
444 | case SHFL_FN_CLOSE:
|
---|
445 | {
|
---|
446 | Log(("svcCall: SHFL_FN_CLOSE\n"));
|
---|
447 |
|
---|
448 | /* Verify parameter count and types. */
|
---|
449 | if (cParms != SHFL_CPARMS_CLOSE)
|
---|
450 | {
|
---|
451 | rc = VERR_INVALID_PARAMETER;
|
---|
452 | }
|
---|
453 | else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
|
---|
454 | || paParms[1].type != VBOX_HGCM_SVC_PARM_64BIT /* handle */
|
---|
455 | )
|
---|
456 | {
|
---|
457 | rc = VERR_INVALID_PARAMETER;
|
---|
458 | }
|
---|
459 | else
|
---|
460 | {
|
---|
461 | /* Fetch parameters. */
|
---|
462 | SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
|
---|
463 | SHFLHANDLE Handle = paParms[1].u.uint64;
|
---|
464 |
|
---|
465 | /* Verify parameters values. */
|
---|
466 | if (Handle == SHFL_HANDLE_ROOT)
|
---|
467 | {
|
---|
468 | rc = VERR_INVALID_PARAMETER;
|
---|
469 | }
|
---|
470 | else
|
---|
471 | if (Handle == SHFL_HANDLE_NIL)
|
---|
472 | {
|
---|
473 | AssertMsgFailed(("Invalid handle!!!!\n"));
|
---|
474 | rc = VERR_INVALID_HANDLE;
|
---|
475 | }
|
---|
476 | else
|
---|
477 | {
|
---|
478 | /* Execute the function. */
|
---|
479 |
|
---|
480 | rc = vbsfClose (pClient, root, Handle);
|
---|
481 |
|
---|
482 | if (VBOX_SUCCESS(rc))
|
---|
483 | {
|
---|
484 | /* Update parameters.*/
|
---|
485 | ; /* none */
|
---|
486 | }
|
---|
487 | }
|
---|
488 | }
|
---|
489 | break;
|
---|
490 |
|
---|
491 | }
|
---|
492 |
|
---|
493 | /** Read object content. */
|
---|
494 | case SHFL_FN_READ:
|
---|
495 | Log(("svcCall: SHFL_FN_READ\n"));
|
---|
496 |
|
---|
497 | /* Verify parameter count and types. */
|
---|
498 | if (cParms != SHFL_CPARMS_READ)
|
---|
499 | {
|
---|
500 | rc = VERR_INVALID_PARAMETER;
|
---|
501 | }
|
---|
502 | else
|
---|
503 | if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
|
---|
504 | || paParms[1].type != VBOX_HGCM_SVC_PARM_64BIT /* handle */
|
---|
505 | || paParms[2].type != VBOX_HGCM_SVC_PARM_64BIT /* offset */
|
---|
506 | || paParms[3].type != VBOX_HGCM_SVC_PARM_32BIT /* count */
|
---|
507 | || paParms[4].type != VBOX_HGCM_SVC_PARM_PTR /* buffer */
|
---|
508 | )
|
---|
509 | {
|
---|
510 | rc = VERR_INVALID_PARAMETER;
|
---|
511 | }
|
---|
512 | else
|
---|
513 | {
|
---|
514 | /* Fetch parameters. */
|
---|
515 | SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
|
---|
516 | SHFLHANDLE Handle = paParms[1].u.uint64;
|
---|
517 | uint64_t offset = paParms[2].u.uint64;
|
---|
518 | uint32_t count = paParms[3].u.uint32;
|
---|
519 | uint8_t *pBuffer = (uint8_t *)paParms[4].u.pointer.addr;
|
---|
520 |
|
---|
521 | /* Verify parameters values. */
|
---|
522 | if (Handle == SHFL_HANDLE_ROOT)
|
---|
523 | {
|
---|
524 | rc = VERR_INVALID_PARAMETER;
|
---|
525 | }
|
---|
526 | else
|
---|
527 | if (Handle == SHFL_HANDLE_NIL)
|
---|
528 | {
|
---|
529 | AssertMsgFailed(("Invalid handle!!!!\n"));
|
---|
530 | rc = VERR_INVALID_HANDLE;
|
---|
531 | }
|
---|
532 | else
|
---|
533 | {
|
---|
534 | /* Execute the function. */
|
---|
535 | if (pStatusLed)
|
---|
536 | {
|
---|
537 | Assert(pStatusLed->u32Magic == PDMLED_MAGIC);
|
---|
538 | pStatusLed->Asserted.s.fReading = pStatusLed->Actual.s.fReading = 1;
|
---|
539 | }
|
---|
540 |
|
---|
541 | rc = vbsfRead (pClient, root, Handle, offset, &count, pBuffer);
|
---|
542 | if (pStatusLed)
|
---|
543 | pStatusLed->Actual.s.fReading = 0;
|
---|
544 |
|
---|
545 | if (VBOX_SUCCESS(rc))
|
---|
546 | {
|
---|
547 | /* Update parameters.*/
|
---|
548 | paParms[3].u.uint32 = count;
|
---|
549 | }
|
---|
550 | else
|
---|
551 | {
|
---|
552 | paParms[3].u.uint32 = 0; /* nothing read */
|
---|
553 | }
|
---|
554 | }
|
---|
555 | }
|
---|
556 | break;
|
---|
557 |
|
---|
558 | /** Write new object content. */
|
---|
559 | case SHFL_FN_WRITE:
|
---|
560 | Log(("svcCall: SHFL_FN_WRITE\n"));
|
---|
561 |
|
---|
562 | /* Verify parameter count and types. */
|
---|
563 | if (cParms != SHFL_CPARMS_WRITE)
|
---|
564 | {
|
---|
565 | rc = VERR_INVALID_PARAMETER;
|
---|
566 | }
|
---|
567 | else
|
---|
568 | if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
|
---|
569 | || paParms[1].type != VBOX_HGCM_SVC_PARM_64BIT /* handle */
|
---|
570 | || paParms[2].type != VBOX_HGCM_SVC_PARM_64BIT /* offset */
|
---|
571 | || paParms[3].type != VBOX_HGCM_SVC_PARM_32BIT /* count */
|
---|
572 | || paParms[4].type != VBOX_HGCM_SVC_PARM_PTR /* buffer */
|
---|
573 | )
|
---|
574 | {
|
---|
575 | rc = VERR_INVALID_PARAMETER;
|
---|
576 | }
|
---|
577 | else
|
---|
578 | {
|
---|
579 | /* Fetch parameters. */
|
---|
580 | SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
|
---|
581 | SHFLHANDLE Handle = paParms[1].u.uint64;
|
---|
582 | uint64_t offset = paParms[2].u.uint64;
|
---|
583 | uint32_t count = paParms[3].u.uint32;
|
---|
584 | uint8_t *pBuffer = (uint8_t *)paParms[4].u.pointer.addr;
|
---|
585 |
|
---|
586 | /* Verify parameters values. */
|
---|
587 | if (Handle == SHFL_HANDLE_ROOT)
|
---|
588 | {
|
---|
589 | rc = VERR_INVALID_PARAMETER;
|
---|
590 | }
|
---|
591 | else
|
---|
592 | if (Handle == SHFL_HANDLE_NIL)
|
---|
593 | {
|
---|
594 | rc = VERR_INVALID_HANDLE;
|
---|
595 | }
|
---|
596 | else
|
---|
597 | {
|
---|
598 | /* Execute the function. */
|
---|
599 | if (pStatusLed)
|
---|
600 | {
|
---|
601 | Assert(pStatusLed->u32Magic == PDMLED_MAGIC);
|
---|
602 | pStatusLed->Asserted.s.fWriting = pStatusLed->Actual.s.fWriting = 1;
|
---|
603 | }
|
---|
604 |
|
---|
605 | rc = vbsfWrite (pClient, root, Handle, offset, &count, pBuffer);
|
---|
606 | if (pStatusLed)
|
---|
607 | pStatusLed->Actual.s.fWriting = 0;
|
---|
608 |
|
---|
609 | if (VBOX_SUCCESS(rc))
|
---|
610 | {
|
---|
611 | /* Update parameters.*/
|
---|
612 | paParms[3].u.uint32 = count;
|
---|
613 | }
|
---|
614 | else
|
---|
615 | {
|
---|
616 | paParms[3].u.uint32 = 0; /* nothing read */
|
---|
617 | }
|
---|
618 | }
|
---|
619 | }
|
---|
620 | break;
|
---|
621 |
|
---|
622 | /** Lock/unlock a range in the object. */
|
---|
623 | case SHFL_FN_LOCK:
|
---|
624 | Log(("svcCall: SHFL_FN_LOCK\n"));
|
---|
625 |
|
---|
626 | /* Verify parameter count and types. */
|
---|
627 | if (cParms != SHFL_CPARMS_LOCK)
|
---|
628 | {
|
---|
629 | rc = VERR_INVALID_PARAMETER;
|
---|
630 | }
|
---|
631 | else
|
---|
632 | if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
|
---|
633 | || paParms[1].type != VBOX_HGCM_SVC_PARM_64BIT /* handle */
|
---|
634 | || paParms[2].type != VBOX_HGCM_SVC_PARM_64BIT /* offset */
|
---|
635 | || paParms[3].type != VBOX_HGCM_SVC_PARM_64BIT /* length */
|
---|
636 | || paParms[4].type != VBOX_HGCM_SVC_PARM_32BIT /* flags */
|
---|
637 | )
|
---|
638 | {
|
---|
639 | rc = VERR_INVALID_PARAMETER;
|
---|
640 | }
|
---|
641 | else
|
---|
642 | {
|
---|
643 | /* Fetch parameters. */
|
---|
644 | SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
|
---|
645 | SHFLHANDLE Handle = paParms[1].u.uint64;
|
---|
646 | uint64_t offset = paParms[2].u.uint64;
|
---|
647 | uint64_t length = paParms[3].u.uint64;
|
---|
648 | uint32_t flags = paParms[4].u.uint32;
|
---|
649 |
|
---|
650 | /* Verify parameters values. */
|
---|
651 | if (Handle == SHFL_HANDLE_ROOT)
|
---|
652 | {
|
---|
653 | rc = VERR_INVALID_PARAMETER;
|
---|
654 | }
|
---|
655 | else
|
---|
656 | if (Handle == SHFL_HANDLE_NIL)
|
---|
657 | {
|
---|
658 | AssertMsgFailed(("Invalid handle!!!!\n"));
|
---|
659 | rc = VERR_INVALID_HANDLE;
|
---|
660 | }
|
---|
661 | else
|
---|
662 | {
|
---|
663 | /* Execute the function. */
|
---|
664 | if ((flags & SHFL_LOCK_MODE_MASK) == SHFL_LOCK_CANCEL)
|
---|
665 | rc = vbsfUnlock(pClient, root, Handle, offset, length, flags);
|
---|
666 | else
|
---|
667 | rc = vbsfLock(pClient, root, Handle, offset, length, flags);
|
---|
668 |
|
---|
669 | if (VBOX_SUCCESS(rc))
|
---|
670 | {
|
---|
671 | /* Update parameters.*/
|
---|
672 | /* none */
|
---|
673 | }
|
---|
674 | }
|
---|
675 | }
|
---|
676 | break;
|
---|
677 |
|
---|
678 | /** List object content. */
|
---|
679 | case SHFL_FN_LIST:
|
---|
680 | {
|
---|
681 | Log(("svcCall: SHFL_FN_LIST\n"));
|
---|
682 |
|
---|
683 | /* Verify parameter count and types. */
|
---|
684 | if (cParms != SHFL_CPARMS_LIST)
|
---|
685 | {
|
---|
686 | rc = VERR_INVALID_PARAMETER;
|
---|
687 | }
|
---|
688 | else
|
---|
689 | if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
|
---|
690 | || paParms[1].type != VBOX_HGCM_SVC_PARM_64BIT /* handle */
|
---|
691 | || paParms[2].type != VBOX_HGCM_SVC_PARM_32BIT /* flags */
|
---|
692 | || paParms[3].type != VBOX_HGCM_SVC_PARM_32BIT /* cb */
|
---|
693 | || paParms[4].type != VBOX_HGCM_SVC_PARM_PTR /* pPath */
|
---|
694 | || paParms[5].type != VBOX_HGCM_SVC_PARM_PTR /* buffer */
|
---|
695 | || paParms[6].type != VBOX_HGCM_SVC_PARM_32BIT /* resumePoint */
|
---|
696 | || paParms[7].type != VBOX_HGCM_SVC_PARM_32BIT /* cFiles (out) */
|
---|
697 | )
|
---|
698 | {
|
---|
699 | rc = VERR_INVALID_PARAMETER;
|
---|
700 | }
|
---|
701 | else
|
---|
702 | {
|
---|
703 | /* Fetch parameters. */
|
---|
704 | SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
|
---|
705 | SHFLHANDLE Handle = paParms[1].u.uint64;
|
---|
706 | uint32_t flags = paParms[2].u.uint32;
|
---|
707 | uint32_t length = paParms[3].u.uint32;
|
---|
708 | SHFLSTRING *pPath = (paParms[4].u.pointer.size == 0) ? 0 : (SHFLSTRING *)paParms[4].u.pointer.addr;
|
---|
709 | uint8_t *pBuffer = (uint8_t *)paParms[5].u.pointer.addr;
|
---|
710 | uint32_t resumePoint = paParms[6].u.uint32;
|
---|
711 | uint32_t cFiles = 0;
|
---|
712 |
|
---|
713 | /* Verify parameters values. */
|
---|
714 | if ( (length < sizeof (SHFLDIRINFO))
|
---|
715 | )
|
---|
716 | {
|
---|
717 | rc = VERR_INVALID_PARAMETER;
|
---|
718 | }
|
---|
719 | else
|
---|
720 | {
|
---|
721 | /* Execute the function. */
|
---|
722 | rc = vbsfDirList (pClient, root, Handle, pPath, flags, &length, pBuffer, &resumePoint, &cFiles);
|
---|
723 |
|
---|
724 | if (VBOX_SUCCESS(rc))
|
---|
725 | {
|
---|
726 | /* Update parameters.*/
|
---|
727 | paParms[3].u.uint32 = length;
|
---|
728 | paParms[6].u.uint32 = resumePoint;
|
---|
729 | paParms[7].u.uint32 = cFiles;
|
---|
730 | }
|
---|
731 | else
|
---|
732 | {
|
---|
733 | paParms[3].u.uint32 = 0; /* nothing read */
|
---|
734 | paParms[6].u.uint32 = 0;
|
---|
735 | paParms[7].u.uint32 = cFiles;
|
---|
736 | }
|
---|
737 | }
|
---|
738 | }
|
---|
739 | break;
|
---|
740 | }
|
---|
741 |
|
---|
742 | /* Legacy interface */
|
---|
743 | case SHFL_FN_MAP_FOLDER_OLD:
|
---|
744 | {
|
---|
745 | Log(("svcCall: SHFL_FN_MAP_FOLDER_OLD\n"));
|
---|
746 |
|
---|
747 | /* Verify parameter count and types. */
|
---|
748 | if (cParms != SHFL_CPARMS_MAP_FOLDER_OLD)
|
---|
749 | {
|
---|
750 | rc = VERR_INVALID_PARAMETER;
|
---|
751 | }
|
---|
752 | else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_PTR /* path */
|
---|
753 | || paParms[1].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
|
---|
754 | || paParms[2].type != VBOX_HGCM_SVC_PARM_32BIT /* delimiter */
|
---|
755 | )
|
---|
756 | {
|
---|
757 | rc = VERR_INVALID_PARAMETER;
|
---|
758 | }
|
---|
759 | else
|
---|
760 | {
|
---|
761 | /* Fetch parameters. */
|
---|
762 | PSHFLSTRING pszMapName = (PSHFLSTRING)paParms[0].u.pointer.addr;
|
---|
763 | SHFLROOT root = (SHFLROOT)paParms[1].u.uint32;
|
---|
764 | RTUCS2 delimiter = (RTUCS2)paParms[2].u.uint32;
|
---|
765 |
|
---|
766 | /* Execute the function. */
|
---|
767 | rc = vbsfMapFolder (pClient, pszMapName, delimiter, false, &root);
|
---|
768 |
|
---|
769 | if (VBOX_SUCCESS(rc))
|
---|
770 | {
|
---|
771 | /* Update parameters.*/
|
---|
772 | paParms[1].u.uint32 = root;
|
---|
773 | }
|
---|
774 | }
|
---|
775 | break;
|
---|
776 | }
|
---|
777 |
|
---|
778 | case SHFL_FN_MAP_FOLDER:
|
---|
779 | {
|
---|
780 | Log(("svcCall: SHFL_FN_MAP_FOLDER\n"));
|
---|
781 |
|
---|
782 | /* Verify parameter count and types. */
|
---|
783 | if (cParms != SHFL_CPARMS_MAP_FOLDER)
|
---|
784 | {
|
---|
785 | rc = VERR_INVALID_PARAMETER;
|
---|
786 | }
|
---|
787 | else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_PTR /* path */
|
---|
788 | || paParms[1].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
|
---|
789 | || paParms[2].type != VBOX_HGCM_SVC_PARM_32BIT /* delimiter */
|
---|
790 | || paParms[3].type != VBOX_HGCM_SVC_PARM_32BIT /* fCaseSensitive */
|
---|
791 | )
|
---|
792 | {
|
---|
793 | rc = VERR_INVALID_PARAMETER;
|
---|
794 | }
|
---|
795 | else
|
---|
796 | {
|
---|
797 | /* Fetch parameters. */
|
---|
798 | PSHFLSTRING pszMapName = (PSHFLSTRING)paParms[0].u.pointer.addr;
|
---|
799 | SHFLROOT root = (SHFLROOT)paParms[1].u.uint32;
|
---|
800 | RTUCS2 delimiter = (RTUCS2)paParms[2].u.uint32;
|
---|
801 | bool fCaseSensitive = !!paParms[3].u.uint32;
|
---|
802 |
|
---|
803 | /* Execute the function. */
|
---|
804 | rc = vbsfMapFolder (pClient, pszMapName, delimiter, fCaseSensitive, &root);
|
---|
805 |
|
---|
806 | if (VBOX_SUCCESS(rc))
|
---|
807 | {
|
---|
808 | /* Update parameters.*/
|
---|
809 | paParms[1].u.uint32 = root;
|
---|
810 | }
|
---|
811 | }
|
---|
812 | break;
|
---|
813 | }
|
---|
814 |
|
---|
815 | case SHFL_FN_UNMAP_FOLDER:
|
---|
816 | {
|
---|
817 | Log(("svcCall: SHFL_FN_UNMAP_FOLDER\n"));
|
---|
818 |
|
---|
819 | /* Verify parameter count and types. */
|
---|
820 | if (cParms != SHFL_CPARMS_UNMAP_FOLDER)
|
---|
821 | {
|
---|
822 | rc = VERR_INVALID_PARAMETER;
|
---|
823 | }
|
---|
824 | else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
|
---|
825 | )
|
---|
826 | {
|
---|
827 | rc = VERR_INVALID_PARAMETER;
|
---|
828 | }
|
---|
829 | else
|
---|
830 | {
|
---|
831 | /* Fetch parameters. */
|
---|
832 | SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
|
---|
833 |
|
---|
834 | /* Execute the function. */
|
---|
835 | rc = vbsfUnmapFolder (pClient, root);
|
---|
836 |
|
---|
837 | if (VBOX_SUCCESS(rc))
|
---|
838 | {
|
---|
839 | /* Update parameters.*/
|
---|
840 | /* nothing */
|
---|
841 | }
|
---|
842 | }
|
---|
843 | break;
|
---|
844 | }
|
---|
845 |
|
---|
846 | /** Query/set object information. */
|
---|
847 | case SHFL_FN_INFORMATION:
|
---|
848 | {
|
---|
849 | Log(("svcCall: SHFL_FN_INFORMATION\n"));
|
---|
850 |
|
---|
851 | /* Verify parameter count and types. */
|
---|
852 | if (cParms != SHFL_CPARMS_INFORMATION)
|
---|
853 | {
|
---|
854 | rc = VERR_INVALID_PARAMETER;
|
---|
855 | }
|
---|
856 | else
|
---|
857 | if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
|
---|
858 | || paParms[1].type != VBOX_HGCM_SVC_PARM_64BIT /* handle */
|
---|
859 | || paParms[2].type != VBOX_HGCM_SVC_PARM_32BIT /* flags */
|
---|
860 | || paParms[3].type != VBOX_HGCM_SVC_PARM_32BIT /* cb */
|
---|
861 | || paParms[4].type != VBOX_HGCM_SVC_PARM_PTR /* buffer */
|
---|
862 | )
|
---|
863 | {
|
---|
864 | rc = VERR_INVALID_PARAMETER;
|
---|
865 | }
|
---|
866 | else
|
---|
867 | {
|
---|
868 | /* Fetch parameters. */
|
---|
869 | SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
|
---|
870 | SHFLHANDLE Handle = paParms[1].u.uint64;
|
---|
871 | uint32_t flags = paParms[2].u.uint32;
|
---|
872 | uint32_t length = paParms[3].u.uint32;
|
---|
873 | uint8_t *pBuffer = (uint8_t *)paParms[4].u.pointer.addr;
|
---|
874 |
|
---|
875 | /* Execute the function. */
|
---|
876 | if (flags & SHFL_INFO_SET)
|
---|
877 | rc = vbsfSetFSInfo (pClient, root, Handle, flags, &length, pBuffer);
|
---|
878 | else /* SHFL_INFO_GET */
|
---|
879 | rc = vbsfQueryFSInfo (pClient, root, Handle, flags, &length, pBuffer);
|
---|
880 |
|
---|
881 | if (VBOX_SUCCESS(rc))
|
---|
882 | {
|
---|
883 | /* Update parameters.*/
|
---|
884 | paParms[3].u.uint32 = length;
|
---|
885 | }
|
---|
886 | else
|
---|
887 | {
|
---|
888 | paParms[3].u.uint32 = 0; /* nothing read */
|
---|
889 | }
|
---|
890 | }
|
---|
891 | break;
|
---|
892 | }
|
---|
893 |
|
---|
894 | /** Remove or rename object */
|
---|
895 | case SHFL_FN_REMOVE:
|
---|
896 | {
|
---|
897 | Log(("svcCall: SHFL_FN_REMOVE\n"));
|
---|
898 |
|
---|
899 | /* Verify parameter count and types. */
|
---|
900 | if (cParms != SHFL_CPARMS_REMOVE)
|
---|
901 | {
|
---|
902 | rc = VERR_INVALID_PARAMETER;
|
---|
903 | }
|
---|
904 | else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
|
---|
905 | || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR /* path */
|
---|
906 | || paParms[2].type != VBOX_HGCM_SVC_PARM_32BIT /* flags */
|
---|
907 | )
|
---|
908 | {
|
---|
909 | rc = VERR_INVALID_PARAMETER;
|
---|
910 | }
|
---|
911 | else
|
---|
912 | {
|
---|
913 | /* Fetch parameters. */
|
---|
914 | SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
|
---|
915 | SHFLSTRING *pPath = (SHFLSTRING *)paParms[1].u.pointer.addr;
|
---|
916 | uint32_t cbPath = paParms[1].u.pointer.size;
|
---|
917 | uint32_t flags = paParms[2].u.uint32;
|
---|
918 |
|
---|
919 | /* Verify parameters values. */
|
---|
920 | if ( (cbPath < sizeof (SHFLSTRING))
|
---|
921 | )
|
---|
922 | {
|
---|
923 | rc = VERR_INVALID_PARAMETER;
|
---|
924 | }
|
---|
925 | else
|
---|
926 | {
|
---|
927 | /* Execute the function. */
|
---|
928 |
|
---|
929 | rc = vbsfRemove (pClient, root, pPath, cbPath, flags);
|
---|
930 | if (VBOX_SUCCESS(rc))
|
---|
931 | {
|
---|
932 | /* Update parameters.*/
|
---|
933 | ; /* none */
|
---|
934 | }
|
---|
935 | }
|
---|
936 | }
|
---|
937 | break;
|
---|
938 | }
|
---|
939 |
|
---|
940 | case SHFL_FN_RENAME:
|
---|
941 | {
|
---|
942 | Log(("svcCall: SHFL_FN_RENAME\n"));
|
---|
943 |
|
---|
944 | /* Verify parameter count and types. */
|
---|
945 | if (cParms != SHFL_CPARMS_RENAME)
|
---|
946 | {
|
---|
947 | rc = VERR_INVALID_PARAMETER;
|
---|
948 | }
|
---|
949 | else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
|
---|
950 | || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR /* src */
|
---|
951 | || paParms[2].type != VBOX_HGCM_SVC_PARM_PTR /* dest */
|
---|
952 | || paParms[3].type != VBOX_HGCM_SVC_PARM_32BIT /* flags */
|
---|
953 | )
|
---|
954 | {
|
---|
955 | rc = VERR_INVALID_PARAMETER;
|
---|
956 | }
|
---|
957 | else
|
---|
958 | {
|
---|
959 | /* Fetch parameters. */
|
---|
960 | SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
|
---|
961 | SHFLSTRING *pSrc = (SHFLSTRING *)paParms[1].u.pointer.addr;
|
---|
962 | uint32_t cbSrc = paParms[1].u.pointer.size;
|
---|
963 | SHFLSTRING *pDest = (SHFLSTRING *)paParms[2].u.pointer.addr;
|
---|
964 | uint32_t cbDest = paParms[2].u.pointer.size;
|
---|
965 | uint32_t flags = paParms[3].u.uint32;
|
---|
966 |
|
---|
967 | /* Verify parameters values. */
|
---|
968 | if ( (cbSrc < sizeof (SHFLSTRING))
|
---|
969 | || (cbDest < sizeof (SHFLSTRING))
|
---|
970 | )
|
---|
971 | {
|
---|
972 | rc = VERR_INVALID_PARAMETER;
|
---|
973 | }
|
---|
974 | else
|
---|
975 | {
|
---|
976 | /* Execute the function. */
|
---|
977 | rc = vbsfRename (pClient, root, pSrc, pDest, flags);
|
---|
978 | if (VBOX_SUCCESS(rc))
|
---|
979 | {
|
---|
980 | /* Update parameters.*/
|
---|
981 | ; /* none */
|
---|
982 | }
|
---|
983 | }
|
---|
984 | }
|
---|
985 | break;
|
---|
986 | }
|
---|
987 |
|
---|
988 | case SHFL_FN_FLUSH:
|
---|
989 | {
|
---|
990 | Log(("svcCall: SHFL_FN_FLUSH\n"));
|
---|
991 |
|
---|
992 | /* Verify parameter count and types. */
|
---|
993 | if (cParms != SHFL_CPARMS_FLUSH)
|
---|
994 | {
|
---|
995 | rc = VERR_INVALID_PARAMETER;
|
---|
996 | }
|
---|
997 | else
|
---|
998 | if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
|
---|
999 | || paParms[1].type != VBOX_HGCM_SVC_PARM_64BIT /* handle */
|
---|
1000 | )
|
---|
1001 | {
|
---|
1002 | rc = VERR_INVALID_PARAMETER;
|
---|
1003 | }
|
---|
1004 | else
|
---|
1005 | {
|
---|
1006 | /* Fetch parameters. */
|
---|
1007 | SHFLROOT root = (SHFLROOT)paParms[0].u.uint32;
|
---|
1008 | SHFLHANDLE Handle = paParms[1].u.uint64;
|
---|
1009 |
|
---|
1010 | /* Verify parameters values. */
|
---|
1011 | if (Handle == SHFL_HANDLE_ROOT)
|
---|
1012 | {
|
---|
1013 | rc = VERR_INVALID_PARAMETER;
|
---|
1014 | }
|
---|
1015 | else
|
---|
1016 | if (Handle == SHFL_HANDLE_NIL)
|
---|
1017 | {
|
---|
1018 | AssertMsgFailed(("Invalid handle!!!!\n"));
|
---|
1019 | rc = VERR_INVALID_HANDLE;
|
---|
1020 | }
|
---|
1021 | else
|
---|
1022 | {
|
---|
1023 | /* Execute the function. */
|
---|
1024 |
|
---|
1025 | rc = vbsfFlush (pClient, root, Handle);
|
---|
1026 |
|
---|
1027 | if (VBOX_SUCCESS(rc))
|
---|
1028 | {
|
---|
1029 | /* Nothing to do */
|
---|
1030 | }
|
---|
1031 | }
|
---|
1032 | }
|
---|
1033 | } break;
|
---|
1034 |
|
---|
1035 | case SHFL_FN_SET_UTF8:
|
---|
1036 | {
|
---|
1037 | pClient->fu32Flags |= SHFL_CF_UTF8;
|
---|
1038 | rc = VINF_SUCCESS;
|
---|
1039 | break;
|
---|
1040 | }
|
---|
1041 |
|
---|
1042 | default:
|
---|
1043 | {
|
---|
1044 | rc = VERR_NOT_IMPLEMENTED;
|
---|
1045 | break;
|
---|
1046 | }
|
---|
1047 | }
|
---|
1048 |
|
---|
1049 | LogFlow(("svcCall: rc = %Vrc\n", rc));
|
---|
1050 |
|
---|
1051 | if (!AsynchronousProcessing)
|
---|
1052 | {
|
---|
1053 | g_pHelpers->pfnCallComplete (callHandle, rc);
|
---|
1054 | }
|
---|
1055 | }
|
---|
1056 |
|
---|
1057 | /*
|
---|
1058 | * We differentiate between a function handler for the guest and one for the host. The guest is not allowed to add or remove mappings for obvious security reasons.
|
---|
1059 | */
|
---|
1060 | static DECLCALLBACK(int) svcHostCall (uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM paParms[])
|
---|
1061 | {
|
---|
1062 | int rc = VINF_SUCCESS;
|
---|
1063 |
|
---|
1064 | Log(("svcHostCall: fn = %d, cParms = %d, pparms = %d\n", u32Function, cParms, paParms));
|
---|
1065 |
|
---|
1066 | #ifdef DEBUG
|
---|
1067 | uint32_t i;
|
---|
1068 |
|
---|
1069 | for (i = 0; i < cParms; i++)
|
---|
1070 | {
|
---|
1071 | /** @todo parameters other than 32 bit */
|
---|
1072 | Log((" pparms[%d]: type %d value %d\n", i, paParms[i].type, paParms[i].u.uint32));
|
---|
1073 | }
|
---|
1074 | #endif
|
---|
1075 |
|
---|
1076 | switch (u32Function)
|
---|
1077 | {
|
---|
1078 | case SHFL_FN_ADD_MAPPING:
|
---|
1079 | {
|
---|
1080 | Log(("svcCall: SHFL_FN_ADD_MAPPING\n"));
|
---|
1081 |
|
---|
1082 | /* Verify parameter count and types. */
|
---|
1083 | if (cParms != SHFL_CPARMS_ADD_MAPPING)
|
---|
1084 | {
|
---|
1085 | rc = VERR_INVALID_PARAMETER;
|
---|
1086 | }
|
---|
1087 | else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_PTR /* host folder name */
|
---|
1088 | || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR /* guest map name */
|
---|
1089 | )
|
---|
1090 | {
|
---|
1091 | rc = VERR_INVALID_PARAMETER;
|
---|
1092 | }
|
---|
1093 | else
|
---|
1094 | {
|
---|
1095 | /* Fetch parameters. */
|
---|
1096 | SHFLSTRING *pFolderName = (SHFLSTRING *)paParms[0].u.pointer.addr;
|
---|
1097 | uint32_t cbStringFolder = paParms[0].u.pointer.size;
|
---|
1098 | SHFLSTRING *pMapName = (SHFLSTRING *)paParms[1].u.pointer.addr;
|
---|
1099 | uint32_t cbStringMap = paParms[1].u.pointer.size;
|
---|
1100 |
|
---|
1101 | /* Verify parameters values. */
|
---|
1102 | if ( (cbStringFolder < sizeof (SHFLSTRING))
|
---|
1103 | || (cbStringFolder < pFolderName->u16Size)
|
---|
1104 | || (cbStringMap < sizeof (SHFLSTRING))
|
---|
1105 | || (cbStringMap < pMapName->u16Size)
|
---|
1106 | )
|
---|
1107 | {
|
---|
1108 | rc = VERR_INVALID_PARAMETER;
|
---|
1109 | }
|
---|
1110 | else
|
---|
1111 | {
|
---|
1112 | /* Execute the function. */
|
---|
1113 | rc = vbsfMappingsAdd (pFolderName, pMapName);
|
---|
1114 |
|
---|
1115 | if (VBOX_SUCCESS(rc))
|
---|
1116 | {
|
---|
1117 | /* Update parameters.*/
|
---|
1118 | ; /* none */
|
---|
1119 | }
|
---|
1120 | }
|
---|
1121 | }
|
---|
1122 | break;
|
---|
1123 | }
|
---|
1124 |
|
---|
1125 | case SHFL_FN_REMOVE_MAPPING:
|
---|
1126 | {
|
---|
1127 | Log(("svcCall: SHFL_FN_REMOVE_MAPPING\n"));
|
---|
1128 |
|
---|
1129 | /* Verify parameter count and types. */
|
---|
1130 | if (cParms != SHFL_CPARMS_REMOVE_MAPPING)
|
---|
1131 | {
|
---|
1132 | rc = VERR_INVALID_PARAMETER;
|
---|
1133 | }
|
---|
1134 | else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_PTR /* folder name */
|
---|
1135 | )
|
---|
1136 | {
|
---|
1137 | rc = VERR_INVALID_PARAMETER;
|
---|
1138 | }
|
---|
1139 | else
|
---|
1140 | {
|
---|
1141 | /* Fetch parameters. */
|
---|
1142 | SHFLSTRING *pString = (SHFLSTRING *)paParms[0].u.pointer.addr;
|
---|
1143 | uint32_t cbString = paParms[0].u.pointer.size;
|
---|
1144 |
|
---|
1145 | /* Verify parameters values. */
|
---|
1146 | if ( (cbString < sizeof (SHFLSTRING))
|
---|
1147 | || (cbString < pString->u16Size)
|
---|
1148 | )
|
---|
1149 | {
|
---|
1150 | rc = VERR_INVALID_PARAMETER;
|
---|
1151 | }
|
---|
1152 | else
|
---|
1153 | {
|
---|
1154 | /* Execute the function. */
|
---|
1155 | rc = vbsfMappingsRemove (pString);
|
---|
1156 |
|
---|
1157 | if (VBOX_SUCCESS(rc))
|
---|
1158 | {
|
---|
1159 | /* Update parameters.*/
|
---|
1160 | ; /* none */
|
---|
1161 | }
|
---|
1162 | }
|
---|
1163 | }
|
---|
1164 | break;
|
---|
1165 | }
|
---|
1166 |
|
---|
1167 | case SHFL_FN_SET_STATUS_LED:
|
---|
1168 | {
|
---|
1169 | Log(("svcCall: SHFL_FN_SET_STATUS_LED\n"));
|
---|
1170 |
|
---|
1171 | /* Verify parameter count and types. */
|
---|
1172 | if (cParms != SHFL_CPARMS_SET_STATUS_LED)
|
---|
1173 | {
|
---|
1174 | rc = VERR_INVALID_PARAMETER;
|
---|
1175 | }
|
---|
1176 | else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_PTR /* folder name */
|
---|
1177 | )
|
---|
1178 | {
|
---|
1179 | rc = VERR_INVALID_PARAMETER;
|
---|
1180 | }
|
---|
1181 | else
|
---|
1182 | {
|
---|
1183 | /* Fetch parameters. */
|
---|
1184 | PPDMLED pLed = (PPDMLED)paParms[0].u.pointer.addr;
|
---|
1185 | uint32_t cbLed = paParms[0].u.pointer.size;
|
---|
1186 |
|
---|
1187 | /* Verify parameters values. */
|
---|
1188 | if ( (cbLed != sizeof (PDMLED))
|
---|
1189 | )
|
---|
1190 | {
|
---|
1191 | rc = VERR_INVALID_PARAMETER;
|
---|
1192 | }
|
---|
1193 | else
|
---|
1194 | {
|
---|
1195 | /* Execute the function. */
|
---|
1196 | pStatusLed = pLed;
|
---|
1197 | rc = VINF_SUCCESS;
|
---|
1198 | }
|
---|
1199 | }
|
---|
1200 | break;
|
---|
1201 | }
|
---|
1202 |
|
---|
1203 | default:
|
---|
1204 | rc = VERR_NOT_IMPLEMENTED;
|
---|
1205 | break;
|
---|
1206 | }
|
---|
1207 |
|
---|
1208 | LogFlow(("svcHostCall: rc = %Vrc\n", rc));
|
---|
1209 | return rc;
|
---|
1210 | }
|
---|
1211 |
|
---|
1212 | extern "C" DECLCALLBACK(DECLEXPORT(int)) VBoxHGCMSvcLoad (VBOXHGCMSVCFNTABLE *ptable)
|
---|
1213 | {
|
---|
1214 | int rc = VINF_SUCCESS;
|
---|
1215 |
|
---|
1216 | Log(("VBoxHGCMSvcLoad: ptable = %p\n", ptable));
|
---|
1217 |
|
---|
1218 | if (!ptable)
|
---|
1219 | {
|
---|
1220 | rc = VERR_INVALID_PARAMETER;
|
---|
1221 | }
|
---|
1222 | else
|
---|
1223 | {
|
---|
1224 | Log(("VBoxHGCMSvcLoad: ptable->cbSize = %d, ptable->u32Version = 0x%08X\n", ptable->cbSize, ptable->u32Version));
|
---|
1225 |
|
---|
1226 | if ( ptable->cbSize != sizeof (VBOXHGCMSVCFNTABLE)
|
---|
1227 | || ptable->u32Version != VBOX_HGCM_SVC_VERSION)
|
---|
1228 | {
|
---|
1229 | rc = VERR_INVALID_PARAMETER;
|
---|
1230 | }
|
---|
1231 | else
|
---|
1232 | {
|
---|
1233 | g_pHelpers = ptable->pHelpers;
|
---|
1234 |
|
---|
1235 | ptable->cbClient = sizeof (SHFLCLIENTDATA);
|
---|
1236 |
|
---|
1237 | ptable->pfnUnload = svcUnload;
|
---|
1238 | ptable->pfnConnect = svcConnect;
|
---|
1239 | ptable->pfnDisconnect = svcDisconnect;
|
---|
1240 | ptable->pfnCall = svcCall;
|
---|
1241 | ptable->pfnHostCall = svcHostCall;
|
---|
1242 | ptable->pfnSaveState = svcSaveState;
|
---|
1243 | ptable->pfnLoadState = svcLoadState;
|
---|
1244 | }
|
---|
1245 |
|
---|
1246 | /* Init handle table */
|
---|
1247 | rc = vbsfInitHandleTable();
|
---|
1248 | AssertRC(rc);
|
---|
1249 | }
|
---|
1250 |
|
---|
1251 | return rc;
|
---|
1252 | }
|
---|