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