VirtualBox

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

Last change on this file since 47631 was 47620, checked in by vboxsync, 11 years ago

GuestCtrl: Fixed per-session command filtering, added command to disable the filter again.

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