VirtualBox

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

Last change on this file since 72097 was 70346, checked in by vboxsync, 7 years ago

VBoxService: Needed to dynamically resolve two more APIs to make it work on NT 3.1.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.1 KB
Line 
1/* $Id: VBoxServiceInternal.h 70346 2017-12-26 15:52:28Z vboxsync $ */
2/** @file
3 * VBoxService - Guest Additions Services.
4 */
5
6/*
7 * Copyright (C) 2007-2017 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 <iprt/win/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#include <iprt/path.h> /* RTPATH_MAX */
30#include <iprt/stdarg.h>
31
32#include <VBox/VBoxGuestLib.h>
33#include <VBox/HostServices/GuestControlSvc.h>
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 *pfShutdown was set.
77 * @param pfShutdown Pointer to a per service termination flag to check
78 * before and after blocking.
79 */
80 DECLCALLBACKMEMBER(int, pfnWorker)(bool volatile *pfShutdown);
81
82 /**
83 * Stops a 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/* Default call-backs for services which do not need special behaviour. */
100DECLCALLBACK(int) VGSvcDefaultPreInit(void);
101DECLCALLBACK(int) VGSvcDefaultOption(const char **ppszShort, int argc, char **argv, int *pi);
102DECLCALLBACK(int) VGSvcDefaultInit(void);
103DECLCALLBACK(void) VGSvcDefaultTerm(void);
104
105/** The service name.
106 * @note Used on windows to name the service as well as the global mutex. */
107#define VBOXSERVICE_NAME "VBoxService"
108
109#ifdef RT_OS_WINDOWS
110/** The friendly service name. */
111# define VBOXSERVICE_FRIENDLY_NAME "VirtualBox Guest Additions Service"
112/** The service description (only W2K+ atm) */
113# define VBOXSERVICE_DESCRIPTION "Manages VM runtime information, time synchronization, guest control execution and miscellaneous utilities for guest operating systems."
114/** The following constant may be defined by including NtStatus.h. */
115# define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
116#endif /* RT_OS_WINDOWS */
117
118#ifdef VBOX_WITH_GUEST_PROPS
119/**
120 * A guest property cache.
121 */
122typedef struct VBOXSERVICEVEPROPCACHE
123{
124 /** The client ID for HGCM communication. */
125 uint32_t uClientID;
126 /** Head in a list of VBOXSERVICEVEPROPCACHEENTRY nodes. */
127 RTLISTANCHOR NodeHead;
128 /** Critical section for thread-safe use. */
129 RTCRITSECT CritSect;
130} VBOXSERVICEVEPROPCACHE;
131/** Pointer to a guest property cache. */
132typedef VBOXSERVICEVEPROPCACHE *PVBOXSERVICEVEPROPCACHE;
133
134/**
135 * An entry in the property cache (VBOXSERVICEVEPROPCACHE).
136 */
137typedef struct VBOXSERVICEVEPROPCACHEENTRY
138{
139 /** Node to successor.
140 * @todo r=bird: This is not really the node to the successor, but
141 * rather the OUR node in the list. If it helps, remember that
142 * its a doubly linked list. */
143 RTLISTNODE NodeSucc;
144 /** Name (and full path) of guest property. */
145 char *pszName;
146 /** The last value stored (for reference). */
147 char *pszValue;
148 /** Reset value to write if property is temporary. If NULL, it will be
149 * deleted. */
150 char *pszValueReset;
151 /** Flags. */
152 uint32_t fFlags;
153} VBOXSERVICEVEPROPCACHEENTRY;
154/** Pointer to a cached guest property. */
155typedef VBOXSERVICEVEPROPCACHEENTRY *PVBOXSERVICEVEPROPCACHEENTRY;
156
157#endif /* VBOX_WITH_GUEST_PROPS */
158
159RT_C_DECLS_BEGIN
160
161extern char *g_pszProgName;
162extern unsigned g_cVerbosity;
163extern char g_szLogFile[RTPATH_MAX + 128];
164extern uint32_t g_DefaultInterval;
165extern VBOXSERVICE g_TimeSync;
166extern VBOXSERVICE g_Clipboard;
167extern VBOXSERVICE g_Control;
168extern VBOXSERVICE g_VMInfo;
169extern VBOXSERVICE g_CpuHotPlug;
170#ifdef VBOX_WITH_VBOXSERVICE_MANAGEMENT
171extern VBOXSERVICE g_MemBalloon;
172extern VBOXSERVICE g_VMStatistics;
173#endif
174#ifdef VBOX_WITH_VBOXSERVICE_PAGE_SHARING
175extern VBOXSERVICE g_PageSharing;
176#endif
177#ifdef VBOX_WITH_SHARED_FOLDERS
178extern VBOXSERVICE g_AutoMount;
179#endif
180#ifdef DEBUG
181extern RTCRITSECT g_csLog; /* For guest process stdout dumping. */
182#endif
183
184extern RTEXITCODE VGSvcSyntax(const char *pszFormat, ...);
185extern RTEXITCODE VGSvcError(const char *pszFormat, ...);
186extern void VGSvcVerbose(unsigned iLevel, const char *pszFormat, ...);
187extern int VGSvcLogCreate(const char *pszLogFile);
188extern void VGSvcLogV(const char *pszFormat, va_list va);
189extern void VGSvcLogDestroy(void);
190extern int VGSvcArgUInt32(int argc, char **argv, const char *psz, int *pi, uint32_t *pu32,
191 uint32_t u32Min, uint32_t u32Max);
192
193/* Exposing the following bits because of windows: */
194extern int VGSvcStartServices(void);
195extern int VGSvcStopServices(void);
196extern void VGSvcMainWait(void);
197extern int VGSvcReportStatus(VBoxGuestFacilityStatus enmStatus);
198#ifdef RT_OS_WINDOWS
199extern void VGSvcWinResolveApis(void);
200extern RTEXITCODE VGSvcWinInstall(void);
201extern RTEXITCODE VGSvcWinUninstall(void);
202extern RTEXITCODE VGSvcWinEnterCtrlDispatcher(void);
203extern void VGSvcWinSetStopPendingStatus(uint32_t uCheckPoint);
204# ifdef TH32CS_SNAPHEAPLIST
205extern decltype(CreateToolhelp32Snapshot) *g_pfnCreateToolhelp32Snapshot;
206extern decltype(Process32First) *g_pfnProcess32First;
207extern decltype(Process32Next) *g_pfnProcess32Next;
208extern decltype(Module32First) *g_pfnModule32First;
209extern decltype(Module32Next) *g_pfnModule32Next;
210# endif
211extern decltype(GetSystemTimeAdjustment) *g_pfnGetSystemTimeAdjustment;
212extern decltype(SetSystemTimeAdjustment) *g_pfnSetSystemTimeAdjustment;
213# ifdef ___iprt_nt_nt_h___
214extern decltype(ZwQuerySystemInformation) *g_pfnZwQuerySystemInformation;
215# endif
216extern ULONG (WINAPI *g_pfnGetAdaptersInfo)(struct _IP_ADAPTER_INFO *, PULONG);
217#ifdef WINSOCK_VERSION
218extern decltype(WSAStartup) *g_pfnWSAStartup;
219extern decltype(WSACleanup) *g_pfnWSACleanup;
220extern decltype(WSASocketA) *g_pfnWSASocketA;
221extern decltype(WSAIoctl) *g_pfnWSAIoctl;
222extern decltype(WSAGetLastError) *g_pfnWSAGetLastError;
223extern decltype(closesocket) *g_pfnclosesocket;
224extern decltype(inet_ntoa) *g_pfninet_ntoa;
225# endif /* WINSOCK_VERSION */
226
227#ifdef SE_INTERACTIVE_LOGON_NAME
228extern decltype(LsaNtStatusToWinError) *g_pfnLsaNtStatusToWinError;
229#endif
230
231# ifdef VBOX_WITH_GUEST_PROPS
232extern int VGSvcVMInfoWinWriteUsers(PVBOXSERVICEVEPROPCACHE pCache, char **ppszUserList, uint32_t *pcUsersInList);
233extern int VGSvcVMInfoWinGetComponentVersions(uint32_t uClientID);
234# endif /* VBOX_WITH_GUEST_PROPS */
235
236#endif /* RT_OS_WINDOWS */
237
238#ifdef VBOX_WITH_VBOXSERVICE_MANAGEMENT
239extern uint32_t VGSvcBalloonQueryPages(uint32_t cbPage);
240#endif
241#if defined(VBOX_WITH_VBOXSERVICE_PAGE_SHARING)
242extern RTEXITCODE VGSvcPageSharingWorkerChild(void);
243#endif
244extern int VGSvcVMInfoSignal(void);
245
246RT_C_DECLS_END
247
248#endif
249
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