1 | /* $Id: VBoxServiceInternal.h 52890 2014-09-29 16:00:24Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxService - Guest Additions Services.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007-2013 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 | #include <VBox/VBoxGuestLib.h>
|
---|
31 | #include <VBox/HostServices/GuestControlSvc.h>
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * A service descriptor.
|
---|
35 | */
|
---|
36 | typedef struct
|
---|
37 | {
|
---|
38 | /** The short service name. */
|
---|
39 | const char *pszName;
|
---|
40 | /** The longer service name. */
|
---|
41 | const char *pszDescription;
|
---|
42 | /** The usage options stuff for the --help screen. */
|
---|
43 | const char *pszUsage;
|
---|
44 | /** The option descriptions for the --help screen. */
|
---|
45 | const char *pszOptions;
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * Called before parsing arguments.
|
---|
49 | * @returns VBox status code.
|
---|
50 | */
|
---|
51 | DECLCALLBACKMEMBER(int, pfnPreInit)(void);
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * Tries to parse the given command line option.
|
---|
55 | *
|
---|
56 | * @returns 0 if we parsed, -1 if it didn't and anything else means exit.
|
---|
57 | * @param ppszShort If not NULL it points to the short option iterator. a short argument.
|
---|
58 | * If NULL examine argv[*pi].
|
---|
59 | * @param argc The argument count.
|
---|
60 | * @param argv The argument vector.
|
---|
61 | * @param pi The argument vector index. Update if any value(s) are eaten.
|
---|
62 | */
|
---|
63 | DECLCALLBACKMEMBER(int, pfnOption)(const char **ppszShort, int argc, char **argv, int *pi);
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * Called before parsing arguments.
|
---|
67 | * @returns VBox status code.
|
---|
68 | */
|
---|
69 | DECLCALLBACKMEMBER(int, pfnInit)(void);
|
---|
70 |
|
---|
71 | /** Called from the worker thread.
|
---|
72 | *
|
---|
73 | * @returns VBox status code.
|
---|
74 | * @retval VINF_SUCCESS if exitting because *pfTerminate was set.
|
---|
75 | * @param pfTerminate Pointer to a per service termination flag to check
|
---|
76 | * before and after blocking.
|
---|
77 | */
|
---|
78 | DECLCALLBACKMEMBER(int, pfnWorker)(bool volatile *pfTerminate);
|
---|
79 |
|
---|
80 | /**
|
---|
81 | * Stop an service.
|
---|
82 | */
|
---|
83 | DECLCALLBACKMEMBER(void, pfnStop)(void);
|
---|
84 |
|
---|
85 | /**
|
---|
86 | * Does termination cleanups.
|
---|
87 | *
|
---|
88 | * @remarks This may be called even if pfnInit hasn't been called!
|
---|
89 | */
|
---|
90 | DECLCALLBACKMEMBER(void, pfnTerm)(void);
|
---|
91 | } VBOXSERVICE;
|
---|
92 | /** Pointer to a VBOXSERVICE. */
|
---|
93 | typedef VBOXSERVICE *PVBOXSERVICE;
|
---|
94 | /** Pointer to a const VBOXSERVICE. */
|
---|
95 | typedef VBOXSERVICE const *PCVBOXSERVICE;
|
---|
96 |
|
---|
97 | /* Default call-backs for services which do not need special behaviour. */
|
---|
98 | DECLCALLBACK(int) VBoxServiceDefaultPreInit(void);
|
---|
99 | DECLCALLBACK(int) VBoxServiceDefaultOption(const char **ppszShort, int argc,
|
---|
100 | char **argv, int *pi);
|
---|
101 | DECLCALLBACK(int) VBoxServiceDefaultInit(void);
|
---|
102 | DECLCALLBACK(void) VBoxServiceDefaultTerm(void);
|
---|
103 |
|
---|
104 | /** The service name.
|
---|
105 | * @note Used on windows to name the service as well as the global mutex. */
|
---|
106 | #define VBOXSERVICE_NAME "VBoxService"
|
---|
107 |
|
---|
108 | #ifdef RT_OS_WINDOWS
|
---|
109 | /** The friendly service name. */
|
---|
110 | # define VBOXSERVICE_FRIENDLY_NAME "VirtualBox Guest Additions Service"
|
---|
111 | /** The service description (only W2K+ atm) */
|
---|
112 | # define VBOXSERVICE_DESCRIPTION "Manages VM runtime information, time synchronization, guest control execution and miscellaneous utilities for guest operating systems."
|
---|
113 | /** The following constant may be defined by including NtStatus.h. */
|
---|
114 | # define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
|
---|
115 | #endif /* RT_OS_WINDOWS */
|
---|
116 |
|
---|
117 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
118 | /**
|
---|
119 | * A guest property cache.
|
---|
120 | */
|
---|
121 | typedef struct VBOXSERVICEVEPROPCACHE
|
---|
122 | {
|
---|
123 | /** The client ID for HGCM communication. */
|
---|
124 | uint32_t uClientID;
|
---|
125 | /** Head in a list of VBOXSERVICEVEPROPCACHEENTRY nodes. */
|
---|
126 | RTLISTANCHOR NodeHead;
|
---|
127 | /** Critical section for thread-safe use. */
|
---|
128 | RTCRITSECT CritSect;
|
---|
129 | } VBOXSERVICEVEPROPCACHE;
|
---|
130 | /** Pointer to a guest property cache. */
|
---|
131 | typedef VBOXSERVICEVEPROPCACHE *PVBOXSERVICEVEPROPCACHE;
|
---|
132 |
|
---|
133 | /**
|
---|
134 | * An entry in the property cache (VBOXSERVICEVEPROPCACHE).
|
---|
135 | */
|
---|
136 | typedef struct VBOXSERVICEVEPROPCACHEENTRY
|
---|
137 | {
|
---|
138 | /** Node to successor.
|
---|
139 | * @todo r=bird: This is not really the node to the successor, but
|
---|
140 | * rather the OUR node in the list. If it helps, remember that
|
---|
141 | * its a doubly linked list. */
|
---|
142 | RTLISTNODE NodeSucc;
|
---|
143 | /** Name (and full path) of guest property. */
|
---|
144 | char *pszName;
|
---|
145 | /** The last value stored (for reference). */
|
---|
146 | char *pszValue;
|
---|
147 | /** Reset value to write if property is temporary. If NULL, it will be
|
---|
148 | * deleted. */
|
---|
149 | char *pszValueReset;
|
---|
150 | /** Flags. */
|
---|
151 | uint32_t fFlags;
|
---|
152 | } VBOXSERVICEVEPROPCACHEENTRY;
|
---|
153 | /** Pointer to a cached guest property. */
|
---|
154 | typedef VBOXSERVICEVEPROPCACHEENTRY *PVBOXSERVICEVEPROPCACHEENTRY;
|
---|
155 |
|
---|
156 | #endif /* VBOX_WITH_GUEST_PROPS */
|
---|
157 |
|
---|
158 | RT_C_DECLS_BEGIN
|
---|
159 |
|
---|
160 | extern char *g_pszProgName;
|
---|
161 | extern int g_cVerbosity;
|
---|
162 | extern char g_szLogFile[RTPATH_MAX + 128];
|
---|
163 | extern uint32_t g_DefaultInterval;
|
---|
164 | extern VBOXSERVICE g_TimeSync;
|
---|
165 | extern VBOXSERVICE g_Clipboard;
|
---|
166 | extern VBOXSERVICE g_Control;
|
---|
167 | extern VBOXSERVICE g_VMInfo;
|
---|
168 | extern VBOXSERVICE g_CpuHotPlug;
|
---|
169 | #ifdef VBOXSERVICE_MANAGEMENT
|
---|
170 | extern VBOXSERVICE g_MemBalloon;
|
---|
171 | extern VBOXSERVICE g_VMStatistics;
|
---|
172 | #endif
|
---|
173 | #ifdef VBOXSERVICE_PAGE_SHARING
|
---|
174 | extern VBOXSERVICE g_PageSharing;
|
---|
175 | #endif
|
---|
176 | #ifdef VBOX_WITH_SHARED_FOLDERS
|
---|
177 | extern VBOXSERVICE g_AutoMount;
|
---|
178 | #endif
|
---|
179 | #ifdef VBOXSERVICE_WITH_DISPLAY
|
---|
180 | extern VBOXSERVICE g_Display;
|
---|
181 | #endif
|
---|
182 | #ifdef DEBUG
|
---|
183 | extern RTCRITSECT g_csLog; /* For guest process stdout dumping. */
|
---|
184 | #endif
|
---|
185 |
|
---|
186 | extern RTEXITCODE VBoxServiceSyntax(const char *pszFormat, ...);
|
---|
187 | extern RTEXITCODE VBoxServiceError(const char *pszFormat, ...);
|
---|
188 | extern void VBoxServiceVerbose(int iLevel, const char *pszFormat, ...);
|
---|
189 | extern int VBoxServiceArgUInt32(int argc, char **argv, const char *psz, int *pi, uint32_t *pu32,
|
---|
190 | uint32_t u32Min, uint32_t u32Max);
|
---|
191 | extern int VBoxServiceStartServices(void);
|
---|
192 | extern int VBoxServiceStopServices(void);
|
---|
193 | extern void VBoxServiceMainWait(void);
|
---|
194 | extern int VBoxServiceReportStatus(VBoxGuestFacilityStatus enmStatus);
|
---|
195 | #ifdef RT_OS_WINDOWS
|
---|
196 | extern RTEXITCODE VBoxServiceWinInstall(void);
|
---|
197 | extern RTEXITCODE VBoxServiceWinUninstall(void);
|
---|
198 | extern RTEXITCODE VBoxServiceWinEnterCtrlDispatcher(void);
|
---|
199 | extern void VBoxServiceWinSetStopPendingStatus(uint32_t uCheckPoint);
|
---|
200 | #endif
|
---|
201 |
|
---|
202 | #ifdef VBOXSERVICE_TOOLBOX
|
---|
203 | extern bool VBoxServiceToolboxMain(int argc, char **argv, RTEXITCODE *prcExit);
|
---|
204 | #endif
|
---|
205 |
|
---|
206 | #ifdef RT_OS_WINDOWS
|
---|
207 | # ifdef VBOX_WITH_GUEST_PROPS
|
---|
208 | extern int VBoxServiceVMInfoWinWriteUsers(PVBOXSERVICEVEPROPCACHE pCache, char **ppszUserList, uint32_t *pcUsersInList);
|
---|
209 | extern int VBoxServiceWinGetComponentVersions(uint32_t uiClientID);
|
---|
210 | # endif /* VBOX_WITH_GUEST_PROPS */
|
---|
211 | #endif /* RT_OS_WINDOWS */
|
---|
212 |
|
---|
213 | #ifdef VBOXSERVICE_MANAGEMENT
|
---|
214 | extern uint32_t VBoxServiceBalloonQueryPages(uint32_t cbPage);
|
---|
215 | #endif
|
---|
216 | #if defined(VBOXSERVICE_PAGE_SHARING)
|
---|
217 | extern RTEXITCODE VBoxServicePageSharingInitFork(void);
|
---|
218 | #endif
|
---|
219 | extern int VBoxServiceVMInfoSignal(void);
|
---|
220 |
|
---|
221 | RT_C_DECLS_END
|
---|
222 |
|
---|
223 | #endif
|
---|
224 |
|
---|