VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibGuestCtrl.cpp@ 70100

Last change on this file since 70100 was 69500, checked in by vboxsync, 7 years ago

*: scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 35.7 KB
Line 
1/* $Id: VBoxGuestR3LibGuestCtrl.cpp 69500 2017-10-28 15:14:05Z vboxsync $ */
2/** @file
3 * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, guest control.
4 */
5
6/*
7 * Copyright (C) 2010-2017 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 "VBoxGuestR3LibInternal.h"
40
41using namespace guestControl;
42
43
44/**
45 * Connects to the guest control service.
46 *
47 * @returns VBox status code
48 * @param pidClient Where to put The client ID on success. The client ID
49 * must be passed to all the other calls to the service.
50 */
51VBGLR3DECL(int) VbglR3GuestCtrlConnect(uint32_t *pidClient)
52{
53 return VbglR3HGCMConnect("VBoxGuestControlSvc", pidClient);
54}
55
56
57/**
58 * Disconnect from the guest control service.
59 *
60 * @returns VBox status code.
61 * @param idClient The client ID returned by VbglR3GuestCtrlConnect().
62 */
63VBGLR3DECL(int) VbglR3GuestCtrlDisconnect(uint32_t idClient)
64{
65 return VbglR3HGCMDisconnect(idClient);
66}
67
68
69/**
70 * Waits until a new host message arrives.
71 * This will block until a message becomes available.
72 *
73 * @returns VBox status code.
74 * @param uClientId The client ID returned by VbglR3GuestCtrlConnect().
75 * @param pidMsg Where to store the message id.
76 * @param pcParameters Where to store the number of parameters which will
77 * be received in a second call to the host.
78 */
79VBGLR3DECL(int) VbglR3GuestCtrlMsgWaitFor(uint32_t uClientId, uint32_t *pidMsg, uint32_t *pcParameters)
80{
81 AssertPtrReturn(pidMsg, VERR_INVALID_POINTER);
82 AssertPtrReturn(pcParameters, VERR_INVALID_POINTER);
83
84 HGCMMsgCmdWaitFor Msg;
85 VBGL_HGCM_HDR_INIT(&Msg.hdr, uClientId,
86 GUEST_MSG_WAIT, /* Tell the host we want our next command. */
87 2); /* Just peek for the next message! */
88 VbglHGCMParmUInt32Set(&Msg.msg, 0);
89 VbglHGCMParmUInt32Set(&Msg.num_parms, 0);
90
91 /*
92 * We should always get a VERR_TOO_MUCH_DATA response here, see
93 * guestControl::HostCommand::Peek() and its caller ClientState::SendReply().
94 * We accept success too here, in case someone decide to make the protocol
95 * slightly more sane.
96 *
97 * Note! A really sane protocol design would have a separate call for getting
98 * info about a pending message (returning VINF_SUCCESS), and a separate
99 * one for retriving the actual message parameters. Not this weird
100 * stuff, to put it rather bluntly.
101 */
102 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
103 if ( rc == VERR_TOO_MUCH_DATA
104 || RT_SUCCESS(rc))
105 {
106 int rc2 = VbglHGCMParmUInt32Get(&Msg.msg, pidMsg);
107 if (RT_SUCCESS(rc2))
108 {
109 rc2 = VbglHGCMParmUInt32Get(&Msg.num_parms, pcParameters);
110 if (RT_SUCCESS(rc2))
111 {
112 /* Ok, so now we know what message type and how much parameters there are. */
113 return rc;
114 }
115 }
116 rc = rc2;
117 }
118 *pidMsg = UINT32_MAX - 1;
119 *pcParameters = UINT32_MAX - 2;
120 return rc;
121}
122
123
124/**
125 * Asks the host guest control service to set a command filter to this
126 * client so that it only will receive certain commands in the future.
127 * The filter(s) are a bitmask for the context IDs, served from the host.
128 *
129 * @return IPRT status code.
130 * @param uClientId The client ID returned by VbglR3GuestCtrlConnect().
131 * @param uValue The value to filter messages for.
132 * @param uMaskAdd Filter mask to add.
133 * @param uMaskRemove Filter mask to remove.
134 */
135VBGLR3DECL(int) VbglR3GuestCtrlMsgFilterSet(uint32_t uClientId, uint32_t uValue,
136 uint32_t uMaskAdd, uint32_t uMaskRemove)
137{
138 HGCMMsgCmdFilterSet Msg;
139
140 /* Tell the host we want to set a filter. */
141 VBGL_HGCM_HDR_INIT(&Msg.hdr, uClientId, GUEST_MSG_FILTER_SET, 4);
142 VbglHGCMParmUInt32Set(&Msg.value, uValue);
143 VbglHGCMParmUInt32Set(&Msg.mask_add, uMaskAdd);
144 VbglHGCMParmUInt32Set(&Msg.mask_remove, uMaskRemove);
145 VbglHGCMParmUInt32Set(&Msg.flags, 0 /* Flags, unused */);
146
147 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
148}
149
150
151/**
152 * Disables a previously set message filter.
153 *
154 * @return IPRT status code.
155 * @param uClientId The client ID returned by VbglR3GuestCtrlConnect().
156 */
157VBGLR3DECL(int) VbglR3GuestCtrlMsgFilterUnset(uint32_t uClientId)
158{
159 /* Tell the host we want to unset the filter. */
160 HGCMMsgCmdFilterUnset Msg;
161 VBGL_HGCM_HDR_INIT(&Msg.hdr, uClientId, GUEST_MSG_FILTER_UNSET, 1);
162 VbglHGCMParmUInt32Set(&Msg.flags, 0 /* Flags, unused */);
163
164 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
165}
166
167
168VBGLR3DECL(int) VbglR3GuestCtrlMsgReply(PVBGLR3GUESTCTRLCMDCTX pCtx,
169 int rc)
170{
171 return VbglR3GuestCtrlMsgReplyEx(pCtx, rc, 0 /* uType */,
172 NULL /* pvPayload */, 0 /* cbPayload */);
173}
174
175
176VBGLR3DECL(int) VbglR3GuestCtrlMsgReplyEx(PVBGLR3GUESTCTRLCMDCTX pCtx,
177 int rc, uint32_t uType,
178 void *pvPayload, uint32_t cbPayload)
179{
180 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
181 /* Everything else is optional. */
182
183 HGCMMsgCmdReply Msg;
184 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_REPLY, 4);
185 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
186 VbglHGCMParmUInt32Set(&Msg.rc, (uint32_t)rc); /* int vs. uint32_t */
187 VbglHGCMParmUInt32Set(&Msg.type, uType);
188 VbglHGCMParmPtrSet(&Msg.payload, pvPayload, cbPayload);
189
190 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
191}
192
193
194/**
195 * Tells the host service to skip the current message returned by
196 * VbglR3GuestCtrlMsgWaitFor().
197 *
198 * @return IPRT status code.
199 * @param uClientId The client ID returned by VbglR3GuestCtrlConnect().
200 */
201VBGLR3DECL(int) VbglR3GuestCtrlMsgSkip(uint32_t uClientId)
202{
203 HGCMMsgCmdSkip Msg;
204
205 /* Tell the host we want to skip the current assigned command. */
206 VBGL_HGCM_HDR_INIT(&Msg.hdr, uClientId, GUEST_MSG_SKIP, 1);
207 VbglHGCMParmUInt32Set(&Msg.flags, 0 /* Flags, unused */);
208 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
209}
210
211
212/**
213 * Asks the host to cancel (release) all pending waits which were deferred.
214 *
215 * @returns VBox status code.
216 * @param uClientId The client ID returned by VbglR3GuestCtrlConnect().
217 */
218VBGLR3DECL(int) VbglR3GuestCtrlCancelPendingWaits(uint32_t uClientId)
219{
220 HGCMMsgCancelPendingWaits Msg;
221 VBGL_HGCM_HDR_INIT(&Msg.hdr, uClientId, GUEST_CANCEL_PENDING_WAITS, 0);
222 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
223}
224
225
226/**
227 * Asks a specific guest session to close.
228 *
229 * @return IPRT status code.
230 * @param pCtx Host context.
231 * @param fFlags Some kind of flag. Figure it out yourself.
232 ** @todo Docs!
233 */
234VBGLR3DECL(int) VbglR3GuestCtrlSessionClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t fFlags)
235{
236 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
237 AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
238
239 HGCMMsgSessionClose Msg;
240 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_SESSION_CLOSE, pCtx->uNumParms);
241 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
242 VbglHGCMParmUInt32Set(&Msg.flags, fFlags);
243
244 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
245}
246
247
248VBGLR3DECL(int) VbglR3GuestCtrlSessionNotify(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uType, uint32_t uResult)
249{
250 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
251
252 HGCMMsgSessionNotify Msg;
253 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_SESSION_NOTIFY, 3);
254 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
255 VbglHGCMParmUInt32Set(&Msg.type, uType);
256 VbglHGCMParmUInt32Set(&Msg.result, uResult);
257
258 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
259}
260
261
262/**
263 * Retrieves the request to create a new guest session.
264 *
265 * @return IPRT status code.
266 ** @todo Docs!
267 */
268VBGLR3DECL(int) VbglR3GuestCtrlSessionGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx,
269 uint32_t *puProtocol,
270 char *pszUser, uint32_t cbUser,
271 char *pszPassword, uint32_t cbPassword,
272 char *pszDomain, uint32_t cbDomain,
273 uint32_t *pfFlags, uint32_t *pidSession)
274{
275 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
276 AssertReturn(pCtx->uNumParms == 6, VERR_INVALID_PARAMETER);
277
278 AssertPtrReturn(puProtocol, VERR_INVALID_POINTER);
279 AssertPtrReturn(pszUser, VERR_INVALID_POINTER);
280 AssertPtrReturn(pszPassword, VERR_INVALID_POINTER);
281 AssertPtrReturn(pszDomain, VERR_INVALID_POINTER);
282 AssertPtrReturn(pfFlags, VERR_INVALID_POINTER);
283
284 HGCMMsgSessionOpen Msg;
285 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
286 VbglHGCMParmUInt32Set(&Msg.context, 0);
287 VbglHGCMParmUInt32Set(&Msg.protocol, 0);
288 VbglHGCMParmPtrSet(&Msg.username, pszUser, cbUser);
289 VbglHGCMParmPtrSet(&Msg.password, pszPassword, cbPassword);
290 VbglHGCMParmPtrSet(&Msg.domain, pszDomain, cbDomain);
291 VbglHGCMParmUInt32Set(&Msg.flags, 0);
292
293 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
294 if (RT_SUCCESS(rc))
295 {
296 Msg.context.GetUInt32(&pCtx->uContextID);
297 Msg.protocol.GetUInt32(puProtocol);
298 Msg.flags.GetUInt32(pfFlags);
299
300 if (pidSession)
301 *pidSession = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pCtx->uContextID);
302 }
303
304 return rc;
305}
306
307
308/**
309 * Retrieves the request to terminate an existing guest session.
310 *
311 * @return IPRT status code.
312 ** @todo Docs!
313 */
314VBGLR3DECL(int) VbglR3GuestCtrlSessionGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *pfFlags, uint32_t *pidSession)
315{
316 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
317 AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
318
319 AssertPtrReturn(pfFlags, VERR_INVALID_POINTER);
320
321 HGCMMsgSessionClose Msg;
322 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
323 VbglHGCMParmUInt32Set(&Msg.context, 0);
324 VbglHGCMParmUInt32Set(&Msg.flags, 0);
325
326 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
327 if (RT_SUCCESS(rc))
328 {
329 Msg.context.GetUInt32(&pCtx->uContextID);
330 Msg.flags.GetUInt32(pfFlags);
331
332 if (pidSession)
333 *pidSession = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pCtx->uContextID);
334 }
335
336 return rc;
337}
338
339
340VBGLR3DECL(int) VbglR3GuestCtrlPathGetRename(PVBGLR3GUESTCTRLCMDCTX pCtx,
341 char *pszSource, uint32_t cbSource,
342 char *pszDest, uint32_t cbDest,
343 uint32_t *pfFlags)
344{
345 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
346 AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
347
348 AssertPtrReturn(pszSource, VERR_INVALID_POINTER);
349 AssertReturn(cbSource, VERR_INVALID_PARAMETER);
350 AssertPtrReturn(pszDest, VERR_INVALID_POINTER);
351 AssertReturn(cbDest, VERR_INVALID_PARAMETER);
352 AssertPtrReturn(pfFlags, VERR_INVALID_POINTER);
353
354 HGCMMsgPathRename Msg;
355 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
356 VbglHGCMParmUInt32Set(&Msg.context, 0);
357 VbglHGCMParmPtrSet(&Msg.source, pszSource, cbSource);
358 VbglHGCMParmPtrSet(&Msg.dest, pszDest, cbDest);
359 VbglHGCMParmUInt32Set(&Msg.flags, 0);
360
361 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
362 if (RT_SUCCESS(rc))
363 {
364 Msg.context.GetUInt32(&pCtx->uContextID);
365 Msg.flags.GetUInt32(pfFlags);
366 }
367 return rc;
368}
369
370
371/**
372 * Allocates and gets host data, based on the message id.
373 *
374 * This will block until data becomes available.
375 *
376 * @returns VBox status code.
377 ** @todo Docs!
378 ** @todo Move the parameters in an own struct!
379 */
380VBGLR3DECL(int) VbglR3GuestCtrlProcGetStart(PVBGLR3GUESTCTRLCMDCTX pCtx,
381 char *pszCmd, uint32_t cbCmd,
382 uint32_t *pfFlags,
383 char *pszArgs, uint32_t cbArgs, uint32_t *pcArgs,
384 char *pszEnv, uint32_t *pcbEnv, uint32_t *pcEnvVars,
385 char *pszUser, uint32_t cbUser,
386 char *pszPassword, uint32_t cbPassword,
387 uint32_t *puTimeoutMS,
388 uint32_t *puPriority,
389 uint64_t *puAffinity, uint32_t cbAffinity, uint32_t *pcAffinity)
390{
391 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
392
393 AssertPtrReturn(pszCmd, VERR_INVALID_POINTER);
394 AssertPtrReturn(pfFlags, VERR_INVALID_POINTER);
395 AssertPtrReturn(pszArgs, VERR_INVALID_POINTER);
396 AssertPtrReturn(pcArgs, VERR_INVALID_POINTER);
397 AssertPtrReturn(pszEnv, VERR_INVALID_POINTER);
398 AssertPtrReturn(pcbEnv, VERR_INVALID_POINTER);
399 AssertPtrReturn(pcEnvVars, VERR_INVALID_POINTER);
400 AssertPtrReturn(puTimeoutMS, VERR_INVALID_POINTER);
401
402 HGCMMsgProcExec Msg;
403 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
404 VbglHGCMParmUInt32Set(&Msg.context, 0);
405 VbglHGCMParmPtrSet(&Msg.cmd, pszCmd, cbCmd);
406 VbglHGCMParmUInt32Set(&Msg.flags, 0);
407 VbglHGCMParmUInt32Set(&Msg.num_args, 0);
408 VbglHGCMParmPtrSet(&Msg.args, pszArgs, cbArgs);
409 VbglHGCMParmUInt32Set(&Msg.num_env, 0);
410 VbglHGCMParmUInt32Set(&Msg.cb_env, 0);
411 VbglHGCMParmPtrSet(&Msg.env, pszEnv, *pcbEnv);
412 if (pCtx->uProtocol < 2)
413 {
414 AssertPtrReturn(pszUser, VERR_INVALID_POINTER);
415 AssertReturn(cbUser, VERR_INVALID_PARAMETER);
416 AssertPtrReturn(pszPassword, VERR_INVALID_POINTER);
417 AssertReturn(pszPassword, VERR_INVALID_PARAMETER);
418
419 VbglHGCMParmPtrSet(&Msg.u.v1.username, pszUser, cbUser);
420 VbglHGCMParmPtrSet(&Msg.u.v1.password, pszPassword, cbPassword);
421 VbglHGCMParmUInt32Set(&Msg.u.v1.timeout, 0);
422 }
423 else
424 {
425 AssertPtrReturn(puAffinity, VERR_INVALID_POINTER);
426 AssertReturn(cbAffinity, VERR_INVALID_PARAMETER);
427
428 VbglHGCMParmUInt32Set(&Msg.u.v2.timeout, 0);
429 VbglHGCMParmUInt32Set(&Msg.u.v2.priority, 0);
430 VbglHGCMParmUInt32Set(&Msg.u.v2.num_affinity, 0);
431 VbglHGCMParmPtrSet(&Msg.u.v2.affinity, puAffinity, cbAffinity);
432 }
433
434 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
435 if (RT_SUCCESS(rc))
436 {
437 Msg.context.GetUInt32(&pCtx->uContextID);
438 Msg.flags.GetUInt32(pfFlags);
439 Msg.num_args.GetUInt32(pcArgs);
440 Msg.num_env.GetUInt32(pcEnvVars);
441 Msg.cb_env.GetUInt32(pcbEnv);
442 if (pCtx->uProtocol < 2)
443 {
444 Msg.u.v1.timeout.GetUInt32(puTimeoutMS);
445 }
446 else
447 {
448 Msg.u.v2.timeout.GetUInt32(puTimeoutMS);
449 Msg.u.v2.priority.GetUInt32(puPriority);
450 Msg.u.v2.num_affinity.GetUInt32(pcAffinity);
451 }
452 }
453 return rc;
454}
455
456
457/**
458 * Allocates and gets host data, based on the message id.
459 *
460 * This will block until data becomes available.
461 *
462 * @returns VBox status code.
463 ** @todo Docs!
464 */
465VBGLR3DECL(int) VbglR3GuestCtrlProcGetOutput(PVBGLR3GUESTCTRLCMDCTX pCtx,
466 uint32_t *puPID, uint32_t *puHandle, uint32_t *pfFlags)
467{
468 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
469 AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
470
471 AssertPtrReturn(puPID, VERR_INVALID_POINTER);
472 AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
473 AssertPtrReturn(pfFlags, VERR_INVALID_POINTER);
474
475 HGCMMsgProcOutput Msg;
476 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
477 VbglHGCMParmUInt32Set(&Msg.context, 0);
478 VbglHGCMParmUInt32Set(&Msg.pid, 0);
479 VbglHGCMParmUInt32Set(&Msg.handle, 0);
480 VbglHGCMParmUInt32Set(&Msg.flags, 0);
481
482 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
483 if (RT_SUCCESS(rc))
484 {
485 Msg.context.GetUInt32(&pCtx->uContextID);
486 Msg.pid.GetUInt32(puPID);
487 Msg.handle.GetUInt32(puHandle);
488 Msg.flags.GetUInt32(pfFlags);
489 }
490 return rc;
491}
492
493
494/**
495 * Retrieves the input data from host which then gets sent to the
496 * started process.
497 *
498 * This will block until data becomes available.
499 *
500 * @returns VBox status code.
501 ** @todo Docs!
502 */
503VBGLR3DECL(int) VbglR3GuestCtrlProcGetInput(PVBGLR3GUESTCTRLCMDCTX pCtx,
504 uint32_t *puPID, uint32_t *pfFlags,
505 void *pvData, uint32_t cbData,
506 uint32_t *pcbSize)
507{
508 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
509 AssertReturn(pCtx->uNumParms == 5, VERR_INVALID_PARAMETER);
510
511 AssertPtrReturn(puPID, VERR_INVALID_POINTER);
512 AssertPtrReturn(pfFlags, VERR_INVALID_POINTER);
513 AssertPtrReturn(pvData, VERR_INVALID_POINTER);
514 AssertPtrReturn(pcbSize, VERR_INVALID_POINTER);
515
516 HGCMMsgProcInput Msg;
517 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
518 VbglHGCMParmUInt32Set(&Msg.context, 0);
519 VbglHGCMParmUInt32Set(&Msg.pid, 0);
520 VbglHGCMParmUInt32Set(&Msg.flags, 0);
521 VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
522 VbglHGCMParmUInt32Set(&Msg.size, 0);
523
524 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
525 if (RT_SUCCESS(rc))
526 {
527 Msg.context.GetUInt32(&pCtx->uContextID);
528 Msg.pid.GetUInt32(puPID);
529 Msg.flags.GetUInt32(pfFlags);
530 Msg.size.GetUInt32(pcbSize);
531 }
532 return rc;
533}
534
535
536VBGLR3DECL(int) VbglR3GuestCtrlDirGetRemove(PVBGLR3GUESTCTRLCMDCTX pCtx,
537 char *pszPath, uint32_t cbPath,
538 uint32_t *pfFlags)
539{
540 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
541 AssertReturn(pCtx->uNumParms == 3, VERR_INVALID_PARAMETER);
542
543 AssertPtrReturn(pszPath, VERR_INVALID_POINTER);
544 AssertReturn(cbPath, VERR_INVALID_PARAMETER);
545 AssertPtrReturn(pfFlags, VERR_INVALID_POINTER);
546
547 HGCMMsgDirRemove Msg;
548 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
549 VbglHGCMParmUInt32Set(&Msg.context, 0);
550 VbglHGCMParmPtrSet(&Msg.path, pszPath, cbPath);
551 VbglHGCMParmUInt32Set(&Msg.flags, 0);
552
553 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
554 if (RT_SUCCESS(rc))
555 {
556 Msg.context.GetUInt32(&pCtx->uContextID);
557 Msg.flags.GetUInt32(pfFlags);
558 }
559 return rc;
560}
561
562
563VBGLR3DECL(int) VbglR3GuestCtrlFileGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx,
564 char *pszFileName, uint32_t cbFileName,
565 char *pszAccess, uint32_t cbAccess,
566 char *pszDisposition, uint32_t cbDisposition,
567 char *pszSharing, uint32_t cbSharing,
568 uint32_t *puCreationMode,
569 uint64_t *poffAt)
570{
571 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
572 AssertReturn(pCtx->uNumParms == 7, VERR_INVALID_PARAMETER);
573
574 AssertPtrReturn(pszFileName, VERR_INVALID_POINTER);
575 AssertReturn(cbFileName, VERR_INVALID_PARAMETER);
576 AssertPtrReturn(pszAccess, VERR_INVALID_POINTER);
577 AssertReturn(cbAccess, VERR_INVALID_PARAMETER);
578 AssertPtrReturn(pszDisposition, VERR_INVALID_POINTER);
579 AssertReturn(cbDisposition, VERR_INVALID_PARAMETER);
580 AssertPtrReturn(pszSharing, VERR_INVALID_POINTER);
581 AssertReturn(cbSharing, VERR_INVALID_PARAMETER);
582 AssertPtrReturn(puCreationMode, VERR_INVALID_POINTER);
583 AssertPtrReturn(poffAt, VERR_INVALID_POINTER);
584
585 HGCMMsgFileOpen Msg;
586 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
587 VbglHGCMParmUInt32Set(&Msg.context, 0);
588 VbglHGCMParmPtrSet(&Msg.filename, pszFileName, cbFileName);
589 VbglHGCMParmPtrSet(&Msg.openmode, pszAccess, cbAccess);
590 VbglHGCMParmPtrSet(&Msg.disposition, pszDisposition, cbDisposition);
591 VbglHGCMParmPtrSet(&Msg.sharing, pszSharing, cbSharing);
592 VbglHGCMParmUInt32Set(&Msg.creationmode, 0);
593 VbglHGCMParmUInt64Set(&Msg.offset, 0);
594
595 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
596 if (RT_SUCCESS(rc))
597 {
598 Msg.context.GetUInt32(&pCtx->uContextID);
599 Msg.creationmode.GetUInt32(puCreationMode);
600 Msg.offset.GetUInt64(poffAt);
601 }
602 return rc;
603}
604
605
606VBGLR3DECL(int) VbglR3GuestCtrlFileGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle)
607{
608 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
609
610 AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
611 AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
612
613 HGCMMsgFileClose Msg;
614 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
615 VbglHGCMParmUInt32Set(&Msg.context, 0);
616 VbglHGCMParmUInt32Set(&Msg.handle, 0);
617
618 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
619 if (RT_SUCCESS(rc))
620 {
621 Msg.context.GetUInt32(&pCtx->uContextID);
622 Msg.handle.GetUInt32(puHandle);
623 }
624 return rc;
625}
626
627
628VBGLR3DECL(int) VbglR3GuestCtrlFileGetRead(PVBGLR3GUESTCTRLCMDCTX pCtx,
629 uint32_t *puHandle, uint32_t *puToRead)
630{
631 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
632
633 AssertReturn(pCtx->uNumParms == 3, VERR_INVALID_PARAMETER);
634 AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
635 AssertPtrReturn(puToRead, VERR_INVALID_POINTER);
636
637 HGCMMsgFileRead Msg;
638 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
639 VbglHGCMParmUInt32Set(&Msg.context, 0);
640 VbglHGCMParmUInt32Set(&Msg.handle, 0);
641 VbglHGCMParmUInt32Set(&Msg.size, 0);
642
643 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
644 if (RT_SUCCESS(rc))
645 {
646 Msg.context.GetUInt32(&pCtx->uContextID);
647 Msg.handle.GetUInt32(puHandle);
648 Msg.size.GetUInt32(puToRead);
649 }
650 return rc;
651}
652
653
654VBGLR3DECL(int) VbglR3GuestCtrlFileGetReadAt(PVBGLR3GUESTCTRLCMDCTX pCtx,
655 uint32_t *puHandle, uint32_t *puToRead, uint64_t *poffAt)
656{
657 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
658
659 AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
660 AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
661 AssertPtrReturn(puToRead, VERR_INVALID_POINTER);
662
663 HGCMMsgFileReadAt Msg;
664 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
665 VbglHGCMParmUInt32Set(&Msg.context, 0);
666 VbglHGCMParmUInt32Set(&Msg.handle, 0);
667 VbglHGCMParmUInt32Set(&Msg.offset, 0);
668 VbglHGCMParmUInt32Set(&Msg.size, 0);
669
670 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
671 if (RT_SUCCESS(rc))
672 {
673 Msg.context.GetUInt32(&pCtx->uContextID);
674 Msg.handle.GetUInt32(puHandle);
675 Msg.offset.GetUInt64(poffAt);
676 Msg.size.GetUInt32(puToRead);
677 }
678 return rc;
679}
680
681
682VBGLR3DECL(int) VbglR3GuestCtrlFileGetWrite(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle,
683 void *pvData, uint32_t cbData, uint32_t *pcbSize)
684{
685 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
686
687 AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
688 AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
689 AssertPtrReturn(pvData, VERR_INVALID_POINTER);
690 AssertReturn(cbData, VERR_INVALID_PARAMETER);
691 AssertPtrReturn(pcbSize, VERR_INVALID_POINTER);
692
693 HGCMMsgFileWrite Msg;
694 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
695 VbglHGCMParmUInt32Set(&Msg.context, 0);
696 VbglHGCMParmUInt32Set(&Msg.handle, 0);
697 VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
698 VbglHGCMParmUInt32Set(&Msg.size, 0);
699
700 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
701 if (RT_SUCCESS(rc))
702 {
703 Msg.context.GetUInt32(&pCtx->uContextID);
704 Msg.handle.GetUInt32(puHandle);
705 Msg.size.GetUInt32(pcbSize);
706 }
707 return rc;
708}
709
710
711VBGLR3DECL(int) VbglR3GuestCtrlFileGetWriteAt(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle,
712 void *pvData, uint32_t cbData, uint32_t *pcbSize, uint64_t *poffAt)
713{
714 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
715
716 AssertReturn(pCtx->uNumParms == 5, VERR_INVALID_PARAMETER);
717 AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
718 AssertPtrReturn(pvData, VERR_INVALID_POINTER);
719 AssertReturn(cbData, VERR_INVALID_PARAMETER);
720 AssertPtrReturn(pcbSize, VERR_INVALID_POINTER);
721
722 HGCMMsgFileWriteAt Msg;
723 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
724 VbglHGCMParmUInt32Set(&Msg.context, 0);
725 VbglHGCMParmUInt32Set(&Msg.handle, 0);
726 VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
727 VbglHGCMParmUInt32Set(&Msg.size, 0);
728 VbglHGCMParmUInt32Set(&Msg.offset, 0);
729
730 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
731 if (RT_SUCCESS(rc))
732 {
733 Msg.context.GetUInt32(&pCtx->uContextID);
734 Msg.handle.GetUInt32(puHandle);
735 Msg.size.GetUInt32(pcbSize);
736 Msg.offset.GetUInt64(poffAt);
737 }
738 return rc;
739}
740
741
742VBGLR3DECL(int) VbglR3GuestCtrlFileGetSeek(PVBGLR3GUESTCTRLCMDCTX pCtx,
743 uint32_t *puHandle, uint32_t *puSeekMethod, uint64_t *poffAt)
744{
745 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
746
747 AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
748 AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
749 AssertPtrReturn(puSeekMethod, VERR_INVALID_POINTER);
750 AssertPtrReturn(poffAt, VERR_INVALID_POINTER);
751
752 HGCMMsgFileSeek Msg;
753 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
754 VbglHGCMParmUInt32Set(&Msg.context, 0);
755 VbglHGCMParmUInt32Set(&Msg.handle, 0);
756 VbglHGCMParmUInt32Set(&Msg.method, 0);
757 VbglHGCMParmUInt64Set(&Msg.offset, 0);
758
759 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
760 if (RT_SUCCESS(rc))
761 {
762 Msg.context.GetUInt32(&pCtx->uContextID);
763 Msg.handle.GetUInt32(puHandle);
764 Msg.method.GetUInt32(puSeekMethod);
765 Msg.offset.GetUInt64(poffAt);
766 }
767 return rc;
768}
769
770
771VBGLR3DECL(int) VbglR3GuestCtrlFileGetTell(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle)
772{
773 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
774
775 AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
776 AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
777
778 HGCMMsgFileTell Msg;
779 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
780 VbglHGCMParmUInt32Set(&Msg.context, 0);
781 VbglHGCMParmUInt32Set(&Msg.handle, 0);
782
783 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
784 if (RT_SUCCESS(rc))
785 {
786 Msg.context.GetUInt32(&pCtx->uContextID);
787 Msg.handle.GetUInt32(puHandle);
788 }
789 return rc;
790}
791
792
793VBGLR3DECL(int) VbglR3GuestCtrlProcGetTerminate(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puPID)
794{
795 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
796
797 AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
798 AssertPtrReturn(puPID, VERR_INVALID_POINTER);
799
800 HGCMMsgProcTerminate Msg;
801 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
802 VbglHGCMParmUInt32Set(&Msg.context, 0);
803 VbglHGCMParmUInt32Set(&Msg.pid, 0);
804
805 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
806 if (RT_SUCCESS(rc))
807 {
808 Msg.context.GetUInt32(&pCtx->uContextID);
809 Msg.pid.GetUInt32(puPID);
810 }
811 return rc;
812}
813
814
815VBGLR3DECL(int) VbglR3GuestCtrlProcGetWaitFor(PVBGLR3GUESTCTRLCMDCTX pCtx,
816 uint32_t *puPID, uint32_t *puWaitFlags, uint32_t *puTimeoutMS)
817{
818 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
819
820 AssertReturn(pCtx->uNumParms == 5, VERR_INVALID_PARAMETER);
821 AssertPtrReturn(puPID, VERR_INVALID_POINTER);
822
823 HGCMMsgProcWaitFor Msg;
824 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
825 VbglHGCMParmUInt32Set(&Msg.context, 0);
826 VbglHGCMParmUInt32Set(&Msg.pid, 0);
827 VbglHGCMParmUInt32Set(&Msg.flags, 0);
828 VbglHGCMParmUInt32Set(&Msg.timeout, 0);
829
830 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
831 if (RT_SUCCESS(rc))
832 {
833 Msg.context.GetUInt32(&pCtx->uContextID);
834 Msg.pid.GetUInt32(puPID);
835 Msg.flags.GetUInt32(puWaitFlags);
836 Msg.timeout.GetUInt32(puTimeoutMS);
837 }
838 return rc;
839}
840
841
842VBGLR3DECL(int) VbglR3GuestCtrlFileCbOpen(PVBGLR3GUESTCTRLCMDCTX pCtx,
843 uint32_t uRc, uint32_t uFileHandle)
844{
845 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
846
847 HGCMReplyFileNotify Msg;
848 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 4);
849 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
850 VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_OPEN);
851 VbglHGCMParmUInt32Set(&Msg.rc, uRc);
852 VbglHGCMParmUInt32Set(&Msg.u.open.handle, uFileHandle);
853
854 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
855}
856
857
858VBGLR3DECL(int) VbglR3GuestCtrlFileCbClose(PVBGLR3GUESTCTRLCMDCTX pCtx,
859 uint32_t uRc)
860{
861 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
862
863 HGCMReplyFileNotify Msg;
864 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 3);
865 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
866 VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_CLOSE);
867 VbglHGCMParmUInt32Set(&Msg.rc, uRc);
868
869 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
870}
871
872
873VBGLR3DECL(int) VbglR3GuestCtrlFileCbError(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc)
874{
875 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
876
877 HGCMReplyFileNotify Msg;
878 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 3);
879 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
880 VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_ERROR);
881 VbglHGCMParmUInt32Set(&Msg.rc, uRc);
882
883 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
884}
885
886
887VBGLR3DECL(int) VbglR3GuestCtrlFileCbRead(PVBGLR3GUESTCTRLCMDCTX pCtx,
888 uint32_t uRc,
889 void *pvData, uint32_t cbData)
890{
891 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
892
893 HGCMReplyFileNotify Msg;
894 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 4);
895 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
896 VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_READ);
897 VbglHGCMParmUInt32Set(&Msg.rc, uRc);
898 VbglHGCMParmPtrSet(&Msg.u.read.data, pvData, cbData);
899
900 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
901}
902
903
904VBGLR3DECL(int) VbglR3GuestCtrlFileCbWrite(PVBGLR3GUESTCTRLCMDCTX pCtx,
905 uint32_t uRc, uint32_t uWritten)
906{
907 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
908
909 HGCMReplyFileNotify Msg;
910 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 4);
911 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
912 VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_WRITE);
913 VbglHGCMParmUInt32Set(&Msg.rc, uRc);
914 VbglHGCMParmUInt32Set(&Msg.u.write.written, uWritten);
915
916 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
917}
918
919
920VBGLR3DECL(int) VbglR3GuestCtrlFileCbSeek(PVBGLR3GUESTCTRLCMDCTX pCtx,
921 uint32_t uRc, uint64_t uOffActual)
922{
923 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
924
925 HGCMReplyFileNotify Msg;
926 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 4);
927 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
928 VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_SEEK);
929 VbglHGCMParmUInt32Set(&Msg.rc, uRc);
930 VbglHGCMParmUInt64Set(&Msg.u.seek.offset, uOffActual);
931
932 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
933}
934
935
936VBGLR3DECL(int) VbglR3GuestCtrlFileCbTell(PVBGLR3GUESTCTRLCMDCTX pCtx,
937 uint32_t uRc, uint64_t uOffActual)
938{
939 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
940
941 HGCMReplyFileNotify Msg;
942 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 4);
943 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
944 VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_TELL);
945 VbglHGCMParmUInt32Set(&Msg.rc, uRc);
946 VbglHGCMParmUInt64Set(&Msg.u.tell.offset, uOffActual);
947
948 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
949}
950
951
952/**
953 * Callback for reporting a guest process status (along with some other stuff) to the host.
954 *
955 * @returns VBox status code.
956 ** @todo Docs!
957 */
958VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatus(PVBGLR3GUESTCTRLCMDCTX pCtx,
959 uint32_t uPID, uint32_t uStatus, uint32_t fFlags,
960 void *pvData, uint32_t cbData)
961{
962 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
963
964 HGCMMsgProcStatus Msg;
965 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_EXEC_STATUS, 5);
966 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
967 VbglHGCMParmUInt32Set(&Msg.pid, uPID);
968 VbglHGCMParmUInt32Set(&Msg.status, uStatus);
969 VbglHGCMParmUInt32Set(&Msg.flags, fFlags);
970 VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
971
972 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
973}
974
975
976/**
977 * Sends output (from stdout/stderr) from a running process.
978 *
979 * @returns VBox status code.
980 ** @todo Docs!
981 */
982VBGLR3DECL(int) VbglR3GuestCtrlProcCbOutput(PVBGLR3GUESTCTRLCMDCTX pCtx,
983 uint32_t uPID,uint32_t uHandle, uint32_t fFlags,
984 void *pvData, uint32_t cbData)
985{
986 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
987
988 HGCMMsgProcOutput Msg;
989 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_EXEC_OUTPUT, 5);
990 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
991 VbglHGCMParmUInt32Set(&Msg.pid, uPID);
992 VbglHGCMParmUInt32Set(&Msg.handle, uHandle);
993 VbglHGCMParmUInt32Set(&Msg.flags, fFlags);
994 VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
995
996 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
997}
998
999
1000/**
1001 * Callback for reporting back the input status of a guest process to the host.
1002 *
1003 * @returns VBox status code.
1004 ** @todo Docs!
1005 */
1006VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatusInput(PVBGLR3GUESTCTRLCMDCTX pCtx,
1007 uint32_t uPID, uint32_t uStatus,
1008 uint32_t fFlags, uint32_t cbWritten)
1009{
1010 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
1011
1012 HGCMMsgProcStatusInput Msg;
1013 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_EXEC_INPUT_STATUS, 5);
1014 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
1015 VbglHGCMParmUInt32Set(&Msg.pid, uPID);
1016 VbglHGCMParmUInt32Set(&Msg.status, uStatus);
1017 VbglHGCMParmUInt32Set(&Msg.flags, fFlags);
1018 VbglHGCMParmUInt32Set(&Msg.written, cbWritten);
1019
1020 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
1021}
1022
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette