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