1 | /* $Id: VBoxGuestR3LibGuestCtrl.cpp 49349 2013-10-31 16:40:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, guest control.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2013 Oracle Corporation
|
---|
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 |
|
---|
27 |
|
---|
28 | /*******************************************************************************
|
---|
29 | * Header Files *
|
---|
30 | *******************************************************************************/
|
---|
31 | #include <iprt/string.h>
|
---|
32 | #include <iprt/mem.h>
|
---|
33 | #include <iprt/assert.h>
|
---|
34 | #include <iprt/cpp/autores.h>
|
---|
35 | #include <iprt/stdarg.h>
|
---|
36 | #include <VBox/log.h>
|
---|
37 | #include <VBox/HostServices/GuestControlSvc.h>
|
---|
38 |
|
---|
39 | #include "VBGLR3Internal.h"
|
---|
40 |
|
---|
41 |
|
---|
42 | /*******************************************************************************
|
---|
43 | * Structures and Typedefs *
|
---|
44 | *******************************************************************************/
|
---|
45 |
|
---|
46 | using namespace guestControl;
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * Connects to the guest control service.
|
---|
50 | *
|
---|
51 | * @returns VBox status code
|
---|
52 | * @param puClientId Where to put The client ID on success. The client ID
|
---|
53 | * must be passed to all the other calls to the service.
|
---|
54 | */
|
---|
55 | VBGLR3DECL(int) VbglR3GuestCtrlConnect(uint32_t *puClientId)
|
---|
56 | {
|
---|
57 | VBoxGuestHGCMConnectInfo Info;
|
---|
58 | Info.result = VERR_WRONG_ORDER;
|
---|
59 | Info.Loc.type = VMMDevHGCMLoc_LocalHost_Existing;
|
---|
60 | RT_ZERO(Info.Loc.u);
|
---|
61 | strcpy(Info.Loc.u.host.achName, "VBoxGuestControlSvc");
|
---|
62 | Info.u32ClientID = UINT32_MAX; /* try make valgrind shut up. */
|
---|
63 |
|
---|
64 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CONNECT, &Info, sizeof(Info));
|
---|
65 | if (RT_SUCCESS(rc))
|
---|
66 | {
|
---|
67 | rc = Info.result;
|
---|
68 | if (RT_SUCCESS(rc))
|
---|
69 | *puClientId = Info.u32ClientID;
|
---|
70 | }
|
---|
71 | return rc;
|
---|
72 | }
|
---|
73 |
|
---|
74 |
|
---|
75 | /**
|
---|
76 | * Disconnect from the guest control service.
|
---|
77 | *
|
---|
78 | * @returns VBox status code.
|
---|
79 | * @param uClientId The client ID returned by VbglR3GuestCtrlConnect().
|
---|
80 | */
|
---|
81 | VBGLR3DECL(int) VbglR3GuestCtrlDisconnect(uint32_t uClientId)
|
---|
82 | {
|
---|
83 | VBoxGuestHGCMDisconnectInfo Info;
|
---|
84 | Info.result = VERR_WRONG_ORDER;
|
---|
85 | Info.u32ClientID = uClientId;
|
---|
86 |
|
---|
87 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_DISCONNECT, &Info, sizeof(Info));
|
---|
88 | if (RT_SUCCESS(rc))
|
---|
89 | rc = Info.result;
|
---|
90 | return rc;
|
---|
91 | }
|
---|
92 |
|
---|
93 |
|
---|
94 | /**
|
---|
95 | * Waits until a new host message arrives.
|
---|
96 | * This will block until a message becomes available.
|
---|
97 | *
|
---|
98 | * @returns VBox status code.
|
---|
99 | * @param uClientId The client ID returned by VbglR3GuestCtrlConnect().
|
---|
100 | * @param puMsg Where to store the message id.
|
---|
101 | * @param puNumParms Where to store the number of parameters which will be received
|
---|
102 | * in a second call to the host.
|
---|
103 | */
|
---|
104 | VBGLR3DECL(int) VbglR3GuestCtrlMsgWaitFor(uint32_t uClientId, uint32_t *puMsg, uint32_t *puNumParms)
|
---|
105 | {
|
---|
106 | AssertPtrReturn(puMsg, VERR_INVALID_POINTER);
|
---|
107 | AssertPtrReturn(puNumParms, VERR_INVALID_POINTER);
|
---|
108 |
|
---|
109 | HGCMMsgCmdWaitFor Msg;
|
---|
110 |
|
---|
111 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
112 | Msg.hdr.u32ClientID = uClientId;
|
---|
113 | Msg.hdr.u32Function = GUEST_MSG_WAIT; /* Tell the host we want our next command. */
|
---|
114 | Msg.hdr.cParms = 2; /* Just peek for the next message! */
|
---|
115 |
|
---|
116 | VbglHGCMParmUInt32Set(&Msg.msg, 0);
|
---|
117 | VbglHGCMParmUInt32Set(&Msg.num_parms, 0);
|
---|
118 |
|
---|
119 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
120 | if (RT_SUCCESS(rc))
|
---|
121 | {
|
---|
122 | rc = VbglHGCMParmUInt32Get(&Msg.msg, puMsg);
|
---|
123 | if (RT_SUCCESS(rc))
|
---|
124 | rc = VbglHGCMParmUInt32Get(&Msg.num_parms, puNumParms);
|
---|
125 | if (RT_SUCCESS(rc))
|
---|
126 | rc = Msg.hdr.result;
|
---|
127 | /* Ok, so now we know what message type and how much parameters there are. */
|
---|
128 | }
|
---|
129 | return rc;
|
---|
130 | }
|
---|
131 |
|
---|
132 |
|
---|
133 | /**
|
---|
134 | * Asks the host guest control service to set a command filter to this
|
---|
135 | * client so that it only will receive certain commands in the future.
|
---|
136 | * The filter(s) are a bitmask for the context IDs, served from the host.
|
---|
137 | *
|
---|
138 | * @return IPRT status code.
|
---|
139 | * @param uClientId The client ID returned by VbglR3GuestCtrlConnect().
|
---|
140 | * @param uValue The value to filter messages for.
|
---|
141 | * @param uMaskAdd Filter mask to add.
|
---|
142 | * @param uMaskRemove Filter mask to remove.
|
---|
143 | */
|
---|
144 | VBGLR3DECL(int) VbglR3GuestCtrlMsgFilterSet(uint32_t uClientId, uint32_t uValue,
|
---|
145 | uint32_t uMaskAdd, uint32_t uMaskRemove)
|
---|
146 | {
|
---|
147 | HGCMMsgCmdFilterSet Msg;
|
---|
148 |
|
---|
149 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
150 | Msg.hdr.u32ClientID = uClientId;
|
---|
151 | Msg.hdr.u32Function = GUEST_MSG_FILTER_SET; /* Tell the host we want to set a filter. */
|
---|
152 | Msg.hdr.cParms = 4;
|
---|
153 |
|
---|
154 | VbglHGCMParmUInt32Set(&Msg.value, uValue);
|
---|
155 | VbglHGCMParmUInt32Set(&Msg.mask_add, uMaskAdd);
|
---|
156 | VbglHGCMParmUInt32Set(&Msg.mask_remove, uMaskRemove);
|
---|
157 | VbglHGCMParmUInt32Set(&Msg.flags, 0 /* Flags, unused */);
|
---|
158 |
|
---|
159 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
160 | if (RT_SUCCESS(rc))
|
---|
161 | rc = Msg.hdr.result;
|
---|
162 | return rc;
|
---|
163 | }
|
---|
164 |
|
---|
165 |
|
---|
166 | /**
|
---|
167 | * Disables a previously set message filter.
|
---|
168 | *
|
---|
169 | * @return IPRT status code.
|
---|
170 | * @param uClientId The client ID returned by VbglR3GuestCtrlConnect().
|
---|
171 | */
|
---|
172 | VBGLR3DECL(int) VbglR3GuestCtrlMsgFilterUnset(uint32_t uClientId)
|
---|
173 | {
|
---|
174 | HGCMMsgCmdFilterUnset Msg;
|
---|
175 |
|
---|
176 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
177 | Msg.hdr.u32ClientID = uClientId;
|
---|
178 | Msg.hdr.u32Function = GUEST_MSG_FILTER_UNSET; /* Tell the host we want to unset the filter. */
|
---|
179 | Msg.hdr.cParms = 1;
|
---|
180 |
|
---|
181 | VbglHGCMParmUInt32Set(&Msg.flags, 0 /* Flags, unused */);
|
---|
182 |
|
---|
183 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
184 | if (RT_SUCCESS(rc))
|
---|
185 | rc = Msg.hdr.result;
|
---|
186 | return rc;
|
---|
187 | }
|
---|
188 |
|
---|
189 |
|
---|
190 | VBGLR3DECL(int) VbglR3GuestCtrlMsgReply(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
191 | int rc)
|
---|
192 | {
|
---|
193 | return VbglR3GuestCtrlMsgReplyEx(pCtx, rc, 0 /* uType */,
|
---|
194 | NULL /* pvPayload */, 0 /* cbPayload */);
|
---|
195 | }
|
---|
196 |
|
---|
197 |
|
---|
198 | VBGLR3DECL(int) VbglR3GuestCtrlMsgReplyEx(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
199 | int rc, uint32_t uType,
|
---|
200 | void *pvPayload, uint32_t cbPayload)
|
---|
201 | {
|
---|
202 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
203 | /* Everything else is optional. */
|
---|
204 |
|
---|
205 | HGCMMsgCmdReply Msg;
|
---|
206 |
|
---|
207 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
208 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
209 | Msg.hdr.u32Function = GUEST_MSG_REPLY;
|
---|
210 | Msg.hdr.cParms = 4;
|
---|
211 |
|
---|
212 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
213 | VbglHGCMParmUInt32Set(&Msg.rc, (uint32_t)rc); /* int vs. uint32_t */
|
---|
214 | VbglHGCMParmUInt32Set(&Msg.type, uType);
|
---|
215 | VbglHGCMParmPtrSet(&Msg.payload, pvPayload, cbPayload);
|
---|
216 |
|
---|
217 | int rc2 = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
218 | if (RT_SUCCESS(rc))
|
---|
219 | {
|
---|
220 | int rc3 = Msg.hdr.result;
|
---|
221 | if (RT_FAILURE(rc3))
|
---|
222 | rc2 = rc3;
|
---|
223 | }
|
---|
224 | return rc2;
|
---|
225 | }
|
---|
226 |
|
---|
227 |
|
---|
228 | /**
|
---|
229 | * Tells the host service to skip the current message returned by
|
---|
230 | * VbglR3GuestCtrlMsgWaitFor().
|
---|
231 | *
|
---|
232 | * @return IPRT status code.
|
---|
233 | * @param uClientId The client ID returned by VbglR3GuestCtrlConnect().
|
---|
234 | */
|
---|
235 | VBGLR3DECL(int) VbglR3GuestCtrlMsgSkip(uint32_t uClientId)
|
---|
236 | {
|
---|
237 | HGCMMsgCmdSkip Msg;
|
---|
238 |
|
---|
239 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
240 | Msg.hdr.u32ClientID = uClientId;
|
---|
241 | Msg.hdr.u32Function = GUEST_MSG_SKIP; /* Tell the host we want to skip
|
---|
242 | the current assigned command. */
|
---|
243 | Msg.hdr.cParms = 1;
|
---|
244 |
|
---|
245 | VbglHGCMParmUInt32Set(&Msg.flags, 0 /* Flags, unused */);
|
---|
246 |
|
---|
247 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
248 | if (RT_SUCCESS(rc))
|
---|
249 | rc = Msg.hdr.result;
|
---|
250 |
|
---|
251 | return rc;
|
---|
252 | }
|
---|
253 |
|
---|
254 |
|
---|
255 | /**
|
---|
256 | * Asks the host to cancel (release) all pending waits which were deferred.
|
---|
257 | *
|
---|
258 | * @returns VBox status code.
|
---|
259 | * @param uClientId The client ID returned by VbglR3GuestCtrlConnect().
|
---|
260 | */
|
---|
261 | VBGLR3DECL(int) VbglR3GuestCtrlCancelPendingWaits(uint32_t uClientId)
|
---|
262 | {
|
---|
263 | HGCMMsgCancelPendingWaits Msg;
|
---|
264 |
|
---|
265 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
266 | Msg.hdr.u32ClientID = uClientId;
|
---|
267 | Msg.hdr.u32Function = GUEST_CANCEL_PENDING_WAITS;
|
---|
268 | Msg.hdr.cParms = 0;
|
---|
269 |
|
---|
270 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
271 | if (RT_SUCCESS(rc))
|
---|
272 | {
|
---|
273 | int rc2 = Msg.hdr.result;
|
---|
274 | if (RT_FAILURE(rc2))
|
---|
275 | rc = rc2;
|
---|
276 | }
|
---|
277 | return rc;
|
---|
278 | }
|
---|
279 |
|
---|
280 |
|
---|
281 | /**
|
---|
282 | * Asks a specific guest session to close.
|
---|
283 | *
|
---|
284 | * @return IPRT status code.
|
---|
285 | * @param pCtx Host context.
|
---|
286 | ** @todo Docs!
|
---|
287 | */
|
---|
288 | VBGLR3DECL(int) VbglR3GuestCtrlSessionClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uFlags)
|
---|
289 | {
|
---|
290 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
291 | AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
|
---|
292 |
|
---|
293 | HGCMMsgSessionClose Msg;
|
---|
294 |
|
---|
295 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
296 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
297 | Msg.hdr.u32Function = GUEST_SESSION_CLOSE;
|
---|
298 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
299 |
|
---|
300 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
301 | VbglHGCMParmUInt32Set(&Msg.flags, uFlags);
|
---|
302 |
|
---|
303 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
304 | if (RT_SUCCESS(rc))
|
---|
305 | {
|
---|
306 | int rc2 = Msg.hdr.result;
|
---|
307 | if (RT_FAILURE(rc2))
|
---|
308 | rc = rc2;
|
---|
309 | }
|
---|
310 |
|
---|
311 | return rc;
|
---|
312 | }
|
---|
313 |
|
---|
314 |
|
---|
315 | VBGLR3DECL(int) VbglR3GuestCtrlSessionNotify(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
316 | uint32_t uType, uint32_t uResult)
|
---|
317 | {
|
---|
318 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
319 |
|
---|
320 | HGCMMsgSessionNotify Msg;
|
---|
321 |
|
---|
322 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
323 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
324 | Msg.hdr.u32Function = GUEST_SESSION_NOTIFY;
|
---|
325 | Msg.hdr.cParms = 3;
|
---|
326 |
|
---|
327 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
328 | VbglHGCMParmUInt32Set(&Msg.type, uType);
|
---|
329 | VbglHGCMParmUInt32Set(&Msg.result, uResult);
|
---|
330 |
|
---|
331 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
332 | if (RT_SUCCESS(rc))
|
---|
333 | {
|
---|
334 | int rc2 = Msg.hdr.result;
|
---|
335 | if (RT_FAILURE(rc2))
|
---|
336 | rc = rc2;
|
---|
337 | }
|
---|
338 | return rc;
|
---|
339 | }
|
---|
340 |
|
---|
341 |
|
---|
342 | /**
|
---|
343 | * Retrieves the request to create a new guest session.
|
---|
344 | *
|
---|
345 | * @return IPRT status code.
|
---|
346 | * @param pCtx Host context.
|
---|
347 | ** @todo Docs!
|
---|
348 | */
|
---|
349 | VBGLR3DECL(int) VbglR3GuestCtrlSessionGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
350 | uint32_t *puProtocol,
|
---|
351 | char *pszUser, uint32_t cbUser,
|
---|
352 | char *pszPassword, uint32_t cbPassword,
|
---|
353 | char *pszDomain, uint32_t cbDomain,
|
---|
354 | uint32_t *puFlags, uint32_t *puSessionID)
|
---|
355 | {
|
---|
356 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
357 | AssertReturn(pCtx->uNumParms == 6, VERR_INVALID_PARAMETER);
|
---|
358 |
|
---|
359 | AssertPtrReturn(puProtocol, VERR_INVALID_POINTER);
|
---|
360 | AssertPtrReturn(pszUser, VERR_INVALID_POINTER);
|
---|
361 | AssertPtrReturn(pszPassword, VERR_INVALID_POINTER);
|
---|
362 | AssertPtrReturn(pszDomain, VERR_INVALID_POINTER);
|
---|
363 | AssertPtrReturn(puFlags, VERR_INVALID_POINTER);
|
---|
364 |
|
---|
365 | HGCMMsgSessionOpen Msg;
|
---|
366 |
|
---|
367 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
368 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
369 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
370 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
371 |
|
---|
372 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
373 | VbglHGCMParmUInt32Set(&Msg.protocol, 0);
|
---|
374 | VbglHGCMParmPtrSet(&Msg.username, pszUser, cbUser);
|
---|
375 | VbglHGCMParmPtrSet(&Msg.password, pszPassword, cbPassword);
|
---|
376 | VbglHGCMParmPtrSet(&Msg.domain, pszDomain, cbDomain);
|
---|
377 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
378 |
|
---|
379 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
380 | if (RT_SUCCESS(rc))
|
---|
381 | {
|
---|
382 | int rc2 = Msg.hdr.result;
|
---|
383 | if (RT_FAILURE(rc2))
|
---|
384 | {
|
---|
385 | rc = rc2;
|
---|
386 | }
|
---|
387 | else
|
---|
388 | {
|
---|
389 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
390 | Msg.protocol.GetUInt32(puProtocol);
|
---|
391 | Msg.flags.GetUInt32(puFlags);
|
---|
392 |
|
---|
393 | if (puSessionID)
|
---|
394 | *puSessionID = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pCtx->uContextID);
|
---|
395 | }
|
---|
396 | }
|
---|
397 |
|
---|
398 | return rc;
|
---|
399 | }
|
---|
400 |
|
---|
401 |
|
---|
402 | /**
|
---|
403 | * Retrieves the request to terminate an existing guest session.
|
---|
404 | *
|
---|
405 | * @return IPRT status code.
|
---|
406 | * @param pCtx Host context.
|
---|
407 | ** @todo Docs!
|
---|
408 | */
|
---|
409 | VBGLR3DECL(int) VbglR3GuestCtrlSessionGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puFlags, uint32_t *puSessionID)
|
---|
410 | {
|
---|
411 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
412 | AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
|
---|
413 |
|
---|
414 | AssertPtrReturn(puFlags, VERR_INVALID_POINTER);
|
---|
415 |
|
---|
416 | HGCMMsgSessionClose Msg;
|
---|
417 |
|
---|
418 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
419 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
420 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
421 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
422 |
|
---|
423 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
424 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
425 |
|
---|
426 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
427 | if (RT_SUCCESS(rc))
|
---|
428 | {
|
---|
429 | int rc2 = Msg.hdr.result;
|
---|
430 | if (RT_FAILURE(rc2))
|
---|
431 | {
|
---|
432 | rc = rc2;
|
---|
433 | }
|
---|
434 | else
|
---|
435 | {
|
---|
436 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
437 | Msg.flags.GetUInt32(puFlags);
|
---|
438 |
|
---|
439 | if (puSessionID)
|
---|
440 | *puSessionID = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pCtx->uContextID);
|
---|
441 | }
|
---|
442 | }
|
---|
443 |
|
---|
444 | return rc;
|
---|
445 | }
|
---|
446 |
|
---|
447 |
|
---|
448 | VBGLR3DECL(int) VbglR3GuestCtrlPathGetRename(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
449 | char *pszSource, uint32_t cbSource,
|
---|
450 | char *pszDest, uint32_t cbDest,
|
---|
451 | uint32_t *puFlags)
|
---|
452 | {
|
---|
453 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
454 | AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
|
---|
455 |
|
---|
456 | AssertPtrReturn(pszSource, VERR_INVALID_POINTER);
|
---|
457 | AssertReturn(cbSource, VERR_INVALID_PARAMETER);
|
---|
458 | AssertPtrReturn(pszDest, VERR_INVALID_POINTER);
|
---|
459 | AssertReturn(cbDest, VERR_INVALID_PARAMETER);
|
---|
460 | AssertPtrReturn(puFlags, VERR_INVALID_POINTER);
|
---|
461 |
|
---|
462 | HGCMMsgPathRename Msg;
|
---|
463 |
|
---|
464 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
465 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
466 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
467 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
468 |
|
---|
469 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
470 | VbglHGCMParmPtrSet(&Msg.source, pszSource, cbSource);
|
---|
471 | VbglHGCMParmPtrSet(&Msg.dest, pszDest, cbDest);
|
---|
472 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
473 |
|
---|
474 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
475 | if (RT_SUCCESS(rc))
|
---|
476 | {
|
---|
477 | int rc2 = Msg.hdr.result;
|
---|
478 | if (RT_FAILURE(rc2))
|
---|
479 | {
|
---|
480 | rc = rc2;
|
---|
481 | }
|
---|
482 | else
|
---|
483 | {
|
---|
484 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
485 | Msg.flags.GetUInt32(puFlags);
|
---|
486 | }
|
---|
487 | }
|
---|
488 | return rc;
|
---|
489 | }
|
---|
490 |
|
---|
491 |
|
---|
492 | /**
|
---|
493 | * Allocates and gets host data, based on the message id.
|
---|
494 | *
|
---|
495 | * This will block until data becomes available.
|
---|
496 | *
|
---|
497 | * @returns VBox status code.
|
---|
498 | ** @todo Docs!
|
---|
499 | ** @todo Move the parameters in an own struct!
|
---|
500 | */
|
---|
501 | VBGLR3DECL(int) VbglR3GuestCtrlProcGetStart(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
502 | char *pszCmd, uint32_t cbCmd,
|
---|
503 | uint32_t *puFlags,
|
---|
504 | char *pszArgs, uint32_t cbArgs, uint32_t *pcArgs,
|
---|
505 | char *pszEnv, uint32_t *pcbEnv, uint32_t *pcEnvVars,
|
---|
506 | char *pszUser, uint32_t cbUser,
|
---|
507 | char *pszPassword, uint32_t cbPassword,
|
---|
508 | uint32_t *puTimeoutMS,
|
---|
509 | uint32_t *puPriority,
|
---|
510 | uint64_t *puAffinity, uint32_t cbAffinity, uint32_t *pcAffinity)
|
---|
511 | {
|
---|
512 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
513 |
|
---|
514 | AssertPtrReturn(pszCmd, VERR_INVALID_POINTER);
|
---|
515 | AssertPtrReturn(puFlags, VERR_INVALID_POINTER);
|
---|
516 | AssertPtrReturn(pszArgs, VERR_INVALID_POINTER);
|
---|
517 | AssertPtrReturn(pcArgs, VERR_INVALID_POINTER);
|
---|
518 | AssertPtrReturn(pszEnv, VERR_INVALID_POINTER);
|
---|
519 | AssertPtrReturn(pcbEnv, VERR_INVALID_POINTER);
|
---|
520 | AssertPtrReturn(pcEnvVars, VERR_INVALID_POINTER);
|
---|
521 | AssertPtrReturn(puTimeoutMS, VERR_INVALID_POINTER);
|
---|
522 |
|
---|
523 | HGCMMsgProcExec Msg;
|
---|
524 |
|
---|
525 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
526 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
527 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
528 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
529 |
|
---|
530 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
531 | VbglHGCMParmPtrSet(&Msg.cmd, pszCmd, cbCmd);
|
---|
532 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
533 | VbglHGCMParmUInt32Set(&Msg.num_args, 0);
|
---|
534 | VbglHGCMParmPtrSet(&Msg.args, pszArgs, cbArgs);
|
---|
535 | VbglHGCMParmUInt32Set(&Msg.num_env, 0);
|
---|
536 | VbglHGCMParmUInt32Set(&Msg.cb_env, 0);
|
---|
537 | VbglHGCMParmPtrSet(&Msg.env, pszEnv, *pcbEnv);
|
---|
538 | if (pCtx->uProtocol < 2)
|
---|
539 | {
|
---|
540 | AssertPtrReturn(pszUser, VERR_INVALID_POINTER);
|
---|
541 | AssertReturn(cbUser, VERR_INVALID_PARAMETER);
|
---|
542 | AssertPtrReturn(pszPassword, VERR_INVALID_POINTER);
|
---|
543 | AssertReturn(pszPassword, VERR_INVALID_PARAMETER);
|
---|
544 |
|
---|
545 | VbglHGCMParmPtrSet(&Msg.u.v1.username, pszUser, cbUser);
|
---|
546 | VbglHGCMParmPtrSet(&Msg.u.v1.password, pszPassword, cbPassword);
|
---|
547 | VbglHGCMParmUInt32Set(&Msg.u.v1.timeout, 0);
|
---|
548 | }
|
---|
549 | else
|
---|
550 | {
|
---|
551 | AssertPtrReturn(puAffinity, VERR_INVALID_POINTER);
|
---|
552 | AssertReturn(cbAffinity, VERR_INVALID_PARAMETER);
|
---|
553 |
|
---|
554 | VbglHGCMParmUInt32Set(&Msg.u.v2.timeout, 0);
|
---|
555 | VbglHGCMParmUInt32Set(&Msg.u.v2.priority, 0);
|
---|
556 | VbglHGCMParmUInt32Set(&Msg.u.v2.num_affinity, 0);
|
---|
557 | VbglHGCMParmPtrSet(&Msg.u.v2.affinity, puAffinity, cbAffinity);
|
---|
558 | }
|
---|
559 |
|
---|
560 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
561 | if (RT_SUCCESS(rc))
|
---|
562 | {
|
---|
563 | int rc2 = Msg.hdr.result;
|
---|
564 | if (RT_FAILURE(rc2))
|
---|
565 | {
|
---|
566 | rc = rc2;
|
---|
567 | }
|
---|
568 | else
|
---|
569 | {
|
---|
570 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
571 | Msg.flags.GetUInt32(puFlags);
|
---|
572 | Msg.num_args.GetUInt32(pcArgs);
|
---|
573 | Msg.num_env.GetUInt32(pcEnvVars);
|
---|
574 | Msg.cb_env.GetUInt32(pcbEnv);
|
---|
575 | if (pCtx->uProtocol < 2)
|
---|
576 | {
|
---|
577 | Msg.u.v1.timeout.GetUInt32(puTimeoutMS);
|
---|
578 | }
|
---|
579 | else
|
---|
580 | {
|
---|
581 | Msg.u.v2.timeout.GetUInt32(puTimeoutMS);
|
---|
582 | Msg.u.v2.priority.GetUInt32(puPriority);
|
---|
583 | Msg.u.v2.num_affinity.GetUInt32(pcAffinity);
|
---|
584 | }
|
---|
585 | }
|
---|
586 | }
|
---|
587 | return rc;
|
---|
588 | }
|
---|
589 |
|
---|
590 |
|
---|
591 | /**
|
---|
592 | * Allocates and gets host data, based on the message id.
|
---|
593 | *
|
---|
594 | * This will block until data becomes available.
|
---|
595 | *
|
---|
596 | * @returns VBox status code.
|
---|
597 | ** @todo Docs!
|
---|
598 | */
|
---|
599 | VBGLR3DECL(int) VbglR3GuestCtrlProcGetOutput(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
600 | uint32_t *puPID, uint32_t *puHandle, uint32_t *puFlags)
|
---|
601 | {
|
---|
602 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
603 | AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
|
---|
604 |
|
---|
605 | AssertPtrReturn(puPID, VERR_INVALID_POINTER);
|
---|
606 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
607 | AssertPtrReturn(puFlags, VERR_INVALID_POINTER);
|
---|
608 |
|
---|
609 | HGCMMsgProcOutput Msg;
|
---|
610 |
|
---|
611 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
612 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
613 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
614 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
615 |
|
---|
616 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
617 | VbglHGCMParmUInt32Set(&Msg.pid, 0);
|
---|
618 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
619 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
620 |
|
---|
621 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
622 | if (RT_SUCCESS(rc))
|
---|
623 | {
|
---|
624 | int rc2 = Msg.hdr.result;
|
---|
625 | if (RT_FAILURE(rc2))
|
---|
626 | {
|
---|
627 | rc = rc2;
|
---|
628 | }
|
---|
629 | else
|
---|
630 | {
|
---|
631 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
632 | Msg.pid.GetUInt32(puPID);
|
---|
633 | Msg.handle.GetUInt32(puHandle);
|
---|
634 | Msg.flags.GetUInt32(puFlags);
|
---|
635 | }
|
---|
636 | }
|
---|
637 | return rc;
|
---|
638 | }
|
---|
639 |
|
---|
640 |
|
---|
641 | /**
|
---|
642 | * Retrieves the input data from host which then gets sent to the
|
---|
643 | * started process.
|
---|
644 | *
|
---|
645 | * This will block until data becomes available.
|
---|
646 | *
|
---|
647 | * @returns VBox status code.
|
---|
648 | ** @todo Docs!
|
---|
649 | */
|
---|
650 | VBGLR3DECL(int) VbglR3GuestCtrlProcGetInput(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
651 | uint32_t *puPID, uint32_t *puFlags,
|
---|
652 | void *pvData, uint32_t cbData,
|
---|
653 | uint32_t *pcbSize)
|
---|
654 | {
|
---|
655 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
656 | AssertReturn(pCtx->uNumParms == 5, VERR_INVALID_PARAMETER);
|
---|
657 |
|
---|
658 | AssertPtrReturn(puPID, VERR_INVALID_POINTER);
|
---|
659 | AssertPtrReturn(puFlags, VERR_INVALID_POINTER);
|
---|
660 | AssertPtrReturn(pvData, VERR_INVALID_POINTER);
|
---|
661 | AssertPtrReturn(pcbSize, VERR_INVALID_POINTER);
|
---|
662 |
|
---|
663 | HGCMMsgProcInput Msg;
|
---|
664 |
|
---|
665 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
666 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
667 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
668 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
669 |
|
---|
670 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
671 | VbglHGCMParmUInt32Set(&Msg.pid, 0);
|
---|
672 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
673 | VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
|
---|
674 | VbglHGCMParmUInt32Set(&Msg.size, 0);
|
---|
675 |
|
---|
676 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
677 | if (RT_SUCCESS(rc))
|
---|
678 | {
|
---|
679 | int rc2 = Msg.hdr.result;
|
---|
680 | if (RT_FAILURE(rc2))
|
---|
681 | {
|
---|
682 | rc = rc2;
|
---|
683 | }
|
---|
684 | else
|
---|
685 | {
|
---|
686 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
687 | Msg.pid.GetUInt32(puPID);
|
---|
688 | Msg.flags.GetUInt32(puFlags);
|
---|
689 | Msg.size.GetUInt32(pcbSize);
|
---|
690 | }
|
---|
691 | }
|
---|
692 | return rc;
|
---|
693 | }
|
---|
694 |
|
---|
695 |
|
---|
696 | VBGLR3DECL(int) VbglR3GuestCtrlDirGetRemove(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
697 | char *pszPath, uint32_t cbPath,
|
---|
698 | uint32_t *puFlags)
|
---|
699 | {
|
---|
700 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
701 | AssertReturn(pCtx->uNumParms == 3, VERR_INVALID_PARAMETER);
|
---|
702 |
|
---|
703 | AssertPtrReturn(pszPath, VERR_INVALID_POINTER);
|
---|
704 | AssertReturn(cbPath, VERR_INVALID_PARAMETER);
|
---|
705 | AssertPtrReturn(puFlags, VERR_INVALID_POINTER);
|
---|
706 |
|
---|
707 | HGCMMsgDirRemove Msg;
|
---|
708 |
|
---|
709 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
710 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
711 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
712 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
713 |
|
---|
714 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
715 | VbglHGCMParmPtrSet(&Msg.path, pszPath, cbPath);
|
---|
716 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
717 |
|
---|
718 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
719 | if (RT_SUCCESS(rc))
|
---|
720 | {
|
---|
721 | int rc2 = Msg.hdr.result;
|
---|
722 | if (RT_FAILURE(rc2))
|
---|
723 | {
|
---|
724 | rc = rc2;
|
---|
725 | }
|
---|
726 | else
|
---|
727 | {
|
---|
728 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
729 | Msg.flags.GetUInt32(puFlags);
|
---|
730 | }
|
---|
731 | }
|
---|
732 | return rc;
|
---|
733 | }
|
---|
734 |
|
---|
735 |
|
---|
736 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
737 | char *pszFileName, uint32_t cbFileName,
|
---|
738 | char *pszAccess, uint32_t cbAccess,
|
---|
739 | char *pszDisposition, uint32_t cbDisposition,
|
---|
740 | char *pszSharing, uint32_t cbSharing,
|
---|
741 | uint32_t *puCreationMode,
|
---|
742 | uint64_t *puOffset)
|
---|
743 | {
|
---|
744 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
745 | AssertReturn(pCtx->uNumParms == 7, VERR_INVALID_PARAMETER);
|
---|
746 |
|
---|
747 | AssertPtrReturn(pszFileName, VERR_INVALID_POINTER);
|
---|
748 | AssertReturn(cbFileName, VERR_INVALID_PARAMETER);
|
---|
749 | AssertPtrReturn(pszAccess, VERR_INVALID_POINTER);
|
---|
750 | AssertReturn(cbAccess, VERR_INVALID_PARAMETER);
|
---|
751 | AssertPtrReturn(pszDisposition, VERR_INVALID_POINTER);
|
---|
752 | AssertReturn(cbDisposition, VERR_INVALID_PARAMETER);
|
---|
753 | AssertPtrReturn(pszSharing, VERR_INVALID_POINTER);
|
---|
754 | AssertReturn(cbSharing, VERR_INVALID_PARAMETER);
|
---|
755 | AssertPtrReturn(puCreationMode, VERR_INVALID_POINTER);
|
---|
756 | AssertPtrReturn(puOffset, VERR_INVALID_POINTER);
|
---|
757 |
|
---|
758 | HGCMMsgFileOpen Msg;
|
---|
759 |
|
---|
760 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
761 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
762 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
763 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
764 |
|
---|
765 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
766 | VbglHGCMParmPtrSet(&Msg.filename, pszFileName, cbFileName);
|
---|
767 | VbglHGCMParmPtrSet(&Msg.openmode, pszAccess, cbAccess);
|
---|
768 | VbglHGCMParmPtrSet(&Msg.disposition, pszDisposition, cbDisposition);
|
---|
769 | VbglHGCMParmPtrSet(&Msg.sharing, pszSharing, cbSharing);
|
---|
770 | VbglHGCMParmUInt32Set(&Msg.creationmode, 0);
|
---|
771 | VbglHGCMParmUInt64Set(&Msg.offset, 0);
|
---|
772 |
|
---|
773 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
774 | if (RT_SUCCESS(rc))
|
---|
775 | {
|
---|
776 | int rc2 = Msg.hdr.result;
|
---|
777 | if (RT_FAILURE(rc2))
|
---|
778 | {
|
---|
779 | rc = rc2;
|
---|
780 | }
|
---|
781 | else
|
---|
782 | {
|
---|
783 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
784 | Msg.creationmode.GetUInt32(puCreationMode);
|
---|
785 | Msg.offset.GetUInt64(puOffset);
|
---|
786 | }
|
---|
787 | }
|
---|
788 | return rc;
|
---|
789 | }
|
---|
790 |
|
---|
791 |
|
---|
792 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle)
|
---|
793 | {
|
---|
794 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
795 |
|
---|
796 | AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
|
---|
797 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
798 |
|
---|
799 | HGCMMsgFileClose Msg;
|
---|
800 |
|
---|
801 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
802 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
803 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
804 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
805 |
|
---|
806 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
807 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
808 |
|
---|
809 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
810 | if (RT_SUCCESS(rc))
|
---|
811 | {
|
---|
812 | int rc2 = Msg.hdr.result;
|
---|
813 | if (RT_FAILURE(rc2))
|
---|
814 | {
|
---|
815 | rc = rc2;
|
---|
816 | }
|
---|
817 | else
|
---|
818 | {
|
---|
819 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
820 | Msg.handle.GetUInt32(puHandle);
|
---|
821 | }
|
---|
822 | }
|
---|
823 | return rc;
|
---|
824 | }
|
---|
825 |
|
---|
826 |
|
---|
827 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetRead(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
828 | uint32_t *puHandle, uint32_t *puToRead)
|
---|
829 | {
|
---|
830 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
831 |
|
---|
832 | AssertReturn(pCtx->uNumParms == 3, VERR_INVALID_PARAMETER);
|
---|
833 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
834 | AssertPtrReturn(puToRead, VERR_INVALID_POINTER);
|
---|
835 |
|
---|
836 | HGCMMsgFileRead Msg;
|
---|
837 |
|
---|
838 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
839 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
840 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
841 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
842 |
|
---|
843 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
844 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
845 | VbglHGCMParmUInt32Set(&Msg.size, 0);
|
---|
846 |
|
---|
847 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
848 | if (RT_SUCCESS(rc))
|
---|
849 | {
|
---|
850 | int rc2 = Msg.hdr.result;
|
---|
851 | if (RT_FAILURE(rc2))
|
---|
852 | {
|
---|
853 | rc = rc2;
|
---|
854 | }
|
---|
855 | else
|
---|
856 | {
|
---|
857 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
858 | Msg.handle.GetUInt32(puHandle);
|
---|
859 | Msg.size.GetUInt32(puToRead);
|
---|
860 | }
|
---|
861 | }
|
---|
862 | return rc;
|
---|
863 | }
|
---|
864 |
|
---|
865 |
|
---|
866 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetReadAt(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
867 | uint32_t *puHandle, uint32_t *puToRead, uint64_t *puOffset)
|
---|
868 | {
|
---|
869 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
870 |
|
---|
871 | AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
|
---|
872 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
873 | AssertPtrReturn(puToRead, VERR_INVALID_POINTER);
|
---|
874 |
|
---|
875 | HGCMMsgFileReadAt Msg;
|
---|
876 |
|
---|
877 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
878 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
879 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
880 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
881 |
|
---|
882 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
883 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
884 | VbglHGCMParmUInt32Set(&Msg.offset, 0);
|
---|
885 | VbglHGCMParmUInt32Set(&Msg.size, 0);
|
---|
886 |
|
---|
887 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
888 | if (RT_SUCCESS(rc))
|
---|
889 | {
|
---|
890 | int rc2 = Msg.hdr.result;
|
---|
891 | if (RT_FAILURE(rc2))
|
---|
892 | {
|
---|
893 | rc = rc2;
|
---|
894 | }
|
---|
895 | else
|
---|
896 | {
|
---|
897 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
898 | Msg.handle.GetUInt32(puHandle);
|
---|
899 | Msg.offset.GetUInt64(puOffset);
|
---|
900 | Msg.size.GetUInt32(puToRead);
|
---|
901 | }
|
---|
902 | }
|
---|
903 | return rc;
|
---|
904 | }
|
---|
905 |
|
---|
906 |
|
---|
907 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetWrite(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle,
|
---|
908 | void *pvData, uint32_t cbData, uint32_t *pcbSize)
|
---|
909 | {
|
---|
910 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
911 |
|
---|
912 | AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
|
---|
913 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
914 | AssertPtrReturn(pvData, VERR_INVALID_POINTER);
|
---|
915 | AssertReturn(cbData, VERR_INVALID_PARAMETER);
|
---|
916 | AssertPtrReturn(pcbSize, VERR_INVALID_POINTER);
|
---|
917 |
|
---|
918 | HGCMMsgFileWrite Msg;
|
---|
919 |
|
---|
920 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
921 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
922 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
923 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
924 |
|
---|
925 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
926 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
927 | VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
|
---|
928 | VbglHGCMParmUInt32Set(&Msg.size, 0);
|
---|
929 |
|
---|
930 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
931 | if (RT_SUCCESS(rc))
|
---|
932 | {
|
---|
933 | int rc2 = Msg.hdr.result;
|
---|
934 | if (RT_FAILURE(rc2))
|
---|
935 | {
|
---|
936 | rc = rc2;
|
---|
937 | }
|
---|
938 | else
|
---|
939 | {
|
---|
940 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
941 | Msg.handle.GetUInt32(puHandle);
|
---|
942 | Msg.size.GetUInt32(pcbSize);
|
---|
943 | }
|
---|
944 | }
|
---|
945 | return rc;
|
---|
946 | }
|
---|
947 |
|
---|
948 |
|
---|
949 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetWriteAt(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle,
|
---|
950 | void *pvData, uint32_t cbData, uint32_t *pcbSize, uint64_t *puOffset)
|
---|
951 | {
|
---|
952 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
953 |
|
---|
954 | AssertReturn(pCtx->uNumParms == 5, VERR_INVALID_PARAMETER);
|
---|
955 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
956 | AssertPtrReturn(pvData, VERR_INVALID_POINTER);
|
---|
957 | AssertReturn(cbData, VERR_INVALID_PARAMETER);
|
---|
958 | AssertPtrReturn(pcbSize, VERR_INVALID_POINTER);
|
---|
959 |
|
---|
960 | HGCMMsgFileWriteAt Msg;
|
---|
961 |
|
---|
962 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
963 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
964 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
965 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
966 |
|
---|
967 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
968 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
969 | VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
|
---|
970 | VbglHGCMParmUInt32Set(&Msg.size, 0);
|
---|
971 | VbglHGCMParmUInt32Set(&Msg.offset, 0);
|
---|
972 |
|
---|
973 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
974 | if (RT_SUCCESS(rc))
|
---|
975 | {
|
---|
976 | int rc2 = Msg.hdr.result;
|
---|
977 | if (RT_FAILURE(rc2))
|
---|
978 | {
|
---|
979 | rc = rc2;
|
---|
980 | }
|
---|
981 | else
|
---|
982 | {
|
---|
983 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
984 | Msg.handle.GetUInt32(puHandle);
|
---|
985 | Msg.size.GetUInt32(pcbSize);
|
---|
986 | }
|
---|
987 | }
|
---|
988 | return rc;
|
---|
989 | }
|
---|
990 |
|
---|
991 |
|
---|
992 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetSeek(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
993 | uint32_t *puHandle, uint32_t *puSeekMethod, uint64_t *puOffset)
|
---|
994 | {
|
---|
995 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
996 |
|
---|
997 | AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
|
---|
998 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
999 | AssertPtrReturn(puSeekMethod, VERR_INVALID_POINTER);
|
---|
1000 | AssertPtrReturn(puOffset, VERR_INVALID_POINTER);
|
---|
1001 |
|
---|
1002 | HGCMMsgFileSeek Msg;
|
---|
1003 |
|
---|
1004 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1005 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1006 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
1007 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
1008 |
|
---|
1009 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
1010 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
1011 | VbglHGCMParmUInt32Set(&Msg.method, 0);
|
---|
1012 | VbglHGCMParmUInt64Set(&Msg.offset, 0);
|
---|
1013 |
|
---|
1014 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1015 | if (RT_SUCCESS(rc))
|
---|
1016 | {
|
---|
1017 | int rc2 = Msg.hdr.result;
|
---|
1018 | if (RT_FAILURE(rc2))
|
---|
1019 | {
|
---|
1020 | rc = rc2;
|
---|
1021 | }
|
---|
1022 | else
|
---|
1023 | {
|
---|
1024 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
1025 | Msg.handle.GetUInt32(puHandle);
|
---|
1026 | Msg.method.GetUInt32(puSeekMethod);
|
---|
1027 | Msg.offset.GetUInt64(puOffset);
|
---|
1028 | }
|
---|
1029 | }
|
---|
1030 | return rc;
|
---|
1031 | }
|
---|
1032 |
|
---|
1033 |
|
---|
1034 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetTell(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle)
|
---|
1035 | {
|
---|
1036 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1037 |
|
---|
1038 | AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
|
---|
1039 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
1040 |
|
---|
1041 | HGCMMsgFileTell Msg;
|
---|
1042 |
|
---|
1043 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1044 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1045 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
1046 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
1047 |
|
---|
1048 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
1049 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
1050 |
|
---|
1051 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1052 | if (RT_SUCCESS(rc))
|
---|
1053 | {
|
---|
1054 | int rc2 = Msg.hdr.result;
|
---|
1055 | if (RT_FAILURE(rc2))
|
---|
1056 | {
|
---|
1057 | rc = rc2;
|
---|
1058 | }
|
---|
1059 | else
|
---|
1060 | {
|
---|
1061 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
1062 | Msg.handle.GetUInt32(puHandle);
|
---|
1063 | }
|
---|
1064 | }
|
---|
1065 | return rc;
|
---|
1066 | }
|
---|
1067 |
|
---|
1068 |
|
---|
1069 | VBGLR3DECL(int) VbglR3GuestCtrlProcGetTerminate(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puPID)
|
---|
1070 | {
|
---|
1071 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1072 |
|
---|
1073 | AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
|
---|
1074 | AssertPtrReturn(puPID, VERR_INVALID_POINTER);
|
---|
1075 |
|
---|
1076 | HGCMMsgProcTerminate Msg;
|
---|
1077 |
|
---|
1078 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1079 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1080 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
1081 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
1082 |
|
---|
1083 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
1084 | VbglHGCMParmUInt32Set(&Msg.pid, 0);
|
---|
1085 |
|
---|
1086 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1087 | if (RT_SUCCESS(rc))
|
---|
1088 | {
|
---|
1089 | int rc2 = Msg.hdr.result;
|
---|
1090 | if (RT_FAILURE(rc2))
|
---|
1091 | {
|
---|
1092 | rc = rc2;
|
---|
1093 | }
|
---|
1094 | else
|
---|
1095 | {
|
---|
1096 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
1097 | Msg.pid.GetUInt32(puPID);
|
---|
1098 | }
|
---|
1099 | }
|
---|
1100 | return rc;
|
---|
1101 | }
|
---|
1102 |
|
---|
1103 |
|
---|
1104 | VBGLR3DECL(int) VbglR3GuestCtrlProcGetWaitFor(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
1105 | uint32_t *puPID, uint32_t *puWaitFlags, uint32_t *puTimeoutMS)
|
---|
1106 | {
|
---|
1107 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1108 |
|
---|
1109 | AssertReturn(pCtx->uNumParms == 5, VERR_INVALID_PARAMETER);
|
---|
1110 | AssertPtrReturn(puPID, VERR_INVALID_POINTER);
|
---|
1111 |
|
---|
1112 | HGCMMsgProcWaitFor Msg;
|
---|
1113 |
|
---|
1114 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1115 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1116 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
1117 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
1118 |
|
---|
1119 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
1120 | VbglHGCMParmUInt32Set(&Msg.pid, 0);
|
---|
1121 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
1122 | VbglHGCMParmUInt32Set(&Msg.timeout, 0);
|
---|
1123 |
|
---|
1124 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1125 | if (RT_SUCCESS(rc))
|
---|
1126 | {
|
---|
1127 | int rc2 = Msg.hdr.result;
|
---|
1128 | if (RT_FAILURE(rc2))
|
---|
1129 | {
|
---|
1130 | rc = rc2;
|
---|
1131 | }
|
---|
1132 | else
|
---|
1133 | {
|
---|
1134 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
1135 | Msg.pid.GetUInt32(puPID);
|
---|
1136 | Msg.flags.GetUInt32(puWaitFlags);
|
---|
1137 | Msg.timeout.GetUInt32(puTimeoutMS);
|
---|
1138 | }
|
---|
1139 | }
|
---|
1140 | return rc;
|
---|
1141 | }
|
---|
1142 |
|
---|
1143 |
|
---|
1144 | VBGLR3DECL(int) VbglR3GuestCtrlFileCbOpen(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
1145 | uint32_t uRc, uint32_t uFileHandle)
|
---|
1146 | {
|
---|
1147 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1148 |
|
---|
1149 | HGCMReplyFileNotify Msg;
|
---|
1150 |
|
---|
1151 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1152 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1153 | Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
|
---|
1154 | Msg.hdr.cParms = 4;
|
---|
1155 |
|
---|
1156 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
1157 | VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_OPEN);
|
---|
1158 | VbglHGCMParmUInt32Set(&Msg.rc, uRc);
|
---|
1159 |
|
---|
1160 | VbglHGCMParmUInt32Set(&Msg.u.open.handle, uFileHandle);
|
---|
1161 |
|
---|
1162 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1163 | if (RT_SUCCESS(rc))
|
---|
1164 | {
|
---|
1165 | int rc2 = Msg.hdr.result;
|
---|
1166 | if (RT_FAILURE(rc2))
|
---|
1167 | rc = rc2;
|
---|
1168 | }
|
---|
1169 | return rc;
|
---|
1170 | }
|
---|
1171 |
|
---|
1172 |
|
---|
1173 | VBGLR3DECL(int) VbglR3GuestCtrlFileCbClose(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
1174 | uint32_t uRc)
|
---|
1175 | {
|
---|
1176 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1177 |
|
---|
1178 | HGCMReplyFileNotify Msg;
|
---|
1179 |
|
---|
1180 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1181 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1182 | Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
|
---|
1183 | Msg.hdr.cParms = 3;
|
---|
1184 |
|
---|
1185 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
1186 | VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_CLOSE);
|
---|
1187 | VbglHGCMParmUInt32Set(&Msg.rc, uRc);
|
---|
1188 |
|
---|
1189 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1190 | if (RT_SUCCESS(rc))
|
---|
1191 | {
|
---|
1192 | int rc2 = Msg.hdr.result;
|
---|
1193 | if (RT_FAILURE(rc2))
|
---|
1194 | rc = rc2;
|
---|
1195 | }
|
---|
1196 | return rc;
|
---|
1197 | }
|
---|
1198 |
|
---|
1199 |
|
---|
1200 | VBGLR3DECL(int) VbglR3GuestCtrlFileCbError(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc)
|
---|
1201 | {
|
---|
1202 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1203 |
|
---|
1204 | HGCMReplyFileNotify Msg;
|
---|
1205 |
|
---|
1206 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1207 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1208 | Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
|
---|
1209 | Msg.hdr.cParms = 3;
|
---|
1210 |
|
---|
1211 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
1212 | VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_ERROR);
|
---|
1213 | VbglHGCMParmUInt32Set(&Msg.rc, uRc);
|
---|
1214 |
|
---|
1215 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1216 | if (RT_SUCCESS(rc))
|
---|
1217 | {
|
---|
1218 | int rc2 = Msg.hdr.result;
|
---|
1219 | if (RT_FAILURE(rc2))
|
---|
1220 | rc = rc2;
|
---|
1221 | }
|
---|
1222 | return rc;
|
---|
1223 | }
|
---|
1224 |
|
---|
1225 |
|
---|
1226 | VBGLR3DECL(int) VbglR3GuestCtrlFileCbRead(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
1227 | uint32_t uRc,
|
---|
1228 | void *pvData, uint32_t cbData)
|
---|
1229 | {
|
---|
1230 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1231 |
|
---|
1232 | HGCMReplyFileNotify Msg;
|
---|
1233 |
|
---|
1234 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1235 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1236 | Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
|
---|
1237 | Msg.hdr.cParms = 4;
|
---|
1238 |
|
---|
1239 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
1240 | VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_READ);
|
---|
1241 | VbglHGCMParmUInt32Set(&Msg.rc, uRc);
|
---|
1242 |
|
---|
1243 | VbglHGCMParmPtrSet(&Msg.u.read.data, pvData, cbData);
|
---|
1244 |
|
---|
1245 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1246 | if (RT_SUCCESS(rc))
|
---|
1247 | {
|
---|
1248 | int rc2 = Msg.hdr.result;
|
---|
1249 | if (RT_FAILURE(rc2))
|
---|
1250 | rc = rc2;
|
---|
1251 | }
|
---|
1252 | return rc;
|
---|
1253 | }
|
---|
1254 |
|
---|
1255 |
|
---|
1256 | VBGLR3DECL(int) VbglR3GuestCtrlFileCbWrite(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
1257 | uint32_t uRc, uint32_t uWritten)
|
---|
1258 | {
|
---|
1259 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1260 |
|
---|
1261 | HGCMReplyFileNotify Msg;
|
---|
1262 |
|
---|
1263 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1264 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1265 | Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
|
---|
1266 | Msg.hdr.cParms = 4;
|
---|
1267 |
|
---|
1268 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
1269 | VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_WRITE);
|
---|
1270 | VbglHGCMParmUInt32Set(&Msg.rc, uRc);
|
---|
1271 |
|
---|
1272 | VbglHGCMParmUInt32Set(&Msg.u.write.written, uWritten);
|
---|
1273 |
|
---|
1274 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1275 | if (RT_SUCCESS(rc))
|
---|
1276 | {
|
---|
1277 | int rc2 = Msg.hdr.result;
|
---|
1278 | if (RT_FAILURE(rc2))
|
---|
1279 | rc = rc2;
|
---|
1280 | }
|
---|
1281 | return rc;
|
---|
1282 | }
|
---|
1283 |
|
---|
1284 |
|
---|
1285 | VBGLR3DECL(int) VbglR3GuestCtrlFileCbSeek(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
1286 | uint32_t uRc, uint64_t uOffActual)
|
---|
1287 | {
|
---|
1288 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1289 |
|
---|
1290 | HGCMReplyFileNotify Msg;
|
---|
1291 |
|
---|
1292 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1293 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1294 | Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
|
---|
1295 | Msg.hdr.cParms = 4;
|
---|
1296 |
|
---|
1297 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
1298 | VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_SEEK);
|
---|
1299 | VbglHGCMParmUInt32Set(&Msg.rc, uRc);
|
---|
1300 |
|
---|
1301 | VbglHGCMParmUInt64Set(&Msg.u.seek.offset, uOffActual);
|
---|
1302 |
|
---|
1303 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1304 | if (RT_SUCCESS(rc))
|
---|
1305 | {
|
---|
1306 | int rc2 = Msg.hdr.result;
|
---|
1307 | if (RT_FAILURE(rc2))
|
---|
1308 | rc = rc2;
|
---|
1309 | }
|
---|
1310 | return rc;
|
---|
1311 | }
|
---|
1312 |
|
---|
1313 |
|
---|
1314 | VBGLR3DECL(int) VbglR3GuestCtrlFileCbTell(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
1315 | uint32_t uRc, uint64_t uOffActual)
|
---|
1316 | {
|
---|
1317 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1318 |
|
---|
1319 | HGCMReplyFileNotify Msg;
|
---|
1320 |
|
---|
1321 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1322 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1323 | Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
|
---|
1324 | Msg.hdr.cParms = 4;
|
---|
1325 |
|
---|
1326 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
1327 | VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_TELL);
|
---|
1328 | VbglHGCMParmUInt32Set(&Msg.rc, uRc);
|
---|
1329 |
|
---|
1330 | VbglHGCMParmUInt64Set(&Msg.u.tell.offset, uOffActual);
|
---|
1331 |
|
---|
1332 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1333 | if (RT_SUCCESS(rc))
|
---|
1334 | {
|
---|
1335 | int rc2 = Msg.hdr.result;
|
---|
1336 | if (RT_FAILURE(rc2))
|
---|
1337 | rc = rc2;
|
---|
1338 | }
|
---|
1339 | return rc;
|
---|
1340 | }
|
---|
1341 |
|
---|
1342 |
|
---|
1343 | /**
|
---|
1344 | * Callback for reporting a guest process status (along with some other stuff) to the host.
|
---|
1345 | *
|
---|
1346 | * @returns VBox status code.
|
---|
1347 | ** @todo Docs!
|
---|
1348 | */
|
---|
1349 | VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatus(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
1350 | uint32_t uPID, uint32_t uStatus, uint32_t uFlags,
|
---|
1351 | void *pvData, uint32_t cbData)
|
---|
1352 | {
|
---|
1353 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1354 |
|
---|
1355 | HGCMMsgProcStatus Msg;
|
---|
1356 |
|
---|
1357 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1358 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1359 | Msg.hdr.u32Function = GUEST_EXEC_STATUS;
|
---|
1360 | Msg.hdr.cParms = 5;
|
---|
1361 |
|
---|
1362 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
1363 | VbglHGCMParmUInt32Set(&Msg.pid, uPID);
|
---|
1364 | VbglHGCMParmUInt32Set(&Msg.status, uStatus);
|
---|
1365 | VbglHGCMParmUInt32Set(&Msg.flags, uFlags);
|
---|
1366 | VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
|
---|
1367 |
|
---|
1368 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1369 | if (RT_SUCCESS(rc))
|
---|
1370 | {
|
---|
1371 | int rc2 = Msg.hdr.result;
|
---|
1372 | if (RT_FAILURE(rc2))
|
---|
1373 | rc = rc2;
|
---|
1374 | }
|
---|
1375 | return rc;
|
---|
1376 | }
|
---|
1377 |
|
---|
1378 |
|
---|
1379 | /**
|
---|
1380 | * Sends output (from stdout/stderr) from a running process.
|
---|
1381 | *
|
---|
1382 | * @returns VBox status code.
|
---|
1383 | ** @todo Docs!
|
---|
1384 | */
|
---|
1385 | VBGLR3DECL(int) VbglR3GuestCtrlProcCbOutput(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
1386 | uint32_t uPID,uint32_t uHandle, uint32_t uFlags,
|
---|
1387 | void *pvData, uint32_t cbData)
|
---|
1388 | {
|
---|
1389 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1390 |
|
---|
1391 | HGCMMsgProcOutput Msg;
|
---|
1392 |
|
---|
1393 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1394 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1395 | Msg.hdr.u32Function = GUEST_EXEC_OUTPUT;
|
---|
1396 | Msg.hdr.cParms = 5;
|
---|
1397 |
|
---|
1398 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
1399 | VbglHGCMParmUInt32Set(&Msg.pid, uPID);
|
---|
1400 | VbglHGCMParmUInt32Set(&Msg.handle, uHandle);
|
---|
1401 | VbglHGCMParmUInt32Set(&Msg.flags, uFlags);
|
---|
1402 | VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
|
---|
1403 |
|
---|
1404 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1405 | if (RT_SUCCESS(rc))
|
---|
1406 | {
|
---|
1407 | int rc2 = Msg.hdr.result;
|
---|
1408 | if (RT_FAILURE(rc2))
|
---|
1409 | rc = rc2;
|
---|
1410 | }
|
---|
1411 | return rc;
|
---|
1412 | }
|
---|
1413 |
|
---|
1414 |
|
---|
1415 | /**
|
---|
1416 | * Callback for reporting back the input status of a guest process to the host.
|
---|
1417 | *
|
---|
1418 | * @returns VBox status code.
|
---|
1419 | ** @todo Docs!
|
---|
1420 | */
|
---|
1421 | VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatusInput(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
1422 | uint32_t uPID, uint32_t uStatus,
|
---|
1423 | uint32_t uFlags, uint32_t cbWritten)
|
---|
1424 | {
|
---|
1425 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1426 |
|
---|
1427 | HGCMMsgProcStatusInput Msg;
|
---|
1428 |
|
---|
1429 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1430 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1431 | Msg.hdr.u32Function = GUEST_EXEC_INPUT_STATUS;
|
---|
1432 | Msg.hdr.cParms = 5;
|
---|
1433 |
|
---|
1434 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
1435 | VbglHGCMParmUInt32Set(&Msg.pid, uPID);
|
---|
1436 | VbglHGCMParmUInt32Set(&Msg.status, uStatus);
|
---|
1437 | VbglHGCMParmUInt32Set(&Msg.flags, uFlags);
|
---|
1438 | VbglHGCMParmUInt32Set(&Msg.written, cbWritten);
|
---|
1439 |
|
---|
1440 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1441 | if (RT_SUCCESS(rc))
|
---|
1442 | {
|
---|
1443 | int rc2 = Msg.hdr.result;
|
---|
1444 | if (RT_FAILURE(rc2))
|
---|
1445 | rc = rc2;
|
---|
1446 | }
|
---|
1447 | return rc;
|
---|
1448 | }
|
---|
1449 |
|
---|