VirtualBox

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

Last change on this file since 80637 was 79296, checked in by vboxsync, 5 years ago

Main,VBoxService,GstCtrlSvc: Added functions for exchanging feature masks between guest and host so new features can more easily be added without resorting to version comparsion magic. Added alternative read and write completion notifications that includes the new file offset. Made sure RTFileReadAt and RTFileWriteAt are followed by a RTFileSeek call so we'll end up with the same file position regardless of guest OS. bugref:9320

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