VirtualBox

source: vbox/trunk/include/VBox/HostServices/GuestControlSvc.h@ 45947

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

GuestCtrl: Implemented using (public) VirtualBox events instead of own callback mechanisms. Bugfixes for testcases (still work in progress).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 27.3 KB
Line 
1/** @file
2 * Guest control service - Common header for host service and guest clients.
3 */
4
5/*
6 * Copyright (C) 2011-2013 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___VBox_HostService_GuestControlService_h
27#define ___VBox_HostService_GuestControlService_h
28
29#include <VBox/types.h>
30#include <VBox/VMMDev.h>
31#include <VBox/VBoxGuest2.h>
32#include <VBox/hgcmsvc.h>
33#include <VBox/log.h>
34#include <iprt/assert.h>
35#include <iprt/string.h>
36
37/* Everything defined in this file lives in this namespace. */
38namespace guestControl {
39
40/******************************************************************************
41* Typedefs, constants and inlines *
42******************************************************************************/
43
44#define HGCMSERVICE_NAME "VBoxGuestControlSvc"
45
46/** Maximum number of concurrent guest sessions a VM can have. */
47#define VBOX_GUESTCTRL_MAX_SESSIONS 32
48/** Maximum number of concurrent guest objects (processes, files, ...)
49 * a guest session can have. */
50#define VBOX_GUESTCTRL_MAX_OBJECTS _2K
51/** Maximum of callback contexts a guest process can have. */
52#define VBOX_GUESTCTRL_MAX_CONTEXTS _64K
53
54/** Builds a context ID out of the session ID, object ID and an
55 * increasing count. */
56#define VBOX_GUESTCTRL_CONTEXTID_MAKE(uSession, uObject, uCount) \
57 ( (uint32_t)((uSession) & 0x1f) << 27 \
58 | (uint32_t)((uObject) & 0x7ff) << 16 \
59 | (uint32_t)((uCount) & 0xffff) \
60 )
61#define VBOX_GUESTCTRL_CONTEXTID_MAKE_SESSION(uSession) \
62 ((uint32_t)((uSession) & 0x1f) << 27)
63/** Gets the session ID out of a context ID. */
64#define VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(uContextID) \
65 (((uContextID) >> 27) & 0x1f)
66/** Gets the process ID out of a context ID. */
67#define VBOX_GUESTCTRL_CONTEXTID_GET_OBJECT(uContextID) \
68 (((uContextID) >> 16) & 0x7ff)
69/** Gets the context count of a process out of a context ID. */
70#define VBOX_GUESTCTRL_CONTEXTID_GET_COUNT(uContextID) \
71 ((uContextID) & 0xffff)
72
73/**
74 * Process status when executed in the guest.
75 */
76enum eProcessStatus
77{
78 /** Process is in an undefined state. */
79 PROC_STS_UNDEFINED = 0,
80 /** Process has been started. */
81 PROC_STS_STARTED = 1,
82 /** Process terminated normally. */
83 PROC_STS_TEN = 2,
84 /** Process terminated via signal. */
85 PROC_STS_TES = 3,
86 /** Process terminated abnormally. */
87 PROC_STS_TEA = 4,
88 /** Process timed out and was killed. */
89 PROC_STS_TOK = 5,
90 /** Process timed out and was not killed successfully. */
91 PROC_STS_TOA = 6,
92 /** Service/OS is stopping, process was killed. */
93 PROC_STS_DWN = 7,
94 /** Something went wrong (error code in flags). */
95 PROC_STS_ERROR = 8
96};
97
98/**
99 * Input flags, set by the host. This is needed for
100 * handling flags on the guest side.
101 * Note: Has to match Main's ProcessInputFlag_* flags!
102 */
103#define INPUT_FLAG_NONE 0x0
104#define INPUT_FLAG_EOF RT_BIT(0)
105
106/**
107 * Guest session creation flags.
108 * Only handled internally at the moment.
109 */
110#define SESSIONCREATIONFLAG_NONE 0x0
111
112/**
113 * Guest process creation flags.
114 * Note: Has to match Main's ProcessCreateFlag_* flags!
115 */
116#define EXECUTEPROCESSFLAG_NONE 0x0
117#define EXECUTEPROCESSFLAG_WAIT_START RT_BIT(0)
118#define EXECUTEPROCESSFLAG_IGNORE_ORPHANED RT_BIT(1)
119#define EXECUTEPROCESSFLAG_HIDDEN RT_BIT(2)
120#define EXECUTEPROCESSFLAG_NO_PROFILE RT_BIT(3)
121#define EXECUTEPROCESSFLAG_WAIT_STDOUT RT_BIT(4)
122#define EXECUTEPROCESSFLAG_WAIT_STDERR RT_BIT(5)
123#define EXECUTEPROCESSFLAG_EXPAND_ARGUMENTS RT_BIT(6)
124
125/**
126 * Pipe handle IDs used internally for referencing to
127 * a certain pipe buffer.
128 */
129#define OUTPUT_HANDLE_ID_STDOUT_DEPRECATED 0 /* Needed for VBox hosts < 4.1.0. */
130#define OUTPUT_HANDLE_ID_STDOUT 1
131#define OUTPUT_HANDLE_ID_STDERR 2
132
133/**
134 * Defines for guest process array lengths.
135 */
136#define GUESTPROCESS_MAX_CMD_LEN _1K
137#define GUESTPROCESS_MAX_ARGS_LEN _1K
138#define GUESTPROCESS_MAX_ENV_LEN _64K
139#define GUESTPROCESS_MAX_USER_LEN 128
140#define GUESTPROCESS_MAX_PASSWORD_LEN 128
141#define GUESTPROCESS_MAX_DOMAIN_LEN 256
142
143/** @name Internal tools built into VBoxService which are used in order to
144 * accomplish tasks host<->guest.
145 * @{
146 */
147#define VBOXSERVICE_TOOL_CAT "vbox_cat"
148#define VBOXSERVICE_TOOL_LS "vbox_ls"
149#define VBOXSERVICE_TOOL_RM "vbox_rm"
150#define VBOXSERVICE_TOOL_MKDIR "vbox_mkdir"
151#define VBOXSERVICE_TOOL_MKTEMP "vbox_mktemp"
152#define VBOXSERVICE_TOOL_STAT "vbox_stat"
153/** @} */
154
155/**
156 * Input status, reported by the client.
157 */
158enum eInputStatus
159{
160 /** Input is in an undefined state. */
161 INPUT_STS_UNDEFINED = 0,
162 /** Input was written (partially, see cbProcessed). */
163 INPUT_STS_WRITTEN = 1,
164 /** Input failed with an error (see flags for rc). */
165 INPUT_STS_ERROR = 20,
166 /** Process has abandoned / terminated input handling. */
167 INPUT_STS_TERMINATED = 21,
168 /** Too much input data. */
169 INPUT_STS_OVERFLOW = 30
170};
171
172/**
173 * Structure keeping the context of a host callback.
174 */
175typedef struct VBoxGuestCtrlHostCbCtx
176{
177 /** HGCM Function number. */
178 uint32_t uFunction;
179 /** The context ID. */
180 uint32_t uContextID;
181 /** Protocol version of this guest session. Might
182 * be 0 if not supported. */
183 uint32_t uProtocol;
184
185} VBOXGUESTCTRLHOSTCBCTX, *PVBOXGUESTCTRLHOSTCBCTX;
186
187/**
188 * Structure for low level HGCM host callback from
189 * the guest. No deep copy. */
190typedef struct VBoxGuestCtrlHostCallback
191{
192 VBoxGuestCtrlHostCallback(uint32_t cParms, VBOXHGCMSVCPARM paParms[])
193 : mParms(cParms), mpaParms(paParms) { }
194
195 uint32_t mParms;
196 PVBOXHGCMSVCPARM mpaParms;
197
198} VBOXGUESTCTRLHOSTCALLBACK, *PVBOXGUESTCTRLHOSTCALLBACK;
199
200/**
201 * The service functions which are callable by host.
202 */
203enum eHostFn
204{
205 /**
206 * The host asks the client to cancel all pending waits and exit.
207 */
208 HOST_CANCEL_PENDING_WAITS = 0,
209 /**
210 * The host wants to create a guest session.
211 */
212 HOST_SESSION_CREATE = 20,
213 /**
214 * The host wants to close a guest session.
215 */
216 HOST_SESSION_CLOSE = 21,
217 /**
218 * The host wants to execute something in the guest. This can be a command line
219 * or starting a program.
220 ** Note: Legacy (VBox < 4.3) command.
221 */
222 HOST_EXEC_CMD = 100,
223 /**
224 * Sends input data for stdin to a running process executed by HOST_EXEC_CMD.
225 ** Note: Legacy (VBox < 4.3) command.
226 */
227 HOST_EXEC_SET_INPUT = 101,
228 /**
229 * Gets the current status of a running process, e.g.
230 * new data on stdout/stderr, process terminated etc.
231 ** Note: Legacy (VBox < 4.3) command.
232 */
233 HOST_EXEC_GET_OUTPUT = 102,
234 /**
235 * Terminates a running guest process.
236 */
237 HOST_EXEC_TERMINATE = 110,
238 /**
239 * Waits for a certain event to happen. This can be an input, output
240 * or status event.
241 */
242 HOST_EXEC_WAIT_FOR = 120,
243 /**
244 * Opens a guest file.
245 */
246 HOST_FILE_OPEN = 240,
247 /**
248 * Closes a guest file.
249 */
250 HOST_FILE_CLOSE = 241,
251 /**
252 * Reads from an opened guest file.
253 */
254 HOST_FILE_READ = 250,
255 /**
256 * Reads from an opened guest file at
257 * a specified offset.
258 */
259 HOST_FILE_READ_AT = 251,
260 /**
261 * Write to an opened guest file.
262 */
263 HOST_FILE_WRITE = 260,
264 /**
265 * Write to an opened guest file at
266 * a specified offset.
267 */
268 HOST_FILE_WRITE_AT = 261,
269 /**
270 * Changes the read & write position of an opened guest file.
271 */
272 HOST_FILE_SEEK = 270,
273 /**
274 * Gets the current file position of an opened guest file.
275 */
276 HOST_FILE_TELL = 271
277};
278
279/**
280 * The service functions which are called by guest. The numbers may not change,
281 * so we hardcode them.
282 *
283 * Note: Callbacks start at 100. See CALLBACKTYPE enum.
284 */
285enum eGuestFn
286{
287 /**
288 * Guest waits for a new message the host wants to process on the guest side.
289 * This is a blocking call and can be deferred.
290 */
291 GUEST_MSG_WAIT = 1,
292 /**
293 * Guest asks the host to cancel all pending waits the guest itself waits on.
294 * This becomes necessary when the guest wants to quit but still waits for
295 * commands from the host.
296 */
297 GUEST_CANCEL_PENDING_WAITS = 2,
298 /**
299 * Guest disconnected (terminated normally or due to a crash HGCM
300 * detected when calling service::clientDisconnect().
301 */
302 GUEST_DISCONNECTED = 3,
303 /**
304 * Sets a message filter to only get messages which have a certain
305 * context ID scheme (that is, a specific session, object etc).
306 * Since VBox 4.3+.
307 */
308 GUEST_MSG_FILTER = 4,
309 /**
310 * Skips the current assigned message returned by GUEST_MSG_WAIT.
311 * Needed for telling the host service to not keep stale
312 * host commands in the queue.
313 */
314 GUEST_MSG_SKIP = 5,
315 /**
316 * Guest reports back a guest session status.
317 */
318 GUEST_SESSION_NOTIFY = 20,
319 /**
320 * Guests sends output from an executed process.
321 */
322 GUEST_EXEC_OUTPUT = 100,
323 /**
324 * Guest sends a status update of an executed process to the host.
325 */
326 GUEST_EXEC_STATUS = 101,
327 /**
328 * Guests sends an input status notification to the host.
329 */
330 GUEST_EXEC_INPUT_STATUS = 102,
331 /**
332 * Guest notifies the host about some I/O event. This can be
333 * a stdout, stderr or a stdin event. The actual event only tells
334 * how many data is available / can be sent without actually
335 * transmitting the data.
336 */
337 GUEST_EXEC_IO_NOTIFY = 210,
338 /**
339 * Guest notifies the host about some file event.
340 */
341 GUEST_FILE_NOTIFY = 240
342};
343
344/**
345 * Guest session notification types.
346 * @sa HGCMMsgSessionNotify.
347 */
348enum GUEST_SESSION_NOTIFYTYPE
349{
350 GUEST_SESSION_NOTIFYTYPE_UNDEFINED = 0,
351 /** Something went wrong (see rc). */
352 GUEST_SESSION_NOTIFYTYPE_ERROR = 1,
353 /** Guest session has been started. */
354 GUEST_SESSION_NOTIFYTYPE_STARTED = 11,
355 /** Guest session terminated normally. */
356 GUEST_SESSION_NOTIFYTYPE_TEN = 20,
357 /** Guest session terminated via signal. */
358 GUEST_SESSION_NOTIFYTYPE_TES = 30,
359 /** Guest session terminated abnormally. */
360 GUEST_SESSION_NOTIFYTYPE_TEA = 40,
361 /** Guest session timed out and was killed. */
362 GUEST_SESSION_NOTIFYTYPE_TOK = 50,
363 /** Guest session timed out and was not killed successfully. */
364 GUEST_SESSION_NOTIFYTYPE_TOA = 60,
365 /** Service/OS is stopping, process was killed. */
366 GUEST_SESSION_NOTIFYTYPE_DWN = 150
367};
368
369/**
370 * Guest file notification types.
371 * @sa HGCMMsgFileNotify.
372 */
373enum GUEST_FILE_NOTIFYTYPE
374{
375 GUEST_FILE_NOTIFYTYPE_UNKNOWN = 0,
376 GUEST_FILE_NOTIFYTYPE_ERROR = 1,
377 GUEST_FILE_NOTIFYTYPE_OPEN = 10,
378 GUEST_FILE_NOTIFYTYPE_CLOSE = 20,
379 GUEST_FILE_NOTIFYTYPE_READ = 30,
380 GUEST_FILE_NOTIFYTYPE_WRITE = 40,
381 GUEST_FILE_NOTIFYTYPE_SEEK = 50,
382 GUEST_FILE_NOTIFYTYPE_TELL = 60
383};
384
385/**
386 * Guest file seeking types. Has to
387 * match FileSeekType in Main.
388 */
389enum GUEST_FILE_SEEKTYPE
390{
391 GUEST_FILE_SEEKTYPE_BEGIN = 1,
392 GUEST_FILE_SEEKTYPE_CURRENT = 4,
393 GUEST_FILE_SEEKTYPE_END = 8
394};
395
396/*
397 * HGCM parameter structures.
398 */
399#pragma pack (1)
400
401/**
402 * Waits for a host command to arrive. The structure then contains the
403 * actual message type + required number of parameters needed to successfully
404 * retrieve that host command (in a next round).
405 */
406typedef struct HGCMMsgCmdWaitFor
407{
408 VBoxGuestHGCMCallInfo hdr;
409
410 /**
411 * The returned command the host wants to
412 * run on the guest.
413 */
414 HGCMFunctionParameter msg; /* OUT uint32_t */
415 /** Number of parameters the message needs. */
416 HGCMFunctionParameter num_parms; /* OUT uint32_t */
417
418} HGCMMsgCmdWaitFor;
419
420/**
421 * Asks the guest control host service to set a command
422 * filter for this client. This filter will then only
423 * deliver messages to the client which match the
424 * wanted context ID (ranges).
425 */
426typedef struct HGCMMsgCmdSetFilter
427{
428 VBoxGuestHGCMCallInfo hdr;
429
430 /* Mask of context IDs to be filtered. */
431 HGCMFunctionParameter add; /* IN uint32_t */
432 /* Exclude masked; unused. */
433 HGCMFunctionParameter remove; /* IN uint32_t */
434
435} HGCMMsgCmdSetFilter;
436
437/**
438 * Asks the guest control host service to skip the
439 * currently assigned host command returned by
440 * VbglR3GuestCtrlMsgWaitFor().
441 */
442typedef struct HGCMMsgCmdSkip
443{
444 VBoxGuestHGCMCallInfo hdr;
445
446} HGCMMsgCmdSkip;
447
448/**
449 * Asks the guest control host service to cancel all pending (outstanding)
450 * waits which were not processed yet. This is handy for a graceful shutdown.
451 */
452typedef struct HGCMMsgCancelPendingWaits
453{
454 VBoxGuestHGCMCallInfo hdr;
455} HGCMMsgCancelPendingWaits;
456
457/**
458 * Creates a guest session.
459 */
460typedef struct HGCMMsgSessionOpen
461{
462 VBoxGuestHGCMCallInfo hdr;
463 /** Context ID. */
464 HGCMFunctionParameter context;
465 /** The guest control protocol version this
466 * session is about to use. */
467 HGCMFunctionParameter protocol;
468 /** The user name to run the guest session under. */
469 HGCMFunctionParameter username;
470 /** The user's password. */
471 HGCMFunctionParameter password;
472 /** The domain to run the guest session under. */
473 HGCMFunctionParameter domain;
474 /** Session creation flags. */
475 HGCMFunctionParameter flags;
476} HGCMMsgSessionOpen;
477
478/**
479 * Terminates (closes) a guest session.
480 */
481typedef struct HGCMMsgSessionClose
482{
483 VBoxGuestHGCMCallInfo hdr;
484 /** Context ID. */
485 HGCMFunctionParameter context;
486 /** Session termination flags. */
487 HGCMFunctionParameter flags;
488} HGCMMsgSessionClose;
489
490/**
491 * Reports back a guest session's status.
492 */
493typedef struct HGCMMsgSessionNotify
494{
495 VBoxGuestHGCMCallInfo hdr;
496 /** Context ID. */
497 HGCMFunctionParameter context;
498 /** Notification type. */
499 HGCMFunctionParameter type;
500 /** Notification result. */
501 HGCMFunctionParameter result;
502} HGCMMsgSessionNotify;
503
504/**
505 * Executes a command inside the guest.
506 */
507typedef struct HGCMMsgProcExec
508{
509 VBoxGuestHGCMCallInfo hdr;
510 /** Context ID. */
511 HGCMFunctionParameter context;
512 /** The command to execute on the guest. */
513 HGCMFunctionParameter cmd;
514 /** Execution flags (see IGuest::ProcessCreateFlag_*). */
515 HGCMFunctionParameter flags;
516 /** Number of arguments. */
517 HGCMFunctionParameter num_args;
518 /** The actual arguments. */
519 HGCMFunctionParameter args;
520 /** Number of environment value pairs. */
521 HGCMFunctionParameter num_env;
522 /** Size (in bytes) of environment block, including terminating zeros. */
523 HGCMFunctionParameter cb_env;
524 /** The actual environment block. */
525 HGCMFunctionParameter env;
526 union
527 {
528 struct
529 {
530 /** The user name to run the executed command under.
531 * Only for VBox < 4.3 hosts. */
532 HGCMFunctionParameter username;
533 /** The user's password.
534 * Only for VBox < 4.3 hosts. */
535 HGCMFunctionParameter password;
536 /** Timeout (in msec) which either specifies the
537 * overall lifetime of the process or how long it
538 * can take to bring the process up and running -
539 * (depends on the IGuest::ProcessCreateFlag_*). */
540 HGCMFunctionParameter timeout;
541 } v1;
542 struct
543 {
544 /** Timeout (in msec) which either specifies the
545 * overall lifetime of the process or how long it
546 * can take to bring the process up and running -
547 * (depends on the IGuest::ProcessCreateFlag_*). */
548 HGCMFunctionParameter timeout;
549 /** Process priority. */
550 HGCMFunctionParameter priority;
551 /** Number of process affinity blocks. */
552 HGCMFunctionParameter num_affinity;
553 /** Pointer to process affinity blocks (uint64_t). */
554 HGCMFunctionParameter affinity;
555 } v2;
556 } u;
557
558} HGCMMsgProcExec;
559
560/**
561 * Sends input to a guest process via stdin.
562 */
563typedef struct HGCMMsgProcInput
564{
565 VBoxGuestHGCMCallInfo hdr;
566 /** Context ID. */
567 HGCMFunctionParameter context;
568 /** The process ID (PID) to send the input to. */
569 HGCMFunctionParameter pid;
570 /** Input flags (see IGuest::ProcessInputFlag_*). */
571 HGCMFunctionParameter flags;
572 /** Data buffer. */
573 HGCMFunctionParameter data;
574 /** Actual size of data (in bytes). */
575 HGCMFunctionParameter size;
576
577} HGCMMsgProcInput;
578
579/**
580 * Retrieves ouptut from a previously executed process
581 * from stdout/stderr.
582 */
583typedef struct HGCMMsgProcOutput
584{
585 VBoxGuestHGCMCallInfo hdr;
586 /** Context ID. */
587 HGCMFunctionParameter context;
588 /** The process ID (PID). */
589 HGCMFunctionParameter pid;
590 /** The pipe handle ID (stdout/stderr). */
591 HGCMFunctionParameter handle;
592 /** Optional flags. */
593 HGCMFunctionParameter flags;
594 /** Data buffer. */
595 HGCMFunctionParameter data;
596
597} HGCMMsgProcOutput;
598
599/**
600 * Reports the current status of a guest process.
601 */
602typedef struct HGCMMsgProcStatus
603{
604 VBoxGuestHGCMCallInfo hdr;
605 /** Context ID. */
606 HGCMFunctionParameter context;
607 /** The process ID (PID). */
608 HGCMFunctionParameter pid;
609 /** The process status. */
610 HGCMFunctionParameter status;
611 /** Optional flags (based on status). */
612 HGCMFunctionParameter flags;
613 /** Optional data buffer (not used atm). */
614 HGCMFunctionParameter data;
615
616} HGCMMsgProcStatus;
617
618/**
619 * Reports back the status of data written to a process.
620 */
621typedef struct HGCMMsgProcStatusInput
622{
623 VBoxGuestHGCMCallInfo hdr;
624 /** Context ID. */
625 HGCMFunctionParameter context;
626 /** The process ID (PID). */
627 HGCMFunctionParameter pid;
628 /** Status of the operation. */
629 HGCMFunctionParameter status;
630 /** Optional flags. */
631 HGCMFunctionParameter flags;
632 /** Data written. */
633 HGCMFunctionParameter written;
634
635} HGCMMsgProcStatusInput;
636
637/*
638 * Guest control 2.0 messages.
639 */
640
641/**
642 * Terminates a guest process.
643 */
644typedef struct HGCMMsgProcTerminate
645{
646 VBoxGuestHGCMCallInfo hdr;
647 /** Context ID. */
648 HGCMFunctionParameter context;
649 /** The process ID (PID). */
650 HGCMFunctionParameter pid;
651
652} HGCMMsgProcTerminate;
653
654/**
655 * Waits for certain events to happen.
656 */
657typedef struct HGCMMsgProcWaitFor
658{
659 VBoxGuestHGCMCallInfo hdr;
660 /** Context ID. */
661 HGCMFunctionParameter context;
662 /** The process ID (PID). */
663 HGCMFunctionParameter pid;
664 /** Wait (event) flags. */
665 HGCMFunctionParameter flags;
666 /** Timeout (in ms). */
667 HGCMFunctionParameter timeout;
668
669} HGCMMsgProcWaitFor;
670
671/**
672 * Opens a guest file.
673 */
674typedef struct HGCMMsgFileOpen
675{
676 VBoxGuestHGCMCallInfo hdr;
677 /** UInt32: Context ID. */
678 HGCMFunctionParameter context;
679 /** String: File to open. */
680 HGCMFunctionParameter filename;
681 /** String: Open mode. */
682 HGCMFunctionParameter openmode;
683 /** String: Disposition. */
684 HGCMFunctionParameter disposition;
685 /** UInt32: Creation mode. */
686 HGCMFunctionParameter creationmode;
687 /** UInt64: Initial offset. */
688 HGCMFunctionParameter offset;
689
690} HGCMMsgFileOpen;
691
692/**
693 * Closes a guest file.
694 */
695typedef struct HGCMMsgFileClose
696{
697 VBoxGuestHGCMCallInfo hdr;
698 /** Context ID. */
699 HGCMFunctionParameter context;
700 /** File handle to close. */
701 HGCMFunctionParameter handle;
702
703} HGCMMsgFileClose;
704
705/**
706 * Reads from a guest file.
707 */
708typedef struct HGCMMsgFileRead
709{
710 VBoxGuestHGCMCallInfo hdr;
711 /** Context ID. */
712 HGCMFunctionParameter context;
713 /** File handle to read from. */
714 HGCMFunctionParameter handle;
715 /** Size (in bytes) to read. */
716 HGCMFunctionParameter size;
717
718} HGCMMsgFileRead;
719
720/**
721 * Reads at a specified offset from a guest file.
722 */
723typedef struct HGCMMsgFileReadAt
724{
725 VBoxGuestHGCMCallInfo hdr;
726 /** Context ID. */
727 HGCMFunctionParameter context;
728 /** File handle to read from. */
729 HGCMFunctionParameter handle;
730 /** Offset where to start reading from. */
731 HGCMFunctionParameter offset;
732 /** Actual size of data (in bytes). */
733 HGCMFunctionParameter size;
734
735} HGCMMsgFileReadAt;
736
737/**
738 * Writes to a guest file.
739 */
740typedef struct HGCMMsgFileWrite
741{
742 VBoxGuestHGCMCallInfo hdr;
743 /** Context ID. */
744 HGCMFunctionParameter context;
745 /** File handle to write to. */
746 HGCMFunctionParameter handle;
747 /** Actual size of data (in bytes). */
748 HGCMFunctionParameter size;
749 /** Data buffer to write to the file. */
750 HGCMFunctionParameter data;
751
752} HGCMMsgFileWrite;
753
754/**
755 * Writes at a specified offset to a guest file.
756 */
757typedef struct HGCMMsgFileWriteAt
758{
759 VBoxGuestHGCMCallInfo hdr;
760 /** Context ID. */
761 HGCMFunctionParameter context;
762 /** File handle to write to. */
763 HGCMFunctionParameter handle;
764 /** Offset where to start reading from. */
765 HGCMFunctionParameter offset;
766 /** Actual size of data (in bytes). */
767 HGCMFunctionParameter size;
768 /** Data buffer to write to the file. */
769 HGCMFunctionParameter data;
770
771} HGCMMsgFileWriteAt;
772
773/**
774 * Seeks the read/write position of a guest file.
775 */
776typedef struct HGCMMsgFileSeek
777{
778 VBoxGuestHGCMCallInfo hdr;
779 /** Context ID. */
780 HGCMFunctionParameter context;
781 /** File handle to seek. */
782 HGCMFunctionParameter handle;
783 /** The seeking method. */
784 HGCMFunctionParameter method;
785 /** The seeking offset. */
786 HGCMFunctionParameter offset;
787
788} HGCMMsgFileSeek;
789
790/**
791 * Tells the current read/write position of a guest file.
792 */
793typedef struct HGCMMsgFileTell
794{
795 VBoxGuestHGCMCallInfo hdr;
796 /** Context ID. */
797 HGCMFunctionParameter context;
798 /** File handle to get the current position for. */
799 HGCMFunctionParameter handle;
800
801} HGCMMsgFileTell;
802
803/******************************************************************************
804* HGCM replies from the guest. These are handled in Main's low-level HGCM *
805* callbacks and dispatched to the appropriate guest object. *
806******************************************************************************/
807
808typedef struct HGCMReplyFileNotify
809{
810 VBoxGuestHGCMCallInfo hdr;
811 /** Context ID. */
812 HGCMFunctionParameter context;
813 /** Notification type. */
814 HGCMFunctionParameter type;
815 /** IPRT result of overall operation. */
816 HGCMFunctionParameter rc;
817 union
818 {
819 struct
820 {
821 /** Guest file handle. */
822 HGCMFunctionParameter handle;
823 } open;
824 /** Note: Close does not have any additional data (yet). */
825 struct
826 {
827 /** Actual data read (if any). */
828 HGCMFunctionParameter data;
829 } read;
830 struct
831 {
832 /** How much data (in bytes) have been successfully written. */
833 HGCMFunctionParameter written;
834 } write;
835 struct
836 {
837 HGCMFunctionParameter offset;
838 } seek;
839 struct
840 {
841 HGCMFunctionParameter offset;
842 } tell;
843 } u;
844
845} HGCMReplyFileNotify;
846
847#pragma pack ()
848
849/******************************************************************************
850* Callback data structures. *
851******************************************************************************/
852
853/**
854 * The guest control callback data header. Must come first
855 * on each callback structure defined below this struct.
856 */
857typedef struct CALLBACKDATA_HEADER
858{
859 /** Context ID to identify callback data. This is
860 * and *must* be the very first parameter in this
861 * structure to still be backwards compatible. */
862 uint32_t uContextID;
863} CALLBACKDATA_HEADER, *PCALLBACKDATA_HEADER;
864
865/*
866 * These structures make up the actual low level HGCM callback data sent from
867 * the guest back to the host.
868 */
869
870typedef struct CALLBACKDATA_CLIENT_DISCONNECTED
871{
872 /** Callback data header. */
873 CALLBACKDATA_HEADER hdr;
874} CALLBACKDATA_CLIENT_DISCONNECTED, *PCALLBACKDATA_CLIENT_DISCONNECTED;
875
876typedef struct CALLBACKDATA_SESSION_NOTIFY
877{
878 /** Callback data header. */
879 CALLBACKDATA_HEADER hdr;
880 /** Notification type. */
881 uint32_t uType;
882 /** Notification result. Note: int vs. uint32! */
883 uint32_t uResult;
884} CALLBACKDATA_SESSION_NOTIFY, *PCALLBACKDATA_SESSION_NOTIFY;
885
886typedef struct CALLBACKDATA_PROC_STATUS
887{
888 /** Callback data header. */
889 CALLBACKDATA_HEADER hdr;
890 /** The process ID (PID). */
891 uint32_t uPID;
892 /** The process status. */
893 uint32_t uStatus;
894 /** Optional flags, varies, based on u32Status. */
895 uint32_t uFlags;
896 /** Optional data buffer (not used atm). */
897 void *pvData;
898 /** Size of optional data buffer (not used atm). */
899 uint32_t cbData;
900} CALLBACKDATA_PROC_STATUS, *PCALLBACKDATA_PROC_STATUS;
901
902typedef struct CALLBACKDATA_PROC_OUTPUT
903{
904 /** Callback data header. */
905 CALLBACKDATA_HEADER hdr;
906 /** The process ID (PID). */
907 uint32_t uPID;
908 /** The handle ID (stdout/stderr). */
909 uint32_t uHandle;
910 /** Optional flags (not used atm). */
911 uint32_t uFlags;
912 /** Optional data buffer. */
913 void *pvData;
914 /** Size (in bytes) of optional data buffer. */
915 uint32_t cbData;
916} CALLBACKDATA_PROC_OUTPUT, *PCALLBACKDATA_PROC_OUTPUT;
917
918typedef struct CALLBACKDATA_PROC_INPUT
919{
920 /** Callback data header. */
921 CALLBACKDATA_HEADER hdr;
922 /** The process ID (PID). */
923 uint32_t uPID;
924 /** Current input status. */
925 uint32_t uStatus;
926 /** Optional flags. */
927 uint32_t uFlags;
928 /** Size (in bytes) of processed input data. */
929 uint32_t uProcessed;
930} CALLBACKDATA_PROC_INPUT, *PCALLBACKDATA_PROC_INPUT;
931
932/**
933 * General guest file notification callback.
934 */
935typedef struct CALLBACKDATA_FILE_NOTIFY
936{
937 /** Callback data header. */
938 CALLBACKDATA_HEADER hdr;
939 /** Notification type. */
940 uint32_t uType;
941 /** IPRT result of overall operation. */
942 uint32_t rc;
943 union
944 {
945 struct
946 {
947 /** Guest file handle. */
948 uint32_t uHandle;
949 } open;
950 /** Note: Close does not have any additional data (yet). */
951 struct
952 {
953 /** How much data (in bytes) have been read. */
954 uint32_t cbData;
955 /** Actual data read (if any). */
956 void *pvData;
957 } read;
958 struct
959 {
960 /** How much data (in bytes) have been successfully written. */
961 uint32_t cbWritten;
962 } write;
963 struct
964 {
965 /** New file offset after successful seek. */
966 uint64_t uOffActual;
967 } seek;
968 struct
969 {
970 /** New file offset after successful tell. */
971 uint64_t uOffActual;
972 } tell;
973 } u;
974} CALLBACKDATA_FILE_NOTIFY, *PCALLBACKDATA_FILE_NOTIFY;
975
976} /* namespace guestControl */
977
978#endif /* !___VBox_HostService_GuestControlService_h */
979
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