VirtualBox

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

Last change on this file since 67640 was 60622, checked in by vboxsync, 9 years ago

Guest Control: Added proper handling for (VBoxService) toolbox exit codes, resolving various copyto/copyfrom bugs.

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