VirtualBox

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

最後變更 在這個檔案從33492是 33492,由 vboxsync 提交於 14 年 前

Guest Copy/Guest Additions: Update.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 10.5 KB
 
1/** @file
2 * Guest control service:
3 * Common header for host service and guest clients.
4 */
5
6/*
7 * Copyright (C) 2010 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.alldomusa.eu.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef ___VBox_HostService_GuestControlService_h
28#define ___VBox_HostService_GuestControlService_h
29
30#include <VBox/types.h>
31#include <VBox/VMMDev.h>
32#include <VBox/VBoxGuest2.h>
33#include <VBox/hgcmsvc.h>
34#include <VBox/log.h>
35#include <iprt/assert.h>
36#include <iprt/string.h>
37
38/** Everything defined in this file lives in this namespace. */
39namespace guestControl {
40
41/******************************************************************************
42* Typedefs, constants and inlines *
43******************************************************************************/
44
45/**
46 * Process status when executed in the guest.
47 */
48enum eProcessStatus
49{
50 /** Process is in an undefined state. */
51 PROC_STS_UNDEFINED = 0,
52 /** Process has been started. */
53 PROC_STS_STARTED = 1,
54 /** Process terminated normally. */
55 PROC_STS_TEN = 2,
56 /** Process terminated via signal. */
57 PROC_STS_TES = 3,
58 /** Process terminated abnormally. */
59 PROC_STS_TEA = 4,
60 /** Process timed out and was killed. */
61 PROC_STS_TOK = 5,
62 /** Process timed out and was not killed successfully. */
63 PROC_STS_TOA = 6,
64 /** Service/OS is stopping, process was killed. */
65 PROC_STS_DWN = 7,
66 /** Something went wrong (error code in flags). */
67 PROC_STS_ERROR = 8
68};
69
70/**
71 * Input flags, set by the host. This is needed for
72 * handling flags on the guest side.
73 * Note: Has to match Main's ProcessInputFlag_* flags!
74 */
75#define INPUT_FLAG_NONE 0
76#define INPUT_FLAG_EOF RT_BIT(0)
77
78/**
79 * Input status, reported by the client.
80 */
81enum eInputStatus
82{
83 /** Input is in an undefined state. */
84 INPUT_STS_UNDEFINED = 0,
85 /** Input was written (partially, see cbProcessed). */
86 INPUT_STS_WRITTEN = 1,
87 /** Input failed with an error (see flags for rc). */
88 INPUT_STS_ERROR = 20,
89 /** Process has abandoned / terminated input handling. */
90 INPUT_STS_TERMINATED = 21,
91 /** Too much input data. */
92 INPUT_STS_OVERFLOW = 30
93};
94
95typedef struct _VBoxGuestCtrlCallbackHeader
96{
97 /** Magic number to identify the structure. */
98 uint32_t u32Magic;
99 /** Context ID to identify callback data. */
100 uint32_t u32ContextID;
101} CALLBACKHEADER, *PCALLBACKHEADER;
102
103/**
104 * Data structure to pass to the service extension callback. We use this to
105 * notify the host of changes to properties.
106 */
107typedef struct _VBoxGuestCtrlCallbackDataExecStatus
108{
109 /** Callback data header. */
110 CALLBACKHEADER hdr;
111 /** The process ID (PID). */
112 uint32_t u32PID;
113 /* The process status. */
114 uint32_t u32Status;
115 /** Optional flags, varies, based on u32Status. */
116 uint32_t u32Flags;
117 /** Optional data buffer (not used atm). */
118 void *pvData;
119 /** Size of optional data buffer (not used atm). */
120 uint32_t cbData;
121} CALLBACKDATAEXECSTATUS, *PCALLBACKDATAEXECSTATUS;
122
123typedef struct _VBoxGuestCtrlCallbackDataExecOut
124{
125 /** Callback data header. */
126 CALLBACKHEADER hdr;
127 /** The process ID (PID). */
128 uint32_t u32PID;
129 /* The handle ID (stdout/stderr). */
130 uint32_t u32HandleId;
131 /** Optional flags (not used atm). */
132 uint32_t u32Flags;
133 /** Optional data buffer. */
134 void *pvData;
135 /** Size (in bytes) of optional data buffer. */
136 uint32_t cbData;
137} CALLBACKDATAEXECOUT, *PCALLBACKDATAEXECOUT;
138
139typedef struct _VBoxGuestCtrlCallbackDataExecInStatus
140{
141 /** Callback data header. */
142 CALLBACKHEADER hdr;
143 /** The process ID (PID). */
144 uint32_t u32PID;
145 /** Current input status. */
146 uint32_t u32Status;
147 /** Optional flags. */
148 uint32_t u32Flags;
149 /** Size (in bytes) of processed input data. */
150 uint32_t cbProcessed;
151} CALLBACKDATAEXECINSTATUS, *PCALLBACKDATAEXECINSTATUS;
152
153typedef struct _VBoxGuestCtrlCallbackDataClientDisconnected
154{
155 /** Callback data header. */
156 CALLBACKHEADER hdr;
157} CALLBACKDATACLIENTDISCONNECTED, *PCALLBACKDATACLIENTDISCONNECTED;
158
159enum
160{
161 /** Magic number for sanity checking the CALLBACKDATACLIENTDISCONNECTED structure. */
162 CALLBACKDATAMAGICCLIENTDISCONNECTED = 0x08041984,
163 /** Magic number for sanity checking the CALLBACKDATAEXECSTATUS structure. */
164 CALLBACKDATAMAGICEXECSTATUS = 0x26011982,
165 /** Magic number for sanity checking the CALLBACKDATAEXECOUT structure. */
166 CALLBACKDATAMAGICEXECOUT = 0x11061949,
167 /** Magic number for sanity checking the CALLBACKDATAEXECIN structure. */
168 CALLBACKDATAMAGICEXECINSTATUS = 0x19091951
169};
170
171enum eVBoxGuestCtrlCallbackType
172{
173 VBOXGUESTCTRLCALLBACKTYPE_UNKNOWN = 0,
174 VBOXGUESTCTRLCALLBACKTYPE_EXEC_START = 1,
175 VBOXGUESTCTRLCALLBACKTYPE_EXEC_OUTPUT = 2,
176 VBOXGUESTCTRLCALLBACKTYPE_EXEC_INPUT_STATUS = 3
177};
178
179/**
180 * The service functions which are callable by host.
181 */
182enum eHostFn
183{
184 /**
185 * The host asks the client to cancel all pending waits and exit.
186 */
187 HOST_CANCEL_PENDING_WAITS = 0,
188 /**
189 * The host wants to execute something in the guest. This can be a command line
190 * or starting a program.
191 */
192 HOST_EXEC_CMD = 100,
193 /**
194 * Sends input data for stdin to a running process executed by HOST_EXEC_CMD.
195 */
196 HOST_EXEC_SET_INPUT = 101,
197 /**
198 * Gets the current status of a running process, e.g.
199 * new data on stdout/stderr, process terminated etc.
200 */
201 HOST_EXEC_GET_OUTPUT = 102
202};
203
204/**
205 * The service functions which are called by guest. The numbers may not change,
206 * so we hardcode them.
207 */
208enum eGuestFn
209{
210 /**
211 * Guest waits for a new message the host wants to process on the guest side.
212 * This is a blocking call and can be deferred.
213 */
214 GUEST_GET_HOST_MSG = 1,
215 /**
216 * Guest asks the host to cancel all pending waits the guest itself waits on.
217 * This becomes necessary when the guest wants to quit but still waits for
218 * commands from the host.
219 */
220 GUEST_CANCEL_PENDING_WAITS = 2,
221 /**
222 * Guest disconnected (terminated normally or due to a crash HGCM
223 * detected when calling service::clientDisconnect().
224 */
225 GUEST_DISCONNECTED = 3,
226 /**
227 * Guests sends output from an executed process.
228 */
229 GUEST_EXEC_SEND_OUTPUT = 100,
230 /**
231 * Guest sends a status update of an executed process to the host.
232 */
233 GUEST_EXEC_SEND_STATUS = 101,
234 /**
235 * Guests sends an input status notification to the host.
236 */
237 GUEST_EXEC_SEND_INPUT_STATUS = 102
238};
239
240/*
241 * HGCM parameter structures.
242 */
243#pragma pack (1)
244typedef struct _VBoxGuestCtrlHGCMMsgType
245{
246 VBoxGuestHGCMCallInfo hdr;
247
248 /**
249 * The returned command the host wants to
250 * run on the guest.
251 */
252 HGCMFunctionParameter msg; /* OUT uint32_t */
253 /** Number of parameters the message needs. */
254 HGCMFunctionParameter num_parms; /* OUT uint32_t */
255
256} VBoxGuestCtrlHGCMMsgType;
257
258typedef struct _VBoxGuestCtrlHGCMMsgCancelPendingWaits
259{
260 VBoxGuestHGCMCallInfo hdr;
261} VBoxGuestCtrlHGCMMsgCancelPendingWaits;
262
263typedef struct _VBoxGuestCtrlHGCMMsgExecCmd
264{
265 VBoxGuestHGCMCallInfo hdr;
266
267 HGCMFunctionParameter context;
268
269 HGCMFunctionParameter cmd;
270
271 HGCMFunctionParameter flags;
272
273 HGCMFunctionParameter num_args;
274
275 HGCMFunctionParameter args;
276
277 HGCMFunctionParameter num_env;
278 /** Size (in bytes) of environment block, including terminating zeros. */
279 HGCMFunctionParameter cb_env;
280
281 HGCMFunctionParameter env;
282
283 HGCMFunctionParameter username;
284
285 HGCMFunctionParameter password;
286
287 HGCMFunctionParameter timeout;
288
289} VBoxGuestCtrlHGCMMsgExecCmd;
290
291typedef struct _VBoxGuestCtrlHGCMMsgExecIn
292{
293 VBoxGuestHGCMCallInfo hdr;
294 /** Context ID. */
295 HGCMFunctionParameter context;
296 /** The process ID (PID). */
297 HGCMFunctionParameter pid;
298 /** Flags (see IGuest::ProcessInputFlag_*). */
299 HGCMFunctionParameter flags;
300 /** Data buffer. */
301 HGCMFunctionParameter data;
302 /** Actual size of data. */
303 HGCMFunctionParameter size;
304
305} VBoxGuestCtrlHGCMMsgExecIn;
306
307typedef struct _VBoxGuestCtrlHGCMMsgExecOut
308{
309 VBoxGuestHGCMCallInfo hdr;
310 /** Context ID. */
311 HGCMFunctionParameter context;
312 /** The process ID (PID). */
313 HGCMFunctionParameter pid;
314 /** The pipe handle ID (stdout/stderr). */
315 HGCMFunctionParameter handle;
316 /** Optional flags. */
317 HGCMFunctionParameter flags;
318 /** Data buffer. */
319 HGCMFunctionParameter data;
320
321} VBoxGuestCtrlHGCMMsgExecOut;
322
323typedef struct _VBoxGuestCtrlHGCMMsgExecStatus
324{
325 VBoxGuestHGCMCallInfo hdr;
326 /** Context ID. */
327 HGCMFunctionParameter context;
328 /** The process ID (PID). */
329 HGCMFunctionParameter pid;
330 /** The process status. */
331 HGCMFunctionParameter status;
332 /** Optional flags (based on status). */
333 HGCMFunctionParameter flags;
334 /** Optional data buffer (not used atm). */
335 HGCMFunctionParameter data;
336
337} VBoxGuestCtrlHGCMMsgExecStatus;
338
339typedef struct _VBoxGuestCtrlHGCMMsgExecStatusIn
340{
341 VBoxGuestHGCMCallInfo hdr;
342 /** Context ID. */
343 HGCMFunctionParameter context;
344 /** The process ID (PID). */
345 HGCMFunctionParameter pid;
346 /** Status of the operation. */
347 HGCMFunctionParameter status;
348 /** Optional flags. */
349 HGCMFunctionParameter flags;
350 /** Data written. */
351 HGCMFunctionParameter written;
352
353} VBoxGuestCtrlHGCMMsgExecStatusIn;
354#pragma pack ()
355
356/* Structure for buffering execution requests in the host service. */
357typedef struct _VBoxGuestCtrlParamBuffer
358{
359 uint32_t uMsg;
360 uint32_t uParmCount;
361 VBOXHGCMSVCPARM *pParms;
362} VBOXGUESTCTRPARAMBUFFER, *PVBOXGUESTCTRPARAMBUFFER;
363
364} /* namespace guestControl */
365
366#endif /* ___VBox_HostService_GuestControlService_h defined */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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