1 | /* $Id: VBoxGuestR3LibGuestCtrl.cpp 45415 2013-04-08 21:40:42Z 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 | *
|
---|
137 | * @return IPRT status code.
|
---|
138 | * @param uClientId The client id returned by VbglR3GuestCtrlConnect().
|
---|
139 | * @param uFilterAdd Filter mask to add.
|
---|
140 | * @param uFilterRemove Filter mask to remove.
|
---|
141 | */
|
---|
142 | VBGLR3DECL(int) VbglR3GuestCtrlMsgSetFilter(uint32_t uClientId,
|
---|
143 | uint32_t uFilterAdd, uint32_t uFilterRemove)
|
---|
144 | {
|
---|
145 | HGCMMsgCmdSetFilter Msg;
|
---|
146 |
|
---|
147 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
148 | Msg.hdr.u32ClientID = uClientId;
|
---|
149 | Msg.hdr.u32Function = GUEST_MSG_FILTER; /* Tell the host we want to set a filter. */
|
---|
150 | Msg.hdr.cParms = 2;
|
---|
151 |
|
---|
152 | VbglHGCMParmUInt32Set(&Msg.add, uFilterAdd);
|
---|
153 | VbglHGCMParmUInt32Set(&Msg.remove, uFilterRemove);
|
---|
154 |
|
---|
155 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
156 | if (RT_SUCCESS(rc))
|
---|
157 | rc = Msg.hdr.result;
|
---|
158 | return rc;
|
---|
159 | }
|
---|
160 |
|
---|
161 |
|
---|
162 | /**
|
---|
163 | * Tells the host service to skip the current message returned by
|
---|
164 | * VbglR3GuestCtrlMsgWaitFor().
|
---|
165 | *
|
---|
166 | * @return IPRT status code.
|
---|
167 | * @param uClientId The client id returned by VbglR3GuestCtrlConnect().
|
---|
168 | */
|
---|
169 | VBGLR3DECL(int) VbglR3GuestCtrlMsgSkip(uint32_t uClientId)
|
---|
170 | {
|
---|
171 | HGCMMsgCmdSkip Msg;
|
---|
172 |
|
---|
173 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
174 | Msg.hdr.u32ClientID = uClientId;
|
---|
175 | Msg.hdr.u32Function = GUEST_MSG_SKIP; /* Tell the host we want to skip
|
---|
176 | the current assigned command. */
|
---|
177 | Msg.hdr.cParms = 0; /* No parameters needed. */
|
---|
178 |
|
---|
179 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
180 | if (RT_SUCCESS(rc))
|
---|
181 | rc = Msg.hdr.result;
|
---|
182 |
|
---|
183 | return rc;
|
---|
184 | }
|
---|
185 |
|
---|
186 |
|
---|
187 | /**
|
---|
188 | * Asks the host to cancel (release) all pending waits which were deferred.
|
---|
189 | *
|
---|
190 | * @returns VBox status code.
|
---|
191 | * @param uClientId The client id returned by VbglR3GuestCtrlConnect().
|
---|
192 | */
|
---|
193 | VBGLR3DECL(int) VbglR3GuestCtrlCancelPendingWaits(uint32_t uClientId)
|
---|
194 | {
|
---|
195 | HGCMMsgCancelPendingWaits Msg;
|
---|
196 |
|
---|
197 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
198 | Msg.hdr.u32ClientID = uClientId;
|
---|
199 | Msg.hdr.u32Function = GUEST_CANCEL_PENDING_WAITS;
|
---|
200 | Msg.hdr.cParms = 0;
|
---|
201 |
|
---|
202 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
203 | if (RT_SUCCESS(rc))
|
---|
204 | {
|
---|
205 | int rc2 = Msg.hdr.result;
|
---|
206 | if (RT_FAILURE(rc2))
|
---|
207 | rc = rc2;
|
---|
208 | }
|
---|
209 | return rc;
|
---|
210 | }
|
---|
211 |
|
---|
212 |
|
---|
213 | VBGLR3DECL(int) VbglR3GuestCtrlSessionNotify(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
214 | uint32_t uType, uint32_t uResult)
|
---|
215 | {
|
---|
216 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
217 |
|
---|
218 | HGCMMsgSessionNotify Msg;
|
---|
219 |
|
---|
220 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
221 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
222 | Msg.hdr.u32Function = GUEST_SESSION_NOTIFY;
|
---|
223 | Msg.hdr.cParms = 3;
|
---|
224 |
|
---|
225 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
226 | VbglHGCMParmUInt32Set(&Msg.type, uType);
|
---|
227 | VbglHGCMParmUInt32Set(&Msg.result, uResult);
|
---|
228 |
|
---|
229 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
230 | if (RT_SUCCESS(rc))
|
---|
231 | {
|
---|
232 | int rc2 = Msg.hdr.result;
|
---|
233 | if (RT_FAILURE(rc2))
|
---|
234 | rc = rc2;
|
---|
235 | }
|
---|
236 | return rc;
|
---|
237 | }
|
---|
238 |
|
---|
239 |
|
---|
240 | /**
|
---|
241 | * Retrieves the request to create a new guest session.
|
---|
242 | *
|
---|
243 | * @return IPRT status code.
|
---|
244 | * @param pCtx Host context.
|
---|
245 | ** @todo Docs!
|
---|
246 | */
|
---|
247 | VBGLR3DECL(int) VbglR3GuestCtrlSessionGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
248 | uint32_t *puProtocol,
|
---|
249 | char *pszUser, uint32_t cbUser,
|
---|
250 | char *pszPassword, uint32_t cbPassword,
|
---|
251 | char *pszDomain, uint32_t cbDomain,
|
---|
252 | uint32_t *puFlags, uint32_t *puSessionID)
|
---|
253 | {
|
---|
254 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
255 | AssertReturn(pCtx->uNumParms == 6, VERR_INVALID_PARAMETER);
|
---|
256 |
|
---|
257 | AssertPtrReturn(puProtocol, VERR_INVALID_POINTER);
|
---|
258 | AssertPtrReturn(pszUser, VERR_INVALID_POINTER);
|
---|
259 | AssertPtrReturn(pszPassword, VERR_INVALID_POINTER);
|
---|
260 | AssertPtrReturn(pszDomain, VERR_INVALID_POINTER);
|
---|
261 | AssertPtrReturn(puFlags, VERR_INVALID_POINTER);
|
---|
262 |
|
---|
263 | HGCMMsgSessionOpen Msg;
|
---|
264 |
|
---|
265 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
266 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
267 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
268 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
269 |
|
---|
270 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
271 | VbglHGCMParmUInt32Set(&Msg.protocol, 0);
|
---|
272 | VbglHGCMParmPtrSet(&Msg.username, pszUser, cbUser);
|
---|
273 | VbglHGCMParmPtrSet(&Msg.password, pszPassword, cbPassword);
|
---|
274 | VbglHGCMParmPtrSet(&Msg.domain, pszDomain, cbDomain);
|
---|
275 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
276 |
|
---|
277 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
278 | if (RT_SUCCESS(rc))
|
---|
279 | {
|
---|
280 | int rc2 = Msg.hdr.result;
|
---|
281 | if (RT_FAILURE(rc2))
|
---|
282 | {
|
---|
283 | rc = rc2;
|
---|
284 | }
|
---|
285 | else
|
---|
286 | {
|
---|
287 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
288 | Msg.protocol.GetUInt32(puProtocol);
|
---|
289 | Msg.flags.GetUInt32(puFlags);
|
---|
290 |
|
---|
291 | if (puSessionID)
|
---|
292 | *puSessionID = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pCtx->uContextID);
|
---|
293 | }
|
---|
294 | }
|
---|
295 |
|
---|
296 | return rc;
|
---|
297 | }
|
---|
298 |
|
---|
299 |
|
---|
300 | /**
|
---|
301 | * Retrieves the request to terminate an existing guest session.
|
---|
302 | *
|
---|
303 | * @return IPRT status code.
|
---|
304 | * @param pCtx Host context.
|
---|
305 | ** @todo Docs!
|
---|
306 | */
|
---|
307 | VBGLR3DECL(int) VbglR3GuestCtrlSessionGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puFlags, uint32_t *puSessionID)
|
---|
308 | {
|
---|
309 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
310 | AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
|
---|
311 |
|
---|
312 | AssertPtrReturn(puFlags, VERR_INVALID_POINTER);
|
---|
313 |
|
---|
314 | HGCMMsgSessionClose Msg;
|
---|
315 |
|
---|
316 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
317 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
318 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
319 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
320 |
|
---|
321 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
322 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
323 |
|
---|
324 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
325 | if (RT_SUCCESS(rc))
|
---|
326 | {
|
---|
327 | int rc2 = Msg.hdr.result;
|
---|
328 | if (RT_FAILURE(rc2))
|
---|
329 | {
|
---|
330 | rc = rc2;
|
---|
331 | }
|
---|
332 | else
|
---|
333 | {
|
---|
334 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
335 | Msg.flags.GetUInt32(puFlags);
|
---|
336 |
|
---|
337 | if (puSessionID)
|
---|
338 | *puSessionID = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pCtx->uContextID);
|
---|
339 | }
|
---|
340 | }
|
---|
341 |
|
---|
342 | return rc;
|
---|
343 | }
|
---|
344 |
|
---|
345 |
|
---|
346 | /**
|
---|
347 | * Allocates and gets host data, based on the message id.
|
---|
348 | *
|
---|
349 | * This will block until data becomes available.
|
---|
350 | *
|
---|
351 | * @returns VBox status code.
|
---|
352 | ** @todo Docs!
|
---|
353 | ** @todo Move the parameters in an own struct!
|
---|
354 | */
|
---|
355 | VBGLR3DECL(int) VbglR3GuestCtrlProcGetStart(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
356 | char *pszCmd, uint32_t cbCmd,
|
---|
357 | uint32_t *puFlags,
|
---|
358 | char *pszArgs, uint32_t cbArgs, uint32_t *pcArgs,
|
---|
359 | char *pszEnv, uint32_t *pcbEnv, uint32_t *pcEnvVars,
|
---|
360 | char *pszUser, uint32_t cbUser,
|
---|
361 | char *pszPassword, uint32_t cbPassword,
|
---|
362 | uint32_t *puTimeoutMS,
|
---|
363 | uint32_t *puPriority,
|
---|
364 | uint64_t *puAffinity, uint32_t cbAffinity, uint32_t *pcAffinity)
|
---|
365 | {
|
---|
366 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
367 |
|
---|
368 | AssertPtrReturn(pszCmd, VERR_INVALID_POINTER);
|
---|
369 | AssertPtrReturn(puFlags, VERR_INVALID_POINTER);
|
---|
370 | AssertPtrReturn(pszArgs, VERR_INVALID_POINTER);
|
---|
371 | AssertPtrReturn(pcArgs, VERR_INVALID_POINTER);
|
---|
372 | AssertPtrReturn(pszEnv, VERR_INVALID_POINTER);
|
---|
373 | AssertPtrReturn(pcbEnv, VERR_INVALID_POINTER);
|
---|
374 | AssertPtrReturn(pcEnvVars, VERR_INVALID_POINTER);
|
---|
375 | AssertPtrReturn(puTimeoutMS, VERR_INVALID_POINTER);
|
---|
376 |
|
---|
377 | HGCMMsgProcExec Msg;
|
---|
378 |
|
---|
379 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
380 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
381 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
382 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
383 |
|
---|
384 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
385 | VbglHGCMParmPtrSet(&Msg.cmd, pszCmd, cbCmd);
|
---|
386 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
387 | VbglHGCMParmUInt32Set(&Msg.num_args, 0);
|
---|
388 | VbglHGCMParmPtrSet(&Msg.args, pszArgs, cbArgs);
|
---|
389 | VbglHGCMParmUInt32Set(&Msg.num_env, 0);
|
---|
390 | VbglHGCMParmUInt32Set(&Msg.cb_env, 0);
|
---|
391 | VbglHGCMParmPtrSet(&Msg.env, pszEnv, *pcbEnv);
|
---|
392 | if (pCtx->uProtocol < 2)
|
---|
393 | {
|
---|
394 | AssertPtrReturn(pszUser, VERR_INVALID_POINTER);
|
---|
395 | AssertReturn(cbUser, VERR_INVALID_PARAMETER);
|
---|
396 | AssertPtrReturn(pszPassword, VERR_INVALID_POINTER);
|
---|
397 | AssertReturn(pszPassword, VERR_INVALID_PARAMETER);
|
---|
398 |
|
---|
399 | VbglHGCMParmPtrSet(&Msg.u.v1.username, pszUser, cbUser);
|
---|
400 | VbglHGCMParmPtrSet(&Msg.u.v1.password, pszPassword, cbPassword);
|
---|
401 | VbglHGCMParmUInt32Set(&Msg.u.v1.timeout, 0);
|
---|
402 | }
|
---|
403 | else
|
---|
404 | {
|
---|
405 | AssertPtrReturn(puAffinity, VERR_INVALID_POINTER);
|
---|
406 | AssertReturn(cbAffinity, VERR_INVALID_PARAMETER);
|
---|
407 |
|
---|
408 | VbglHGCMParmUInt32Set(&Msg.u.v2.timeout, 0);
|
---|
409 | VbglHGCMParmUInt32Set(&Msg.u.v2.priority, 0);
|
---|
410 | VbglHGCMParmUInt32Set(&Msg.u.v2.num_affinity, 0);
|
---|
411 | VbglHGCMParmPtrSet(&Msg.u.v2.affinity, puAffinity, cbAffinity);
|
---|
412 | }
|
---|
413 |
|
---|
414 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
415 | if (RT_SUCCESS(rc))
|
---|
416 | {
|
---|
417 | int rc2 = Msg.hdr.result;
|
---|
418 | if (RT_FAILURE(rc2))
|
---|
419 | {
|
---|
420 | rc = rc2;
|
---|
421 | }
|
---|
422 | else
|
---|
423 | {
|
---|
424 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
425 | Msg.flags.GetUInt32(puFlags);
|
---|
426 | Msg.num_args.GetUInt32(pcArgs);
|
---|
427 | Msg.num_env.GetUInt32(pcEnvVars);
|
---|
428 | Msg.cb_env.GetUInt32(pcbEnv);
|
---|
429 | if (pCtx->uProtocol < 2)
|
---|
430 | {
|
---|
431 | Msg.u.v1.timeout.GetUInt32(puTimeoutMS);
|
---|
432 | }
|
---|
433 | else
|
---|
434 | {
|
---|
435 | Msg.u.v2.timeout.GetUInt32(puTimeoutMS);
|
---|
436 | Msg.u.v2.priority.GetUInt32(puPriority);
|
---|
437 | Msg.u.v2.num_affinity.GetUInt32(pcAffinity);
|
---|
438 | }
|
---|
439 | }
|
---|
440 | }
|
---|
441 | return rc;
|
---|
442 | }
|
---|
443 |
|
---|
444 |
|
---|
445 | /**
|
---|
446 | * Allocates and gets host data, based on the message id.
|
---|
447 | *
|
---|
448 | * This will block until data becomes available.
|
---|
449 | *
|
---|
450 | * @returns VBox status code.
|
---|
451 | ** @todo Docs!
|
---|
452 | */
|
---|
453 | VBGLR3DECL(int) VbglR3GuestCtrlProcGetOutput(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
454 | uint32_t *puPID, uint32_t *puHandle, uint32_t *puFlags)
|
---|
455 | {
|
---|
456 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
457 | AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
|
---|
458 |
|
---|
459 | AssertPtrReturn(puPID, VERR_INVALID_POINTER);
|
---|
460 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
461 | AssertPtrReturn(puFlags, VERR_INVALID_POINTER);
|
---|
462 |
|
---|
463 | HGCMMsgProcOutput Msg;
|
---|
464 |
|
---|
465 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
466 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
467 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
468 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
469 |
|
---|
470 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
471 | VbglHGCMParmUInt32Set(&Msg.pid, 0);
|
---|
472 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
473 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
474 |
|
---|
475 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
476 | if (RT_SUCCESS(rc))
|
---|
477 | {
|
---|
478 | int rc2 = Msg.hdr.result;
|
---|
479 | if (RT_FAILURE(rc2))
|
---|
480 | {
|
---|
481 | rc = rc2;
|
---|
482 | }
|
---|
483 | else
|
---|
484 | {
|
---|
485 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
486 | Msg.pid.GetUInt32(puPID);
|
---|
487 | Msg.handle.GetUInt32(puHandle);
|
---|
488 | Msg.flags.GetUInt32(puFlags);
|
---|
489 | }
|
---|
490 | }
|
---|
491 | return rc;
|
---|
492 | }
|
---|
493 |
|
---|
494 |
|
---|
495 | /**
|
---|
496 | * Retrieves the input data from host which then gets sent to the
|
---|
497 | * started process.
|
---|
498 | *
|
---|
499 | * This will block until data becomes available.
|
---|
500 | *
|
---|
501 | * @returns VBox status code.
|
---|
502 | ** @todo Docs!
|
---|
503 | */
|
---|
504 | VBGLR3DECL(int) VbglR3GuestCtrlProcGetInput(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
505 | uint32_t *puPID, uint32_t *puFlags,
|
---|
506 | void *pvData, uint32_t cbData,
|
---|
507 | uint32_t *pcbSize)
|
---|
508 | {
|
---|
509 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
510 | AssertReturn(pCtx->uNumParms == 5, VERR_INVALID_PARAMETER);
|
---|
511 |
|
---|
512 | AssertPtrReturn(puPID, VERR_INVALID_POINTER);
|
---|
513 | AssertPtrReturn(puFlags, VERR_INVALID_POINTER);
|
---|
514 | AssertPtrReturn(pvData, VERR_INVALID_POINTER);
|
---|
515 | AssertPtrReturn(pcbSize, VERR_INVALID_POINTER);
|
---|
516 |
|
---|
517 | HGCMMsgProcInput Msg;
|
---|
518 |
|
---|
519 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
520 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
521 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
522 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
523 |
|
---|
524 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
525 | VbglHGCMParmUInt32Set(&Msg.pid, 0);
|
---|
526 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
527 | VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
|
---|
528 | VbglHGCMParmUInt32Set(&Msg.size, 0);
|
---|
529 |
|
---|
530 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
531 | if (RT_SUCCESS(rc))
|
---|
532 | {
|
---|
533 | int rc2 = Msg.hdr.result;
|
---|
534 | if (RT_FAILURE(rc2))
|
---|
535 | {
|
---|
536 | rc = rc2;
|
---|
537 | }
|
---|
538 | else
|
---|
539 | {
|
---|
540 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
541 | Msg.pid.GetUInt32(puPID);
|
---|
542 | Msg.flags.GetUInt32(puFlags);
|
---|
543 | Msg.size.GetUInt32(pcbSize);
|
---|
544 | }
|
---|
545 | }
|
---|
546 | return rc;
|
---|
547 | }
|
---|
548 |
|
---|
549 |
|
---|
550 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
551 | char *pszFileName, uint32_t cbFileName,
|
---|
552 | char *pszOpenMode, uint32_t cbOpenMode,
|
---|
553 | char *pszDisposition, uint32_t cbDisposition,
|
---|
554 | uint32_t *puCreationMode,
|
---|
555 | uint64_t *puOffset)
|
---|
556 | {
|
---|
557 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
558 | AssertReturn(pCtx->uNumParms == 6, VERR_INVALID_PARAMETER);
|
---|
559 |
|
---|
560 | AssertPtrReturn(pszFileName, VERR_INVALID_POINTER);
|
---|
561 | AssertReturn(cbFileName, VERR_INVALID_PARAMETER);
|
---|
562 | AssertPtrReturn(pszOpenMode, VERR_INVALID_POINTER);
|
---|
563 | AssertReturn(cbOpenMode, VERR_INVALID_PARAMETER);
|
---|
564 | AssertPtrReturn(pszDisposition, VERR_INVALID_POINTER);
|
---|
565 | AssertReturn(cbDisposition, VERR_INVALID_PARAMETER);
|
---|
566 | AssertPtrReturn(puCreationMode, VERR_INVALID_POINTER);
|
---|
567 | AssertPtrReturn(puOffset, VERR_INVALID_POINTER);
|
---|
568 |
|
---|
569 | HGCMMsgFileOpen Msg;
|
---|
570 |
|
---|
571 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
572 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
573 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
574 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
575 |
|
---|
576 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
577 | VbglHGCMParmPtrSet(&Msg.filename, pszFileName, cbFileName);
|
---|
578 | VbglHGCMParmPtrSet(&Msg.openmode, pszOpenMode, cbOpenMode);
|
---|
579 | VbglHGCMParmPtrSet(&Msg.disposition, pszDisposition, cbDisposition);
|
---|
580 | VbglHGCMParmUInt32Set(&Msg.creationmode, 0);
|
---|
581 | VbglHGCMParmUInt64Set(&Msg.offset, 0);
|
---|
582 |
|
---|
583 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
584 | if (RT_SUCCESS(rc))
|
---|
585 | {
|
---|
586 | int rc2 = Msg.hdr.result;
|
---|
587 | if (RT_FAILURE(rc2))
|
---|
588 | {
|
---|
589 | rc = rc2;
|
---|
590 | }
|
---|
591 | else
|
---|
592 | {
|
---|
593 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
594 | Msg.creationmode.GetUInt32(puCreationMode);
|
---|
595 | Msg.offset.GetUInt64(puOffset);
|
---|
596 | }
|
---|
597 | }
|
---|
598 | return rc;
|
---|
599 | }
|
---|
600 |
|
---|
601 |
|
---|
602 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle)
|
---|
603 | {
|
---|
604 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
605 |
|
---|
606 | AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
|
---|
607 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
608 |
|
---|
609 | HGCMMsgFileClose 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.handle, 0);
|
---|
618 |
|
---|
619 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
620 | if (RT_SUCCESS(rc))
|
---|
621 | {
|
---|
622 | int rc2 = Msg.hdr.result;
|
---|
623 | if (RT_FAILURE(rc2))
|
---|
624 | {
|
---|
625 | rc = rc2;
|
---|
626 | }
|
---|
627 | else
|
---|
628 | {
|
---|
629 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
630 | Msg.handle.GetUInt32(puHandle);
|
---|
631 | }
|
---|
632 | }
|
---|
633 | return rc;
|
---|
634 | }
|
---|
635 |
|
---|
636 |
|
---|
637 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetRead(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
638 | uint32_t *puHandle, uint32_t *puToRead)
|
---|
639 | {
|
---|
640 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
641 |
|
---|
642 | AssertReturn(pCtx->uNumParms == 3, VERR_INVALID_PARAMETER);
|
---|
643 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
644 | AssertPtrReturn(puToRead, VERR_INVALID_POINTER);
|
---|
645 |
|
---|
646 | HGCMMsgFileRead Msg;
|
---|
647 |
|
---|
648 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
649 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
650 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
651 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
652 |
|
---|
653 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
654 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
655 | VbglHGCMParmUInt32Set(&Msg.size, 0);
|
---|
656 |
|
---|
657 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
658 | if (RT_SUCCESS(rc))
|
---|
659 | {
|
---|
660 | int rc2 = Msg.hdr.result;
|
---|
661 | if (RT_FAILURE(rc2))
|
---|
662 | {
|
---|
663 | rc = rc2;
|
---|
664 | }
|
---|
665 | else
|
---|
666 | {
|
---|
667 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
668 | Msg.handle.GetUInt32(puHandle);
|
---|
669 | Msg.size.GetUInt32(puToRead);
|
---|
670 | }
|
---|
671 | }
|
---|
672 | return rc;
|
---|
673 | }
|
---|
674 |
|
---|
675 |
|
---|
676 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetReadAt(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
677 | uint32_t *puHandle, uint32_t *puToRead, uint64_t *puOffset)
|
---|
678 | {
|
---|
679 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
680 |
|
---|
681 | AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
|
---|
682 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
683 | AssertPtrReturn(puToRead, VERR_INVALID_POINTER);
|
---|
684 |
|
---|
685 | HGCMMsgFileReadAt Msg;
|
---|
686 |
|
---|
687 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
688 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
689 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
690 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
691 |
|
---|
692 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
693 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
694 | VbglHGCMParmUInt32Set(&Msg.offset, 0);
|
---|
695 | VbglHGCMParmUInt32Set(&Msg.size, 0);
|
---|
696 |
|
---|
697 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
698 | if (RT_SUCCESS(rc))
|
---|
699 | {
|
---|
700 | int rc2 = Msg.hdr.result;
|
---|
701 | if (RT_FAILURE(rc2))
|
---|
702 | {
|
---|
703 | rc = rc2;
|
---|
704 | }
|
---|
705 | else
|
---|
706 | {
|
---|
707 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
708 | Msg.handle.GetUInt32(puHandle);
|
---|
709 | Msg.offset.GetUInt64(puOffset);
|
---|
710 | Msg.size.GetUInt32(puToRead);
|
---|
711 | }
|
---|
712 | }
|
---|
713 | return rc;
|
---|
714 | }
|
---|
715 |
|
---|
716 |
|
---|
717 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetWrite(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle,
|
---|
718 | void *pvData, uint32_t cbData, uint32_t *pcbSize)
|
---|
719 | {
|
---|
720 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
721 |
|
---|
722 | AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
|
---|
723 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
724 | AssertPtrReturn(pvData, VERR_INVALID_POINTER);
|
---|
725 | AssertReturn(cbData, VERR_INVALID_PARAMETER);
|
---|
726 | AssertPtrReturn(pcbSize, VERR_INVALID_POINTER);
|
---|
727 |
|
---|
728 | HGCMMsgFileWrite Msg;
|
---|
729 |
|
---|
730 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
731 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
732 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
733 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
734 |
|
---|
735 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
736 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
737 | VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
|
---|
738 | VbglHGCMParmUInt32Set(&Msg.size, 0);
|
---|
739 |
|
---|
740 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
741 | if (RT_SUCCESS(rc))
|
---|
742 | {
|
---|
743 | int rc2 = Msg.hdr.result;
|
---|
744 | if (RT_FAILURE(rc2))
|
---|
745 | {
|
---|
746 | rc = rc2;
|
---|
747 | }
|
---|
748 | else
|
---|
749 | {
|
---|
750 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
751 | Msg.handle.GetUInt32(puHandle);
|
---|
752 | Msg.size.GetUInt32(pcbSize);
|
---|
753 | }
|
---|
754 | }
|
---|
755 | return rc;
|
---|
756 | }
|
---|
757 |
|
---|
758 |
|
---|
759 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetWriteAt(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle,
|
---|
760 | void *pvData, uint32_t cbData, uint32_t *pcbSize, uint64_t *puOffset)
|
---|
761 | {
|
---|
762 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
763 |
|
---|
764 | AssertReturn(pCtx->uNumParms == 5, VERR_INVALID_PARAMETER);
|
---|
765 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
766 | AssertPtrReturn(pvData, VERR_INVALID_POINTER);
|
---|
767 | AssertReturn(cbData, VERR_INVALID_PARAMETER);
|
---|
768 | AssertPtrReturn(pcbSize, VERR_INVALID_POINTER);
|
---|
769 |
|
---|
770 | HGCMMsgFileWriteAt Msg;
|
---|
771 |
|
---|
772 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
773 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
774 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
775 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
776 |
|
---|
777 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
778 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
779 | VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
|
---|
780 | VbglHGCMParmUInt32Set(&Msg.size, 0);
|
---|
781 | VbglHGCMParmUInt32Set(&Msg.offset, 0);
|
---|
782 |
|
---|
783 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
784 | if (RT_SUCCESS(rc))
|
---|
785 | {
|
---|
786 | int rc2 = Msg.hdr.result;
|
---|
787 | if (RT_FAILURE(rc2))
|
---|
788 | {
|
---|
789 | rc = rc2;
|
---|
790 | }
|
---|
791 | else
|
---|
792 | {
|
---|
793 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
794 | Msg.handle.GetUInt32(puHandle);
|
---|
795 | Msg.size.GetUInt32(pcbSize);
|
---|
796 | }
|
---|
797 | }
|
---|
798 | return rc;
|
---|
799 | }
|
---|
800 |
|
---|
801 |
|
---|
802 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetSeek(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
803 | uint32_t *puHandle, uint32_t *puSeekMethod, uint64_t *puOffset)
|
---|
804 | {
|
---|
805 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
806 |
|
---|
807 | AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
|
---|
808 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
809 | AssertPtrReturn(puSeekMethod, VERR_INVALID_POINTER);
|
---|
810 | AssertPtrReturn(puOffset, VERR_INVALID_POINTER);
|
---|
811 |
|
---|
812 | HGCMMsgFileSeek Msg;
|
---|
813 |
|
---|
814 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
815 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
816 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
817 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
818 |
|
---|
819 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
820 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
821 | VbglHGCMParmUInt32Set(&Msg.method, 0);
|
---|
822 | VbglHGCMParmUInt64Set(&Msg.offset, 0);
|
---|
823 |
|
---|
824 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
825 | if (RT_SUCCESS(rc))
|
---|
826 | {
|
---|
827 | int rc2 = Msg.hdr.result;
|
---|
828 | if (RT_FAILURE(rc2))
|
---|
829 | {
|
---|
830 | rc = rc2;
|
---|
831 | }
|
---|
832 | else
|
---|
833 | {
|
---|
834 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
835 | Msg.handle.GetUInt32(puHandle);
|
---|
836 | Msg.method.GetUInt32(puSeekMethod);
|
---|
837 | Msg.offset.GetUInt64(puOffset);
|
---|
838 | }
|
---|
839 | }
|
---|
840 | return rc;
|
---|
841 | }
|
---|
842 |
|
---|
843 |
|
---|
844 | VBGLR3DECL(int) VbglR3GuestCtrlFileGetTell(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle)
|
---|
845 | {
|
---|
846 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
847 |
|
---|
848 | AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
|
---|
849 | AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
|
---|
850 |
|
---|
851 | HGCMMsgFileTell Msg;
|
---|
852 |
|
---|
853 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
854 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
855 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
856 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
857 |
|
---|
858 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
859 | VbglHGCMParmUInt32Set(&Msg.handle, 0);
|
---|
860 |
|
---|
861 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
862 | if (RT_SUCCESS(rc))
|
---|
863 | {
|
---|
864 | int rc2 = Msg.hdr.result;
|
---|
865 | if (RT_FAILURE(rc2))
|
---|
866 | {
|
---|
867 | rc = rc2;
|
---|
868 | }
|
---|
869 | else
|
---|
870 | {
|
---|
871 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
872 | Msg.handle.GetUInt32(puHandle);
|
---|
873 | }
|
---|
874 | }
|
---|
875 | return rc;
|
---|
876 | }
|
---|
877 |
|
---|
878 |
|
---|
879 | VBGLR3DECL(int) VbglR3GuestCtrlProcGetTerminate(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puPID)
|
---|
880 | {
|
---|
881 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
882 |
|
---|
883 | AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
|
---|
884 | AssertPtrReturn(puPID, VERR_INVALID_POINTER);
|
---|
885 |
|
---|
886 | HGCMMsgProcTerminate Msg;
|
---|
887 |
|
---|
888 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
889 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
890 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
891 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
892 |
|
---|
893 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
894 | VbglHGCMParmUInt32Set(&Msg.pid, 0);
|
---|
895 |
|
---|
896 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
897 | if (RT_SUCCESS(rc))
|
---|
898 | {
|
---|
899 | int rc2 = Msg.hdr.result;
|
---|
900 | if (RT_FAILURE(rc2))
|
---|
901 | {
|
---|
902 | rc = rc2;
|
---|
903 | }
|
---|
904 | else
|
---|
905 | {
|
---|
906 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
907 | Msg.pid.GetUInt32(puPID);
|
---|
908 | }
|
---|
909 | }
|
---|
910 | return rc;
|
---|
911 | }
|
---|
912 |
|
---|
913 |
|
---|
914 | VBGLR3DECL(int) VbglR3GuestCtrlProcGetWaitFor(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
915 | uint32_t *puPID, uint32_t *puWaitFlags, uint32_t *puTimeoutMS)
|
---|
916 | {
|
---|
917 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
918 |
|
---|
919 | AssertReturn(pCtx->uNumParms == 5, VERR_INVALID_PARAMETER);
|
---|
920 | AssertPtrReturn(puPID, VERR_INVALID_POINTER);
|
---|
921 |
|
---|
922 | HGCMMsgProcWaitFor Msg;
|
---|
923 |
|
---|
924 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
925 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
926 | Msg.hdr.u32Function = GUEST_MSG_WAIT;
|
---|
927 | Msg.hdr.cParms = pCtx->uNumParms;
|
---|
928 |
|
---|
929 | VbglHGCMParmUInt32Set(&Msg.context, 0);
|
---|
930 | VbglHGCMParmUInt32Set(&Msg.pid, 0);
|
---|
931 | VbglHGCMParmUInt32Set(&Msg.flags, 0);
|
---|
932 | VbglHGCMParmUInt32Set(&Msg.timeout, 0);
|
---|
933 |
|
---|
934 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
935 | if (RT_SUCCESS(rc))
|
---|
936 | {
|
---|
937 | int rc2 = Msg.hdr.result;
|
---|
938 | if (RT_FAILURE(rc2))
|
---|
939 | {
|
---|
940 | rc = rc2;
|
---|
941 | }
|
---|
942 | else
|
---|
943 | {
|
---|
944 | Msg.context.GetUInt32(&pCtx->uContextID);
|
---|
945 | Msg.pid.GetUInt32(puPID);
|
---|
946 | Msg.flags.GetUInt32(puWaitFlags);
|
---|
947 | Msg.timeout.GetUInt32(puTimeoutMS);
|
---|
948 | }
|
---|
949 | }
|
---|
950 | return rc;
|
---|
951 | }
|
---|
952 |
|
---|
953 |
|
---|
954 | VBGLR3DECL(int) VbglR3GuestCtrlFileCbOpen(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
955 | uint32_t uRc, uint32_t uFileHandle)
|
---|
956 | {
|
---|
957 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
958 |
|
---|
959 | HGCMReplyFileNotify Msg;
|
---|
960 |
|
---|
961 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
962 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
963 | Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
|
---|
964 | Msg.hdr.cParms = 4;
|
---|
965 |
|
---|
966 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
967 | VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_OPEN);
|
---|
968 | VbglHGCMParmUInt32Set(&Msg.rc, uRc);
|
---|
969 |
|
---|
970 | VbglHGCMParmUInt32Set(&Msg.u.open.handle, uFileHandle);
|
---|
971 |
|
---|
972 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
973 | if (RT_SUCCESS(rc))
|
---|
974 | {
|
---|
975 | int rc2 = Msg.hdr.result;
|
---|
976 | if (RT_FAILURE(rc2))
|
---|
977 | rc = rc2;
|
---|
978 | }
|
---|
979 | return rc;
|
---|
980 | }
|
---|
981 |
|
---|
982 |
|
---|
983 | VBGLR3DECL(int) VbglR3GuestCtrlFileCbClose(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
984 | uint32_t uRc)
|
---|
985 | {
|
---|
986 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
987 |
|
---|
988 | HGCMReplyFileNotify Msg;
|
---|
989 |
|
---|
990 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
991 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
992 | Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
|
---|
993 | Msg.hdr.cParms = 3;
|
---|
994 |
|
---|
995 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
996 | VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_CLOSE);
|
---|
997 | VbglHGCMParmUInt32Set(&Msg.rc, uRc);
|
---|
998 |
|
---|
999 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1000 | if (RT_SUCCESS(rc))
|
---|
1001 | {
|
---|
1002 | int rc2 = Msg.hdr.result;
|
---|
1003 | if (RT_FAILURE(rc2))
|
---|
1004 | rc = rc2;
|
---|
1005 | }
|
---|
1006 | return rc;
|
---|
1007 | }
|
---|
1008 |
|
---|
1009 |
|
---|
1010 | VBGLR3DECL(int) VbglR3GuestCtrlFileCbRead(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
1011 | uint32_t uRc,
|
---|
1012 | void *pvData, uint32_t cbData)
|
---|
1013 | {
|
---|
1014 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1015 |
|
---|
1016 | HGCMReplyFileNotify Msg;
|
---|
1017 |
|
---|
1018 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1019 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1020 | Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
|
---|
1021 | Msg.hdr.cParms = 4;
|
---|
1022 |
|
---|
1023 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
1024 | VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_READ);
|
---|
1025 | VbglHGCMParmUInt32Set(&Msg.rc, uRc);
|
---|
1026 |
|
---|
1027 | VbglHGCMParmPtrSet(&Msg.u.read.data, pvData, cbData);
|
---|
1028 |
|
---|
1029 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1030 | if (RT_SUCCESS(rc))
|
---|
1031 | {
|
---|
1032 | int rc2 = Msg.hdr.result;
|
---|
1033 | if (RT_FAILURE(rc2))
|
---|
1034 | rc = rc2;
|
---|
1035 | }
|
---|
1036 | return rc;
|
---|
1037 | }
|
---|
1038 |
|
---|
1039 |
|
---|
1040 | VBGLR3DECL(int) VbglR3GuestCtrlFileCbWrite(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
1041 | uint32_t uRc, uint32_t uWritten)
|
---|
1042 | {
|
---|
1043 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1044 |
|
---|
1045 | HGCMReplyFileNotify Msg;
|
---|
1046 |
|
---|
1047 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1048 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1049 | Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
|
---|
1050 | Msg.hdr.cParms = 4;
|
---|
1051 |
|
---|
1052 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
1053 | VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_WRITE);
|
---|
1054 | VbglHGCMParmUInt32Set(&Msg.rc, uRc);
|
---|
1055 |
|
---|
1056 | VbglHGCMParmUInt32Set(&Msg.u.write.written, uWritten);
|
---|
1057 |
|
---|
1058 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1059 | if (RT_SUCCESS(rc))
|
---|
1060 | {
|
---|
1061 | int rc2 = Msg.hdr.result;
|
---|
1062 | if (RT_FAILURE(rc2))
|
---|
1063 | rc = rc2;
|
---|
1064 | }
|
---|
1065 | return rc;
|
---|
1066 | }
|
---|
1067 |
|
---|
1068 |
|
---|
1069 | VBGLR3DECL(int) VbglR3GuestCtrlFileCbSeek(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
1070 | uint32_t uRc, uint64_t uOffActual)
|
---|
1071 | {
|
---|
1072 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1073 |
|
---|
1074 | HGCMReplyFileNotify Msg;
|
---|
1075 |
|
---|
1076 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1077 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1078 | Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
|
---|
1079 | Msg.hdr.cParms = 4;
|
---|
1080 |
|
---|
1081 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
1082 | VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_SEEK);
|
---|
1083 | VbglHGCMParmUInt32Set(&Msg.rc, uRc);
|
---|
1084 |
|
---|
1085 | VbglHGCMParmUInt64Set(&Msg.u.seek.offset, uOffActual);
|
---|
1086 |
|
---|
1087 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1088 | if (RT_SUCCESS(rc))
|
---|
1089 | {
|
---|
1090 | int rc2 = Msg.hdr.result;
|
---|
1091 | if (RT_FAILURE(rc2))
|
---|
1092 | rc = rc2;
|
---|
1093 | }
|
---|
1094 | return rc;
|
---|
1095 | }
|
---|
1096 |
|
---|
1097 |
|
---|
1098 | VBGLR3DECL(int) VbglR3GuestCtrlFileCbTell(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
1099 | uint32_t uRc, uint64_t uOffActual)
|
---|
1100 | {
|
---|
1101 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1102 |
|
---|
1103 | HGCMReplyFileNotify Msg;
|
---|
1104 |
|
---|
1105 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1106 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1107 | Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
|
---|
1108 | Msg.hdr.cParms = 4;
|
---|
1109 |
|
---|
1110 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
1111 | VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_TELL);
|
---|
1112 | VbglHGCMParmUInt32Set(&Msg.rc, uRc);
|
---|
1113 |
|
---|
1114 | VbglHGCMParmUInt64Set(&Msg.u.tell.offset, uOffActual);
|
---|
1115 |
|
---|
1116 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1117 | if (RT_SUCCESS(rc))
|
---|
1118 | {
|
---|
1119 | int rc2 = Msg.hdr.result;
|
---|
1120 | if (RT_FAILURE(rc2))
|
---|
1121 | rc = rc2;
|
---|
1122 | }
|
---|
1123 | return rc;
|
---|
1124 | }
|
---|
1125 |
|
---|
1126 |
|
---|
1127 | /**
|
---|
1128 | * Callback for reporting a guest process status (along with some other stuff) to the host.
|
---|
1129 | *
|
---|
1130 | * @returns VBox status code.
|
---|
1131 | ** @todo Docs!
|
---|
1132 | */
|
---|
1133 | VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatus(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
1134 | uint32_t uPID, uint32_t uStatus, uint32_t uFlags,
|
---|
1135 | void *pvData, uint32_t cbData)
|
---|
1136 | {
|
---|
1137 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1138 |
|
---|
1139 | HGCMMsgProcStatus Msg;
|
---|
1140 |
|
---|
1141 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1142 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1143 | Msg.hdr.u32Function = GUEST_EXEC_STATUS;
|
---|
1144 | Msg.hdr.cParms = 5;
|
---|
1145 |
|
---|
1146 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
1147 | VbglHGCMParmUInt32Set(&Msg.pid, uPID);
|
---|
1148 | VbglHGCMParmUInt32Set(&Msg.status, uStatus);
|
---|
1149 | VbglHGCMParmUInt32Set(&Msg.flags, uFlags);
|
---|
1150 | VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
|
---|
1151 |
|
---|
1152 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1153 | if (RT_SUCCESS(rc))
|
---|
1154 | {
|
---|
1155 | int rc2 = Msg.hdr.result;
|
---|
1156 | if (RT_FAILURE(rc2))
|
---|
1157 | rc = rc2;
|
---|
1158 | }
|
---|
1159 | return rc;
|
---|
1160 | }
|
---|
1161 |
|
---|
1162 |
|
---|
1163 | /**
|
---|
1164 | * Sends output (from stdout/stderr) from a running process.
|
---|
1165 | *
|
---|
1166 | * @returns VBox status code.
|
---|
1167 | ** @todo Docs!
|
---|
1168 | */
|
---|
1169 | VBGLR3DECL(int) VbglR3GuestCtrlProcCbOutput(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
1170 | uint32_t uPID,uint32_t uHandle, uint32_t uFlags,
|
---|
1171 | void *pvData, uint32_t cbData)
|
---|
1172 | {
|
---|
1173 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1174 |
|
---|
1175 | HGCMMsgProcOutput Msg;
|
---|
1176 |
|
---|
1177 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1178 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1179 | Msg.hdr.u32Function = GUEST_EXEC_OUTPUT;
|
---|
1180 | Msg.hdr.cParms = 5;
|
---|
1181 |
|
---|
1182 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
1183 | VbglHGCMParmUInt32Set(&Msg.pid, uPID);
|
---|
1184 | VbglHGCMParmUInt32Set(&Msg.handle, uHandle);
|
---|
1185 | VbglHGCMParmUInt32Set(&Msg.flags, uFlags);
|
---|
1186 | VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
|
---|
1187 |
|
---|
1188 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1189 | if (RT_SUCCESS(rc))
|
---|
1190 | {
|
---|
1191 | int rc2 = Msg.hdr.result;
|
---|
1192 | if (RT_FAILURE(rc2))
|
---|
1193 | rc = rc2;
|
---|
1194 | }
|
---|
1195 | return rc;
|
---|
1196 | }
|
---|
1197 |
|
---|
1198 |
|
---|
1199 | /**
|
---|
1200 | * Callback for reporting back the input status of a guest process to the host.
|
---|
1201 | *
|
---|
1202 | * @returns VBox status code.
|
---|
1203 | ** @todo Docs!
|
---|
1204 | */
|
---|
1205 | VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatusInput(PVBGLR3GUESTCTRLCMDCTX pCtx,
|
---|
1206 | uint32_t uPID, uint32_t uStatus,
|
---|
1207 | uint32_t uFlags, uint32_t cbWritten)
|
---|
1208 | {
|
---|
1209 | AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
|
---|
1210 |
|
---|
1211 | HGCMMsgProcStatusInput Msg;
|
---|
1212 |
|
---|
1213 | Msg.hdr.result = VERR_WRONG_ORDER;
|
---|
1214 | Msg.hdr.u32ClientID = pCtx->uClientID;
|
---|
1215 | Msg.hdr.u32Function = GUEST_EXEC_INPUT_STATUS;
|
---|
1216 | Msg.hdr.cParms = 5;
|
---|
1217 |
|
---|
1218 | VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
|
---|
1219 | VbglHGCMParmUInt32Set(&Msg.pid, uPID);
|
---|
1220 | VbglHGCMParmUInt32Set(&Msg.status, uStatus);
|
---|
1221 | VbglHGCMParmUInt32Set(&Msg.flags, uFlags);
|
---|
1222 | VbglHGCMParmUInt32Set(&Msg.written, cbWritten);
|
---|
1223 |
|
---|
1224 | int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
|
---|
1225 | if (RT_SUCCESS(rc))
|
---|
1226 | {
|
---|
1227 | int rc2 = Msg.hdr.result;
|
---|
1228 | if (RT_FAILURE(rc2))
|
---|
1229 | rc = rc2;
|
---|
1230 | }
|
---|
1231 | return rc;
|
---|
1232 | }
|
---|
1233 |
|
---|