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