1 | /** @file
|
---|
2 | *
|
---|
3 | * VBoxGuestLib - A support library for VirtualBox guest additions:
|
---|
4 | * Central calls
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | *
|
---|
18 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
19 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
20 | * additional information or have any questions.
|
---|
21 | */
|
---|
22 |
|
---|
23 | /* Entire file is ifdef'ed with !VBGL_VBOXGUEST */
|
---|
24 | #ifndef VBGL_VBOXGUEST
|
---|
25 |
|
---|
26 | #ifdef RT_OS_LINUX
|
---|
27 | # include "VBoxCalls.h"
|
---|
28 | # define DbgPrint AssertMsg2
|
---|
29 | #else
|
---|
30 | # include "VBoxCalls.h"
|
---|
31 | #endif
|
---|
32 | #include <iprt/time.h>
|
---|
33 | #include <iprt/path.h>
|
---|
34 | #include <iprt/string.h>
|
---|
35 |
|
---|
36 | #define SHFL_CPARMS_SET_UTF8 0
|
---|
37 |
|
---|
38 | #define VBOX_INIT_CALL(a, b, c) \
|
---|
39 | (a)->result = VINF_SUCCESS; \
|
---|
40 | (a)->u32ClientID = (c)->ulClientID; \
|
---|
41 | (a)->u32Function = SHFL_FN_##b; \
|
---|
42 | (a)->cParms = SHFL_CPARMS_##b
|
---|
43 |
|
---|
44 | #ifndef RT_OS_WINDOWS
|
---|
45 | # define RtlZeroMemory(a, b) memset (a, 0, b)
|
---|
46 | #endif
|
---|
47 |
|
---|
48 |
|
---|
49 | DECLVBGL(int) vboxInit (void)
|
---|
50 | {
|
---|
51 | int rc = VINF_SUCCESS;
|
---|
52 |
|
---|
53 | rc = VbglInit ();
|
---|
54 | return rc;
|
---|
55 | }
|
---|
56 |
|
---|
57 | DECLVBGL(void) vboxUninit (void)
|
---|
58 | {
|
---|
59 | VbglTerminate ();
|
---|
60 | }
|
---|
61 |
|
---|
62 | DECLVBGL(int) vboxConnect (PVBSFCLIENT pClient)
|
---|
63 | {
|
---|
64 | int rc = VINF_SUCCESS;
|
---|
65 |
|
---|
66 | VBoxGuestHGCMConnectInfo data;
|
---|
67 |
|
---|
68 | RtlZeroMemory (&data, sizeof (VBoxGuestHGCMConnectInfo));
|
---|
69 |
|
---|
70 | pClient->handle = NULL;
|
---|
71 |
|
---|
72 | data.result = VINF_SUCCESS;
|
---|
73 | data.Loc.type = VMMDevHGCMLoc_LocalHost_Existing;
|
---|
74 | strcpy (data.Loc.u.host.achName, "VBoxSharedFolders");
|
---|
75 |
|
---|
76 | rc = VbglHGCMConnect (&pClient->handle, &data);
|
---|
77 |
|
---|
78 | /* Log(("VBOXSF: VBoxSF::vboxConnect: VbglHGCMConnect rc = %#x, result = %#x\n",
|
---|
79 | rc, data.result));
|
---|
80 | */
|
---|
81 | if (RT_SUCCESS (rc))
|
---|
82 | {
|
---|
83 | rc = data.result;
|
---|
84 | }
|
---|
85 |
|
---|
86 | if (RT_SUCCESS (rc))
|
---|
87 | {
|
---|
88 | pClient->ulClientID = data.u32ClientID;
|
---|
89 | }
|
---|
90 | return rc;
|
---|
91 | }
|
---|
92 |
|
---|
93 | DECLVBGL(void) vboxDisconnect (PVBSFCLIENT pClient)
|
---|
94 | {
|
---|
95 | int rc;
|
---|
96 |
|
---|
97 | VBoxGuestHGCMDisconnectInfo data;
|
---|
98 |
|
---|
99 | if (pClient->handle == NULL)
|
---|
100 | return; /* not connected */
|
---|
101 |
|
---|
102 | RtlZeroMemory (&data, sizeof (VBoxGuestHGCMDisconnectInfo));
|
---|
103 |
|
---|
104 | data.result = VINF_SUCCESS;
|
---|
105 | data.u32ClientID = pClient->ulClientID;
|
---|
106 |
|
---|
107 | rc = VbglHGCMDisconnect (pClient->handle, &data);
|
---|
108 | /* Log(("VBOXSF: VBoxSF::vboxDisconnect: "
|
---|
109 | "VbglHGCMDisconnect rc = %#x, result = %#x\n", rc, data.result));
|
---|
110 | */
|
---|
111 | return;
|
---|
112 | }
|
---|
113 |
|
---|
114 | DECLVBGL(int) vboxCallQueryMappings (PVBSFCLIENT pClient, SHFLMAPPING paMappings[],
|
---|
115 | uint32_t *pcMappings)
|
---|
116 | {
|
---|
117 | int rc = VINF_SUCCESS;
|
---|
118 |
|
---|
119 | VBoxSFQueryMappings data;
|
---|
120 |
|
---|
121 | VBOX_INIT_CALL(&data.callInfo, QUERY_MAPPINGS, pClient);
|
---|
122 |
|
---|
123 | data.flags.type = VMMDevHGCMParmType_32bit;
|
---|
124 | data.flags.u.value32 = SHFL_MF_UCS2;
|
---|
125 |
|
---|
126 | data.numberOfMappings.type = VMMDevHGCMParmType_32bit;
|
---|
127 | data.numberOfMappings.u.value32 = *pcMappings;
|
---|
128 |
|
---|
129 | data.mappings.type = VMMDevHGCMParmType_LinAddr;
|
---|
130 | data.mappings.u.Pointer.size = sizeof (SHFLMAPPING) * *pcMappings;
|
---|
131 | data.mappings.u.Pointer.u.linearAddr = (uintptr_t)&paMappings[0];
|
---|
132 |
|
---|
133 | /* Log(("VBOXSF: in ifs difference %d\n",
|
---|
134 | (char *)&data.flags.type - (char *)&data.callInfo.cParms));
|
---|
135 | */
|
---|
136 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
137 |
|
---|
138 | /*
|
---|
139 | Log(("VBOXSF: VBoxSF::vboxCallQueryMappings: "
|
---|
140 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
141 | */
|
---|
142 | if (RT_SUCCESS (rc))
|
---|
143 | {
|
---|
144 | rc = data.callInfo.result;
|
---|
145 | }
|
---|
146 |
|
---|
147 | if (RT_SUCCESS (rc))
|
---|
148 | {
|
---|
149 | *pcMappings = data.numberOfMappings.u.value32;
|
---|
150 | }
|
---|
151 |
|
---|
152 | return rc;
|
---|
153 | }
|
---|
154 |
|
---|
155 | DECLVBGL(int) vboxCallQueryMapName (PVBSFCLIENT pClient, SHFLROOT root, SHFLSTRING *pString, uint32_t size)
|
---|
156 | {
|
---|
157 | int rc = VINF_SUCCESS;
|
---|
158 |
|
---|
159 | VBoxSFQueryMapName data;
|
---|
160 |
|
---|
161 | VBOX_INIT_CALL(&data.callInfo, QUERY_MAP_NAME, pClient);
|
---|
162 |
|
---|
163 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
164 | data.root.u.value32 = root;
|
---|
165 |
|
---|
166 | data.name.type = VMMDevHGCMParmType_LinAddr;
|
---|
167 | data.name.u.Pointer.size = size;
|
---|
168 | data.name.u.Pointer.u.linearAddr = (uintptr_t)pString;
|
---|
169 |
|
---|
170 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
171 |
|
---|
172 | /* Log(("VBOXSF: VBoxSF::vboxCallQueryMapName: "
|
---|
173 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
174 | */
|
---|
175 | if (RT_SUCCESS (rc))
|
---|
176 | {
|
---|
177 | rc = data.callInfo.result;
|
---|
178 | }
|
---|
179 |
|
---|
180 | return rc;
|
---|
181 | }
|
---|
182 |
|
---|
183 | DECLVBGL(int) vboxCallMapFolder(PVBSFCLIENT pClient, PSHFLSTRING szFolderName,
|
---|
184 | PVBSFMAP pMap)
|
---|
185 | {
|
---|
186 | int rc = VINF_SUCCESS;
|
---|
187 |
|
---|
188 | VBoxSFMapFolder data;
|
---|
189 |
|
---|
190 | VBOX_INIT_CALL(&data.callInfo, MAP_FOLDER, pClient);
|
---|
191 |
|
---|
192 | data.path.type = VMMDevHGCMParmType_LinAddr;
|
---|
193 | data.path.u.Pointer.size = ShflStringSizeOfBuffer (szFolderName);
|
---|
194 | data.path.u.Pointer.u.linearAddr = (uintptr_t)szFolderName;
|
---|
195 |
|
---|
196 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
197 | data.root.u.value32 = 0;
|
---|
198 |
|
---|
199 | data.delimiter.type = VMMDevHGCMParmType_32bit;
|
---|
200 | data.delimiter.u.value32 = RTPATH_DELIMITER;
|
---|
201 |
|
---|
202 | data.fCaseSensitive.type = VMMDevHGCMParmType_32bit;
|
---|
203 | #if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
|
---|
204 | data.fCaseSensitive.u.value32 = 0;
|
---|
205 | #else
|
---|
206 | data.fCaseSensitive.u.value32 = 1;
|
---|
207 | #endif
|
---|
208 |
|
---|
209 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
210 |
|
---|
211 | /* Log(("VBOXSF: VBoxSF::vboxCallMapFolder: "
|
---|
212 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
213 | */
|
---|
214 | if (RT_SUCCESS (rc))
|
---|
215 | {
|
---|
216 | pMap->root = data.root.u.value32;
|
---|
217 | rc = data.callInfo.result;
|
---|
218 | }
|
---|
219 | else
|
---|
220 | if (rc == VERR_NOT_IMPLEMENTED)
|
---|
221 | {
|
---|
222 | /* try the legacy interface too; temporary to assure backwards compatibility */
|
---|
223 | VBoxSFMapFolder_Old data;
|
---|
224 |
|
---|
225 | VBOX_INIT_CALL(&data.callInfo, MAP_FOLDER_OLD, pClient);
|
---|
226 |
|
---|
227 | data.path.type = VMMDevHGCMParmType_LinAddr;
|
---|
228 | data.path.u.Pointer.size = ShflStringSizeOfBuffer (szFolderName);
|
---|
229 | data.path.u.Pointer.u.linearAddr = (uintptr_t)szFolderName;
|
---|
230 |
|
---|
231 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
232 | data.root.u.value32 = 0;
|
---|
233 |
|
---|
234 | data.delimiter.type = VMMDevHGCMParmType_32bit;
|
---|
235 | data.delimiter.u.value32 = RTPATH_DELIMITER;
|
---|
236 |
|
---|
237 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
238 |
|
---|
239 | if (RT_SUCCESS (rc))
|
---|
240 | {
|
---|
241 | pMap->root = data.root.u.value32;
|
---|
242 | rc = data.callInfo.result;
|
---|
243 | }
|
---|
244 | }
|
---|
245 | return rc;
|
---|
246 | }
|
---|
247 |
|
---|
248 | DECLVBGL(int) vboxCallUnmapFolder(PVBSFCLIENT pClient, PVBSFMAP pMap)
|
---|
249 | {
|
---|
250 | int rc = VINF_SUCCESS;
|
---|
251 |
|
---|
252 | VBoxSFUnmapFolder data;
|
---|
253 |
|
---|
254 | VBOX_INIT_CALL(&data.callInfo, UNMAP_FOLDER, pClient);
|
---|
255 |
|
---|
256 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
257 | data.root.u.value32 = pMap->root;
|
---|
258 |
|
---|
259 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
260 |
|
---|
261 | /* Log(("VBOXSF: VBoxSF::vboxCallUnmapFolder: "
|
---|
262 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
263 | */
|
---|
264 | if (RT_SUCCESS (rc))
|
---|
265 | {
|
---|
266 | rc = data.callInfo.result;
|
---|
267 | }
|
---|
268 | return rc;
|
---|
269 | }
|
---|
270 |
|
---|
271 | DECLVBGL(int) vboxCallCreate (PVBSFCLIENT pClient, PVBSFMAP pMap,
|
---|
272 | PSHFLSTRING pParsedPath, PSHFLCREATEPARMS pCreateParms)
|
---|
273 | {
|
---|
274 | /** @todo copy buffers to physical or mapped memory. */
|
---|
275 | int rc = VINF_SUCCESS;
|
---|
276 |
|
---|
277 | VBoxSFCreate data;
|
---|
278 |
|
---|
279 | VBOX_INIT_CALL(&data.callInfo, CREATE, pClient);
|
---|
280 |
|
---|
281 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
282 | data.root.u.value32 = pMap->root;
|
---|
283 |
|
---|
284 | data.path.type = VMMDevHGCMParmType_LinAddr;
|
---|
285 | data.path.u.Pointer.size = ShflStringSizeOfBuffer (pParsedPath);
|
---|
286 | data.path.u.Pointer.u.linearAddr = (uintptr_t)pParsedPath;
|
---|
287 |
|
---|
288 | data.parms.type = VMMDevHGCMParmType_LinAddr;
|
---|
289 | data.parms.u.Pointer.size = sizeof (SHFLCREATEPARMS);
|
---|
290 | data.parms.u.Pointer.u.linearAddr = (uintptr_t)pCreateParms;
|
---|
291 |
|
---|
292 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
293 |
|
---|
294 | /* Log(("VBOXSF: VBoxSF::vboxCallCreate: "
|
---|
295 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
296 | */
|
---|
297 | if (RT_SUCCESS (rc))
|
---|
298 | {
|
---|
299 | rc = data.callInfo.result;
|
---|
300 | }
|
---|
301 | return rc;
|
---|
302 | }
|
---|
303 |
|
---|
304 | DECLVBGL(int) vboxCallClose (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE Handle)
|
---|
305 | {
|
---|
306 | int rc = VINF_SUCCESS;
|
---|
307 |
|
---|
308 | VBoxSFClose data;
|
---|
309 |
|
---|
310 | VBOX_INIT_CALL(&data.callInfo, CLOSE, pClient);
|
---|
311 |
|
---|
312 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
313 | data.root.u.value32 = pMap->root;
|
---|
314 |
|
---|
315 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
316 | data.handle.u.value64 = Handle;
|
---|
317 |
|
---|
318 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
319 |
|
---|
320 | /* Log(("VBOXSF: VBoxSF::vboxCallClose: "
|
---|
321 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
322 | */
|
---|
323 | if (RT_SUCCESS (rc))
|
---|
324 | {
|
---|
325 | rc = data.callInfo.result;
|
---|
326 | }
|
---|
327 |
|
---|
328 | return rc;
|
---|
329 | }
|
---|
330 |
|
---|
331 | DECLVBGL(int) vboxCallRemove (PVBSFCLIENT pClient, PVBSFMAP pMap,
|
---|
332 | PSHFLSTRING pParsedPath, uint32_t flags)
|
---|
333 | {
|
---|
334 | int rc = VINF_SUCCESS;
|
---|
335 |
|
---|
336 | VBoxSFRemove data;
|
---|
337 |
|
---|
338 | VBOX_INIT_CALL(&data.callInfo, REMOVE, pClient);
|
---|
339 |
|
---|
340 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
341 | data.root.u.value32 = pMap->root;
|
---|
342 |
|
---|
343 | data.path.type = VMMDevHGCMParmType_LinAddr_In;
|
---|
344 | data.path.u.Pointer.size = ShflStringSizeOfBuffer (pParsedPath);
|
---|
345 | data.path.u.Pointer.u.linearAddr = (uintptr_t)pParsedPath;
|
---|
346 |
|
---|
347 | data.flags.type = VMMDevHGCMParmType_32bit;
|
---|
348 | data.flags.u.value32 = flags;
|
---|
349 |
|
---|
350 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
351 |
|
---|
352 | /* Log(("VBOXSF: VBoxSF::vboxCallRemove: "
|
---|
353 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
354 | */
|
---|
355 | if (RT_SUCCESS (rc))
|
---|
356 | {
|
---|
357 | rc = data.callInfo.result;
|
---|
358 | }
|
---|
359 |
|
---|
360 | return rc;
|
---|
361 | }
|
---|
362 |
|
---|
363 | DECLVBGL(int) vboxCallRename (PVBSFCLIENT pClient, PVBSFMAP pMap,
|
---|
364 | PSHFLSTRING pSrcPath, PSHFLSTRING pDestPath, uint32_t flags)
|
---|
365 | {
|
---|
366 | int rc = VINF_SUCCESS;
|
---|
367 |
|
---|
368 | VBoxSFRename data;
|
---|
369 |
|
---|
370 | VBOX_INIT_CALL(&data.callInfo, RENAME, pClient);
|
---|
371 |
|
---|
372 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
373 | data.root.u.value32 = pMap->root;
|
---|
374 |
|
---|
375 | data.src.type = VMMDevHGCMParmType_LinAddr_In;
|
---|
376 | data.src.u.Pointer.size = ShflStringSizeOfBuffer (pSrcPath);
|
---|
377 | data.src.u.Pointer.u.linearAddr = (uintptr_t)pSrcPath;
|
---|
378 |
|
---|
379 | data.dest.type = VMMDevHGCMParmType_LinAddr_In;
|
---|
380 | data.dest.u.Pointer.size = ShflStringSizeOfBuffer (pDestPath);
|
---|
381 | data.dest.u.Pointer.u.linearAddr = (uintptr_t)pDestPath;
|
---|
382 |
|
---|
383 | data.flags.type = VMMDevHGCMParmType_32bit;
|
---|
384 | data.flags.u.value32 = flags;
|
---|
385 |
|
---|
386 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
387 |
|
---|
388 | /* Log(("VBOXSF: VBoxSF::vboxCallRename: "
|
---|
389 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
390 | */
|
---|
391 | if (RT_SUCCESS (rc))
|
---|
392 | {
|
---|
393 | rc = data.callInfo.result;
|
---|
394 | }
|
---|
395 | return rc;
|
---|
396 | }
|
---|
397 |
|
---|
398 | DECLVBGL(int) vboxCallRead(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
|
---|
399 | uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer, bool fLocked)
|
---|
400 | {
|
---|
401 | int rc = VINF_SUCCESS;
|
---|
402 |
|
---|
403 | VBoxSFRead data;
|
---|
404 |
|
---|
405 | VBOX_INIT_CALL(&data.callInfo, READ, pClient);
|
---|
406 |
|
---|
407 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
408 | data.root.u.value32 = pMap->root;
|
---|
409 |
|
---|
410 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
411 | data.handle.u.value64 = hFile;
|
---|
412 | data.offset.type = VMMDevHGCMParmType_64bit;
|
---|
413 | data.offset.u.value64 = offset;
|
---|
414 | data.cb.type = VMMDevHGCMParmType_32bit;
|
---|
415 | data.cb.u.value32 = *pcbBuffer;
|
---|
416 | data.buffer.type = (fLocked) ? VMMDevHGCMParmType_LinAddr_Locked_Out : VMMDevHGCMParmType_LinAddr_Out;
|
---|
417 | data.buffer.u.Pointer.size = *pcbBuffer;
|
---|
418 | data.buffer.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
|
---|
419 |
|
---|
420 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
421 |
|
---|
422 | /* Log(("VBOXSF: VBoxSF::vboxCallRead: "
|
---|
423 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
424 | */
|
---|
425 | if (RT_SUCCESS (rc))
|
---|
426 | {
|
---|
427 | rc = data.callInfo.result;
|
---|
428 | *pcbBuffer = data.cb.u.value32;
|
---|
429 | }
|
---|
430 | return rc;
|
---|
431 | }
|
---|
432 |
|
---|
433 | DECLVBGL(int) vboxCallWrite(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
|
---|
434 | uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer, bool fLocked)
|
---|
435 | {
|
---|
436 | int rc = VINF_SUCCESS;
|
---|
437 |
|
---|
438 | VBoxSFWrite data;
|
---|
439 |
|
---|
440 | VBOX_INIT_CALL(&data.callInfo, WRITE, pClient);
|
---|
441 |
|
---|
442 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
443 | data.root.u.value32 = pMap->root;
|
---|
444 |
|
---|
445 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
446 | data.handle.u.value64 = hFile;
|
---|
447 | data.offset.type = VMMDevHGCMParmType_64bit;
|
---|
448 | data.offset.u.value64 = offset;
|
---|
449 | data.cb.type = VMMDevHGCMParmType_32bit;
|
---|
450 | data.cb.u.value32 = *pcbBuffer;
|
---|
451 | data.buffer.type = (fLocked) ? VMMDevHGCMParmType_LinAddr_Locked_In : VMMDevHGCMParmType_LinAddr_In;
|
---|
452 | data.buffer.u.Pointer.size = *pcbBuffer;
|
---|
453 | data.buffer.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
|
---|
454 |
|
---|
455 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
456 |
|
---|
457 | /* Log(("VBOXSF: VBoxSF::vboxCallWrite: "
|
---|
458 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
459 | */
|
---|
460 | if (RT_SUCCESS (rc))
|
---|
461 | {
|
---|
462 | rc = data.callInfo.result;
|
---|
463 | *pcbBuffer = data.cb.u.value32;
|
---|
464 | }
|
---|
465 | return rc;
|
---|
466 | }
|
---|
467 |
|
---|
468 | DECLVBGL(int) vboxCallFlush(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile)
|
---|
469 | {
|
---|
470 | int rc = VINF_SUCCESS;
|
---|
471 |
|
---|
472 | VBoxSFFlush data;
|
---|
473 |
|
---|
474 | VBOX_INIT_CALL(&data.callInfo, FLUSH, pClient);
|
---|
475 |
|
---|
476 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
477 | data.root.u.value32 = pMap->root;
|
---|
478 |
|
---|
479 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
480 | data.handle.u.value64 = hFile;
|
---|
481 |
|
---|
482 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
483 |
|
---|
484 | /* Log(("VBOXSF: VBoxSF::vboxCallFlush: "
|
---|
485 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
486 | */
|
---|
487 | if (RT_SUCCESS (rc))
|
---|
488 | {
|
---|
489 | rc = data.callInfo.result;
|
---|
490 | }
|
---|
491 | return rc;
|
---|
492 | }
|
---|
493 |
|
---|
494 | DECLVBGL(int) vboxCallDirInfo (
|
---|
495 | PVBSFCLIENT pClient,
|
---|
496 | PVBSFMAP pMap,
|
---|
497 | SHFLHANDLE hFile,
|
---|
498 | PSHFLSTRING ParsedPath,
|
---|
499 | uint32_t flags,
|
---|
500 | uint32_t index,
|
---|
501 | uint32_t *pcbBuffer,
|
---|
502 | PSHFLDIRINFO pBuffer,
|
---|
503 | uint32_t *pcFiles)
|
---|
504 | {
|
---|
505 | int rc = VINF_SUCCESS;
|
---|
506 |
|
---|
507 | VBoxSFList data;
|
---|
508 |
|
---|
509 | VBOX_INIT_CALL(&data.callInfo, LIST, pClient);
|
---|
510 |
|
---|
511 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
512 | data.root.u.value32 = pMap->root;
|
---|
513 |
|
---|
514 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
515 | data.handle.u.value64 = hFile;
|
---|
516 | data.flags.type = VMMDevHGCMParmType_32bit;
|
---|
517 | data.flags.u.value32 = flags;
|
---|
518 | data.cb.type = VMMDevHGCMParmType_32bit;
|
---|
519 | data.cb.u.value32 = *pcbBuffer;
|
---|
520 | data.path.type = VMMDevHGCMParmType_LinAddr_In;
|
---|
521 | data.path.u.Pointer.size =
|
---|
522 | (ParsedPath) ? ShflStringSizeOfBuffer(ParsedPath) : 0;
|
---|
523 | data.path.u.Pointer.u.linearAddr = (uintptr_t) ParsedPath;
|
---|
524 |
|
---|
525 | data.buffer.type = VMMDevHGCMParmType_LinAddr_Out;
|
---|
526 | data.buffer.u.Pointer.size = *pcbBuffer;
|
---|
527 | data.buffer.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
|
---|
528 |
|
---|
529 | data.resumePoint.type = VMMDevHGCMParmType_32bit;
|
---|
530 | data.resumePoint.u.value32 = index;
|
---|
531 | data.cFiles.type = VMMDevHGCMParmType_32bit;
|
---|
532 | data.cFiles.u.value32 = 0; /* out parameters only */
|
---|
533 |
|
---|
534 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
535 |
|
---|
536 | /* Log(("VBOXSF: VBoxSF::vboxCallDirInfo: "
|
---|
537 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
538 | */
|
---|
539 | if (RT_SUCCESS (rc))
|
---|
540 | {
|
---|
541 | rc = data.callInfo.result;
|
---|
542 | }
|
---|
543 | *pcbBuffer = data.cb.u.value32;
|
---|
544 | *pcFiles = data.cFiles.u.value32;
|
---|
545 | return rc;
|
---|
546 | }
|
---|
547 |
|
---|
548 | DECLVBGL(int) vboxCallFSInfo(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
|
---|
549 | uint32_t flags, uint32_t *pcbBuffer, PSHFLDIRINFO pBuffer)
|
---|
550 | {
|
---|
551 | int rc = VINF_SUCCESS;
|
---|
552 |
|
---|
553 | VBoxSFInformation data;
|
---|
554 |
|
---|
555 | VBOX_INIT_CALL(&data.callInfo, INFORMATION, pClient);
|
---|
556 |
|
---|
557 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
558 | data.root.u.value32 = pMap->root;
|
---|
559 |
|
---|
560 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
561 | data.handle.u.value64 = hFile;
|
---|
562 | data.flags.type = VMMDevHGCMParmType_32bit;
|
---|
563 | data.flags.u.value32 = flags;
|
---|
564 | data.cb.type = VMMDevHGCMParmType_32bit;
|
---|
565 | data.cb.u.value32 = *pcbBuffer;
|
---|
566 | data.info.type = VMMDevHGCMParmType_LinAddr;
|
---|
567 | data.info.u.Pointer.size = *pcbBuffer;
|
---|
568 | data.info.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
|
---|
569 |
|
---|
570 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
571 |
|
---|
572 | /* Log(("VBOXSF: VBoxSF::vboxCallFileInfo: "
|
---|
573 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
574 | */
|
---|
575 | if (RT_SUCCESS (rc))
|
---|
576 | {
|
---|
577 | rc = data.callInfo.result;
|
---|
578 | *pcbBuffer = data.cb.u.value32;
|
---|
579 | }
|
---|
580 | return rc;
|
---|
581 | }
|
---|
582 |
|
---|
583 | DECLVBGL(int) vboxCallLock(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
|
---|
584 | uint64_t offset, uint64_t cbSize, uint32_t fLock)
|
---|
585 | {
|
---|
586 | int rc = VINF_SUCCESS;
|
---|
587 |
|
---|
588 | VBoxSFLock data;
|
---|
589 |
|
---|
590 | VBOX_INIT_CALL(&data.callInfo, LOCK, pClient);
|
---|
591 |
|
---|
592 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
593 | data.root.u.value32 = pMap->root;
|
---|
594 |
|
---|
595 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
596 | data.handle.u.value64 = hFile;
|
---|
597 | data.offset.type = VMMDevHGCMParmType_64bit;
|
---|
598 | data.offset.u.value64 = offset;
|
---|
599 | data.length.type = VMMDevHGCMParmType_64bit;
|
---|
600 | data.length.u.value64 = cbSize;
|
---|
601 |
|
---|
602 | data.flags.type = VMMDevHGCMParmType_32bit;
|
---|
603 | data.flags.u.value32 = fLock;
|
---|
604 |
|
---|
605 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
606 |
|
---|
607 | /* Log(("VBOXSF: VBoxSF::vboxCallLock: "
|
---|
608 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
609 | */
|
---|
610 | if (RT_SUCCESS (rc))
|
---|
611 | {
|
---|
612 | rc = data.callInfo.result;
|
---|
613 | }
|
---|
614 | return rc;
|
---|
615 | }
|
---|
616 |
|
---|
617 | DECLVBGL(int) vboxCallSetUtf8 (PVBSFCLIENT pClient)
|
---|
618 | {
|
---|
619 | int rc = VINF_SUCCESS;
|
---|
620 |
|
---|
621 | VBoxGuestHGCMCallInfo callInfo;
|
---|
622 |
|
---|
623 | VBOX_INIT_CALL (&callInfo, SET_UTF8, pClient);
|
---|
624 | rc = VbglHGCMCall (pClient->handle, &callInfo, sizeof (callInfo));
|
---|
625 | if (RT_SUCCESS (rc))
|
---|
626 | {
|
---|
627 | rc = callInfo.result;
|
---|
628 | }
|
---|
629 | return rc;
|
---|
630 | }
|
---|
631 |
|
---|
632 | #endif /* !VBGL_VBOXGUEST */
|
---|