VirtualBox

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

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

GuestCtrl: More stuff for IGuestFile and IGuestSession handling (work in progress).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 26.8 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)
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 * Guest reports back a guest session status.
311 */
312 GUEST_SESSION_NOTIFY = 20,
313 /**
314 * Guests sends output from an executed process.
315 */
316 GUEST_EXEC_OUTPUT = 100,
317 /**
318 * Guest sends a status update of an executed process to the host.
319 */
320 GUEST_EXEC_STATUS = 101,
321 /**
322 * Guests sends an input status notification to the host.
323 */
324 GUEST_EXEC_INPUT_STATUS = 102,
325 /**
326 * Guest notifies the host about some I/O event. This can be
327 * a stdout, stderr or a stdin event. The actual event only tells
328 * how many data is available / can be sent without actually
329 * transmitting the data.
330 */
331 GUEST_EXEC_IO_NOTIFY = 210,
332 /**
333 * Guest notifies the host about some file event.
334 */
335 GUEST_FILE_NOTIFY = 240
336};
337
338/**
339 * Guest session notification types.
340 * @sa HGCMMsgSessionNotify.
341 */
342enum GUEST_SESSION_NOTIFYTYPE
343{
344 GUEST_SESSION_NOTIFYTYPE_UNDEFINED = 0,
345 /** Something went wrong (see rc). */
346 GUEST_SESSION_NOTIFYTYPE_ERROR = 1,
347 /** Guest session has been started. */
348 GUEST_SESSION_NOTIFYTYPE_STARTED = 11,
349 /** Guest session terminated normally. */
350 GUEST_SESSION_NOTIFYTYPE_TEN = 20,
351 /** Guest session terminated via signal. */
352 GUEST_SESSION_NOTIFYTYPE_TES = 30,
353 /** Guest session terminated abnormally. */
354 GUEST_SESSION_NOTIFYTYPE_TEA = 40,
355 /** Guest session timed out and was killed. */
356 GUEST_SESSION_NOTIFYTYPE_TOK = 50,
357 /** Guest session timed out and was not killed successfully. */
358 GUEST_SESSION_NOTIFYTYPE_TOA = 60,
359 /** Service/OS is stopping, process was killed. */
360 GUEST_SESSION_NOTIFYTYPE_DWN = 150
361};
362
363/**
364 * Guest file notification types.
365 * @sa HGCMMsgFileNotify.
366 */
367enum GUEST_FILE_NOTIFYTYPE
368{
369 GUEST_FILE_NOTIFYTYPE_UNKNOWN = 0,
370 GUEST_FILE_NOTIFYTYPE_ERROR = 1,
371 GUEST_FILE_NOTIFYTYPE_OPEN = 10,
372 GUEST_FILE_NOTIFYTYPE_CLOSE = 20,
373 GUEST_FILE_NOTIFYTYPE_READ = 30,
374 GUEST_FILE_NOTIFYTYPE_WRITE = 40,
375 GUEST_FILE_NOTIFYTYPE_SEEK = 50,
376 GUEST_FILE_NOTIFYTYPE_TELL = 60
377};
378
379/**
380 * Guest file seeking types. Has to
381 * match FileSeekType in Main.
382 */
383enum GUEST_FILE_SEEKTYPE
384{
385 GUEST_FILE_SEEKTYPE_BEGIN = 1,
386 GUEST_FILE_SEEKTYPE_CURRENT = 4,
387 GUEST_FILE_SEEKTYPE_END = 8
388};
389
390/*
391 * HGCM parameter structures.
392 */
393#pragma pack (1)
394
395/**
396 * Waits for a host command to arrive. The structure then contains the
397 * actual message type + required number of parameters needed to successfully
398 * retrieve that host command (in a next round).
399 */
400typedef struct HGCMMsgCmdWaitFor
401{
402 VBoxGuestHGCMCallInfo hdr;
403
404 /**
405 * The returned command the host wants to
406 * run on the guest.
407 */
408 HGCMFunctionParameter msg; /* OUT uint32_t */
409 /** Number of parameters the message needs. */
410 HGCMFunctionParameter num_parms; /* OUT uint32_t */
411
412} HGCMMsgCmdWaitFor;
413
414/**
415 * Asks the guest control host service to set a command
416 * filter for this client. The filter itself will affect
417 * the context ID bound to a command.
418 */
419typedef struct HGCMMsgCmdSetFilter
420{
421 VBoxGuestHGCMCallInfo hdr;
422
423 /* Mask of context IDs to be filtered. */
424 HGCMFunctionParameter add; /* IN uint32_t */
425 /* Exclude masked; unused. */
426 HGCMFunctionParameter remove; /* IN uint32_t */
427
428} HGCMMsgCmdSetFilter;
429
430/**
431 * Asks the guest control host service to cancel all pending (outstanding)
432 * waits which were not processed yet. This is handy for a graceful shutdown.
433 */
434typedef struct HGCMMsgCancelPendingWaits
435{
436 VBoxGuestHGCMCallInfo hdr;
437} HGCMMsgCancelPendingWaits;
438
439/**
440 * Creates a guest session.
441 */
442typedef struct HGCMMsgSessionOpen
443{
444 VBoxGuestHGCMCallInfo hdr;
445 /** Context ID. */
446 HGCMFunctionParameter context;
447 /** The guest control protocol version this
448 * session is about to use. */
449 HGCMFunctionParameter protocol;
450 /** The user name to run the guest session under. */
451 HGCMFunctionParameter username;
452 /** The user's password. */
453 HGCMFunctionParameter password;
454 /** The domain to run the guest session under. */
455 HGCMFunctionParameter domain;
456 /** Session creation flags. */
457 HGCMFunctionParameter flags;
458} HGCMMsgSessionOpen;
459
460/**
461 * Terminates (closes) a guest session.
462 */
463typedef struct HGCMMsgSessionClose
464{
465 VBoxGuestHGCMCallInfo hdr;
466 /** Context ID. */
467 HGCMFunctionParameter context;
468 /** Session termination flags. */
469 HGCMFunctionParameter flags;
470} HGCMMsgSessionClose;
471
472/**
473 * Reports back a guest session's status.
474 */
475typedef struct HGCMMsgSessionNotify
476{
477 VBoxGuestHGCMCallInfo hdr;
478 /** Context ID. */
479 HGCMFunctionParameter context;
480 /** Notification type. */
481 HGCMFunctionParameter type;
482 /** Notification result. */
483 HGCMFunctionParameter result;
484} HGCMMsgSessionNotify;
485
486/**
487 * Executes a command inside the guest.
488 */
489typedef struct HGCMMsgProcExec
490{
491 VBoxGuestHGCMCallInfo hdr;
492 /** Context ID. */
493 HGCMFunctionParameter context;
494 /** The command to execute on the guest. */
495 HGCMFunctionParameter cmd;
496 /** Execution flags (see IGuest::ProcessCreateFlag_*). */
497 HGCMFunctionParameter flags;
498 /** Number of arguments. */
499 HGCMFunctionParameter num_args;
500 /** The actual arguments. */
501 HGCMFunctionParameter args;
502 /** Number of environment value pairs. */
503 HGCMFunctionParameter num_env;
504 /** Size (in bytes) of environment block, including terminating zeros. */
505 HGCMFunctionParameter cb_env;
506 /** The actual environment block. */
507 HGCMFunctionParameter env;
508 union
509 {
510 struct
511 {
512 /** The user name to run the executed command under.
513 * Only for VBox < 4.3 hosts. */
514 HGCMFunctionParameter username;
515 /** The user's password.
516 * Only for VBox < 4.3 hosts. */
517 HGCMFunctionParameter password;
518 /** Timeout (in msec) which either specifies the
519 * overall lifetime of the process or how long it
520 * can take to bring the process up and running -
521 * (depends on the IGuest::ProcessCreateFlag_*). */
522 HGCMFunctionParameter timeout;
523 } v1;
524 struct
525 {
526 /** Timeout (in msec) which either specifies the
527 * overall lifetime of the process or how long it
528 * can take to bring the process up and running -
529 * (depends on the IGuest::ProcessCreateFlag_*). */
530 HGCMFunctionParameter timeout;
531 /** Process priority. */
532 HGCMFunctionParameter priority;
533 /** Number of process affinity blocks. */
534 HGCMFunctionParameter num_affinity;
535 /** Pointer to process affinity blocks (uint64_t). */
536 HGCMFunctionParameter affinity;
537 } v2;
538 } u;
539
540} HGCMMsgProcExec;
541
542/**
543 * Sends input to a guest process via stdin.
544 */
545typedef struct HGCMMsgProcInput
546{
547 VBoxGuestHGCMCallInfo hdr;
548 /** Context ID. */
549 HGCMFunctionParameter context;
550 /** The process ID (PID) to send the input to. */
551 HGCMFunctionParameter pid;
552 /** Input flags (see IGuest::ProcessInputFlag_*). */
553 HGCMFunctionParameter flags;
554 /** Data buffer. */
555 HGCMFunctionParameter data;
556 /** Actual size of data (in bytes). */
557 HGCMFunctionParameter size;
558
559} HGCMMsgProcInput;
560
561/**
562 * Retrieves ouptut from a previously executed process
563 * from stdout/stderr.
564 */
565typedef struct HGCMMsgProcOutput
566{
567 VBoxGuestHGCMCallInfo hdr;
568 /** Context ID. */
569 HGCMFunctionParameter context;
570 /** The process ID (PID). */
571 HGCMFunctionParameter pid;
572 /** The pipe handle ID (stdout/stderr). */
573 HGCMFunctionParameter handle;
574 /** Optional flags. */
575 HGCMFunctionParameter flags;
576 /** Data buffer. */
577 HGCMFunctionParameter data;
578
579} HGCMMsgProcOutput;
580
581/**
582 * Reports the current status of a guest process.
583 */
584typedef struct HGCMMsgProcStatus
585{
586 VBoxGuestHGCMCallInfo hdr;
587 /** Context ID. */
588 HGCMFunctionParameter context;
589 /** The process ID (PID). */
590 HGCMFunctionParameter pid;
591 /** The process status. */
592 HGCMFunctionParameter status;
593 /** Optional flags (based on status). */
594 HGCMFunctionParameter flags;
595 /** Optional data buffer (not used atm). */
596 HGCMFunctionParameter data;
597
598} HGCMMsgProcStatus;
599
600/**
601 * Reports back the status of data written to a process.
602 */
603typedef struct HGCMMsgProcStatusInput
604{
605 VBoxGuestHGCMCallInfo hdr;
606 /** Context ID. */
607 HGCMFunctionParameter context;
608 /** The process ID (PID). */
609 HGCMFunctionParameter pid;
610 /** Status of the operation. */
611 HGCMFunctionParameter status;
612 /** Optional flags. */
613 HGCMFunctionParameter flags;
614 /** Data written. */
615 HGCMFunctionParameter written;
616
617} HGCMMsgProcStatusInput;
618
619/*
620 * Guest control 2.0 messages.
621 */
622
623/**
624 * Terminates a guest process.
625 */
626typedef struct HGCMMsgProcTerminate
627{
628 VBoxGuestHGCMCallInfo hdr;
629 /** Context ID. */
630 HGCMFunctionParameter context;
631 /** The process ID (PID). */
632 HGCMFunctionParameter pid;
633
634} HGCMMsgProcTerminate;
635
636/**
637 * Waits for certain events to happen.
638 */
639typedef struct HGCMMsgProcWaitFor
640{
641 VBoxGuestHGCMCallInfo hdr;
642 /** Context ID. */
643 HGCMFunctionParameter context;
644 /** The process ID (PID). */
645 HGCMFunctionParameter pid;
646 /** Wait (event) flags. */
647 HGCMFunctionParameter flags;
648 /** Timeout (in ms). */
649 HGCMFunctionParameter timeout;
650
651} HGCMMsgProcWaitFor;
652
653/**
654 * Opens a guest file.
655 */
656typedef struct HGCMMsgFileOpen
657{
658 VBoxGuestHGCMCallInfo hdr;
659 /** UInt32: Context ID. */
660 HGCMFunctionParameter context;
661 /** String: File to open. */
662 HGCMFunctionParameter filename;
663 /** String: Open mode. */
664 HGCMFunctionParameter openmode;
665 /** String: Disposition. */
666 HGCMFunctionParameter disposition;
667 /** UInt32: Creation mode. */
668 HGCMFunctionParameter creationmode;
669 /** UInt64: Initial offset. */
670 HGCMFunctionParameter offset;
671
672} HGCMMsgFileOpen;
673
674/**
675 * Closes a guest file.
676 */
677typedef struct HGCMMsgFileClose
678{
679 VBoxGuestHGCMCallInfo hdr;
680 /** Context ID. */
681 HGCMFunctionParameter context;
682 /** File handle to close. */
683 HGCMFunctionParameter handle;
684
685} HGCMMsgFileClose;
686
687/**
688 * Reads from a guest file.
689 */
690typedef struct HGCMMsgFileRead
691{
692 VBoxGuestHGCMCallInfo hdr;
693 /** Context ID. */
694 HGCMFunctionParameter context;
695 /** File handle to read from. */
696 HGCMFunctionParameter handle;
697 /** Size (in bytes) to read. */
698 HGCMFunctionParameter size;
699
700} HGCMMsgFileRead;
701
702/**
703 * Reads at a specified offset from a guest file.
704 */
705typedef struct HGCMMsgFileReadAt
706{
707 VBoxGuestHGCMCallInfo hdr;
708 /** Context ID. */
709 HGCMFunctionParameter context;
710 /** File handle to read from. */
711 HGCMFunctionParameter handle;
712 /** Offset where to start reading from. */
713 HGCMFunctionParameter offset;
714 /** Actual size of data (in bytes). */
715 HGCMFunctionParameter size;
716
717} HGCMMsgFileReadAt;
718
719/**
720 * Writes to a guest file.
721 */
722typedef struct HGCMMsgFileWrite
723{
724 VBoxGuestHGCMCallInfo hdr;
725 /** Context ID. */
726 HGCMFunctionParameter context;
727 /** File handle to write to. */
728 HGCMFunctionParameter handle;
729 /** Actual size of data (in bytes). */
730 HGCMFunctionParameter size;
731 /** Data buffer to write to the file. */
732 HGCMFunctionParameter data;
733
734} HGCMMsgFileWrite;
735
736/**
737 * Writes at a specified offset to a guest file.
738 */
739typedef struct HGCMMsgFileWriteAt
740{
741 VBoxGuestHGCMCallInfo hdr;
742 /** Context ID. */
743 HGCMFunctionParameter context;
744 /** File handle to write to. */
745 HGCMFunctionParameter handle;
746 /** Offset where to start reading from. */
747 HGCMFunctionParameter offset;
748 /** Actual size of data (in bytes). */
749 HGCMFunctionParameter size;
750 /** Data buffer to write to the file. */
751 HGCMFunctionParameter data;
752
753} HGCMMsgFileWriteAt;
754
755/**
756 * Seeks the read/write position of a guest file.
757 */
758typedef struct HGCMMsgFileSeek
759{
760 VBoxGuestHGCMCallInfo hdr;
761 /** Context ID. */
762 HGCMFunctionParameter context;
763 /** File handle to seek. */
764 HGCMFunctionParameter handle;
765 /** The seeking method. */
766 HGCMFunctionParameter method;
767 /** The seeking offset. */
768 HGCMFunctionParameter offset;
769
770} HGCMMsgFileSeek;
771
772/**
773 * Tells the current read/write position of a guest file.
774 */
775typedef struct HGCMMsgFileTell
776{
777 VBoxGuestHGCMCallInfo hdr;
778 /** Context ID. */
779 HGCMFunctionParameter context;
780 /** File handle to get the current position for. */
781 HGCMFunctionParameter handle;
782
783} HGCMMsgFileTell;
784
785/******************************************************************************
786* HGCM replies from the guest. These are handled in Main's low-level HGCM *
787* callbacks and dispatched to the appropriate guest object. *
788******************************************************************************/
789
790typedef struct HGCMReplyFileNotify
791{
792 VBoxGuestHGCMCallInfo hdr;
793 /** Context ID. */
794 HGCMFunctionParameter context;
795 /** Notification type. */
796 HGCMFunctionParameter type;
797 /** IPRT result of overall operation. */
798 HGCMFunctionParameter rc;
799 union
800 {
801 struct
802 {
803 /** Guest file handle. */
804 HGCMFunctionParameter handle;
805 } open;
806 /** Note: Close does not have any additional data (yet). */
807 struct
808 {
809 /** Actual data read (if any). */
810 HGCMFunctionParameter data;
811 } read;
812 struct
813 {
814 /** How much data (in bytes) have been successfully written. */
815 HGCMFunctionParameter written;
816 } write;
817 struct
818 {
819 HGCMFunctionParameter offset;
820 } seek;
821 struct
822 {
823 HGCMFunctionParameter offset;
824 } tell;
825 } u;
826
827} HGCMReplyFileNotify;
828
829#pragma pack ()
830
831/******************************************************************************
832* Callback data structures. *
833******************************************************************************/
834
835/**
836 * The guest control callback data header. Must come first
837 * on each callback structure defined below this struct.
838 */
839typedef struct CALLBACKDATA_HEADER
840{
841 /** Context ID to identify callback data. This is
842 * and *must* be the very first parameter in this
843 * structure to still be backwards compatible. */
844 uint32_t uContextID;
845} CALLBACKDATA_HEADER, *PCALLBACKDATA_HEADER;
846
847/*
848 * These structures make up the actual low level HGCM callback data sent from
849 * the guest back to the host.
850 */
851
852typedef struct CALLBACKDATA_CLIENT_DISCONNECTED
853{
854 /** Callback data header. */
855 CALLBACKDATA_HEADER hdr;
856} CALLBACKDATA_CLIENT_DISCONNECTED, *PCALLBACKDATA_CLIENT_DISCONNECTED;
857
858typedef struct CALLBACKDATA_SESSION_NOTIFY
859{
860 /** Callback data header. */
861 CALLBACKDATA_HEADER hdr;
862 /** Notification type. */
863 uint32_t uType;
864 /** Notification result. Note: int vs. uint32! */
865 uint32_t uResult;
866} CALLBACKDATA_SESSION_NOTIFY, *PCALLBACKDATA_SESSION_NOTIFY;
867
868typedef struct CALLBACKDATA_PROC_STATUS
869{
870 /** Callback data header. */
871 CALLBACKDATA_HEADER hdr;
872 /** The process ID (PID). */
873 uint32_t uPID;
874 /** The process status. */
875 uint32_t uStatus;
876 /** Optional flags, varies, based on u32Status. */
877 uint32_t uFlags;
878 /** Optional data buffer (not used atm). */
879 void *pvData;
880 /** Size of optional data buffer (not used atm). */
881 uint32_t cbData;
882} CALLBACKDATA_PROC_STATUS, *PCALLBACKDATA_PROC_STATUS;
883
884typedef struct CALLBACKDATA_PROC_OUTPUT
885{
886 /** Callback data header. */
887 CALLBACKDATA_HEADER hdr;
888 /** The process ID (PID). */
889 uint32_t uPID;
890 /** The handle ID (stdout/stderr). */
891 uint32_t uHandle;
892 /** Optional flags (not used atm). */
893 uint32_t uFlags;
894 /** Optional data buffer. */
895 void *pvData;
896 /** Size (in bytes) of optional data buffer. */
897 uint32_t cbData;
898} CALLBACKDATA_PROC_OUTPUT, *PCALLBACKDATA_PROC_OUTPUT;
899
900typedef struct CALLBACKDATA_PROC_INPUT
901{
902 /** Callback data header. */
903 CALLBACKDATA_HEADER hdr;
904 /** The process ID (PID). */
905 uint32_t uPID;
906 /** Current input status. */
907 uint32_t uStatus;
908 /** Optional flags. */
909 uint32_t uFlags;
910 /** Size (in bytes) of processed input data. */
911 uint32_t uProcessed;
912} CALLBACKDATA_PROC_INPUT, *PCALLBACKDATA_PROC_INPUT;
913
914/**
915 * General guest file notification callback.
916 */
917typedef struct CALLBACKDATA_FILE_NOTIFY
918{
919 /** Callback data header. */
920 CALLBACKDATA_HEADER hdr;
921 /** Notification type. */
922 uint32_t uType;
923 /** IPRT result of overall operation. */
924 uint32_t rc;
925 union
926 {
927 struct
928 {
929 /** Guest file handle. */
930 uint32_t uHandle;
931 } open;
932 /** Note: Close does not have any additional data (yet). */
933 struct
934 {
935 /** How much data (in bytes) have been read. */
936 uint32_t cbData;
937 /** Actual data read (if any). */
938 void *pvData;
939 } read;
940 struct
941 {
942 /** How much data (in bytes) have been successfully written. */
943 uint32_t cbWritten;
944 } write;
945 struct
946 {
947 /** New file offset after successful seek. */
948 uint64_t uOffActual;
949 } seek;
950 struct
951 {
952 /** New file offset after successful tell. */
953 uint64_t uOffActual;
954 } tell;
955 } u;
956} CALLBACKDATA_FILE_NOTIFY, *PCALLBACKDATA_FILE_NOTIFY;
957
958} /* namespace guestControl */
959
960#endif /* !___VBox_HostService_GuestControlService_h */
961
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette