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