VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestCtrl.cpp@ 68502

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

VBoxGuestR3Lib: Fixed clipboard and guest control breakage since r117608.

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

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