VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxService/VBoxServiceInternal.h@ 29743

Last change on this file since 29743 was 29516, checked in by vboxsync, 15 years ago

Guest Control: Remove unused Std* arguments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.6 KB
Line 
1/* $Id: VBoxServiceInternal.h 29516 2010-05-17 09:55:17Z vboxsync $ */
2/** @file
3 * VBoxService - Guest Additions Services.
4 */
5
6/*
7 * Copyright (C) 2007-2010 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
18#ifndef ___VBoxServiceInternal_h
19#define ___VBoxServiceInternal_h
20
21#include <stdio.h>
22#ifdef RT_OS_WINDOWS
23# include <Windows.h>
24# include <process.h> /* Needed for file version information. */
25#endif
26
27#include <iprt/list.h>
28#include <iprt/critsect.h>
29
30/**
31 * A service descriptor.
32 */
33typedef struct
34{
35 /** The short service name. */
36 const char *pszName;
37 /** The longer service name. */
38 const char *pszDescription;
39 /** The usage options stuff for the --help screen. */
40 const char *pszUsage;
41 /** The option descriptions for the --help screen. */
42 const char *pszOptions;
43
44 /**
45 * Called before parsing arguments.
46 * @returns VBox status code.
47 */
48 DECLCALLBACKMEMBER(int, pfnPreInit)(void);
49
50 /**
51 * Tries to parse the given command line option.
52 *
53 * @returns 0 if we parsed, -1 if it didn't and anything else means exit.
54 * @param ppszShort If not NULL it points to the short option iterator. a short argument.
55 * If NULL examine argv[*pi].
56 * @param argc The argument count.
57 * @param argv The argument vector.
58 * @param pi The argument vector index. Update if any value(s) are eaten.
59 */
60 DECLCALLBACKMEMBER(int, pfnOption)(const char **ppszShort, int argc, char **argv, int *pi);
61
62 /**
63 * Called before parsing arguments.
64 * @returns VBox status code.
65 */
66 DECLCALLBACKMEMBER(int, pfnInit)(void);
67
68 /** Called from the worker thread.
69 *
70 * @returns VBox status code.
71 * @retval VINF_SUCCESS if exitting because *pfTerminate was set.
72 * @param pfTerminate Pointer to a per service termination flag to check
73 * before and after blocking.
74 */
75 DECLCALLBACKMEMBER(int, pfnWorker)(bool volatile *pfTerminate);
76
77 /**
78 * Stop an service.
79 */
80 DECLCALLBACKMEMBER(void, pfnStop)(void);
81
82 /**
83 * Does termination cleanups.
84 *
85 * @remarks This may be called even if pfnInit hasn't been called!
86 */
87 DECLCALLBACKMEMBER(void, pfnTerm)(void);
88} VBOXSERVICE;
89/** Pointer to a VBOXSERVICE. */
90typedef VBOXSERVICE *PVBOXSERVICE;
91/** Pointer to a const VBOXSERVICE. */
92typedef VBOXSERVICE const *PCVBOXSERVICE;
93
94#ifdef RT_OS_WINDOWS
95
96/** The service name (needed for mutex creation on Windows). */
97# define VBOXSERVICE_NAME "VBoxService"
98/** The friendly service name. */
99# define VBOXSERVICE_FRIENDLY_NAME "VirtualBox Guest Additions Service"
100/** The service description (only W2K+ atm) */
101# define VBOXSERVICE_DESCRIPTION "Manages VM runtime information, time synchronization, remote sysprep execution and miscellaneous utilities for guest operating systems."
102/** The following constant may be defined by including NtStatus.h. */
103# define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
104/** Structure for storing the looked up user information. */
105typedef struct
106{
107 WCHAR wszUser[_MAX_PATH];
108 WCHAR wszAuthenticationPackage[_MAX_PATH];
109 WCHAR wszLogonDomain[_MAX_PATH];
110} VBOXSERVICEVMINFOUSER, *PVBOXSERVICEVMINFOUSER;
111/** Structure for the file information lookup. */
112typedef struct
113{
114 char *pszFilePath;
115 char *pszFileName;
116} VBOXSERVICEVMINFOFILE, *PVBOXSERVICEVMINFOFILE;
117/** Structure for process information lookup. */
118typedef struct
119{
120 DWORD id;
121 LUID luid;
122} VBOXSERVICEVMINFOPROC, *PVBOXSERVICEVMINFOPROC;
123/** Function prototypes for dynamic loading. */
124typedef DWORD (WINAPI *PFNWTSGETACTIVECONSOLESESSIONID)(void);
125
126#endif /* RT_OS_WINDOWS */
127#ifdef VBOX_WITH_GUEST_CONTROL
128
129enum VBOXSERVICECTRLTHREADDATATYPE
130{
131 VBoxServiceCtrlThreadDataUnknown = 0,
132 VBoxServiceCtrlThreadDataExec = 1
133};
134
135typedef struct
136{
137 uint8_t *pbData;
138 uint32_t cbSize;
139 uint32_t cbOffset;
140 uint32_t cbRead;
141 RTCRITSECT CritSect;
142} VBOXSERVICECTRLEXECPIPEBUF;
143/** Pointer to thread data. */
144typedef VBOXSERVICECTRLEXECPIPEBUF *PVBOXSERVICECTRLEXECPIPEBUF;
145
146/* Structure for holding guest exection relevant data. */
147typedef struct
148{
149 uint32_t uPID;
150 char *pszCmd;
151 uint32_t uFlags;
152 char **papszArgs;
153 uint32_t uNumArgs;
154 char **papszEnv;
155 uint32_t uNumEnvVars;
156 char *pszUser;
157 char *pszPassword;
158 uint32_t uTimeLimitMS;
159
160 VBOXSERVICECTRLEXECPIPEBUF stdOut;
161 VBOXSERVICECTRLEXECPIPEBUF stdErr;
162
163} VBOXSERVICECTRLTHREADDATAEXEC;
164/** Pointer to thread data. */
165typedef VBOXSERVICECTRLTHREADDATAEXEC *PVBOXSERVICECTRLTHREADDATAEXEC;
166
167/* Structure for holding thread relevant data. */
168typedef struct VBOXSERVICECTRLTHREAD
169{
170 /** Node. */
171 RTLISTNODE Node;
172 /** The worker thread. */
173 RTTHREAD Thread;
174 /** Shutdown indicator. */
175 bool volatile fShutdown;
176 /** Indicator set by the service thread exiting. */
177 bool volatile fStopped;
178 /** Whether the service was started or not. */
179 bool fStarted;
180 /** Client ID. */
181 uint32_t uClientID;
182 /** Context ID. */
183 uint32_t uContextID;
184 /** Type of thread. See VBOXSERVICECTRLTHREADDATATYPE for more info. */
185 VBOXSERVICECTRLTHREADDATATYPE enmType;
186 /** Pointer to actual thread data, depending on enmType. */
187 void *pvData;
188} VBOXSERVICECTRLTHREAD;
189/** Pointer to thread data. */
190typedef VBOXSERVICECTRLTHREAD *PVBOXSERVICECTRLTHREAD;
191
192/**
193 * For buffering process input supplied by the client.
194 */
195typedef struct VBOXSERVICECTRLSTDINBUF
196{
197 /** The mount of buffered data. */
198 size_t cb;
199 /** The current data offset. */
200 size_t off;
201 /** The data buffer. */
202 char *pch;
203 /** The amount of allocated buffer space. */
204 size_t cbAllocated;
205 /** Send further input into the bit bucket (stdin is dead). */
206 bool fBitBucket;
207 /** The CRC-32 for standard input (received part). */
208 uint32_t uCrc32;
209} VBOXSERVICECTRLSTDINBUF;
210/** Pointer to a standard input buffer. */
211typedef VBOXSERVICECTRLSTDINBUF *PVBOXSERVICECTRLSTDINBUF;
212
213#endif /* VBOX_WITH_GUEST_CONTROL */
214#ifdef VBOX_WITH_GUEST_PROPS
215
216/**
217 * A guest property cache.
218 */
219typedef struct VBOXSERVICEVEPROPCACHE
220{
221 /** The client ID for HGCM communication. */
222 uint32_t uClientID;
223 /** List of VBOXSERVICEVEPROPCACHEENTRY nodes. */
224 RTLISTNODE ListEntries;
225 /** Critical section for thread-safe use. */
226 RTCRITSECT CritSect;
227} VBOXSERVICEVEPROPCACHE;
228/** Pointer to a guest property cache. */
229typedef VBOXSERVICEVEPROPCACHE *PVBOXSERVICEVEPROPCACHE;
230
231/**
232 * An entry in the property cache (VBOXSERVICEVEPROPCACHE).
233 */
234typedef struct VBOXSERVICEVEPROPCACHEENTRY
235{
236 /** Node. */
237 RTLISTNODE Node;
238 /** Name (and full path) of guest property. */
239 char *pszName;
240 /** The last value stored (for reference). */
241 char *pszValue;
242 /** Reset value to write if property is temporary. If NULL, it will be
243 * deleted. */
244 char *pszValueReset;
245 /** Flags. */
246 uint32_t fFlags;
247} VBOXSERVICEVEPROPCACHEENTRY;
248/** Pointer to a cached guest property. */
249typedef VBOXSERVICEVEPROPCACHEENTRY *PVBOXSERVICEVEPROPCACHEENTRY;
250
251#endif /* VBOX_WITH_GUEST_PROPS */
252
253RT_C_DECLS_BEGIN
254
255extern char *g_pszProgName;
256extern int g_cVerbosity;
257extern uint32_t g_DefaultInterval;
258
259extern int VBoxServiceSyntax(const char *pszFormat, ...);
260extern int VBoxServiceError(const char *pszFormat, ...);
261extern void VBoxServiceVerbose(int iLevel, const char *pszFormat, ...);
262extern int VBoxServiceArgUInt32(int argc, char **argv, const char *psz, int *pi, uint32_t *pu32, uint32_t u32Min, uint32_t u32Max);
263extern unsigned VBoxServiceGetStartedServices(void);
264extern int VBoxServiceStartServices(unsigned iMain);
265extern int VBoxServiceStopServices(void);
266
267extern VBOXSERVICE g_TimeSync;
268extern VBOXSERVICE g_Clipboard;
269extern VBOXSERVICE g_Control;
270extern VBOXSERVICE g_VMInfo;
271extern VBOXSERVICE g_CpuHotPlug;
272#ifdef VBOXSERVICE_MANAGEMENT
273extern VBOXSERVICE g_MemBalloon;
274extern VBOXSERVICE g_VMStatistics;
275#endif
276#ifdef VBOX_WITH_PAGE_SHARING
277extern VBOXSERVICE g_PageSharing;
278#endif
279
280#ifdef RT_OS_WINDOWS
281extern DWORD g_rcWinService;
282extern SERVICE_TABLE_ENTRY const g_aServiceTable[]; /** @todo generate on the fly, see comment in main() from the enabled sub services. */
283extern PFNWTSGETACTIVECONSOLESESSIONID g_pfnWTSGetActiveConsoleSessionId; /* VBoxServiceVMInfo-win.cpp */
284
285extern int VBoxServiceWinInstall(void);
286extern int VBoxServiceWinUninstall(void);
287extern BOOL VBoxServiceWinSetStatus(DWORD dwStatus, DWORD dwCheckPoint);
288# ifdef VBOX_WITH_GUEST_PROPS
289extern bool VBoxServiceVMInfoWinSessionHasProcesses(PLUID pSession, VBOXSERVICEVMINFOPROC const *paProcs, DWORD cProcs);
290extern bool VBoxServiceVMInfoWinIsLoggedIn(PVBOXSERVICEVMINFOUSER a_pUserInfo, PLUID a_pSession);
291extern int VBoxServiceVMInfoWinProcessesEnumerate(PVBOXSERVICEVMINFOPROC *ppProc, DWORD *pdwCount);
292extern void VBoxServiceVMInfoWinProcessesFree(PVBOXSERVICEVMINFOPROC paProcs);
293extern int VBoxServiceWinGetComponentVersions(uint32_t uiClientID);
294# endif /* VBOX_WITH_GUEST_PROPS */
295#endif /* RT_OS_WINDOWS */
296
297#ifdef VBOX_WITH_GUEST_CONTROL
298extern int VBoxServiceControlExecProcess(uint32_t uContext, const char *pszCmd, uint32_t uFlags,
299 const char *pszArgs, uint32_t uNumArgs,
300 const char *pszEnv, uint32_t cbEnv, uint32_t uNumEnvVars,
301 const char *pszUser, const char *pszPassword, uint32_t uTimeLimitMS);
302extern void VBoxServiceControlExecDestroyThreadData(PVBOXSERVICECTRLTHREADDATAEXEC pThread);
303extern int VBoxServiceControlExecReadPipeBufferContent(PVBOXSERVICECTRLEXECPIPEBUF pBuf,
304 uint8_t *pbBuffer, uint32_t cbBuffer, uint32_t *pcbToRead);
305extern int VBoxServiceControlExecWritePipeBuffer(PVBOXSERVICECTRLEXECPIPEBUF pBuf,
306 uint8_t *pbData, uint32_t cbData);
307#endif
308
309#ifdef VBOXSERVICE_MANAGEMENT
310extern uint32_t VBoxServiceBalloonQueryPages(uint32_t cbPage);
311#endif
312
313RT_C_DECLS_END
314
315#endif
316
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