VirtualBox

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

Last change on this file since 83503 was 83408, checked in by vboxsync, 5 years ago

Guest Control: Adjusted the ARGV0 feature flag docs.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 46.9 KB
Line 
1/* $Id: GuestControlSvc.h 83408 2020-03-25 13:12:09Z vboxsync $ */
2/** @file
3 * Guest control service - Common header for host service and guest clients.
4 */
5
6/*
7 * Copyright (C) 2011-2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.215389.xyz. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef VBOX_INCLUDED_HostServices_GuestControlSvc_h
28#define VBOX_INCLUDED_HostServices_GuestControlSvc_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include <VBox/VMMDevCoreTypes.h>
34#include <VBox/VBoxGuestCoreTypes.h>
35#include <VBox/hgcmsvc.h>
36#include <iprt/assert.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 message number. */
90 uint32_t uMessage;
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} VBOXGUESTCTRLHOSTCBCTX, *PVBOXGUESTCTRLHOSTCBCTX;
97
98/**
99 * Structure for low level HGCM host callback from
100 * the guest. No deep copy. */
101typedef struct VBOXGUESTCTRLHOSTCALLBACK
102{
103 /** Number of HGCM parameters. */
104 uint32_t mParms;
105 /** Actual HGCM parameters. */
106 PVBOXHGCMSVCPARM mpaParms;
107} VBOXGUESTCTRLHOSTCALLBACK, *PVBOXGUESTCTRLHOSTCALLBACK;
108
109/** @name Host message destination flags.
110 *
111 * This is ORed into the context ID parameter Main after extending it to 64-bit.
112 *
113 * @internal Host internal.
114 * @{ */
115#define VBOX_GUESTCTRL_DST_ROOT_SVC RT_BIT_64(63)
116#define VBOX_GUESTCTRL_DST_SESSION RT_BIT_64(62)
117#define VBOX_GUESTCTRL_DST_BOTH ( VBOX_GUESTCTRL_DST_ROOT_SVC | VBOX_GUESTCTRL_DST_SESSION )
118/** @} */
119
120
121/**
122 * The service messages which are callable by host.
123 */
124enum eHostMsg
125{
126 /**
127 * The host asks the client to cancel all pending waits and exit.
128 */
129 HOST_MSG_CANCEL_PENDING_WAITS = 0,
130 /**
131 * The host wants to create a guest session.
132 */
133 HOST_MSG_SESSION_CREATE = 20,
134 /**
135 * The host wants to close a guest session.
136 */
137 HOST_MSG_SESSION_CLOSE = 21,
138 /**
139 * The host wants to execute something in the guest. This can be a command
140 * line or starting a program.
141 */
142 HOST_MSG_EXEC_CMD = 100,
143 /**
144 * Sends input data for stdin to a running process executed by HOST_EXEC_CMD.
145 */
146 HOST_MSG_EXEC_SET_INPUT = 101,
147 /**
148 * Gets the current status of a running process, e.g.
149 * new data on stdout/stderr, process terminated etc.
150 */
151 HOST_MSG_EXEC_GET_OUTPUT = 102,
152 /**
153 * Terminates a running guest process.
154 */
155 HOST_MSG_EXEC_TERMINATE = 110,
156 /**
157 * Waits for a certain event to happen. This can be an input, output
158 * or status event.
159 */
160 HOST_MSG_EXEC_WAIT_FOR = 120,
161 /**
162 * Opens a guest file.
163 */
164 HOST_MSG_FILE_OPEN = 240,
165 /**
166 * Closes a guest file.
167 */
168 HOST_MSG_FILE_CLOSE,
169 /**
170 * Reads from an opened guest file.
171 */
172 HOST_MSG_FILE_READ = 250,
173 /**
174 * Reads from an opened guest file at a specified offset.
175 */
176 HOST_MSG_FILE_READ_AT,
177 /**
178 * Write to an opened guest file.
179 */
180 HOST_MSG_FILE_WRITE = 260,
181 /**
182 * Write to an opened guest file at a specified offset.
183 */
184 HOST_MSG_FILE_WRITE_AT,
185 /**
186 * Changes the read & write position of an opened guest file.
187 */
188 HOST_MSG_FILE_SEEK = 270,
189 /**
190 * Gets the current file position of an opened guest file.
191 */
192 HOST_MSG_FILE_TELL,
193 /**
194 * Changes the file size.
195 */
196 HOST_MSG_FILE_SET_SIZE,
197 /**
198 * Removes a directory on the guest.
199 */
200 HOST_MSG_DIR_REMOVE = 320,
201 /**
202 * Renames a path on the guest.
203 */
204 HOST_MSG_PATH_RENAME = 330,
205 /**
206 * Retrieves the user's documents directory.
207 */
208 HOST_MSG_PATH_USER_DOCUMENTS,
209 /**
210 * Retrieves the user's home directory.
211 */
212 HOST_MSG_PATH_USER_HOME,
213
214 /** Blow the type up to 32-bits. */
215 HOST_MSG_32BIT_HACK = 0x7fffffff
216};
217
218
219/**
220 * Translates a guest control host message enum to a string.
221 *
222 * @returns Enum string name.
223 * @param enmMsg The message to translate.
224 */
225DECLINLINE(const char *) GstCtrlHostMsgtoStr(enum eHostMsg enmMsg)
226{
227 switch (enmMsg)
228 {
229 RT_CASE_RET_STR(HOST_MSG_CANCEL_PENDING_WAITS);
230 RT_CASE_RET_STR(HOST_MSG_SESSION_CREATE);
231 RT_CASE_RET_STR(HOST_MSG_SESSION_CLOSE);
232 RT_CASE_RET_STR(HOST_MSG_EXEC_CMD);
233 RT_CASE_RET_STR(HOST_MSG_EXEC_SET_INPUT);
234 RT_CASE_RET_STR(HOST_MSG_EXEC_GET_OUTPUT);
235 RT_CASE_RET_STR(HOST_MSG_EXEC_TERMINATE);
236 RT_CASE_RET_STR(HOST_MSG_EXEC_WAIT_FOR);
237 RT_CASE_RET_STR(HOST_MSG_FILE_OPEN);
238 RT_CASE_RET_STR(HOST_MSG_FILE_CLOSE);
239 RT_CASE_RET_STR(HOST_MSG_FILE_READ);
240 RT_CASE_RET_STR(HOST_MSG_FILE_READ_AT);
241 RT_CASE_RET_STR(HOST_MSG_FILE_WRITE);
242 RT_CASE_RET_STR(HOST_MSG_FILE_WRITE_AT);
243 RT_CASE_RET_STR(HOST_MSG_FILE_SEEK);
244 RT_CASE_RET_STR(HOST_MSG_FILE_TELL);
245 RT_CASE_RET_STR(HOST_MSG_FILE_SET_SIZE);
246 RT_CASE_RET_STR(HOST_MSG_DIR_REMOVE);
247 RT_CASE_RET_STR(HOST_MSG_PATH_RENAME);
248 RT_CASE_RET_STR(HOST_MSG_PATH_USER_DOCUMENTS);
249 RT_CASE_RET_STR(HOST_MSG_PATH_USER_HOME);
250 RT_CASE_RET_STR(HOST_MSG_32BIT_HACK);
251 }
252 return "Unknown";
253}
254
255
256/**
257 * The service messages which are callable by the guest.
258 *
259 * @note The message numbers cannot be changed. Please use the first non-zero
260 * number that's not in use when adding new messages.
261 *
262 * @note Remember to update service.cpp when adding new messages for Main,
263 * as it validates all incoming messages before passing them on.
264 */
265enum eGuestMsg
266{
267 /** Guest waits for a new message the host wants to process on the guest side.
268 * This is a blocking call and can be deferred.
269 *
270 * @note This message is rather odd. The above description isn't really
271 * correct. Yes, it (1) waits for a new message and will return the
272 * mesage number and parameter count when one is available. However, it
273 * is also (2) used to retrieve the message parameters. For some weird
274 * reasons it was decided that it should always return VERR_TOO_MUCH_DATA
275 * when used in the first capacity.
276 *
277 * @note Has a problem if the guest kernel module cancels the HGCM call, as the
278 * guest cannot resume waiting till the host issues a message for it and
279 * the cancelled call returns. The new message may potentially end up in
280 * /dev/null depending and hang the message conversation between the guest
281 * and the host (SIGCHLD).
282 *
283 * @deprecated Replaced by GUEST_MSG_PEEK_WAIT, GUEST_MSG_GET and
284 * GUEST_MSG_CANCEL.
285 */
286 GUEST_MSG_WAIT = 1,
287 /** Cancels pending calls for this client session.
288 *
289 * This should be used if a GUEST_MSG_PEEK_WAIT or GUEST_MSG_WAIT call gets
290 * interrupted on the client end, so as to prevent being rebuffed with
291 * VERR_RESOURCE_BUSY when restarting the call.
292 *
293 * @retval VINF_SUCCESS if cancelled any calls.
294 * @retval VWRN_NOT_FOUND if no callers.
295 * @retval VERR_INVALID_CLIENT_ID
296 * @retval VERR_WRONG_PARAMETER_COUNT
297 * @since 6.0
298 */
299 GUEST_MSG_CANCEL = 2,
300 /** Guest disconnected (terminated normally or due to a crash HGCM
301 * detected when calling service::clientDisconnect().
302 *
303 * @note This is a host side notification message that has no business in this
304 * enum. The guest cannot use this message number, host will reject it.
305 */
306 GUEST_MSG_DISCONNECTED = 3,
307 /** Sets a message filter to only get messages which have a certain
308 * context ID scheme (that is, a specific session, object etc).
309 * Since VBox 4.3+.
310 * @deprecated Replaced by GUEST_SESSION_ACCEPT.
311 */
312 GUEST_MSG_FILTER_SET = 4,
313 /** Unsets (and resets) a previously set message filter.
314 * @retval VERR_NOT_IMPLEMENTED since 6.0.
315 * @deprecated Never needed or used,
316 */
317 GUEST_MSG_FILTER_UNSET = 5,
318 /** Peeks at the next message, returning immediately.
319 *
320 * Returns two 32-bit parameters, first is the message ID and the second the
321 * parameter count. May optionally return additional 32-bit parameters with the
322 * sizes of respective message parameters. To distinguish buffer sizes from
323 * integer parameters, the latter gets their sizes inverted (uint32_t is ~4U,
324 * uint64_t is ~8U).
325 *
326 * Does also support the VM restore checking as in GUEST_MSG_PEEK_WAIT (64-bit
327 * param \# 0), see documentation there.
328 *
329 * @retval VINF_SUCCESS if a message was pending and is being returned.
330 * @retval VERR_TRY_AGAIN if no message pending.
331 * @retval VERR_VM_RESTORED if first parameter is a non-zero 64-bit value that
332 * does not match VbglR3GetSessionId() any more. The new value is
333 * returned.
334 * @retval VERR_INVALID_CLIENT_ID
335 * @retval VERR_WRONG_PARAMETER_COUNT
336 * @retval VERR_WRONG_PARAMETER_TYPE
337 * @since 6.0
338 */
339 GUEST_MSG_PEEK_NOWAIT = 6,
340 /** Peeks at the next message, waiting for one to arrive.
341 *
342 * Returns two 32-bit parameters, first is the message ID and the second the
343 * parameter count. May optionally return additional 32-bit parameters with the
344 * sizes of respective message parameters. To distinguish buffer sizes from
345 * integer parameters, the latter gets their sizes inverted (uint32_t is ~4U,
346 * uint64_t is ~8U).
347 *
348 * To facilitate VM restore checking, the first parameter can be a 64-bit
349 * integer holding the VbglR3GetSessionId() value the guest knowns. The
350 * function will then check this before going to sleep and return
351 * VERR_VM_RESTORED if it doesn't match, same thing happens when the VM is
352 * restored.
353 *
354 * @retval VINF_SUCCESS if info about an pending message is being returned.
355 * @retval VINF_TRY_AGAIN and message set to HOST_CANCEL_PENDING_WAITS if
356 * cancelled by GUEST_MSG_CANCEL.
357 * @retval VERR_RESOURCE_BUSY if another thread already made a waiting call.
358 * @retval VERR_VM_RESTORED if first parameter is a non-zero 64-bit value that
359 * does not match VbglR3GetSessionId() any more. The new value is
360 * returned.
361 * @retval VERR_INVALID_CLIENT_ID
362 * @retval VERR_WRONG_PARAMETER_COUNT
363 * @retval VERR_WRONG_PARAMETER_TYPE
364 * @note This replaces GUEST_MSG_WAIT.
365 * @since 6.0
366 */
367 GUEST_MSG_PEEK_WAIT = 7,
368 /** Gets the next message, returning immediately.
369 *
370 * All parameters are specific to the message being retrieved, however if the
371 * first one is an integer value it shall be an input parameter holding the
372 * ID of the message being retrieved. While it would be nice to add a separate
373 * parameter for this purpose, this is difficult without breaking GUEST_MSG_WAIT
374 * compatibility.
375 *
376 * @retval VINF_SUCCESS if message retrieved and removed from the pending queue.
377 * @retval VERR_TRY_AGAIN if no message pending.
378 * @retval VERR_MISMATCH if the incoming message ID does not match the pending.
379 * @retval VERR_BUFFER_OVERFLOW if a parmeter buffer is too small. The buffer
380 * size was updated to reflect the required size.
381 * @retval VERR_INVALID_CLIENT_ID
382 * @retval VERR_WRONG_PARAMETER_COUNT
383 * @retval VERR_WRONG_PARAMETER_TYPE
384 * @note This replaces GUEST_MSG_WAIT.
385 * @since 6.0
386 */
387 GUEST_MSG_GET = 8,
388 /** Skip message.
389 *
390 * This skips the current message, replying to the main backend as best it can.
391 * Takes between zero and two parameters. The first parameter is the 32-bit
392 * VBox status code to pass onto Main when skipping the message, defaults to
393 * VERR_NOT_SUPPORTED. The second parameter is the 32-bit message ID of the
394 * message to skip, by default whatever is first in the queue is removed. This
395 * is also the case if UINT32_MAX is specified.
396 *
397 * @retval VINF_SUCCESS on success.
398 * @retval VERR_NOT_FOUND if no message pending.
399 * @retval VERR_MISMATCH if the specified message ID didn't match.
400 * @retval VERR_INVALID_CLIENT_ID
401 * @retval VERR_WRONG_PARAMETER_COUNT
402 * @since 6.0
403 */
404 GUEST_MSG_SKIP = 9,
405 /**
406 * Skips the current assigned message returned by GUEST_MSG_WAIT.
407 * Needed for telling the host service to not keep stale
408 * host messages in the queue.
409 * @deprecated Replaced by GUEST_MSG_SKIP.
410 */
411 GUEST_MSG_SKIP_OLD = 10,
412 /** General reply to a host message.
413 * Only contains basic data along with a simple payload.
414 * @todo proper docs.
415 */
416 GUEST_MSG_REPLY = 11,
417 /** General message for updating a pending progress for a long task.
418 * @todo proper docs.
419 */
420 GUEST_MSG_PROGRESS_UPDATE = 12,
421 /** Sets the caller as the master.
422 *
423 * Called by the root VBoxService to explicitly tell the host that's the master
424 * service. Required to use main VBoxGuest device node. No parameters.
425 *
426 * @retval VINF_SUCCESS on success.
427 * @retval VERR_ACCESS_DENIED if not using main VBoxGuest device not
428 * @retval VERR_RESOURCE_BUSY if there is already a master.
429 * @retval VERR_VERSION_MISMATCH if VBoxGuest didn't supply requestor info.
430 * @retval VERR_INVALID_CLIENT_ID
431 * @retval VERR_WRONG_PARAMETER_COUNT
432 * @since 6.0
433 */
434 GUEST_MSG_MAKE_ME_MASTER = 13,
435 /** Prepares the starting of a session.
436 *
437 * VBoxService makes this call before spawning a session process (must be
438 * master). The first parameter is the session ID and the second is a one time
439 * key for identifying the right session process. First parameter is a 32-bit
440 * session ID with a value between 1 and 0xfff0. The second parameter is a byte
441 * buffer containing a key that GUEST_SESSION_ACCEPT checks against, minimum
442 * length is 64 bytes, maximum 16384 bytes.
443 *
444 * @retval VINF_SUCCESS on success.
445 * @retval VERR_OUT_OF_RESOURCES if too many pending sessions hanging around.
446 * @retval VERR_OUT_OF_RANGE if the session ID outside the allowed range.
447 * @retval VERR_BUFFER_OVERFLOW if key too large.
448 * @retval VERR_BUFFER_UNDERFLOW if key too small.
449 * @retval VERR_ACCESS_DENIED if not master or in legacy mode.
450 * @retval VERR_DUPLICATE if the session ID has been prepared already.
451 * @retval VERR_INVALID_CLIENT_ID
452 * @retval VERR_WRONG_PARAMETER_COUNT
453 * @retval VERR_WRONG_PARAMETER_TYPE
454 * @since 6.0
455 */
456 GUEST_MSG_SESSION_PREPARE = 14,
457 /** Cancels a prepared session.
458 *
459 * VBoxService makes this call to clean up after spawning a session process
460 * failed. One parameter, 32-bit session ID. If UINT32_MAX is passed, all
461 * prepared sessions are cancelled.
462 *
463 * @retval VINF_SUCCESS on success.
464 * @retval VWRN_NOT_FOUND if no session with the specified ID.
465 * @retval VERR_ACCESS_DENIED if not master or in legacy mode.
466 * @retval VERR_INVALID_CLIENT_ID
467 * @retval VERR_WRONG_PARAMETER_COUNT
468 * @retval VERR_WRONG_PARAMETER_TYPE
469 * @since 6.0
470 */
471 GUEST_MSG_SESSION_CANCEL_PREPARED = 15,
472 /** Accepts a prepared session.
473 *
474 * The session processes makes this call to accept a prepared session. The
475 * session ID is then uniquely associated with the HGCM client ID of the caller.
476 * The parameters must be identical to the matching GUEST_SESSION_PREPARE call.
477 *
478 * @retval VINF_SUCCESS on success.
479 * @retval VERR_NOT_FOUND if the specified session ID wasn't found.
480 * @retval VERR_OUT_OF_RANGE if the session ID outside the allowed range.
481 * @retval VERR_BUFFER_OVERFLOW if key too large.
482 * @retval VERR_BUFFER_UNDERFLOW if key too small.
483 * @retval VERR_ACCESS_DENIED if we're in legacy mode or is master.
484 * @retval VERR_RESOURCE_BUSY if the client is already associated with a session.
485 * @retval VERR_MISMATCH if the key didn't match.
486 * @retval VERR_INVALID_CLIENT_ID
487 * @retval VERR_WRONG_PARAMETER_COUNT
488 * @retval VERR_WRONG_PARAMETER_TYPE
489 * @since 6.0
490 */
491 GUEST_MSG_SESSION_ACCEPT = 16,
492 /**
493 * Guest reports back a guest session status.
494 * @todo proper docs.
495 */
496 GUEST_MSG_SESSION_NOTIFY = 20,
497 /**
498 * Guest wants to close a specific guest session.
499 * @todo proper docs.
500 */
501 GUEST_MSG_SESSION_CLOSE = 21,
502
503 /** Report guest side feature flags and retrieve the host ones.
504 *
505 * VBoxService makes this call right after becoming master to indicate to the
506 * host what features it support in addition. In return the host will return
507 * features the host supports. Two 64-bit parameters are passed in from the
508 * guest with the guest features (VBOX_GUESTCTRL_GF_XXX), the host replies by
509 * replacing the parameter values with the host ones (VBOX_GUESTCTRL_HF_XXX).
510 *
511 * @retval VINF_SUCCESS on success.
512 * @retval VERR_ACCESS_DENIED it not master.
513 * @retval VERR_INVALID_CLIENT_ID
514 * @retval VERR_WRONG_PARAMETER_COUNT
515 * @retval VERR_WRONG_PARAMETER_TYPE
516 * @since 6.0.10, 5.2.32
517 */
518 GUEST_MSG_REPORT_FEATURES,
519 /** Query the host ones feature masks.
520 *
521 * This is for the session sub-process so that it can get hold of the features
522 * from the host. Again, it is prudent to set the 127 bit and observe it being
523 * cleared on success, as older hosts might return success without doing
524 * anything.
525 *
526 * @retval VINF_SUCCESS on success.
527 * @retval VERR_INVALID_CLIENT_ID
528 * @retval VERR_WRONG_PARAMETER_COUNT
529 * @retval VERR_WRONG_PARAMETER_TYPE
530 * @since 6.0.10, 5.2.32
531 */
532 GUEST_MSG_QUERY_FEATURES,
533
534 /**
535 * Guests sends output from an executed process.
536 * @todo proper docs.
537 */
538 GUEST_MSG_EXEC_OUTPUT = 100,
539 /**
540 * Guest sends a status update of an executed process to the host.
541 * @todo proper docs.
542 */
543 GUEST_MSG_EXEC_STATUS = 101,
544 /**
545 * Guests sends an input status notification to the host.
546 * @todo proper docs.
547 */
548 GUEST_MSG_EXEC_INPUT_STATUS = 102,
549 /**
550 * Guest notifies the host about some I/O event. This can be
551 * a stdout, stderr or a stdin event. The actual event only tells
552 * how many data is available / can be sent without actually
553 * transmitting the data.
554 * @todo proper docs.
555 */
556 GUEST_MSG_EXEC_IO_NOTIFY = 210,
557 /**
558 * Guest notifies the host about some directory event.
559 * @todo proper docs.
560 */
561 GUEST_MSG_DIR_NOTIFY = 230,
562 /**
563 * Guest notifies the host about some file event.
564 * @todo proper docs.
565 */
566 GUEST_MSG_FILE_NOTIFY = 240
567};
568
569/**
570 * Translates a guest control guest message enum to a string.
571 *
572 * @returns Enum string name.
573 * @param enmMsg The message to translate.
574 */
575DECLINLINE(const char *) GstCtrlGuestMsgToStr(enum eGuestMsg enmMsg)
576{
577 switch (enmMsg)
578 {
579 RT_CASE_RET_STR(GUEST_MSG_WAIT);
580 RT_CASE_RET_STR(GUEST_MSG_CANCEL);
581 RT_CASE_RET_STR(GUEST_MSG_DISCONNECTED);
582 RT_CASE_RET_STR(GUEST_MSG_FILTER_SET);
583 RT_CASE_RET_STR(GUEST_MSG_FILTER_UNSET);
584 RT_CASE_RET_STR(GUEST_MSG_PEEK_NOWAIT);
585 RT_CASE_RET_STR(GUEST_MSG_PEEK_WAIT);
586 RT_CASE_RET_STR(GUEST_MSG_GET);
587 RT_CASE_RET_STR(GUEST_MSG_SKIP_OLD);
588 RT_CASE_RET_STR(GUEST_MSG_REPLY);
589 RT_CASE_RET_STR(GUEST_MSG_PROGRESS_UPDATE);
590 RT_CASE_RET_STR(GUEST_MSG_SKIP);
591 RT_CASE_RET_STR(GUEST_MSG_MAKE_ME_MASTER);
592 RT_CASE_RET_STR(GUEST_MSG_SESSION_PREPARE);
593 RT_CASE_RET_STR(GUEST_MSG_SESSION_CANCEL_PREPARED);
594 RT_CASE_RET_STR(GUEST_MSG_SESSION_ACCEPT);
595 RT_CASE_RET_STR(GUEST_MSG_SESSION_NOTIFY);
596 RT_CASE_RET_STR(GUEST_MSG_SESSION_CLOSE);
597 RT_CASE_RET_STR(GUEST_MSG_REPORT_FEATURES);
598 RT_CASE_RET_STR(GUEST_MSG_QUERY_FEATURES);
599 RT_CASE_RET_STR(GUEST_MSG_EXEC_OUTPUT);
600 RT_CASE_RET_STR(GUEST_MSG_EXEC_STATUS);
601 RT_CASE_RET_STR(GUEST_MSG_EXEC_INPUT_STATUS);
602 RT_CASE_RET_STR(GUEST_MSG_EXEC_IO_NOTIFY);
603 RT_CASE_RET_STR(GUEST_MSG_DIR_NOTIFY);
604 RT_CASE_RET_STR(GUEST_MSG_FILE_NOTIFY);
605 }
606 return "Unknown";
607}
608
609
610/**
611 * Guest session notification types.
612 * @sa HGCMMsgSessionNotify.
613 */
614enum GUEST_SESSION_NOTIFYTYPE
615{
616 GUEST_SESSION_NOTIFYTYPE_UNDEFINED = 0,
617 /** Something went wrong (see rc). */
618 GUEST_SESSION_NOTIFYTYPE_ERROR = 1,
619 /** Guest session has been started. */
620 GUEST_SESSION_NOTIFYTYPE_STARTED = 11,
621 /** Guest session terminated normally. */
622 GUEST_SESSION_NOTIFYTYPE_TEN = 20,
623 /** Guest session terminated via signal. */
624 GUEST_SESSION_NOTIFYTYPE_TES = 30,
625 /** Guest session terminated abnormally. */
626 GUEST_SESSION_NOTIFYTYPE_TEA = 40,
627 /** Guest session timed out and was killed. */
628 GUEST_SESSION_NOTIFYTYPE_TOK = 50,
629 /** Guest session timed out and was not killed successfully. */
630 GUEST_SESSION_NOTIFYTYPE_TOA = 60,
631 /** Service/OS is stopping, process was killed. */
632 GUEST_SESSION_NOTIFYTYPE_DWN = 150
633};
634
635/**
636 * Guest directory notification types.
637 * @sa HGCMMsgDirNotify.
638 */
639enum GUEST_DIR_NOTIFYTYPE
640{
641 GUEST_DIR_NOTIFYTYPE_UNKNOWN = 0,
642 /** Something went wrong (see rc). */
643 GUEST_DIR_NOTIFYTYPE_ERROR = 1,
644 /** Guest directory opened. */
645 GUEST_DIR_NOTIFYTYPE_OPEN = 10,
646 /** Guest directory closed. */
647 GUEST_DIR_NOTIFYTYPE_CLOSE = 20,
648 /** Information about an open guest directory. */
649 GUEST_DIR_NOTIFYTYPE_INFO = 40,
650 /** Guest directory created. */
651 GUEST_DIR_NOTIFYTYPE_CREATE = 70,
652 /** Guest directory deleted. */
653 GUEST_DIR_NOTIFYTYPE_REMOVE = 80
654};
655
656/**
657 * Guest file notification types.
658 * @sa HGCMMsgFileNotify.
659 */
660enum GUEST_FILE_NOTIFYTYPE
661{
662 GUEST_FILE_NOTIFYTYPE_UNKNOWN = 0,
663 GUEST_FILE_NOTIFYTYPE_ERROR = 1,
664 GUEST_FILE_NOTIFYTYPE_OPEN = 10,
665 GUEST_FILE_NOTIFYTYPE_CLOSE = 20,
666 GUEST_FILE_NOTIFYTYPE_READ = 30,
667 GUEST_FILE_NOTIFYTYPE_READ_OFFSET, /**< @since 6.0.10, 5.2.32 - VBOX_GUESTCTRL_HF_0_NOTIFY_RDWR_OFFSET */
668 GUEST_FILE_NOTIFYTYPE_WRITE = 40,
669 GUEST_FILE_NOTIFYTYPE_WRITE_OFFSET, /**< @since 6.0.10, 5.2.32 - VBOX_GUESTCTRL_HF_0_NOTIFY_RDWR_OFFSET */
670 GUEST_FILE_NOTIFYTYPE_SEEK = 50,
671 GUEST_FILE_NOTIFYTYPE_TELL = 60,
672 GUEST_FILE_NOTIFYTYPE_SET_SIZE
673};
674
675/**
676 * Guest file seeking types. Has to match FileSeekType in Main.
677 *
678 * @note This is not compatible with RTFileSeek, which is an unncessary pain.
679 */
680enum GUEST_FILE_SEEKTYPE
681{
682 GUEST_FILE_SEEKTYPE_BEGIN = 1,
683 GUEST_FILE_SEEKTYPE_CURRENT = 4,
684 GUEST_FILE_SEEKTYPE_END = 8
685};
686
687/** @name VBOX_GUESTCTRL_GF_XXX - Guest features.
688 * @sa GUEST_MSG_REPORT_FEATURES
689 * @{ */
690/** Supports HOST_MSG_FILE_SET_SIZE. */
691#define VBOX_GUESTCTRL_GF_0_SET_SIZE RT_BIT_64(0)
692/** Supports passing process arguments starting at argv[0] rather than argv[1].
693 * Guest additions which doesn't support this feature will instead use the
694 * executable image path as argv[0].
695 * @sa VBOX_GUESTCTRL_HF_0_PROCESS_ARGV0
696 * @since 6.1.6 */
697#define VBOX_GUESTCTRL_GF_0_PROCESS_ARGV0 RT_BIT_64(1)
698/** Bit that must be set in the 2nd parameter, will be cleared if the host reponds
699 * correctly (old hosts might not). */
700#define VBOX_GUESTCTRL_GF_1_MUST_BE_ONE RT_BIT_64(63)
701/** @} */
702
703/** @name VBOX_GUESTCTRL_HF_XXX - Host features.
704 * @sa GUEST_MSG_REPORT_FEATURES
705 * @{ */
706/** Host supports the GUEST_FILE_NOTIFYTYPE_READ_OFFSET and
707 * GUEST_FILE_NOTIFYTYPE_WRITE_OFFSET notification types. */
708#define VBOX_GUESTCTRL_HF_0_NOTIFY_RDWR_OFFSET RT_BIT_64(0)
709/** Host supports process passing arguments starting at argv[0] rather than
710 * argv[1], when the guest additions reports VBOX_GUESTCTRL_GF_0_PROCESS_ARGV0.
711 * @since 6.1.6 */
712#define VBOX_GUESTCTRL_HF_0_PROCESS_ARGV0 RT_BIT_64(1)
713/** @} */
714
715
716/*
717 * HGCM parameter structures.
718 */
719#pragma pack (1)
720
721/**
722 * Waits for a host message to arrive. The structure then contains the
723 * actual message type + required number of parameters needed to successfully
724 * retrieve that host message (in a next round).
725 */
726typedef struct HGCMMsgWaitFor
727{
728 VBGLIOCHGCMCALL hdr;
729 /** The returned message the host wants to run on the guest. */
730 HGCMFunctionParameter msg; /* OUT uint32_t */
731 /** Number of parameters the message needs. */
732 HGCMFunctionParameter num_parms; /* OUT uint32_t */
733} HGCMMsgWaitFor;
734
735/**
736 * Asks the guest control host service to set a message
737 * filter for this client. This filter will then only
738 * deliver messages to the client which match the
739 * wanted context ID (ranges).
740 */
741typedef struct HGCMMsgFilterSet
742{
743 VBGLIOCHGCMCALL hdr;
744 /** Value to filter for after filter mask was applied. */
745 HGCMFunctionParameter value; /* IN uint32_t */
746 /** Mask to add to the current set filter. */
747 HGCMFunctionParameter mask_add; /* IN uint32_t */
748 /** Mask to remove from the current set filter. */
749 HGCMFunctionParameter mask_remove; /* IN uint32_t */
750 /** Filter flags; currently unused. */
751 HGCMFunctionParameter flags; /* IN uint32_t */
752} HGCMMsgFilterSet;
753
754/**
755 * Asks the guest control host service to disable
756 * a previously set message filter again.
757 */
758typedef struct HGCMMsgFilterUnset
759{
760 VBGLIOCHGCMCALL hdr;
761 /** Unset flags; currently unused. */
762 HGCMFunctionParameter flags; /* IN uint32_t */
763} HGCMMsgFilterUnset;
764
765/**
766 * Asks the guest control host service to skip the
767 * currently assigned host message returned by
768 * VbglR3GuestCtrlMsgWaitFor().
769 */
770typedef struct HGCMMsgSkip
771{
772 VBGLIOCHGCMCALL hdr;
773 /** Skip flags; currently unused. */
774 HGCMFunctionParameter flags; /* IN uint32_t */
775} HGCMMsgSkip;
776
777/**
778 * Asks the guest control host service to cancel all pending (outstanding)
779 * waits which were not processed yet. This is handy for a graceful shutdown.
780 */
781typedef struct HGCMMsgCancelPendingWaits
782{
783 VBGLIOCHGCMCALL hdr;
784} HGCMMsgCancelPendingWaits;
785
786typedef struct HGCMMsgReply
787{
788 VBGLIOCHGCMCALL hdr;
789 /** Context ID. */
790 HGCMFunctionParameter context;
791 /** Message type. */
792 HGCMFunctionParameter type;
793 /** IPRT result of overall operation. */
794 HGCMFunctionParameter rc;
795 /** Optional payload to this reply. */
796 HGCMFunctionParameter payload;
797} HGCMMsgReply;
798
799/**
800 * Creates a guest session.
801 */
802typedef struct HGCMMsgSessionOpen
803{
804 VBGLIOCHGCMCALL hdr;
805 /** Context ID. */
806 HGCMFunctionParameter context;
807 /** The guest control protocol version this
808 * session is about to use. */
809 HGCMFunctionParameter protocol;
810 /** The user name to run the guest session under. */
811 HGCMFunctionParameter username;
812 /** The user's password. */
813 HGCMFunctionParameter password;
814 /** The domain to run the guest session under. */
815 HGCMFunctionParameter domain;
816 /** Session creation flags. */
817 HGCMFunctionParameter flags;
818} HGCMMsgSessionOpen;
819
820/**
821 * Terminates (closes) a guest session.
822 */
823typedef struct HGCMMsgSessionClose
824{
825 VBGLIOCHGCMCALL hdr;
826 /** Context ID. */
827 HGCMFunctionParameter context;
828 /** Session termination flags. */
829 HGCMFunctionParameter flags;
830} HGCMMsgSessionClose;
831
832/**
833 * Reports back a guest session's status.
834 */
835typedef struct HGCMMsgSessionNotify
836{
837 VBGLIOCHGCMCALL hdr;
838 /** Context ID. */
839 HGCMFunctionParameter context;
840 /** Notification type. */
841 HGCMFunctionParameter type;
842 /** Notification result. */
843 HGCMFunctionParameter result;
844} HGCMMsgSessionNotify;
845
846typedef struct HGCMMsgPathRename
847{
848 VBGLIOCHGCMCALL hdr;
849 /** UInt32: Context ID. */
850 HGCMFunctionParameter context;
851 /** Source to rename. */
852 HGCMFunctionParameter source;
853 /** Destination to rename source to. */
854 HGCMFunctionParameter dest;
855 /** UInt32: Rename flags. */
856 HGCMFunctionParameter flags;
857} HGCMMsgPathRename;
858
859typedef struct HGCMMsgPathUserDocuments
860{
861 VBGLIOCHGCMCALL hdr;
862 /** UInt32: Context ID. */
863 HGCMFunctionParameter context;
864} HGCMMsgPathUserDocuments;
865
866typedef struct HGCMMsgPathUserHome
867{
868 VBGLIOCHGCMCALL hdr;
869 /** UInt32: Context ID. */
870 HGCMFunctionParameter context;
871} HGCMMsgPathUserHome;
872
873/**
874 * Executes a command inside the guest.
875 */
876typedef struct HGCMMsgProcExec
877{
878 VBGLIOCHGCMCALL hdr;
879 /** Context ID. */
880 HGCMFunctionParameter context;
881 /** The command to execute on the guest. */
882 HGCMFunctionParameter cmd;
883 /** Execution flags (see IGuest::ProcessCreateFlag_*). */
884 HGCMFunctionParameter flags;
885 /** Number of arguments. */
886 HGCMFunctionParameter num_args;
887 /** The actual arguments. */
888 HGCMFunctionParameter args;
889 /** Number of environment value pairs. */
890 HGCMFunctionParameter num_env;
891 /** Size (in bytes) of environment block, including terminating zeros. */
892 HGCMFunctionParameter cb_env;
893 /** The actual environment block. */
894 HGCMFunctionParameter env;
895 union
896 {
897 struct
898 {
899 /** The user name to run the executed command under.
900 * Only for VBox < 4.3 hosts. */
901 HGCMFunctionParameter username;
902 /** The user's password.
903 * Only for VBox < 4.3 hosts. */
904 HGCMFunctionParameter password;
905 /** Timeout (in msec) which either specifies the
906 * overall lifetime of the process or how long it
907 * can take to bring the process up and running -
908 * (depends on the IGuest::ProcessCreateFlag_*). */
909 HGCMFunctionParameter timeout;
910 } v1;
911 struct
912 {
913 /** Timeout (in ms) which either specifies the
914 * overall lifetime of the process or how long it
915 * can take to bring the process up and running -
916 * (depends on the IGuest::ProcessCreateFlag_*). */
917 HGCMFunctionParameter timeout;
918 /** Process priority. */
919 HGCMFunctionParameter priority;
920 /** Number of process affinity blocks. */
921 HGCMFunctionParameter num_affinity;
922 /** Pointer to process affinity blocks (uint64_t). */
923 HGCMFunctionParameter affinity;
924 } v2;
925 } u;
926} HGCMMsgProcExec;
927
928/**
929 * Sends input to a guest process via stdin.
930 */
931typedef struct HGCMMsgProcInput
932{
933 VBGLIOCHGCMCALL hdr;
934 /** Context ID. */
935 HGCMFunctionParameter context;
936 /** The process ID (PID) to send the input to. */
937 HGCMFunctionParameter pid;
938 /** Input flags (see IGuest::ProcessInputFlag_*). */
939 HGCMFunctionParameter flags;
940 /** Data buffer. */
941 HGCMFunctionParameter data;
942 /** Actual size of data (in bytes). */
943 HGCMFunctionParameter size;
944} HGCMMsgProcInput;
945
946/**
947 * Retrieves ouptut from a previously executed process
948 * from stdout/stderr.
949 */
950typedef struct HGCMMsgProcOutput
951{
952 VBGLIOCHGCMCALL hdr;
953 /** Context ID. */
954 HGCMFunctionParameter context;
955 /** The process ID (PID). */
956 HGCMFunctionParameter pid;
957 /** The pipe handle ID (stdout/stderr). */
958 HGCMFunctionParameter handle;
959 /** Optional flags. */
960 HGCMFunctionParameter flags;
961 /** Data buffer. */
962 HGCMFunctionParameter data;
963} HGCMMsgProcOutput;
964
965/**
966 * Reports the current status of a guest process.
967 */
968typedef struct HGCMMsgProcStatus
969{
970 VBGLIOCHGCMCALL hdr;
971 /** Context ID. */
972 HGCMFunctionParameter context;
973 /** The process ID (PID). */
974 HGCMFunctionParameter pid;
975 /** The process status. */
976 HGCMFunctionParameter status;
977 /** Optional flags (based on status). */
978 HGCMFunctionParameter flags;
979 /** Optional data buffer (not used atm). */
980 HGCMFunctionParameter data;
981} HGCMMsgProcStatus;
982
983/**
984 * Reports back the status of data written to a process.
985 */
986typedef struct HGCMMsgProcStatusInput
987{
988 VBGLIOCHGCMCALL hdr;
989 /** Context ID. */
990 HGCMFunctionParameter context;
991 /** The process ID (PID). */
992 HGCMFunctionParameter pid;
993 /** Status of the operation. */
994 HGCMFunctionParameter status;
995 /** Optional flags. */
996 HGCMFunctionParameter flags;
997 /** Data written. */
998 HGCMFunctionParameter written;
999} HGCMMsgProcStatusInput;
1000
1001/*
1002 * Guest control 2.0 messages.
1003 */
1004
1005/**
1006 * Terminates a guest process.
1007 */
1008typedef struct HGCMMsgProcTerminate
1009{
1010 VBGLIOCHGCMCALL hdr;
1011 /** Context ID. */
1012 HGCMFunctionParameter context;
1013 /** The process ID (PID). */
1014 HGCMFunctionParameter pid;
1015} HGCMMsgProcTerminate;
1016
1017/**
1018 * Waits for certain events to happen.
1019 */
1020typedef struct HGCMMsgProcWaitFor
1021{
1022 VBGLIOCHGCMCALL hdr;
1023 /** Context ID. */
1024 HGCMFunctionParameter context;
1025 /** The process ID (PID). */
1026 HGCMFunctionParameter pid;
1027 /** Wait (event) flags. */
1028 HGCMFunctionParameter flags;
1029 /** Timeout (in ms). */
1030 HGCMFunctionParameter timeout;
1031} HGCMMsgProcWaitFor;
1032
1033typedef struct HGCMMsgDirRemove
1034{
1035 VBGLIOCHGCMCALL hdr;
1036 /** UInt32: Context ID. */
1037 HGCMFunctionParameter context;
1038 /** Directory to remove. */
1039 HGCMFunctionParameter path;
1040 /** UInt32: Removement flags. */
1041 HGCMFunctionParameter flags;
1042} HGCMMsgDirRemove;
1043
1044/**
1045 * Opens a guest file.
1046 */
1047typedef struct HGCMMsgFileOpen
1048{
1049 VBGLIOCHGCMCALL hdr;
1050 /** UInt32: Context ID. */
1051 HGCMFunctionParameter context;
1052 /** File to open. */
1053 HGCMFunctionParameter filename;
1054 /** Open mode. */
1055 HGCMFunctionParameter openmode;
1056 /** Disposition mode. */
1057 HGCMFunctionParameter disposition;
1058 /** Sharing mode. */
1059 HGCMFunctionParameter sharing;
1060 /** UInt32: Creation mode. */
1061 HGCMFunctionParameter creationmode;
1062 /** UInt64: Initial offset. */
1063 HGCMFunctionParameter offset;
1064} HGCMMsgFileOpen;
1065
1066/**
1067 * Closes a guest file.
1068 */
1069typedef struct HGCMMsgFileClose
1070{
1071 VBGLIOCHGCMCALL hdr;
1072 /** Context ID. */
1073 HGCMFunctionParameter context;
1074 /** File handle to close. */
1075 HGCMFunctionParameter handle;
1076} HGCMMsgFileClose;
1077
1078/**
1079 * Reads from a guest file.
1080 */
1081typedef struct HGCMMsgFileRead
1082{
1083 VBGLIOCHGCMCALL hdr;
1084 /** Context ID. */
1085 HGCMFunctionParameter context;
1086 /** File handle to read from. */
1087 HGCMFunctionParameter handle;
1088 /** Size (in bytes) to read. */
1089 HGCMFunctionParameter size;
1090} HGCMMsgFileRead;
1091
1092/**
1093 * Reads at a specified offset from a guest file.
1094 */
1095typedef struct HGCMMsgFileReadAt
1096{
1097 VBGLIOCHGCMCALL hdr;
1098 /** Context ID. */
1099 HGCMFunctionParameter context;
1100 /** File handle to read from. */
1101 HGCMFunctionParameter handle;
1102 /** Offset where to start reading from. */
1103 HGCMFunctionParameter offset;
1104 /** Actual size of data (in bytes). */
1105 HGCMFunctionParameter size;
1106} HGCMMsgFileReadAt;
1107
1108/**
1109 * Writes to a guest file.
1110 */
1111typedef struct HGCMMsgFileWrite
1112{
1113 VBGLIOCHGCMCALL hdr;
1114 /** Context ID. */
1115 HGCMFunctionParameter context;
1116 /** File handle to write to. */
1117 HGCMFunctionParameter handle;
1118 /** Actual size of data (in bytes). */
1119 HGCMFunctionParameter size;
1120 /** Data buffer to write to the file. */
1121 HGCMFunctionParameter data;
1122} HGCMMsgFileWrite;
1123
1124/**
1125 * Writes at a specified offset to a guest file.
1126 */
1127typedef struct HGCMMsgFileWriteAt
1128{
1129 VBGLIOCHGCMCALL hdr;
1130 /** Context ID. */
1131 HGCMFunctionParameter context;
1132 /** File handle to write to. */
1133 HGCMFunctionParameter handle;
1134 /** Offset where to start reading from. */
1135 HGCMFunctionParameter offset;
1136 /** Actual size of data (in bytes). */
1137 HGCMFunctionParameter size;
1138 /** Data buffer to write to the file. */
1139 HGCMFunctionParameter data;
1140} HGCMMsgFileWriteAt;
1141
1142/**
1143 * Seeks the read/write position of a guest file.
1144 */
1145typedef struct HGCMMsgFileSeek
1146{
1147 VBGLIOCHGCMCALL hdr;
1148 /** Context ID. */
1149 HGCMFunctionParameter context;
1150 /** File handle to seek. */
1151 HGCMFunctionParameter handle;
1152 /** The seeking method. */
1153 HGCMFunctionParameter method;
1154 /** The seeking offset. */
1155 HGCMFunctionParameter offset;
1156} HGCMMsgFileSeek;
1157
1158/**
1159 * Tells the current read/write position of a guest file.
1160 */
1161typedef struct HGCMMsgFileTell
1162{
1163 VBGLIOCHGCMCALL hdr;
1164 /** Context ID. */
1165 HGCMFunctionParameter context;
1166 /** File handle to get the current position for. */
1167 HGCMFunctionParameter handle;
1168} HGCMMsgFileTell;
1169
1170/**
1171 * Changes the file size.
1172 */
1173typedef struct HGCMMsgFileSetSize
1174{
1175 VBGLIOCHGCMCALL Hdr;
1176 /** Context ID. */
1177 HGCMFunctionParameter id32Context;
1178 /** File handle to seek. */
1179 HGCMFunctionParameter id32Handle;
1180 /** The new file size. */
1181 HGCMFunctionParameter cb64NewSize;
1182} HGCMMsgFileSetSize;
1183
1184
1185/******************************************************************************
1186* HGCM replies from the guest. These are handled in Main's low-level HGCM *
1187* callbacks and dispatched to the appropriate guest object. *
1188******************************************************************************/
1189
1190typedef struct HGCMReplyFileNotify
1191{
1192 VBGLIOCHGCMCALL hdr;
1193 /** Context ID. */
1194 HGCMFunctionParameter context;
1195 /** Notification type. */
1196 HGCMFunctionParameter type;
1197 /** IPRT result of overall operation. */
1198 HGCMFunctionParameter rc;
1199 union
1200 {
1201 struct
1202 {
1203 /** Guest file handle. */
1204 HGCMFunctionParameter handle;
1205 } open;
1206 /** Note: Close does not have any additional data (yet). */
1207 struct
1208 {
1209 /** Actual data read (if any). */
1210 HGCMFunctionParameter data;
1211 } read;
1212 struct
1213 {
1214 /** Actual data read (if any). */
1215 HGCMFunctionParameter pvData;
1216 /** The new file offset (signed). Negative value if non-seekable files. */
1217 HGCMFunctionParameter off64New;
1218 } ReadOffset;
1219 struct
1220 {
1221 /** How much data (in bytes) have been successfully written. */
1222 HGCMFunctionParameter written;
1223 } write;
1224 struct
1225 {
1226 /** Number of bytes that was successfully written. */
1227 HGCMFunctionParameter cb32Written;
1228 /** The new file offset (signed). Negative value if non-seekable files. */
1229 HGCMFunctionParameter off64New;
1230 } WriteOffset;
1231 struct
1232 {
1233 HGCMFunctionParameter offset;
1234 } seek;
1235 struct
1236 {
1237 HGCMFunctionParameter offset;
1238 } tell;
1239 struct
1240 {
1241 HGCMFunctionParameter cb64Size;
1242 } SetSize;
1243 } u;
1244} HGCMReplyFileNotify;
1245
1246typedef struct HGCMReplyDirNotify
1247{
1248 VBGLIOCHGCMCALL hdr;
1249 /** Context ID. */
1250 HGCMFunctionParameter context;
1251 /** Notification type. */
1252 HGCMFunctionParameter type;
1253 /** IPRT result of overall operation. */
1254 HGCMFunctionParameter rc;
1255 union
1256 {
1257 struct
1258 {
1259 /** Directory information. */
1260 HGCMFunctionParameter objInfo;
1261 } info;
1262 struct
1263 {
1264 /** Guest directory handle. */
1265 HGCMFunctionParameter handle;
1266 } open;
1267 struct
1268 {
1269 /** Current read directory entry. */
1270 HGCMFunctionParameter entry;
1271 /** Extended entry object information. Optional. */
1272 HGCMFunctionParameter objInfo;
1273 } read;
1274 } u;
1275} HGCMReplyDirNotify;
1276
1277#pragma pack ()
1278
1279/******************************************************************************
1280* Callback data structures. *
1281******************************************************************************/
1282
1283/**
1284 * The guest control callback data header. Must come first
1285 * on each callback structure defined below this struct.
1286 */
1287typedef struct CALLBACKDATA_HEADER
1288{
1289 /** Context ID to identify callback data. This is
1290 * and *must* be the very first parameter in this
1291 * structure to still be backwards compatible. */
1292 uint32_t uContextID;
1293} CALLBACKDATA_HEADER, *PCALLBACKDATA_HEADER;
1294
1295/*
1296 * These structures make up the actual low level HGCM callback data sent from
1297 * the guest back to the host.
1298 */
1299
1300typedef struct CALLBACKDATA_CLIENT_DISCONNECTED
1301{
1302 /** Callback data header. */
1303 CALLBACKDATA_HEADER hdr;
1304} CALLBACKDATA_CLIENT_DISCONNECTED, *PCALLBACKDATA_CLIENT_DISCONNECTED;
1305
1306typedef struct CALLBACKDATA_MSG_REPLY
1307{
1308 /** Callback data header. */
1309 CALLBACKDATA_HEADER hdr;
1310 /** Notification type. */
1311 uint32_t uType;
1312 /** Notification result. Note: int vs. uint32! */
1313 uint32_t rc;
1314 /** Pointer to optional payload. */
1315 void *pvPayload;
1316 /** Payload size (in bytes). */
1317 uint32_t cbPayload;
1318} CALLBACKDATA_MSG_REPLY, *PCALLBACKDATA_MSG_REPLY;
1319
1320typedef struct CALLBACKDATA_SESSION_NOTIFY
1321{
1322 /** Callback data header. */
1323 CALLBACKDATA_HEADER hdr;
1324 /** Notification type. */
1325 uint32_t uType;
1326 /** Notification result. Note: int vs. uint32! */
1327 uint32_t uResult;
1328} CALLBACKDATA_SESSION_NOTIFY, *PCALLBACKDATA_SESSION_NOTIFY;
1329
1330typedef struct CALLBACKDATA_PROC_STATUS
1331{
1332 /** Callback data header. */
1333 CALLBACKDATA_HEADER hdr;
1334 /** The process ID (PID). */
1335 uint32_t uPID;
1336 /** The process status. */
1337 uint32_t uStatus;
1338 /** Optional flags, varies, based on u32Status. */
1339 uint32_t uFlags;
1340 /** Optional data buffer (not used atm). */
1341 void *pvData;
1342 /** Size of optional data buffer (not used atm). */
1343 uint32_t cbData;
1344} CALLBACKDATA_PROC_STATUS, *PCALLBACKDATA_PROC_STATUS;
1345
1346typedef struct CALLBACKDATA_PROC_OUTPUT
1347{
1348 /** Callback data header. */
1349 CALLBACKDATA_HEADER hdr;
1350 /** The process ID (PID). */
1351 uint32_t uPID;
1352 /** The handle ID (stdout/stderr). */
1353 uint32_t uHandle;
1354 /** Optional flags (not used atm). */
1355 uint32_t uFlags;
1356 /** Optional data buffer. */
1357 void *pvData;
1358 /** Size (in bytes) of optional data buffer. */
1359 uint32_t cbData;
1360} CALLBACKDATA_PROC_OUTPUT, *PCALLBACKDATA_PROC_OUTPUT;
1361
1362typedef struct CALLBACKDATA_PROC_INPUT
1363{
1364 /** Callback data header. */
1365 CALLBACKDATA_HEADER hdr;
1366 /** The process ID (PID). */
1367 uint32_t uPID;
1368 /** Current input status. */
1369 uint32_t uStatus;
1370 /** Optional flags. */
1371 uint32_t uFlags;
1372 /** Size (in bytes) of processed input data. */
1373 uint32_t uProcessed;
1374} CALLBACKDATA_PROC_INPUT, *PCALLBACKDATA_PROC_INPUT;
1375
1376/**
1377 * General guest directory notification callback.
1378 */
1379typedef struct CALLBACKDATA_DIR_NOTIFY
1380{
1381 /** Callback data header. */
1382 CALLBACKDATA_HEADER hdr;
1383 /** Notification type. */
1384 uint32_t uType;
1385 /** IPRT result of overall operation. */
1386 uint32_t rc;
1387 union
1388 {
1389 struct
1390 {
1391 /** Size (in bytes) of directory information. */
1392 uint32_t cbObjInfo;
1393 /** Pointer to directory information. */
1394 void *pvObjInfo;
1395 } info;
1396 struct
1397 {
1398 /** Guest directory handle. */
1399 uint32_t uHandle;
1400 } open;
1401 /** Note: Close does not have any additional data (yet). */
1402 struct
1403 {
1404 /** Size (in bytes) of directory entry information. */
1405 uint32_t cbEntry;
1406 /** Pointer to directory entry information. */
1407 void *pvEntry;
1408 /** Size (in bytes) of directory entry object information. */
1409 uint32_t cbObjInfo;
1410 /** Pointer to directory entry object information. */
1411 void *pvObjInfo;
1412 } read;
1413 } u;
1414} CALLBACKDATA_DIR_NOTIFY, *PCALLBACKDATA_DIR_NOTIFY;
1415
1416/**
1417 * General guest file notification callback.
1418 */
1419typedef struct CALLBACKDATA_FILE_NOTIFY
1420{
1421 /** Callback data header. */
1422 CALLBACKDATA_HEADER hdr;
1423 /** Notification type. */
1424 uint32_t uType;
1425 /** IPRT result of overall operation. */
1426 uint32_t rc;
1427 union
1428 {
1429 struct
1430 {
1431 /** Guest file handle. */
1432 uint32_t uHandle;
1433 } open;
1434 /** Note: Close does not have any additional data (yet). */
1435 struct
1436 {
1437 /** How much data (in bytes) have been read. */
1438 uint32_t cbData;
1439 /** Actual data read (if any). */
1440 void *pvData;
1441 } read;
1442 struct
1443 {
1444 /** How much data (in bytes) have been successfully written. */
1445 uint32_t cbWritten;
1446 } write;
1447 struct
1448 {
1449 /** New file offset after successful seek. */
1450 uint64_t uOffActual;
1451 } seek;
1452 struct
1453 {
1454 /** New file offset after successful tell. */
1455 uint64_t uOffActual;
1456 } tell;
1457 struct
1458 {
1459 /** The new file siz.e */
1460 uint64_t cbSize;
1461 } SetSize;
1462 } u;
1463} CALLBACKDATA_FILE_NOTIFY, *PCALLBACKDATA_FILE_NOTIFY;
1464
1465} /* namespace guestControl */
1466
1467#endif /* !VBOX_INCLUDED_HostServices_GuestControlSvc_h */
1468
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