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