VirtualBox

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

Last change on this file since 47695 was 47695, checked in by vboxsync, 12 years ago

Additions/GuestCtrl: Use a separate filter mask + value for message filtering.

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