VirtualBox

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

Last change on this file since 28546 was 28434, checked in by vboxsync, 15 years ago

*: whitespace cleanups by scm and two manually picked nits.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.4 KB
Line 
1/* $Id: VBoxServiceInternal.h 28434 2010-04-17 18:08:28Z vboxsync $ */
2/** @file
3 * VBoxService - Guest Additions Services.
4 */
5
6/*
7 * Copyright (C) 2007-2010 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#ifndef ___VBoxServiceInternal_h
23#define ___VBoxServiceInternal_h
24
25#include <stdio.h>
26#ifdef RT_OS_WINDOWS
27# include <Windows.h>
28# include <process.h> /* Needed for file version information. */
29#endif
30
31#ifdef VBOX_WITH_GUEST_CONTROL
32# include <iprt/list.h>
33#endif
34
35/**
36 * A service descriptor.
37 */
38typedef struct
39{
40 /** The short service name. */
41 const char *pszName;
42 /** The longer service name. */
43 const char *pszDescription;
44 /** The usage options stuff for the --help screen. */
45 const char *pszUsage;
46 /** The option descriptions for the --help screen. */
47 const char *pszOptions;
48
49 /**
50 * Called before parsing arguments.
51 * @returns VBox status code.
52 */
53 DECLCALLBACKMEMBER(int, pfnPreInit)(void);
54
55 /**
56 * Tries to parse the given command line option.
57 *
58 * @returns 0 if we parsed, -1 if it didn't and anything else means exit.
59 * @param ppszShort If not NULL it points to the short option iterator. a short argument.
60 * If NULL examine argv[*pi].
61 * @param argc The argument count.
62 * @param argv The argument vector.
63 * @param pi The argument vector index. Update if any value(s) are eaten.
64 */
65 DECLCALLBACKMEMBER(int, pfnOption)(const char **ppszShort, int argc, char **argv, int *pi);
66
67 /**
68 * Called before parsing arguments.
69 * @returns VBox status code.
70 */
71 DECLCALLBACKMEMBER(int, pfnInit)(void);
72
73 /** Called from the worker thread.
74 *
75 * @returns VBox status code.
76 * @retval VINF_SUCCESS if exitting because *pfTerminate was set.
77 * @param pfTerminate Pointer to a per service termination flag to check
78 * before and after blocking.
79 */
80 DECLCALLBACKMEMBER(int, pfnWorker)(bool volatile *pfTerminate);
81
82 /**
83 * Stop an service.
84 */
85 DECLCALLBACKMEMBER(void, pfnStop)(void);
86
87 /**
88 * Does termination cleanups.
89 *
90 * @remarks This may be called even if pfnInit hasn't been called!
91 */
92 DECLCALLBACKMEMBER(void, pfnTerm)(void);
93} VBOXSERVICE;
94/** Pointer to a VBOXSERVICE. */
95typedef VBOXSERVICE *PVBOXSERVICE;
96/** Pointer to a const VBOXSERVICE. */
97typedef VBOXSERVICE const *PCVBOXSERVICE;
98
99#ifdef RT_OS_WINDOWS
100/** The service name (needed for mutex creation on Windows). */
101# define VBOXSERVICE_NAME "VBoxService"
102/** The friendly service name. */
103# define VBOXSERVICE_FRIENDLY_NAME "VirtualBox Guest Additions Service"
104/** The service description (only W2K+ atm) */
105# define VBOXSERVICE_DESCRIPTION "Manages VM runtime information, time synchronization, remote sysprep execution and miscellaneous utilities for guest operating systems."
106/** The following constant may be defined by including NtStatus.h. */
107# define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
108/** Structure for storing the looked up user information. */
109typedef struct
110{
111 WCHAR wszUser[_MAX_PATH];
112 WCHAR wszAuthenticationPackage[_MAX_PATH];
113 WCHAR wszLogonDomain[_MAX_PATH];
114} VBOXSERVICEVMINFOUSER, *PVBOXSERVICEVMINFOUSER;
115/** Structure for the file information lookup. */
116typedef struct
117{
118 char *pszFilePath;
119 char *pszFileName;
120} VBOXSERVICEVMINFOFILE, *PVBOXSERVICEVMINFOFILE;
121/** Structure for process information lookup. */
122typedef struct
123{
124 DWORD id;
125 LUID luid;
126} VBOXSERVICEVMINFOPROC, *PVBOXSERVICEVMINFOPROC;
127/** Function prototypes for dynamic loading. */
128typedef DWORD (WINAPI *PFNWTSGETACTIVECONSOLESESSIONID)(void);
129#endif /* RT_OS_WINDOWS */
130
131#ifdef VBOX_WITH_GUEST_CONTROL
132/* Structure for holding thread relevant data. */
133typedef struct
134{
135 /** Node. */
136 RTLISTNODE Node;
137 /** The worker thread. */
138 RTTHREAD Thread;
139 /** Shutdown indicator. */
140 bool volatile fShutdown;
141 /** Indicator set by the service thread exiting. */
142 bool volatile fStopped;
143 /** Whether the service was started or not. */
144 bool fStarted;
145 /** @todo */
146 uint32_t uClientID;
147 uint32_t uContextID;
148 uint32_t uPID;
149 char *pszCmd;
150 uint32_t uFlags;
151 char **papszArgs;
152 uint32_t uNumArgs;
153 char **papszEnv;
154 uint32_t uNumEnvVars;
155 char *pszStdIn;
156 char *pszStdOut;
157 char *pszStdErr;
158 char *pszUser;
159 char *pszPassword;
160 uint32_t uTimeLimitMS;
161} VBOXSERVICECTRLTHREAD;
162/** Pointer to thread data. */
163typedef VBOXSERVICECTRLTHREAD *PVBOXSERVICECTRLTHREAD;
164
165/**
166 * For buffering process input supplied by the client.
167 */
168typedef struct
169{
170 /** The mount of buffered data. */
171 size_t cb;
172 /** The current data offset. */
173 size_t off;
174 /** The data buffer. */
175 char *pch;
176 /** The amount of allocated buffer space. */
177 size_t cbAllocated;
178 /** Send further input into the bit bucket (stdin is dead). */
179 bool fBitBucket;
180 /** The CRC-32 for standard input (received part). */
181 uint32_t uCrc32;
182} VBOXSERVICECTRLSTDINBUF;
183/** Pointer to a standard input buffer. */
184typedef VBOXSERVICECTRLSTDINBUF *PVBOXSERVICECTRLSTDINBUF;
185#endif
186
187RT_C_DECLS_BEGIN
188
189extern char *g_pszProgName;
190extern int g_cVerbosity;
191extern uint32_t g_DefaultInterval;
192
193extern int VBoxServiceSyntax(const char *pszFormat, ...);
194extern int VBoxServiceError(const char *pszFormat, ...);
195extern void VBoxServiceVerbose(int iLevel, const char *pszFormat, ...);
196extern int VBoxServiceArgUInt32(int argc, char **argv, const char *psz, int *pi, uint32_t *pu32, uint32_t u32Min, uint32_t u32Max);
197extern unsigned VBoxServiceGetStartedServices(void);
198extern int VBoxServiceStartServices(unsigned iMain);
199extern int VBoxServiceStopServices(void);
200
201extern VBOXSERVICE g_TimeSync;
202extern VBOXSERVICE g_Clipboard;
203extern VBOXSERVICE g_Control;
204extern VBOXSERVICE g_VMInfo;
205extern VBOXSERVICE g_Exec;
206extern VBOXSERVICE g_CpuHotPlug;
207#ifdef VBOXSERVICE_MANAGEMENT
208extern VBOXSERVICE g_MemBalloon;
209extern VBOXSERVICE g_VMStatistics;
210#endif
211#ifdef VBOX_WITH_PAGE_SHARING
212extern VBOXSERVICE g_PageSharing;
213#endif
214
215#ifdef RT_OS_WINDOWS
216extern DWORD g_rcWinService;
217extern SERVICE_TABLE_ENTRY const g_aServiceTable[]; /** @todo generate on the fly, see comment in main() from the enabled sub services. */
218extern PFNWTSGETACTIVECONSOLESESSIONID g_pfnWTSGetActiveConsoleSessionId; /* VBoxServiceVMInfo-win.cpp */
219
220extern int VBoxServiceWinInstall(void);
221extern int VBoxServiceWinUninstall(void);
222extern BOOL VBoxServiceWinSetStatus(DWORD dwStatus, DWORD dwCheckPoint);
223# ifdef VBOX_WITH_GUEST_PROPS
224extern bool VBoxServiceVMInfoWinSessionHasProcesses(PLUID pSession, VBOXSERVICEVMINFOPROC const *paProcs, DWORD cProcs);
225extern bool VBoxServiceVMInfoWinIsLoggedIn(PVBOXSERVICEVMINFOUSER a_pUserInfo, PLUID a_pSession);
226extern int VBoxServiceVMInfoWinProcessesEnumerate(PVBOXSERVICEVMINFOPROC *ppProc, DWORD *pdwCount);
227extern void VBoxServiceVMInfoWinProcessesFree(PVBOXSERVICEVMINFOPROC paProcs);
228extern int VBoxServiceWinGetComponentVersions(uint32_t uiClientID);
229# endif /* VBOX_WITH_GUEST_PROPS */
230#endif /* RT_OS_WINDOWS */
231
232#ifdef VBOX_WITH_GUEST_CONTROL
233extern int VBoxServiceControlExecProcess(uint32_t uContext, const char *pszCmd, uint32_t uFlags,
234 const char *pszArgs, uint32_t uNumArgs,
235 const char *pszEnv, uint32_t cbEnv, uint32_t uNumEnvVars,
236 const char *pszStdIn, const char *pszStdOut, const char *pszStdErr,
237 const char *pszUser, const char *pszPassword, uint32_t uTimeLimitMS);
238extern void VBoxServiceControlExecDestroyThreadData(PVBOXSERVICECTRLTHREAD pThread);
239#endif
240
241#ifdef VBOXSERVICE_MANAGEMENT
242extern uint32_t VBoxServiceBalloonQueryPages(uint32_t cbPage);
243#endif
244
245RT_C_DECLS_END
246
247#endif
248
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