VirtualBox

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

Last change on this file since 73768 was 71364, checked in by vboxsync, 6 years ago

GuestControl: Added and implemented IGuestSession::userHome and IGuestSession::userDocuments attributes. Untested.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 30.9 KB
Line 
1/* $Id: GuestControlSvc.h 71364 2018-03-16 09:58:05Z vboxsync $ */
2/** @file
3 * Guest control service - Common header for host service and guest clients.
4 */
5
6/*
7 * Copyright (C) 2011-2018 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#ifndef ___VBox_HostService_GuestControlService_h
28#define ___VBox_HostService_GuestControlService_h
29
30#include <VBox/VMMDevCoreTypes.h>
31#include <VBox/VBoxGuestCoreTypes.h>
32#include <VBox/hgcmsvc.h>
33#include <iprt/assert.h>
34
35/* Everything defined in this file lives in this namespace. */
36namespace guestControl {
37
38/******************************************************************************
39* Typedefs, constants and inlines *
40******************************************************************************/
41
42#define HGCMSERVICE_NAME "VBoxGuestControlSvc"
43
44/** Maximum number of concurrent guest sessions a VM can have. */
45#define VBOX_GUESTCTRL_MAX_SESSIONS 32
46/** Maximum number of concurrent guest objects (processes, files, ...)
47 * a guest session can have. */
48#define VBOX_GUESTCTRL_MAX_OBJECTS _2K
49/** Maximum of callback contexts a guest process can have. */
50#define VBOX_GUESTCTRL_MAX_CONTEXTS _64K
51
52/** Base (start) of guest control session IDs. Session
53 * ID 0 is reserved for the root process which
54 * hosts all other guest session processes. */
55#define VBOX_GUESTCTRL_SESSION_ID_BASE 1
56
57/** Builds a context ID out of the session ID, object ID and an
58 * increasing count. */
59#define VBOX_GUESTCTRL_CONTEXTID_MAKE(uSession, uObject, uCount) \
60 ( (uint32_t)((uSession) & 0x1f) << 27 \
61 | (uint32_t)((uObject) & 0x7ff) << 16 \
62 | (uint32_t)((uCount) & 0xffff) \
63 )
64/** Creates a context ID out of a session ID. */
65#define VBOX_GUESTCTRL_CONTEXTID_MAKE_SESSION(uSession) \
66 ((uint32_t)((uSession) & 0x1f) << 27)
67/** Gets the session ID out of a context ID. */
68#define VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(uContextID) \
69 (((uContextID) >> 27) & 0x1f)
70/** Gets the process ID out of a context ID. */
71#define VBOX_GUESTCTRL_CONTEXTID_GET_OBJECT(uContextID) \
72 (((uContextID) >> 16) & 0x7ff)
73/** Gets the context count of a process out of a context ID. */
74#define VBOX_GUESTCTRL_CONTEXTID_GET_COUNT(uContextID) \
75 ((uContextID) & 0xffff)
76/** Filter context IDs by session. Can be used in conjunction
77 * with VbglR3GuestCtrlMsgFilterSet(). */
78#define VBOX_GUESTCTRL_FILTER_BY_SESSION(uSession) \
79 (VBOX_GUESTCTRL_CONTEXTID_MAKE_SESSION(uSession) | 0xF8000000)
80
81/**
82 * Structure keeping the context of a host callback.
83 */
84typedef struct VBoxGuestCtrlHostCbCtx
85{
86 /** HGCM Function number. */
87 uint32_t uFunction;
88 /** The context ID. */
89 uint32_t uContextID;
90 /** Protocol version of this guest session. Might
91 * be 0 if not supported. */
92 uint32_t uProtocol;
93
94} VBOXGUESTCTRLHOSTCBCTX, *PVBOXGUESTCTRLHOSTCBCTX;
95
96/**
97 * Structure for low level HGCM host callback from
98 * the guest. No deep copy. */
99typedef struct VBoxGuestCtrlHostCallback
100{
101 VBoxGuestCtrlHostCallback(uint32_t cParms, VBOXHGCMSVCPARM paParms[])
102 : mParms(cParms), mpaParms(paParms) { }
103
104 /** Number of HGCM parameters. */
105 uint32_t mParms;
106 /** Actual HGCM parameters. */
107 PVBOXHGCMSVCPARM mpaParms;
108
109} VBOXGUESTCTRLHOSTCALLBACK, *PVBOXGUESTCTRLHOSTCALLBACK;
110
111/**
112 * The service functions which are callable by host.
113 */
114enum eHostFn
115{
116 /**
117 * The host asks the client to cancel all pending waits and exit.
118 */
119 HOST_CANCEL_PENDING_WAITS = 0,
120 /**
121 * The host wants to create a guest session.
122 */
123 HOST_SESSION_CREATE = 20,
124 /**
125 * The host wants to close a guest session.
126 */
127 HOST_SESSION_CLOSE = 21,
128 /**
129 * The host wants to execute something in the guest. This can be a command line
130 * or starting a program.
131 ** Note: Legacy (VBox < 4.3) command.
132 */
133 HOST_EXEC_CMD = 100,
134 /**
135 * Sends input data for stdin to a running process executed by HOST_EXEC_CMD.
136 ** Note: Legacy (VBox < 4.3) command.
137 */
138 HOST_EXEC_SET_INPUT = 101,
139 /**
140 * Gets the current status of a running process, e.g.
141 * new data on stdout/stderr, process terminated etc.
142 ** Note: Legacy (VBox < 4.3) command.
143 */
144 HOST_EXEC_GET_OUTPUT = 102,
145 /**
146 * Terminates a running guest process.
147 */
148 HOST_EXEC_TERMINATE = 110,
149 /**
150 * Waits for a certain event to happen. This can be an input, output
151 * or status event.
152 */
153 HOST_EXEC_WAIT_FOR = 120,
154 /**
155 * Opens a guest file.
156 */
157 HOST_FILE_OPEN = 240,
158 /**
159 * Closes a guest file.
160 */
161 HOST_FILE_CLOSE = 241,
162 /**
163 * Reads from an opened guest file.
164 */
165 HOST_FILE_READ = 250,
166 /**
167 * Reads from an opened guest file at
168 * a specified offset.
169 */
170 HOST_FILE_READ_AT = 251,
171 /**
172 * Write to an opened guest file.
173 */
174 HOST_FILE_WRITE = 260,
175 /**
176 * Write to an opened guest file at
177 * a specified offset.
178 */
179 HOST_FILE_WRITE_AT = 261,
180 /**
181 * Changes the read & write position of an opened guest file.
182 */
183 HOST_FILE_SEEK = 270,
184 /**
185 * Gets the current file position of an opened guest file.
186 */
187 HOST_FILE_TELL = 271,
188 /**
189 * Removes a directory on the guest.
190 */
191 HOST_DIR_REMOVE = 320,
192 /**
193 * Renames a path on the guest.
194 */
195 HOST_PATH_RENAME = 330,
196 /**
197 * Retrieves the user's documents directory.
198 */
199 HOST_PATH_USER_DOCUMENTS = 331,
200 /**
201 * Retrieves the user's home directory.
202 */
203 HOST_PATH_USER_HOME = 332
204};
205
206/**
207 * The service functions which are called by guest. The numbers may not change,
208 * so we hardcode them.
209 */
210enum eGuestFn
211{
212 /**
213 * Guest waits for a new message the host wants to process on the guest side.
214 * This is a blocking call and can be deferred.
215 *
216 * @note This command is rather odd. The above description isn't really
217 * correct. Yes, it (1) waits for a new message and will return the
218 * mesage number and parameter count when one is available. However, it
219 * is also (2) used to retrieve the message parameters. For some weird
220 * reasons it was decided that it should always return VERR_TOO_MUCH_DATA
221 * when used in the first capacity.
222 *
223 * @todo r=bird: Next time this interface gets a major adjustment, please split
224 * this function up into two calls and, for heavens sake, make them return
225 * VINF_SUCCESS on success.
226 */
227 GUEST_MSG_WAIT = 1,
228 /**
229 * Guest asks the host to cancel all pending waits the guest itself waits on.
230 * This becomes necessary when the guest wants to quit but still waits for
231 * commands from the host.
232 */
233 GUEST_CANCEL_PENDING_WAITS = 2,
234 /**
235 * Guest disconnected (terminated normally or due to a crash HGCM
236 * detected when calling service::clientDisconnect().
237 */
238 GUEST_DISCONNECTED = 3,
239 /**
240 * Sets a message filter to only get messages which have a certain
241 * context ID scheme (that is, a specific session, object etc).
242 * Since VBox 4.3+.
243 */
244 GUEST_MSG_FILTER_SET = 4,
245 /**
246 * Unsets (and resets) a previously set message filter.
247 */
248 GUEST_MSG_FILTER_UNSET = 5,
249 /**
250 * Skips the current assigned message returned by GUEST_MSG_WAIT.
251 * Needed for telling the host service to not keep stale
252 * host commands in the queue.
253 */
254 GUEST_MSG_SKIP = 10,
255 /**
256 * General reply to a host message. Only contains basic data
257 * along with a simple payload.
258 */
259 GUEST_MSG_REPLY = 11,
260 /**
261 * General message for updating a pending progress for
262 * a long task.
263 */
264 GUEST_MSG_PROGRESS_UPDATE = 12,
265 /**
266 * Guest reports back a guest session status.
267 */
268 GUEST_SESSION_NOTIFY = 20,
269 /**
270 * Guest wants to close a specific guest session.
271 */
272 GUEST_SESSION_CLOSE = 21,
273 /**
274 * Guests sends output from an executed process.
275 */
276 GUEST_EXEC_OUTPUT = 100,
277 /**
278 * Guest sends a status update of an executed process to the host.
279 */
280 GUEST_EXEC_STATUS = 101,
281 /**
282 * Guests sends an input status notification to the host.
283 */
284 GUEST_EXEC_INPUT_STATUS = 102,
285 /**
286 * Guest notifies the host about some I/O event. This can be
287 * a stdout, stderr or a stdin event. The actual event only tells
288 * how many data is available / can be sent without actually
289 * transmitting the data.
290 */
291 GUEST_EXEC_IO_NOTIFY = 210,
292 /**
293 * Guest notifies the host about some directory event.
294 */
295 GUEST_DIR_NOTIFY = 230,
296 /**
297 * Guest notifies the host about some file event.
298 */
299 GUEST_FILE_NOTIFY = 240
300};
301
302/**
303 * Guest session notification types.
304 * @sa HGCMMsgSessionNotify.
305 */
306enum GUEST_SESSION_NOTIFYTYPE
307{
308 GUEST_SESSION_NOTIFYTYPE_UNDEFINED = 0,
309 /** Something went wrong (see rc). */
310 GUEST_SESSION_NOTIFYTYPE_ERROR = 1,
311 /** Guest session has been started. */
312 GUEST_SESSION_NOTIFYTYPE_STARTED = 11,
313 /** Guest session terminated normally. */
314 GUEST_SESSION_NOTIFYTYPE_TEN = 20,
315 /** Guest session terminated via signal. */
316 GUEST_SESSION_NOTIFYTYPE_TES = 30,
317 /** Guest session terminated abnormally. */
318 GUEST_SESSION_NOTIFYTYPE_TEA = 40,
319 /** Guest session timed out and was killed. */
320 GUEST_SESSION_NOTIFYTYPE_TOK = 50,
321 /** Guest session timed out and was not killed successfully. */
322 GUEST_SESSION_NOTIFYTYPE_TOA = 60,
323 /** Service/OS is stopping, process was killed. */
324 GUEST_SESSION_NOTIFYTYPE_DWN = 150
325};
326
327/**
328 * Guest directory notification types.
329 * @sa HGCMMsgDirNotify.
330 */
331enum GUEST_DIR_NOTIFYTYPE
332{
333 GUEST_DIR_NOTIFYTYPE_UNKNOWN = 0,
334 /** Something went wrong (see rc). */
335 GUEST_DIR_NOTIFYTYPE_ERROR = 1,
336 /** Guest directory opened. */
337 GUEST_DIR_NOTIFYTYPE_OPEN = 10,
338 /** Guest directory closed. */
339 GUEST_DIR_NOTIFYTYPE_CLOSE = 20,
340 /** Information about an open guest directory. */
341 GUEST_DIR_NOTIFYTYPE_INFO = 40,
342 /** Guest directory created. */
343 GUEST_DIR_NOTIFYTYPE_CREATE = 70,
344 /** Guest directory deleted. */
345 GUEST_DIR_NOTIFYTYPE_REMOVE = 80
346};
347
348/**
349 * Guest file notification types.
350 * @sa HGCMMsgFileNotify.
351 */
352enum GUEST_FILE_NOTIFYTYPE
353{
354 GUEST_FILE_NOTIFYTYPE_UNKNOWN = 0,
355 GUEST_FILE_NOTIFYTYPE_ERROR = 1,
356 GUEST_FILE_NOTIFYTYPE_OPEN = 10,
357 GUEST_FILE_NOTIFYTYPE_CLOSE = 20,
358 GUEST_FILE_NOTIFYTYPE_READ = 30,
359 GUEST_FILE_NOTIFYTYPE_WRITE = 40,
360 GUEST_FILE_NOTIFYTYPE_SEEK = 50,
361 GUEST_FILE_NOTIFYTYPE_TELL = 60
362};
363
364/**
365 * Guest file seeking types. Has to
366 * match FileSeekType in Main.
367 */
368enum GUEST_FILE_SEEKTYPE
369{
370 GUEST_FILE_SEEKTYPE_BEGIN = 1,
371 GUEST_FILE_SEEKTYPE_CURRENT = 4,
372 GUEST_FILE_SEEKTYPE_END = 8
373};
374
375/*
376 * HGCM parameter structures.
377 */
378#pragma pack (1)
379
380/**
381 * Waits for a host command to arrive. The structure then contains the
382 * actual message type + required number of parameters needed to successfully
383 * retrieve that host command (in a next round).
384 */
385typedef struct HGCMMsgCmdWaitFor
386{
387 VBGLIOCHGCMCALL hdr;
388 /**
389 * The returned command the host wants to
390 * run on the guest.
391 */
392 HGCMFunctionParameter msg; /* OUT uint32_t */
393 /** Number of parameters the message needs. */
394 HGCMFunctionParameter num_parms; /* OUT uint32_t */
395} HGCMMsgCmdWaitFor;
396
397/**
398 * Asks the guest control host service to set a command
399 * filter for this client. This filter will then only
400 * deliver messages to the client which match the
401 * wanted context ID (ranges).
402 */
403typedef struct HGCMMsgCmdFilterSet
404{
405 VBGLIOCHGCMCALL hdr;
406 /** Value to filter for after filter mask
407 * was applied. */
408 HGCMFunctionParameter value; /* IN uint32_t */
409 /** Mask to add to the current set filter. */
410 HGCMFunctionParameter mask_add; /* IN uint32_t */
411 /** Mask to remove from the current set filter. */
412 HGCMFunctionParameter mask_remove; /* IN uint32_t */
413 /** Filter flags; currently unused. */
414 HGCMFunctionParameter flags; /* IN uint32_t */
415} HGCMMsgCmdFilterSet;
416
417/**
418 * Asks the guest control host service to disable
419 * a previously set message filter again.
420 */
421typedef struct HGCMMsgCmdFilterUnset
422{
423 VBGLIOCHGCMCALL hdr;
424 /** Unset flags; currently unused. */
425 HGCMFunctionParameter flags; /* IN uint32_t */
426} HGCMMsgCmdFilterUnset;
427
428/**
429 * Asks the guest control host service to skip the
430 * currently assigned host command returned by
431 * VbglR3GuestCtrlMsgWaitFor().
432 */
433typedef struct HGCMMsgCmdSkip
434{
435 VBGLIOCHGCMCALL hdr;
436 /** Skip flags; currently unused. */
437 HGCMFunctionParameter flags; /* IN uint32_t */
438} HGCMMsgCmdSkip;
439
440/**
441 * Asks the guest control host service to cancel all pending (outstanding)
442 * waits which were not processed yet. This is handy for a graceful shutdown.
443 */
444typedef struct HGCMMsgCancelPendingWaits
445{
446 VBGLIOCHGCMCALL hdr;
447} HGCMMsgCancelPendingWaits;
448
449typedef struct HGCMMsgCmdReply
450{
451 VBGLIOCHGCMCALL hdr;
452 /** Context ID. */
453 HGCMFunctionParameter context;
454 /** Message type. */
455 HGCMFunctionParameter type;
456 /** IPRT result of overall operation. */
457 HGCMFunctionParameter rc;
458 /** Optional payload to this reply. */
459 HGCMFunctionParameter payload;
460} HGCMMsgCmdReply;
461
462/**
463 * Creates a guest session.
464 */
465typedef struct HGCMMsgSessionOpen
466{
467 VBGLIOCHGCMCALL hdr;
468 /** Context ID. */
469 HGCMFunctionParameter context;
470 /** The guest control protocol version this
471 * session is about to use. */
472 HGCMFunctionParameter protocol;
473 /** The user name to run the guest session under. */
474 HGCMFunctionParameter username;
475 /** The user's password. */
476 HGCMFunctionParameter password;
477 /** The domain to run the guest session under. */
478 HGCMFunctionParameter domain;
479 /** Session creation flags. */
480 HGCMFunctionParameter flags;
481} HGCMMsgSessionOpen;
482
483/**
484 * Terminates (closes) a guest session.
485 */
486typedef struct HGCMMsgSessionClose
487{
488 VBGLIOCHGCMCALL hdr;
489 /** Context ID. */
490 HGCMFunctionParameter context;
491 /** Session termination flags. */
492 HGCMFunctionParameter flags;
493} HGCMMsgSessionClose;
494
495/**
496 * Reports back a guest session's status.
497 */
498typedef struct HGCMMsgSessionNotify
499{
500 VBGLIOCHGCMCALL hdr;
501 /** Context ID. */
502 HGCMFunctionParameter context;
503 /** Notification type. */
504 HGCMFunctionParameter type;
505 /** Notification result. */
506 HGCMFunctionParameter result;
507} HGCMMsgSessionNotify;
508
509typedef struct HGCMMsgPathRename
510{
511 VBGLIOCHGCMCALL hdr;
512 /** UInt32: Context ID. */
513 HGCMFunctionParameter context;
514 /** Source to rename. */
515 HGCMFunctionParameter source;
516 /** Destination to rename source to. */
517 HGCMFunctionParameter dest;
518 /** UInt32: Rename flags. */
519 HGCMFunctionParameter flags;
520} HGCMMsgPathRename;
521
522typedef struct HGCMMsgPathUserDocuments
523{
524 VBGLIOCHGCMCALL hdr;
525 /** UInt32: Context ID. */
526 HGCMFunctionParameter context;
527} HGCMMsgPathUserDocuments;
528
529typedef struct HGCMMsgPathUserHome
530{
531 VBGLIOCHGCMCALL hdr;
532 /** UInt32: Context ID. */
533 HGCMFunctionParameter context;
534} HGCMMsgPathUserHome;
535
536/**
537 * Executes a command inside the guest.
538 */
539typedef struct HGCMMsgProcExec
540{
541 VBGLIOCHGCMCALL hdr;
542 /** Context ID. */
543 HGCMFunctionParameter context;
544 /** The command to execute on the guest. */
545 HGCMFunctionParameter cmd;
546 /** Execution flags (see IGuest::ProcessCreateFlag_*). */
547 HGCMFunctionParameter flags;
548 /** Number of arguments. */
549 HGCMFunctionParameter num_args;
550 /** The actual arguments. */
551 HGCMFunctionParameter args;
552 /** Number of environment value pairs. */
553 HGCMFunctionParameter num_env;
554 /** Size (in bytes) of environment block, including terminating zeros. */
555 HGCMFunctionParameter cb_env;
556 /** The actual environment block. */
557 HGCMFunctionParameter env;
558 union
559 {
560 struct
561 {
562 /** The user name to run the executed command under.
563 * Only for VBox < 4.3 hosts. */
564 HGCMFunctionParameter username;
565 /** The user's password.
566 * Only for VBox < 4.3 hosts. */
567 HGCMFunctionParameter password;
568 /** Timeout (in msec) which either specifies the
569 * overall lifetime of the process or how long it
570 * can take to bring the process up and running -
571 * (depends on the IGuest::ProcessCreateFlag_*). */
572 HGCMFunctionParameter timeout;
573 } v1;
574 struct
575 {
576 /** Timeout (in ms) which either specifies the
577 * overall lifetime of the process or how long it
578 * can take to bring the process up and running -
579 * (depends on the IGuest::ProcessCreateFlag_*). */
580 HGCMFunctionParameter timeout;
581 /** Process priority. */
582 HGCMFunctionParameter priority;
583 /** Number of process affinity blocks. */
584 HGCMFunctionParameter num_affinity;
585 /** Pointer to process affinity blocks (uint64_t). */
586 HGCMFunctionParameter affinity;
587 } v2;
588 } u;
589} HGCMMsgProcExec;
590
591/**
592 * Sends input to a guest process via stdin.
593 */
594typedef struct HGCMMsgProcInput
595{
596 VBGLIOCHGCMCALL hdr;
597 /** Context ID. */
598 HGCMFunctionParameter context;
599 /** The process ID (PID) to send the input to. */
600 HGCMFunctionParameter pid;
601 /** Input flags (see IGuest::ProcessInputFlag_*). */
602 HGCMFunctionParameter flags;
603 /** Data buffer. */
604 HGCMFunctionParameter data;
605 /** Actual size of data (in bytes). */
606 HGCMFunctionParameter size;
607} HGCMMsgProcInput;
608
609/**
610 * Retrieves ouptut from a previously executed process
611 * from stdout/stderr.
612 */
613typedef struct HGCMMsgProcOutput
614{
615 VBGLIOCHGCMCALL hdr;
616 /** Context ID. */
617 HGCMFunctionParameter context;
618 /** The process ID (PID). */
619 HGCMFunctionParameter pid;
620 /** The pipe handle ID (stdout/stderr). */
621 HGCMFunctionParameter handle;
622 /** Optional flags. */
623 HGCMFunctionParameter flags;
624 /** Data buffer. */
625 HGCMFunctionParameter data;
626} HGCMMsgProcOutput;
627
628/**
629 * Reports the current status of a guest process.
630 */
631typedef struct HGCMMsgProcStatus
632{
633 VBGLIOCHGCMCALL hdr;
634 /** Context ID. */
635 HGCMFunctionParameter context;
636 /** The process ID (PID). */
637 HGCMFunctionParameter pid;
638 /** The process status. */
639 HGCMFunctionParameter status;
640 /** Optional flags (based on status). */
641 HGCMFunctionParameter flags;
642 /** Optional data buffer (not used atm). */
643 HGCMFunctionParameter data;
644} HGCMMsgProcStatus;
645
646/**
647 * Reports back the status of data written to a process.
648 */
649typedef struct HGCMMsgProcStatusInput
650{
651 VBGLIOCHGCMCALL hdr;
652 /** Context ID. */
653 HGCMFunctionParameter context;
654 /** The process ID (PID). */
655 HGCMFunctionParameter pid;
656 /** Status of the operation. */
657 HGCMFunctionParameter status;
658 /** Optional flags. */
659 HGCMFunctionParameter flags;
660 /** Data written. */
661 HGCMFunctionParameter written;
662} HGCMMsgProcStatusInput;
663
664/*
665 * Guest control 2.0 messages.
666 */
667
668/**
669 * Terminates a guest process.
670 */
671typedef struct HGCMMsgProcTerminate
672{
673 VBGLIOCHGCMCALL hdr;
674 /** Context ID. */
675 HGCMFunctionParameter context;
676 /** The process ID (PID). */
677 HGCMFunctionParameter pid;
678} HGCMMsgProcTerminate;
679
680/**
681 * Waits for certain events to happen.
682 */
683typedef struct HGCMMsgProcWaitFor
684{
685 VBGLIOCHGCMCALL hdr;
686 /** Context ID. */
687 HGCMFunctionParameter context;
688 /** The process ID (PID). */
689 HGCMFunctionParameter pid;
690 /** Wait (event) flags. */
691 HGCMFunctionParameter flags;
692 /** Timeout (in ms). */
693 HGCMFunctionParameter timeout;
694} HGCMMsgProcWaitFor;
695
696typedef struct HGCMMsgDirRemove
697{
698 VBGLIOCHGCMCALL hdr;
699 /** UInt32: Context ID. */
700 HGCMFunctionParameter context;
701 /** Directory to remove. */
702 HGCMFunctionParameter path;
703 /** UInt32: Removement flags. */
704 HGCMFunctionParameter flags;
705} HGCMMsgDirRemove;
706
707/**
708 * Opens a guest file.
709 */
710typedef struct HGCMMsgFileOpen
711{
712 VBGLIOCHGCMCALL hdr;
713 /** UInt32: Context ID. */
714 HGCMFunctionParameter context;
715 /** File to open. */
716 HGCMFunctionParameter filename;
717 /** Open mode. */
718 HGCMFunctionParameter openmode;
719 /** Disposition mode. */
720 HGCMFunctionParameter disposition;
721 /** Sharing mode. */
722 HGCMFunctionParameter sharing;
723 /** UInt32: Creation mode. */
724 HGCMFunctionParameter creationmode;
725 /** UInt64: Initial offset. */
726 HGCMFunctionParameter offset;
727} HGCMMsgFileOpen;
728
729/**
730 * Closes a guest file.
731 */
732typedef struct HGCMMsgFileClose
733{
734 VBGLIOCHGCMCALL hdr;
735 /** Context ID. */
736 HGCMFunctionParameter context;
737 /** File handle to close. */
738 HGCMFunctionParameter handle;
739} HGCMMsgFileClose;
740
741/**
742 * Reads from a guest file.
743 */
744typedef struct HGCMMsgFileRead
745{
746 VBGLIOCHGCMCALL hdr;
747 /** Context ID. */
748 HGCMFunctionParameter context;
749 /** File handle to read from. */
750 HGCMFunctionParameter handle;
751 /** Size (in bytes) to read. */
752 HGCMFunctionParameter size;
753} HGCMMsgFileRead;
754
755/**
756 * Reads at a specified offset from a guest file.
757 */
758typedef struct HGCMMsgFileReadAt
759{
760 VBGLIOCHGCMCALL hdr;
761 /** Context ID. */
762 HGCMFunctionParameter context;
763 /** File handle to read from. */
764 HGCMFunctionParameter handle;
765 /** Offset where to start reading from. */
766 HGCMFunctionParameter offset;
767 /** Actual size of data (in bytes). */
768 HGCMFunctionParameter size;
769} HGCMMsgFileReadAt;
770
771/**
772 * Writes to a guest file.
773 */
774typedef struct HGCMMsgFileWrite
775{
776 VBGLIOCHGCMCALL hdr;
777 /** Context ID. */
778 HGCMFunctionParameter context;
779 /** File handle to write to. */
780 HGCMFunctionParameter handle;
781 /** Actual size of data (in bytes). */
782 HGCMFunctionParameter size;
783 /** Data buffer to write to the file. */
784 HGCMFunctionParameter data;
785} HGCMMsgFileWrite;
786
787/**
788 * Writes at a specified offset to a guest file.
789 */
790typedef struct HGCMMsgFileWriteAt
791{
792 VBGLIOCHGCMCALL hdr;
793 /** Context ID. */
794 HGCMFunctionParameter context;
795 /** File handle to write to. */
796 HGCMFunctionParameter handle;
797 /** Offset where to start reading from. */
798 HGCMFunctionParameter offset;
799 /** Actual size of data (in bytes). */
800 HGCMFunctionParameter size;
801 /** Data buffer to write to the file. */
802 HGCMFunctionParameter data;
803} HGCMMsgFileWriteAt;
804
805/**
806 * Seeks the read/write position of a guest file.
807 */
808typedef struct HGCMMsgFileSeek
809{
810 VBGLIOCHGCMCALL hdr;
811 /** Context ID. */
812 HGCMFunctionParameter context;
813 /** File handle to seek. */
814 HGCMFunctionParameter handle;
815 /** The seeking method. */
816 HGCMFunctionParameter method;
817 /** The seeking offset. */
818 HGCMFunctionParameter offset;
819} HGCMMsgFileSeek;
820
821/**
822 * Tells the current read/write position of a guest file.
823 */
824typedef struct HGCMMsgFileTell
825{
826 VBGLIOCHGCMCALL hdr;
827 /** Context ID. */
828 HGCMFunctionParameter context;
829 /** File handle to get the current position for. */
830 HGCMFunctionParameter handle;
831} HGCMMsgFileTell;
832
833/******************************************************************************
834* HGCM replies from the guest. These are handled in Main's low-level HGCM *
835* callbacks and dispatched to the appropriate guest object. *
836******************************************************************************/
837
838typedef struct HGCMReplyFileNotify
839{
840 VBGLIOCHGCMCALL hdr;
841 /** Context ID. */
842 HGCMFunctionParameter context;
843 /** Notification type. */
844 HGCMFunctionParameter type;
845 /** IPRT result of overall operation. */
846 HGCMFunctionParameter rc;
847 union
848 {
849 struct
850 {
851 /** Guest file handle. */
852 HGCMFunctionParameter handle;
853 } open;
854 /** Note: Close does not have any additional data (yet). */
855 struct
856 {
857 /** Actual data read (if any). */
858 HGCMFunctionParameter data;
859 } read;
860 struct
861 {
862 /** How much data (in bytes) have been successfully written. */
863 HGCMFunctionParameter written;
864 } write;
865 struct
866 {
867 HGCMFunctionParameter offset;
868 } seek;
869 struct
870 {
871 HGCMFunctionParameter offset;
872 } tell;
873 } u;
874} HGCMReplyFileNotify;
875
876typedef struct HGCMReplyDirNotify
877{
878 VBGLIOCHGCMCALL hdr;
879 /** Context ID. */
880 HGCMFunctionParameter context;
881 /** Notification type. */
882 HGCMFunctionParameter type;
883 /** IPRT result of overall operation. */
884 HGCMFunctionParameter rc;
885 union
886 {
887 struct
888 {
889 /** Directory information. */
890 HGCMFunctionParameter objInfo;
891 } info;
892 struct
893 {
894 /** Guest directory handle. */
895 HGCMFunctionParameter handle;
896 } open;
897 struct
898 {
899 /** Current read directory entry. */
900 HGCMFunctionParameter entry;
901 /** Extended entry object information. Optional. */
902 HGCMFunctionParameter objInfo;
903 } read;
904 } u;
905} HGCMReplyDirNotify;
906
907#pragma pack ()
908
909/******************************************************************************
910* Callback data structures. *
911******************************************************************************/
912
913/**
914 * The guest control callback data header. Must come first
915 * on each callback structure defined below this struct.
916 */
917typedef struct CALLBACKDATA_HEADER
918{
919 /** Context ID to identify callback data. This is
920 * and *must* be the very first parameter in this
921 * structure to still be backwards compatible. */
922 uint32_t uContextID;
923} CALLBACKDATA_HEADER, *PCALLBACKDATA_HEADER;
924
925/*
926 * These structures make up the actual low level HGCM callback data sent from
927 * the guest back to the host.
928 */
929
930typedef struct CALLBACKDATA_CLIENT_DISCONNECTED
931{
932 /** Callback data header. */
933 CALLBACKDATA_HEADER hdr;
934} CALLBACKDATA_CLIENT_DISCONNECTED, *PCALLBACKDATA_CLIENT_DISCONNECTED;
935
936typedef struct CALLBACKDATA_MSG_REPLY
937{
938 /** Callback data header. */
939 CALLBACKDATA_HEADER hdr;
940 /** Notification type. */
941 uint32_t uType;
942 /** Notification result. Note: int vs. uint32! */
943 uint32_t rc;
944 /** Pointer to optional payload. */
945 void *pvPayload;
946 /** Payload size (in bytes). */
947 uint32_t cbPayload;
948} CALLBACKDATA_MSG_REPLY, *PCALLBACKDATA_MSG_REPLY;
949
950typedef struct CALLBACKDATA_SESSION_NOTIFY
951{
952 /** Callback data header. */
953 CALLBACKDATA_HEADER hdr;
954 /** Notification type. */
955 uint32_t uType;
956 /** Notification result. Note: int vs. uint32! */
957 uint32_t uResult;
958} CALLBACKDATA_SESSION_NOTIFY, *PCALLBACKDATA_SESSION_NOTIFY;
959
960typedef struct CALLBACKDATA_PROC_STATUS
961{
962 /** Callback data header. */
963 CALLBACKDATA_HEADER hdr;
964 /** The process ID (PID). */
965 uint32_t uPID;
966 /** The process status. */
967 uint32_t uStatus;
968 /** Optional flags, varies, based on u32Status. */
969 uint32_t uFlags;
970 /** Optional data buffer (not used atm). */
971 void *pvData;
972 /** Size of optional data buffer (not used atm). */
973 uint32_t cbData;
974} CALLBACKDATA_PROC_STATUS, *PCALLBACKDATA_PROC_STATUS;
975
976typedef struct CALLBACKDATA_PROC_OUTPUT
977{
978 /** Callback data header. */
979 CALLBACKDATA_HEADER hdr;
980 /** The process ID (PID). */
981 uint32_t uPID;
982 /** The handle ID (stdout/stderr). */
983 uint32_t uHandle;
984 /** Optional flags (not used atm). */
985 uint32_t uFlags;
986 /** Optional data buffer. */
987 void *pvData;
988 /** Size (in bytes) of optional data buffer. */
989 uint32_t cbData;
990} CALLBACKDATA_PROC_OUTPUT, *PCALLBACKDATA_PROC_OUTPUT;
991
992typedef struct CALLBACKDATA_PROC_INPUT
993{
994 /** Callback data header. */
995 CALLBACKDATA_HEADER hdr;
996 /** The process ID (PID). */
997 uint32_t uPID;
998 /** Current input status. */
999 uint32_t uStatus;
1000 /** Optional flags. */
1001 uint32_t uFlags;
1002 /** Size (in bytes) of processed input data. */
1003 uint32_t uProcessed;
1004} CALLBACKDATA_PROC_INPUT, *PCALLBACKDATA_PROC_INPUT;
1005
1006/**
1007 * General guest directory notification callback.
1008 */
1009typedef struct CALLBACKDATA_DIR_NOTIFY
1010{
1011 /** Callback data header. */
1012 CALLBACKDATA_HEADER hdr;
1013 /** Notification type. */
1014 uint32_t uType;
1015 /** IPRT result of overall operation. */
1016 uint32_t rc;
1017 union
1018 {
1019 struct
1020 {
1021 /** Size (in bytes) of directory information. */
1022 uint32_t cbObjInfo;
1023 /** Pointer to directory information. */
1024 void *pvObjInfo;
1025 } info;
1026 struct
1027 {
1028 /** Guest directory handle. */
1029 uint32_t uHandle;
1030 } open;
1031 /** Note: Close does not have any additional data (yet). */
1032 struct
1033 {
1034 /** Size (in bytes) of directory entry information. */
1035 uint32_t cbEntry;
1036 /** Pointer to directory entry information. */
1037 void *pvEntry;
1038 /** Size (in bytes) of directory entry object information. */
1039 uint32_t cbObjInfo;
1040 /** Pointer to directory entry object information. */
1041 void *pvObjInfo;
1042 } read;
1043 } u;
1044} CALLBACKDATA_DIR_NOTIFY, *PCALLBACKDATA_DIR_NOTIFY;
1045
1046/**
1047 * General guest file notification callback.
1048 */
1049typedef struct CALLBACKDATA_FILE_NOTIFY
1050{
1051 /** Callback data header. */
1052 CALLBACKDATA_HEADER hdr;
1053 /** Notification type. */
1054 uint32_t uType;
1055 /** IPRT result of overall operation. */
1056 uint32_t rc;
1057 union
1058 {
1059 struct
1060 {
1061 /** Guest file handle. */
1062 uint32_t uHandle;
1063 } open;
1064 /** Note: Close does not have any additional data (yet). */
1065 struct
1066 {
1067 /** How much data (in bytes) have been read. */
1068 uint32_t cbData;
1069 /** Actual data read (if any). */
1070 void *pvData;
1071 } read;
1072 struct
1073 {
1074 /** How much data (in bytes) have been successfully written. */
1075 uint32_t cbWritten;
1076 } write;
1077 struct
1078 {
1079 /** New file offset after successful seek. */
1080 uint64_t uOffActual;
1081 } seek;
1082 struct
1083 {
1084 /** New file offset after successful tell. */
1085 uint64_t uOffActual;
1086 } tell;
1087 } u;
1088} CALLBACKDATA_FILE_NOTIFY, *PCALLBACKDATA_FILE_NOTIFY;
1089
1090} /* namespace guestControl */
1091
1092#endif /* !___VBox_HostService_GuestControlService_h */
1093
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use