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 | 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 (VBOX_SUCCESS (rc))
|
---|
82 | {
|
---|
83 | rc = data.result;
|
---|
84 | }
|
---|
85 |
|
---|
86 | if (VBOX_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 = (VBOXGCPTR)&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 (VBOX_SUCCESS (rc))
|
---|
143 | {
|
---|
144 | rc = data.callInfo.result;
|
---|
145 | }
|
---|
146 |
|
---|
147 | if (VBOX_SUCCESS (rc))
|
---|
148 | {
|
---|
149 | *pcMappings = data.numberOfMappings.u.value32;
|
---|
150 | }
|
---|
151 |
|
---|
152 | return rc;
|
---|
153 | }
|
---|
154 |
|
---|
155 | DECLVBGL(int) vboxCallQueryMapName (PVBSFCLIENT pClient, SHFLROOT root,
|
---|
156 | int type, SHFLSTRING *pString, uint32_t size)
|
---|
157 | {
|
---|
158 | int rc = VINF_SUCCESS;
|
---|
159 |
|
---|
160 | VBoxSFQueryMapName data;
|
---|
161 |
|
---|
162 | VBOX_INIT_CALL(&data.callInfo, QUERY_MAP_NAME, pClient);
|
---|
163 |
|
---|
164 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
165 | data.root.u.value32 = root;
|
---|
166 |
|
---|
167 | data.type.type = VMMDevHGCMParmType_32bit;
|
---|
168 | data.type.u.value32 = type;
|
---|
169 |
|
---|
170 | data.name.type = VMMDevHGCMParmType_LinAddr;
|
---|
171 | data.name.u.Pointer.size = size;
|
---|
172 | data.name.u.Pointer.u.linearAddr = (VBOXGCPTR)pString;
|
---|
173 |
|
---|
174 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
175 |
|
---|
176 | /* Log(("VBOXSF: VBoxSF::vboxCallQueryMapName: "
|
---|
177 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
178 | */
|
---|
179 | if (VBOX_SUCCESS (rc))
|
---|
180 | {
|
---|
181 | rc = data.callInfo.result;
|
---|
182 | }
|
---|
183 |
|
---|
184 | return rc;
|
---|
185 | }
|
---|
186 |
|
---|
187 | DECLVBGL(int) vboxCallMapFolder(PVBSFCLIENT pClient, PSHFLSTRING szFolderName,
|
---|
188 | PVBSFMAP pMap)
|
---|
189 | {
|
---|
190 | int rc = VINF_SUCCESS;
|
---|
191 |
|
---|
192 | VBoxSFMapFolder data;
|
---|
193 |
|
---|
194 | VBOX_INIT_CALL(&data.callInfo, MAP_FOLDER, pClient);
|
---|
195 |
|
---|
196 | data.path.type = VMMDevHGCMParmType_LinAddr;
|
---|
197 | data.path.u.Pointer.size = ShflStringSizeOfBuffer (szFolderName);
|
---|
198 | data.path.u.Pointer.u.linearAddr = (VBOXGCPTR)szFolderName;
|
---|
199 |
|
---|
200 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
201 | data.root.u.value32 = 0;
|
---|
202 |
|
---|
203 | data.delimiter.type = VMMDevHGCMParmType_32bit;
|
---|
204 | data.delimiter.u.value32 = RTPATH_DELIMITER;
|
---|
205 |
|
---|
206 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
207 |
|
---|
208 | /* Log(("VBOXSF: VBoxSF::vboxCallMapFolder: "
|
---|
209 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
210 | */
|
---|
211 | if (VBOX_SUCCESS (rc))
|
---|
212 | {
|
---|
213 | pMap->root = data.root.u.value32;
|
---|
214 | rc = data.callInfo.result;
|
---|
215 | }
|
---|
216 | return rc;
|
---|
217 | }
|
---|
218 |
|
---|
219 | DECLVBGL(int) vboxCallUnmapFolder(PVBSFCLIENT pClient, PVBSFMAP pMap)
|
---|
220 | {
|
---|
221 | int rc = VINF_SUCCESS;
|
---|
222 |
|
---|
223 | VBoxSFUnmapFolder data;
|
---|
224 |
|
---|
225 | VBOX_INIT_CALL(&data.callInfo, UNMAP_FOLDER, pClient);
|
---|
226 |
|
---|
227 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
228 | data.root.u.value32 = pMap->root;
|
---|
229 |
|
---|
230 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
231 |
|
---|
232 | /* Log(("VBOXSF: VBoxSF::vboxCallUnmapFolder: "
|
---|
233 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
234 | */
|
---|
235 | if (VBOX_SUCCESS (rc))
|
---|
236 | {
|
---|
237 | rc = data.callInfo.result;
|
---|
238 | }
|
---|
239 | return rc;
|
---|
240 | }
|
---|
241 |
|
---|
242 | DECLVBGL(int) vboxCallCreate (PVBSFCLIENT pClient, PVBSFMAP pMap,
|
---|
243 | PSHFLSTRING pParsedPath, PSHFLCREATEPARMS pCreateParms)
|
---|
244 | {
|
---|
245 | /** @todo copy buffers to physical or mapped memory. */
|
---|
246 | int rc = VINF_SUCCESS;
|
---|
247 |
|
---|
248 | VBoxSFCreate data;
|
---|
249 |
|
---|
250 | VBOX_INIT_CALL(&data.callInfo, CREATE, pClient);
|
---|
251 |
|
---|
252 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
253 | data.root.u.value32 = pMap->root;
|
---|
254 |
|
---|
255 | data.path.type = VMMDevHGCMParmType_LinAddr;
|
---|
256 | data.path.u.Pointer.size = ShflStringSizeOfBuffer (pParsedPath);
|
---|
257 | data.path.u.Pointer.u.linearAddr = (VBOXGCPTR)pParsedPath;
|
---|
258 |
|
---|
259 | data.parms.type = VMMDevHGCMParmType_LinAddr;
|
---|
260 | data.parms.u.Pointer.size = sizeof (SHFLCREATEPARMS);
|
---|
261 | data.parms.u.Pointer.u.linearAddr = (VBOXGCPTR)pCreateParms;
|
---|
262 |
|
---|
263 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
264 |
|
---|
265 | /* Log(("VBOXSF: VBoxSF::vboxCallCreate: "
|
---|
266 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
267 | */
|
---|
268 | if (VBOX_SUCCESS (rc))
|
---|
269 | {
|
---|
270 | rc = data.callInfo.result;
|
---|
271 | }
|
---|
272 | return rc;
|
---|
273 | }
|
---|
274 |
|
---|
275 | DECLVBGL(int) vboxCallClose (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE Handle)
|
---|
276 | {
|
---|
277 | int rc = VINF_SUCCESS;
|
---|
278 |
|
---|
279 | VBoxSFClose data;
|
---|
280 |
|
---|
281 | VBOX_INIT_CALL(&data.callInfo, CLOSE, pClient);
|
---|
282 |
|
---|
283 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
284 | data.root.u.value32 = pMap->root;
|
---|
285 |
|
---|
286 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
287 | data.handle.u.value64 = Handle;
|
---|
288 |
|
---|
289 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
290 |
|
---|
291 | /* Log(("VBOXSF: VBoxSF::vboxCallClose: "
|
---|
292 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
293 | */
|
---|
294 | if (VBOX_SUCCESS (rc))
|
---|
295 | {
|
---|
296 | rc = data.callInfo.result;
|
---|
297 | }
|
---|
298 |
|
---|
299 | return rc;
|
---|
300 | }
|
---|
301 |
|
---|
302 | DECLVBGL(int) vboxCallRemove (PVBSFCLIENT pClient, PVBSFMAP pMap,
|
---|
303 | PSHFLSTRING pParsedPath, uint32_t flags)
|
---|
304 | {
|
---|
305 | int rc = VINF_SUCCESS;
|
---|
306 |
|
---|
307 | VBoxSFRemove data;
|
---|
308 |
|
---|
309 | VBOX_INIT_CALL(&data.callInfo, REMOVE, pClient);
|
---|
310 |
|
---|
311 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
312 | data.root.u.value32 = pMap->root;
|
---|
313 |
|
---|
314 | data.path.type = VMMDevHGCMParmType_LinAddr_In;
|
---|
315 | data.path.u.Pointer.size = ShflStringSizeOfBuffer (pParsedPath);
|
---|
316 | data.path.u.Pointer.u.linearAddr = (VBOXGCPTR)pParsedPath;
|
---|
317 |
|
---|
318 | data.flags.type = VMMDevHGCMParmType_32bit;
|
---|
319 | data.flags.u.value32 = flags;
|
---|
320 |
|
---|
321 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
322 |
|
---|
323 | /* Log(("VBOXSF: VBoxSF::vboxCallRemove: "
|
---|
324 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
325 | */
|
---|
326 | if (VBOX_SUCCESS (rc))
|
---|
327 | {
|
---|
328 | rc = data.callInfo.result;
|
---|
329 | }
|
---|
330 |
|
---|
331 | return rc;
|
---|
332 | }
|
---|
333 |
|
---|
334 | DECLVBGL(int) vboxCallRename (PVBSFCLIENT pClient, PVBSFMAP pMap,
|
---|
335 | PSHFLSTRING pSrcPath, PSHFLSTRING pDestPath, uint32_t flags)
|
---|
336 | {
|
---|
337 | int rc = VINF_SUCCESS;
|
---|
338 |
|
---|
339 | VBoxSFRename data;
|
---|
340 |
|
---|
341 | VBOX_INIT_CALL(&data.callInfo, RENAME, pClient);
|
---|
342 |
|
---|
343 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
344 | data.root.u.value32 = pMap->root;
|
---|
345 |
|
---|
346 | data.src.type = VMMDevHGCMParmType_LinAddr_In;
|
---|
347 | data.src.u.Pointer.size = ShflStringSizeOfBuffer (pSrcPath);
|
---|
348 | data.src.u.Pointer.u.linearAddr = (VBOXGCPTR)pSrcPath;
|
---|
349 |
|
---|
350 | data.dest.type = VMMDevHGCMParmType_LinAddr_In;
|
---|
351 | data.dest.u.Pointer.size = ShflStringSizeOfBuffer (pDestPath);
|
---|
352 | data.dest.u.Pointer.u.linearAddr = (VBOXGCPTR)pDestPath;
|
---|
353 |
|
---|
354 | data.flags.type = VMMDevHGCMParmType_32bit;
|
---|
355 | data.flags.u.value32 = flags;
|
---|
356 |
|
---|
357 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
358 |
|
---|
359 | /* Log(("VBOXSF: VBoxSF::vboxCallRename: "
|
---|
360 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
361 | */
|
---|
362 | if (VBOX_SUCCESS (rc))
|
---|
363 | {
|
---|
364 | rc = data.callInfo.result;
|
---|
365 | }
|
---|
366 | return rc;
|
---|
367 | }
|
---|
368 |
|
---|
369 | DECLVBGL(int) vboxCallRead(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
|
---|
370 | uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer)
|
---|
371 | {
|
---|
372 | int rc = VINF_SUCCESS;
|
---|
373 |
|
---|
374 | VBoxSFRead data;
|
---|
375 |
|
---|
376 | VBOX_INIT_CALL(&data.callInfo, READ, pClient);
|
---|
377 |
|
---|
378 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
379 | data.root.u.value32 = pMap->root;
|
---|
380 |
|
---|
381 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
382 | data.handle.u.value64 = hFile;
|
---|
383 | data.offset.type = VMMDevHGCMParmType_64bit;
|
---|
384 | data.offset.u.value64 = offset;
|
---|
385 | data.cb.type = VMMDevHGCMParmType_32bit;
|
---|
386 | data.cb.u.value32 = *pcbBuffer;
|
---|
387 | data.buffer.type = VMMDevHGCMParmType_LinAddr_Out;
|
---|
388 | data.buffer.u.Pointer.size = *pcbBuffer;
|
---|
389 | data.buffer.u.Pointer.u.linearAddr = (VBOXGCPTR)pBuffer;
|
---|
390 |
|
---|
391 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
392 |
|
---|
393 | /* Log(("VBOXSF: VBoxSF::vboxCallRead: "
|
---|
394 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
395 | */
|
---|
396 | if (VBOX_SUCCESS (rc))
|
---|
397 | {
|
---|
398 | rc = data.callInfo.result;
|
---|
399 | *pcbBuffer = data.cb.u.value32;
|
---|
400 | }
|
---|
401 | return rc;
|
---|
402 | }
|
---|
403 |
|
---|
404 | DECLVBGL(int) vboxCallWrite(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
|
---|
405 | uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer)
|
---|
406 | {
|
---|
407 | int rc = VINF_SUCCESS;
|
---|
408 |
|
---|
409 | VBoxSFWrite data;
|
---|
410 |
|
---|
411 | VBOX_INIT_CALL(&data.callInfo, WRITE, pClient);
|
---|
412 |
|
---|
413 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
414 | data.root.u.value32 = pMap->root;
|
---|
415 |
|
---|
416 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
417 | data.handle.u.value64 = hFile;
|
---|
418 | data.offset.type = VMMDevHGCMParmType_64bit;
|
---|
419 | data.offset.u.value64 = offset;
|
---|
420 | data.cb.type = VMMDevHGCMParmType_32bit;
|
---|
421 | data.cb.u.value32 = *pcbBuffer;
|
---|
422 | data.buffer.type = VMMDevHGCMParmType_LinAddr_In;
|
---|
423 | data.buffer.u.Pointer.size = *pcbBuffer;
|
---|
424 | data.buffer.u.Pointer.u.linearAddr = (VBOXGCPTR)pBuffer;
|
---|
425 |
|
---|
426 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
427 |
|
---|
428 | /* Log(("VBOXSF: VBoxSF::vboxCallWrite: "
|
---|
429 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
430 | */
|
---|
431 | if (VBOX_SUCCESS (rc))
|
---|
432 | {
|
---|
433 | rc = data.callInfo.result;
|
---|
434 | *pcbBuffer = data.cb.u.value32;
|
---|
435 | }
|
---|
436 | return rc;
|
---|
437 | }
|
---|
438 |
|
---|
439 | DECLVBGL(int) vboxCallFlush(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile)
|
---|
440 | {
|
---|
441 | int rc = VINF_SUCCESS;
|
---|
442 |
|
---|
443 | VBoxSFFlush data;
|
---|
444 |
|
---|
445 | VBOX_INIT_CALL(&data.callInfo, FLUSH, pClient);
|
---|
446 |
|
---|
447 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
448 | data.root.u.value32 = pMap->root;
|
---|
449 |
|
---|
450 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
451 | data.handle.u.value64 = hFile;
|
---|
452 |
|
---|
453 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
454 |
|
---|
455 | /* Log(("VBOXSF: VBoxSF::vboxCallFlush: "
|
---|
456 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
457 | */
|
---|
458 | if (VBOX_SUCCESS (rc))
|
---|
459 | {
|
---|
460 | rc = data.callInfo.result;
|
---|
461 | }
|
---|
462 | return rc;
|
---|
463 | }
|
---|
464 |
|
---|
465 | DECLVBGL(int) vboxCallDirInfo (
|
---|
466 | PVBSFCLIENT pClient,
|
---|
467 | PVBSFMAP pMap,
|
---|
468 | SHFLHANDLE hFile,
|
---|
469 | PSHFLSTRING ParsedPath,
|
---|
470 | uint32_t flags,
|
---|
471 | uint32_t index,
|
---|
472 | uint32_t *pcbBuffer,
|
---|
473 | PSHFLDIRINFO pBuffer,
|
---|
474 | uint32_t *pcFiles)
|
---|
475 | {
|
---|
476 | int rc = VINF_SUCCESS;
|
---|
477 |
|
---|
478 | VBoxSFList data;
|
---|
479 |
|
---|
480 | VBOX_INIT_CALL(&data.callInfo, LIST, pClient);
|
---|
481 |
|
---|
482 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
483 | data.root.u.value32 = pMap->root;
|
---|
484 |
|
---|
485 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
486 | data.handle.u.value64 = hFile;
|
---|
487 | data.flags.type = VMMDevHGCMParmType_32bit;
|
---|
488 | data.flags.u.value32 = flags;
|
---|
489 | data.cb.type = VMMDevHGCMParmType_32bit;
|
---|
490 | data.cb.u.value32 = *pcbBuffer;
|
---|
491 | data.path.type = VMMDevHGCMParmType_LinAddr_In;
|
---|
492 | data.path.u.Pointer.size =
|
---|
493 | (ParsedPath) ? ShflStringSizeOfBuffer(ParsedPath) : 0;
|
---|
494 | data.path.u.Pointer.u.linearAddr = (VBOXGCPTR) ParsedPath;
|
---|
495 |
|
---|
496 | data.buffer.type = VMMDevHGCMParmType_LinAddr_Out;
|
---|
497 | data.buffer.u.Pointer.size = *pcbBuffer;
|
---|
498 | data.buffer.u.Pointer.u.linearAddr = (VBOXGCPTR)pBuffer;
|
---|
499 |
|
---|
500 | data.resumePoint.type = VMMDevHGCMParmType_32bit;
|
---|
501 | data.resumePoint.u.value32 = index;
|
---|
502 | data.cFiles.type = VMMDevHGCMParmType_32bit;
|
---|
503 | data.cFiles.u.value32 = 0; /* out parameters only */
|
---|
504 |
|
---|
505 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
506 |
|
---|
507 | /* Log(("VBOXSF: VBoxSF::vboxCallDirInfo: "
|
---|
508 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
509 | */
|
---|
510 | if (VBOX_SUCCESS (rc))
|
---|
511 | {
|
---|
512 | rc = data.callInfo.result;
|
---|
513 | }
|
---|
514 | *pcbBuffer = data.cb.u.value32;
|
---|
515 | *pcFiles = data.cFiles.u.value32;
|
---|
516 | return rc;
|
---|
517 | }
|
---|
518 |
|
---|
519 | DECLVBGL(int) vboxCallFSInfo(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
|
---|
520 | uint32_t flags, uint32_t *pcbBuffer, PSHFLDIRINFO pBuffer)
|
---|
521 | {
|
---|
522 | int rc = VINF_SUCCESS;
|
---|
523 |
|
---|
524 | VBoxSFInformation data;
|
---|
525 |
|
---|
526 | VBOX_INIT_CALL(&data.callInfo, INFORMATION, pClient);
|
---|
527 |
|
---|
528 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
529 | data.root.u.value32 = pMap->root;
|
---|
530 |
|
---|
531 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
532 | data.handle.u.value64 = hFile;
|
---|
533 | data.flags.type = VMMDevHGCMParmType_32bit;
|
---|
534 | data.flags.u.value32 = flags;
|
---|
535 | data.cb.type = VMMDevHGCMParmType_32bit;
|
---|
536 | data.cb.u.value32 = *pcbBuffer;
|
---|
537 | data.info.type = VMMDevHGCMParmType_LinAddr;
|
---|
538 | data.info.u.Pointer.size = *pcbBuffer;
|
---|
539 | data.info.u.Pointer.u.linearAddr = (VBOXGCPTR)pBuffer;
|
---|
540 |
|
---|
541 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
542 |
|
---|
543 | /* Log(("VBOXSF: VBoxSF::vboxCallFileInfo: "
|
---|
544 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
545 | */
|
---|
546 | if (VBOX_SUCCESS (rc))
|
---|
547 | {
|
---|
548 | rc = data.callInfo.result;
|
---|
549 | *pcbBuffer = data.cb.u.value32;
|
---|
550 | }
|
---|
551 | return rc;
|
---|
552 | }
|
---|
553 |
|
---|
554 | DECLVBGL(int) vboxCallLock(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
|
---|
555 | uint64_t offset, uint64_t cbSize, uint32_t fLock)
|
---|
556 | {
|
---|
557 | int rc = VINF_SUCCESS;
|
---|
558 |
|
---|
559 | VBoxSFLock data;
|
---|
560 |
|
---|
561 | VBOX_INIT_CALL(&data.callInfo, LOCK, pClient);
|
---|
562 |
|
---|
563 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
564 | data.root.u.value32 = pMap->root;
|
---|
565 |
|
---|
566 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
567 | data.handle.u.value64 = hFile;
|
---|
568 | data.offset.type = VMMDevHGCMParmType_64bit;
|
---|
569 | data.offset.u.value64 = offset;
|
---|
570 | data.length.type = VMMDevHGCMParmType_64bit;
|
---|
571 | data.length.u.value64 = cbSize;
|
---|
572 |
|
---|
573 | data.flags.type = VMMDevHGCMParmType_32bit;
|
---|
574 | data.flags.u.value32 = fLock;
|
---|
575 |
|
---|
576 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
577 |
|
---|
578 | /* Log(("VBOXSF: VBoxSF::vboxCallLock: "
|
---|
579 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
580 | */
|
---|
581 | if (VBOX_SUCCESS (rc))
|
---|
582 | {
|
---|
583 | rc = data.callInfo.result;
|
---|
584 | }
|
---|
585 | return rc;
|
---|
586 | }
|
---|
587 |
|
---|
588 | DECLVBGL(int) vboxCallSetUtf8 (PVBSFCLIENT pClient)
|
---|
589 | {
|
---|
590 | int rc = VINF_SUCCESS;
|
---|
591 |
|
---|
592 | VBoxGuestHGCMCallInfo callInfo;
|
---|
593 |
|
---|
594 | VBOX_INIT_CALL (&callInfo, SET_UTF8, pClient);
|
---|
595 | rc = VbglHGCMCall (pClient->handle, &callInfo, sizeof (callInfo));
|
---|
596 | if (VBOX_SUCCESS (rc))
|
---|
597 | {
|
---|
598 | rc = callInfo.result;
|
---|
599 | }
|
---|
600 | return rc;
|
---|
601 | }
|
---|
602 |
|
---|
603 | #endif /* !VBGL_VBOXGUEST */
|
---|