VirtualBox

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

Last change on this file since 78393 was 76563, checked in by vboxsync, 6 years ago

Additions: Use GA_INCLUDED_ and variations_ as header guard prefixes with scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.4 KB
Line 
1/* $Id: VBoxServiceInternal.h 76563 2019-01-01 03:53:56Z vboxsync $ */
2/** @file
3 * VBoxService - Guest Additions Services.
4 */
5
6/*
7 * Copyright (C) 2007-2019 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 GA_INCLUDED_SRC_common_VBoxService_VBoxServiceInternal_h
19#define GA_INCLUDED_SRC_common_VBoxService_VBoxServiceInternal_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <stdio.h>
25#ifdef RT_OS_WINDOWS
26# include <iprt/win/windows.h>
27# include <process.h> /* Needed for file version information. */
28#endif
29
30#include <iprt/list.h>
31#include <iprt/critsect.h>
32#include <iprt/path.h> /* RTPATH_MAX */
33#include <iprt/stdarg.h>
34
35#include <VBox/VBoxGuestLib.h>
36#include <VBox/HostServices/GuestControlSvc.h>
37
38/**
39 * A service descriptor.
40 */
41typedef struct
42{
43 /** The short service name. */
44 const char *pszName;
45 /** The longer service name. */
46 const char *pszDescription;
47 /** The usage options stuff for the --help screen. */
48 const char *pszUsage;
49 /** The option descriptions for the --help screen. */
50 const char *pszOptions;
51
52 /**
53 * Called before parsing arguments.
54 * @returns VBox status code.
55 */
56 DECLCALLBACKMEMBER(int, pfnPreInit)(void);
57
58 /**
59 * Tries to parse the given command line option.
60 *
61 * @returns 0 if we parsed, -1 if it didn't and anything else means exit.
62 * @param ppszShort If not NULL it points to the short option iterator. a short argument.
63 * If NULL examine argv[*pi].
64 * @param argc The argument count.
65 * @param argv The argument vector.
66 * @param pi The argument vector index. Update if any value(s) are eaten.
67 */
68 DECLCALLBACKMEMBER(int, pfnOption)(const char **ppszShort, int argc, char **argv, int *pi);
69
70 /**
71 * Called before parsing arguments.
72 * @returns VBox status code.
73 */
74 DECLCALLBACKMEMBER(int, pfnInit)(void);
75
76 /** Called from the worker thread.
77 *
78 * @returns VBox status code.
79 * @retval VINF_SUCCESS if exitting because *pfShutdown was set.
80 * @param pfShutdown Pointer to a per service termination flag to check
81 * before and after blocking.
82 */
83 DECLCALLBACKMEMBER(int, pfnWorker)(bool volatile *pfShutdown);
84
85 /**
86 * Stops a service.
87 */
88 DECLCALLBACKMEMBER(void, pfnStop)(void);
89
90 /**
91 * Does termination cleanups.
92 *
93 * @remarks This may be called even if pfnInit hasn't been called!
94 */
95 DECLCALLBACKMEMBER(void, pfnTerm)(void);
96} VBOXSERVICE;
97/** Pointer to a VBOXSERVICE. */
98typedef VBOXSERVICE *PVBOXSERVICE;
99/** Pointer to a const VBOXSERVICE. */
100typedef VBOXSERVICE const *PCVBOXSERVICE;
101
102/* Default call-backs for services which do not need special behaviour. */
103DECLCALLBACK(int) VGSvcDefaultPreInit(void);
104DECLCALLBACK(int) VGSvcDefaultOption(const char **ppszShort, int argc, char **argv, int *pi);
105DECLCALLBACK(int) VGSvcDefaultInit(void);
106DECLCALLBACK(void) VGSvcDefaultTerm(void);
107
108/** The service name.
109 * @note Used on windows to name the service as well as the global mutex. */
110#define VBOXSERVICE_NAME "VBoxService"
111
112#ifdef RT_OS_WINDOWS
113/** The friendly service name. */
114# define VBOXSERVICE_FRIENDLY_NAME "VirtualBox Guest Additions Service"
115/** The service description (only W2K+ atm) */
116# define VBOXSERVICE_DESCRIPTION "Manages VM runtime information, time synchronization, guest control execution and miscellaneous utilities for guest operating systems."
117/** The following constant may be defined by including NtStatus.h. */
118# define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
119#endif /* RT_OS_WINDOWS */
120
121#ifdef VBOX_WITH_GUEST_PROPS
122/**
123 * A guest property cache.
124 */
125typedef struct VBOXSERVICEVEPROPCACHE
126{
127 /** The client ID for HGCM communication. */
128 uint32_t uClientID;
129 /** Head in a list of VBOXSERVICEVEPROPCACHEENTRY nodes. */
130 RTLISTANCHOR NodeHead;
131 /** Critical section for thread-safe use. */
132 RTCRITSECT CritSect;
133} VBOXSERVICEVEPROPCACHE;
134/** Pointer to a guest property cache. */
135typedef VBOXSERVICEVEPROPCACHE *PVBOXSERVICEVEPROPCACHE;
136
137/**
138 * An entry in the property cache (VBOXSERVICEVEPROPCACHE).
139 */
140typedef struct VBOXSERVICEVEPROPCACHEENTRY
141{
142 /** Node to successor.
143 * @todo r=bird: This is not really the node to the successor, but
144 * rather the OUR node in the list. If it helps, remember that
145 * its a doubly linked list. */
146 RTLISTNODE NodeSucc;
147 /** Name (and full path) of guest property. */
148 char *pszName;
149 /** The last value stored (for reference). */
150 char *pszValue;
151 /** Reset value to write if property is temporary. If NULL, it will be
152 * deleted. */
153 char *pszValueReset;
154 /** Flags. */
155 uint32_t fFlags;
156} VBOXSERVICEVEPROPCACHEENTRY;
157/** Pointer to a cached guest property. */
158typedef VBOXSERVICEVEPROPCACHEENTRY *PVBOXSERVICEVEPROPCACHEENTRY;
159
160#endif /* VBOX_WITH_GUEST_PROPS */
161
162RT_C_DECLS_BEGIN
163
164extern char *g_pszProgName;
165extern unsigned g_cVerbosity;
166extern char g_szLogFile[RTPATH_MAX + 128];
167extern uint32_t g_DefaultInterval;
168extern VBOXSERVICE g_TimeSync;
169extern VBOXSERVICE g_Clipboard;
170extern VBOXSERVICE g_Control;
171extern VBOXSERVICE g_VMInfo;
172extern VBOXSERVICE g_CpuHotPlug;
173#ifdef VBOX_WITH_VBOXSERVICE_MANAGEMENT
174extern VBOXSERVICE g_MemBalloon;
175extern VBOXSERVICE g_VMStatistics;
176#endif
177#ifdef VBOX_WITH_VBOXSERVICE_PAGE_SHARING
178extern VBOXSERVICE g_PageSharing;
179#endif
180#ifdef VBOX_WITH_SHARED_FOLDERS
181extern VBOXSERVICE g_AutoMount;
182#endif
183#ifdef DEBUG
184extern RTCRITSECT g_csLog; /* For guest process stdout dumping. */
185#endif
186
187extern RTEXITCODE VGSvcSyntax(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
188extern RTEXITCODE VGSvcError(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
189extern void VGSvcVerbose(unsigned iLevel, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(2, 3);
190extern int VGSvcLogCreate(const char *pszLogFile);
191extern void VGSvcLogV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
192extern void VGSvcLogDestroy(void);
193extern int VGSvcArgUInt32(int argc, char **argv, const char *psz, int *pi, uint32_t *pu32,
194 uint32_t u32Min, uint32_t u32Max);
195
196/* Exposing the following bits because of windows: */
197extern int VGSvcStartServices(void);
198extern int VGSvcStopServices(void);
199extern void VGSvcMainWait(void);
200extern int VGSvcReportStatus(VBoxGuestFacilityStatus enmStatus);
201#ifdef RT_OS_WINDOWS
202extern void VGSvcWinResolveApis(void);
203extern RTEXITCODE VGSvcWinInstall(void);
204extern RTEXITCODE VGSvcWinUninstall(void);
205extern RTEXITCODE VGSvcWinEnterCtrlDispatcher(void);
206extern void VGSvcWinSetStopPendingStatus(uint32_t uCheckPoint);
207# ifdef TH32CS_SNAPHEAPLIST
208extern decltype(CreateToolhelp32Snapshot) *g_pfnCreateToolhelp32Snapshot;
209extern decltype(Process32First) *g_pfnProcess32First;
210extern decltype(Process32Next) *g_pfnProcess32Next;
211extern decltype(Module32First) *g_pfnModule32First;
212extern decltype(Module32Next) *g_pfnModule32Next;
213# endif
214extern decltype(GetSystemTimeAdjustment) *g_pfnGetSystemTimeAdjustment;
215extern decltype(SetSystemTimeAdjustment) *g_pfnSetSystemTimeAdjustment;
216# ifdef IPRT_INCLUDED_nt_nt_h
217extern decltype(ZwQuerySystemInformation) *g_pfnZwQuerySystemInformation;
218# endif
219extern ULONG (WINAPI *g_pfnGetAdaptersInfo)(struct _IP_ADAPTER_INFO *, PULONG);
220#ifdef WINSOCK_VERSION
221extern decltype(WSAStartup) *g_pfnWSAStartup;
222extern decltype(WSACleanup) *g_pfnWSACleanup;
223extern decltype(WSASocketA) *g_pfnWSASocketA;
224extern decltype(WSAIoctl) *g_pfnWSAIoctl;
225extern decltype(WSAGetLastError) *g_pfnWSAGetLastError;
226extern decltype(closesocket) *g_pfnclosesocket;
227extern decltype(inet_ntoa) *g_pfninet_ntoa;
228# endif /* WINSOCK_VERSION */
229
230#ifdef SE_INTERACTIVE_LOGON_NAME
231extern decltype(LsaNtStatusToWinError) *g_pfnLsaNtStatusToWinError;
232#endif
233
234# ifdef VBOX_WITH_GUEST_PROPS
235extern int VGSvcVMInfoWinWriteUsers(PVBOXSERVICEVEPROPCACHE pCache, char **ppszUserList, uint32_t *pcUsersInList);
236extern int VGSvcVMInfoWinGetComponentVersions(uint32_t uClientID);
237# endif /* VBOX_WITH_GUEST_PROPS */
238
239#endif /* RT_OS_WINDOWS */
240
241#ifdef VBOX_WITH_VBOXSERVICE_MANAGEMENT
242extern uint32_t VGSvcBalloonQueryPages(uint32_t cbPage);
243#endif
244#if defined(VBOX_WITH_VBOXSERVICE_PAGE_SHARING)
245extern RTEXITCODE VGSvcPageSharingWorkerChild(void);
246#endif
247extern int VGSvcVMInfoSignal(void);
248
249RT_C_DECLS_END
250
251#endif /* !GA_INCLUDED_SRC_common_VBoxService_VBoxServiceInternal_h */
252
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