VirtualBox

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

Last change on this file since 83826 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by 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 82968 2020-02-04 10:35:17Z vboxsync $ */
2/** @file
3 * VBoxService - Guest Additions Services.
4 */
5
6/*
7 * Copyright (C) 2007-2020 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;
169#ifdef VBOX_WITH_VBOXSERVICE_CLIPBOARD
170extern VBOXSERVICE g_Clipboard;
171#endif
172extern VBOXSERVICE g_Control;
173extern VBOXSERVICE g_VMInfo;
174extern VBOXSERVICE g_CpuHotPlug;
175#ifdef VBOX_WITH_VBOXSERVICE_MANAGEMENT
176extern VBOXSERVICE g_MemBalloon;
177extern VBOXSERVICE g_VMStatistics;
178#endif
179#ifdef VBOX_WITH_VBOXSERVICE_PAGE_SHARING
180extern VBOXSERVICE g_PageSharing;
181#endif
182#ifdef VBOX_WITH_SHARED_FOLDERS
183extern VBOXSERVICE g_AutoMount;
184#endif
185#ifdef DEBUG
186extern RTCRITSECT g_csLog; /* For guest process stdout dumping. */
187#endif
188
189extern RTEXITCODE VGSvcSyntax(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
190extern RTEXITCODE VGSvcError(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
191extern void VGSvcVerbose(unsigned iLevel, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(2, 3);
192extern int VGSvcLogCreate(const char *pszLogFile);
193extern void VGSvcLogV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
194extern void VGSvcLogDestroy(void);
195extern int VGSvcArgUInt32(int argc, char **argv, const char *psz, int *pi, uint32_t *pu32,
196 uint32_t u32Min, uint32_t u32Max);
197
198/* Exposing the following bits because of windows: */
199extern int VGSvcStartServices(void);
200extern int VGSvcStopServices(void);
201extern void VGSvcMainWait(void);
202extern int VGSvcReportStatus(VBoxGuestFacilityStatus enmStatus);
203#ifdef RT_OS_WINDOWS
204extern void VGSvcWinResolveApis(void);
205extern RTEXITCODE VGSvcWinInstall(void);
206extern RTEXITCODE VGSvcWinUninstall(void);
207extern RTEXITCODE VGSvcWinEnterCtrlDispatcher(void);
208extern void VGSvcWinSetStopPendingStatus(uint32_t uCheckPoint);
209# ifdef TH32CS_SNAPHEAPLIST
210extern decltype(CreateToolhelp32Snapshot) *g_pfnCreateToolhelp32Snapshot;
211extern decltype(Process32First) *g_pfnProcess32First;
212extern decltype(Process32Next) *g_pfnProcess32Next;
213extern decltype(Module32First) *g_pfnModule32First;
214extern decltype(Module32Next) *g_pfnModule32Next;
215# endif
216extern decltype(GetSystemTimeAdjustment) *g_pfnGetSystemTimeAdjustment;
217extern decltype(SetSystemTimeAdjustment) *g_pfnSetSystemTimeAdjustment;
218# ifdef IPRT_INCLUDED_nt_nt_h
219extern decltype(ZwQuerySystemInformation) *g_pfnZwQuerySystemInformation;
220# endif
221extern ULONG (WINAPI *g_pfnGetAdaptersInfo)(struct _IP_ADAPTER_INFO *, PULONG);
222#ifdef WINSOCK_VERSION
223extern decltype(WSAStartup) *g_pfnWSAStartup;
224extern decltype(WSACleanup) *g_pfnWSACleanup;
225extern decltype(WSASocketA) *g_pfnWSASocketA;
226extern decltype(WSAIoctl) *g_pfnWSAIoctl;
227extern decltype(WSAGetLastError) *g_pfnWSAGetLastError;
228extern decltype(closesocket) *g_pfnclosesocket;
229extern decltype(inet_ntoa) *g_pfninet_ntoa;
230# endif /* WINSOCK_VERSION */
231
232#ifdef SE_INTERACTIVE_LOGON_NAME
233extern decltype(LsaNtStatusToWinError) *g_pfnLsaNtStatusToWinError;
234#endif
235
236# ifdef VBOX_WITH_GUEST_PROPS
237extern int VGSvcVMInfoWinWriteUsers(PVBOXSERVICEVEPROPCACHE pCache, char **ppszUserList, uint32_t *pcUsersInList);
238extern int VGSvcVMInfoWinGetComponentVersions(uint32_t uClientID);
239# endif /* VBOX_WITH_GUEST_PROPS */
240
241#endif /* RT_OS_WINDOWS */
242
243#ifdef VBOX_WITH_VBOXSERVICE_MANAGEMENT
244extern uint32_t VGSvcBalloonQueryPages(uint32_t cbPage);
245#endif
246#if defined(VBOX_WITH_VBOXSERVICE_PAGE_SHARING)
247extern RTEXITCODE VGSvcPageSharingWorkerChild(void);
248#endif
249extern int VGSvcVMInfoSignal(void);
250
251RT_C_DECLS_END
252
253#endif /* !GA_INCLUDED_SRC_common_VBoxService_VBoxServiceInternal_h */
254
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