VirtualBox

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

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.5 KB
RevLine 
[3725]1/* $Id: VBoxServiceInternal.h 98103 2023-01-17 14:15:46Z vboxsync $ */
[3655]2/** @file
3 * VBoxService - Guest Additions Services.
4 */
5
6/*
[98103]7 * Copyright (C) 2007-2023 Oracle and/or its affiliates.
[3655]8 *
[96407]9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
[3655]26 */
27
[76563]28#ifndef GA_INCLUDED_SRC_common_VBoxService_VBoxServiceInternal_h
29#define GA_INCLUDED_SRC_common_VBoxService_VBoxServiceInternal_h
[76533]30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
[3655]33
[18712]34#ifdef RT_OS_WINDOWS
[62679]35# include <iprt/win/windows.h>
[18640]36#endif
[28420]37
[28983]38#include <iprt/list.h>
[29040]39#include <iprt/critsect.h>
[68660]40#include <iprt/path.h> /* RTPATH_MAX */
[69997]41#include <iprt/stdarg.h>
[18640]42
[36338]43#include <VBox/VBoxGuestLib.h>
[39906]44#include <VBox/HostServices/GuestControlSvc.h>
[36338]45
[92662]46
[92767]47#if !defined(RT_OS_WINDOWS) || defined(DOXYGEN_RUNNING)
[92662]48/** Special argv[1] value that indicates that argv is UTF-8.
49 * This causes RTR3Init to be called with RTR3INIT_FLAGS_UTF8_ARGV and helps
50 * work around potential issues caused by a user's locale config not being
51 * UTF-8. See @bugref{10153}.
52 *
53 * @note We don't need this on windows and it would be harmful to enable it
54 * as the argc/argv vs __argc/__argv comparison would fail and we would
55 * not use the unicode command line to create a UTF-8 argv. Since the
56 * original argv is ANSI, it may be missing codepoints not present in
57 * the ANSI code page of the process. */
[92767]58# define VBOXSERVICE_ARG1_UTF8_ARGV "--utf8-argv"
[92662]59#endif
60/** RTProcCreateEx flags corresponding to VBOXSERVICE_ARG1_UTF8_ARGV. */
61#ifdef VBOXSERVICE_ARG1_UTF8_ARGV
[92673]62# define VBOXSERVICE_PROC_F_UTF8_ARGV RTPROC_FLAGS_UTF8_ARGV
[92662]63#else
64# define VBOXSERVICE_PROC_F_UTF8_ARGV 0
65#endif
66
67
[3655]68/**
69 * A service descriptor.
70 */
[3725]71typedef struct
[3655]72{
73 /** The short service name. */
74 const char *pszName;
75 /** The longer service name. */
76 const char *pszDescription;
77 /** The usage options stuff for the --help screen. */
78 const char *pszUsage;
79 /** The option descriptions for the --help screen. */
80 const char *pszOptions;
81
82 /**
[51564]83 * Called before parsing arguments.
[3655]84 * @returns VBox status code.
85 */
[85121]86 DECLCALLBACKMEMBER(int, pfnPreInit,(void));
[3725]87
[3655]88 /**
[51564]89 * Tries to parse the given command line option.
[3655]90 *
91 * @returns 0 if we parsed, -1 if it didn't and anything else means exit.
[3725]92 * @param ppszShort If not NULL it points to the short option iterator. a short argument.
[3655]93 * If NULL examine argv[*pi].
94 * @param argc The argument count.
95 * @param argv The argument vector.
96 * @param pi The argument vector index. Update if any value(s) are eaten.
97 */
[85121]98 DECLCALLBACKMEMBER(int, pfnOption,(const char **ppszShort, int argc, char **argv, int *pi));
[3725]99
[3655]100 /**
[51564]101 * Called before parsing arguments.
[3655]102 * @returns VBox status code.
103 */
[85121]104 DECLCALLBACKMEMBER(int, pfnInit,(void));
[3655]105
[3725]106 /** Called from the worker thread.
107 *
[3655]108 * @returns VBox status code.
[57710]109 * @retval VINF_SUCCESS if exitting because *pfShutdown was set.
110 * @param pfShutdown Pointer to a per service termination flag to check
[3655]111 * before and after blocking.
112 */
[85121]113 DECLCALLBACKMEMBER(int, pfnWorker,(bool volatile *pfShutdown));
[3725]114
[3655]115 /**
[57708]116 * Stops a service.
[3655]117 */
[85121]118 DECLCALLBACKMEMBER(void, pfnStop,(void));
[3655]119
120 /**
[51564]121 * Does termination cleanups.
[21167]122 *
123 * @remarks This may be called even if pfnInit hasn't been called!
[3655]124 */
[85121]125 DECLCALLBACKMEMBER(void, pfnTerm,(void));
[3655]126} VBOXSERVICE;
127/** Pointer to a VBOXSERVICE. */
128typedef VBOXSERVICE *PVBOXSERVICE;
129/** Pointer to a const VBOXSERVICE. */
130typedef VBOXSERVICE const *PCVBOXSERVICE;
[3725]131
[51570]132/* Default call-backs for services which do not need special behaviour. */
[58029]133DECLCALLBACK(int) VGSvcDefaultPreInit(void);
134DECLCALLBACK(int) VGSvcDefaultOption(const char **ppszShort, int argc, char **argv, int *pi);
135DECLCALLBACK(int) VGSvcDefaultInit(void);
136DECLCALLBACK(void) VGSvcDefaultTerm(void);
[51570]137
[36330]138/** The service name.
139 * @note Used on windows to name the service as well as the global mutex. */
[34867]140#define VBOXSERVICE_NAME "VBoxService"
[33275]141
[19327]142#ifdef RT_OS_WINDOWS
143/** The friendly service name. */
[26061]144# define VBOXSERVICE_FRIENDLY_NAME "VirtualBox Guest Additions Service"
[25795]145/** The service description (only W2K+ atm) */
[38113]146# define VBOXSERVICE_DESCRIPTION "Manages VM runtime information, time synchronization, guest control execution and miscellaneous utilities for guest operating systems."
[19327]147/** The following constant may be defined by including NtStatus.h. */
[26061]148# define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
[33275]149#endif /* RT_OS_WINDOWS */
[29817]150
[29026]151#ifdef VBOX_WITH_GUEST_PROPS
[28967]152/**
[28968]153 * A guest property cache.
[28967]154 */
[29026]155typedef struct VBOXSERVICEVEPROPCACHE
156{
[28967]157 /** The client ID for HGCM communication. */
[39515]158 uint32_t uClientID;
[30095]159 /** Head in a list of VBOXSERVICEVEPROPCACHEENTRY nodes. */
[39515]160 RTLISTANCHOR NodeHead;
[29040]161 /** Critical section for thread-safe use. */
[39515]162 RTCRITSECT CritSect;
[28967]163} VBOXSERVICEVEPROPCACHE;
164/** Pointer to a guest property cache. */
165typedef VBOXSERVICEVEPROPCACHE *PVBOXSERVICEVEPROPCACHE;
166
167/**
[29026]168 * An entry in the property cache (VBOXSERVICEVEPROPCACHE).
[28967]169 */
[29026]170typedef struct VBOXSERVICEVEPROPCACHEENTRY
171{
[30095]172 /** Node to successor.
173 * @todo r=bird: This is not really the node to the successor, but
174 * rather the OUR node in the list. If it helps, remember that
175 * its a doubly linked list. */
[30082]176 RTLISTNODE NodeSucc;
[28967]177 /** Name (and full path) of guest property. */
[29026]178 char *pszName;
[28967]179 /** The last value stored (for reference). */
[29026]180 char *pszValue;
181 /** Reset value to write if property is temporary. If NULL, it will be
182 * deleted. */
183 char *pszValueReset;
[28967]184 /** Flags. */
[29026]185 uint32_t fFlags;
[28967]186} VBOXSERVICEVEPROPCACHEENTRY;
187/** Pointer to a cached guest property. */
188typedef VBOXSERVICEVEPROPCACHEENTRY *PVBOXSERVICEVEPROPCACHEENTRY;
[29026]189
[28967]190#endif /* VBOX_WITH_GUEST_PROPS */
191
[20374]192RT_C_DECLS_BEGIN
[3655]193
[29817]194extern char *g_pszProgName;
[57966]195extern unsigned g_cVerbosity;
[44863]196extern char g_szLogFile[RTPATH_MAX + 128];
[29817]197extern uint32_t g_DefaultInterval;
198extern VBOXSERVICE g_TimeSync;
[78450]199#ifdef VBOX_WITH_VBOXSERVICE_CLIPBOARD
[29817]200extern VBOXSERVICE g_Clipboard;
[78450]201#endif
[29817]202extern VBOXSERVICE g_Control;
203extern VBOXSERVICE g_VMInfo;
204extern VBOXSERVICE g_CpuHotPlug;
[60583]205#ifdef VBOX_WITH_VBOXSERVICE_MANAGEMENT
[29817]206extern VBOXSERVICE g_MemBalloon;
207extern VBOXSERVICE g_VMStatistics;
[26292]208#endif
[60583]209#ifdef VBOX_WITH_VBOXSERVICE_PAGE_SHARING
[29817]210extern VBOXSERVICE g_PageSharing;
[28251]211#endif
[31202]212#ifdef VBOX_WITH_SHARED_FOLDERS
213extern VBOXSERVICE g_AutoMount;
214#endif
[38633]215#ifdef DEBUG
216extern RTCRITSECT g_csLog; /* For guest process stdout dumping. */
217#endif
[3655]218
[75858]219extern RTEXITCODE VGSvcSyntax(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
220extern RTEXITCODE VGSvcError(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
221extern void VGSvcVerbose(unsigned iLevel, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(2, 3);
[58029]222extern int VGSvcLogCreate(const char *pszLogFile);
[75858]223extern void VGSvcLogV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
[58029]224extern void VGSvcLogDestroy(void);
225extern int VGSvcArgUInt32(int argc, char **argv, const char *psz, int *pi, uint32_t *pu32,
226 uint32_t u32Min, uint32_t u32Max);
227
228/* Exposing the following bits because of windows: */
229extern int VGSvcStartServices(void);
230extern int VGSvcStopServices(void);
231extern void VGSvcMainWait(void);
232extern int VGSvcReportStatus(VBoxGuestFacilityStatus enmStatus);
[19328]233#ifdef RT_OS_WINDOWS
[70171]234extern void VGSvcWinResolveApis(void);
[58029]235extern RTEXITCODE VGSvcWinInstall(void);
236extern RTEXITCODE VGSvcWinUninstall(void);
237extern RTEXITCODE VGSvcWinEnterCtrlDispatcher(void);
238extern void VGSvcWinSetStopPendingStatus(uint32_t uCheckPoint);
[70171]239# ifdef TH32CS_SNAPHEAPLIST
240extern decltype(CreateToolhelp32Snapshot) *g_pfnCreateToolhelp32Snapshot;
241extern decltype(Process32First) *g_pfnProcess32First;
242extern decltype(Process32Next) *g_pfnProcess32Next;
243extern decltype(Module32First) *g_pfnModule32First;
244extern decltype(Module32Next) *g_pfnModule32Next;
245# endif
[70346]246extern decltype(GetSystemTimeAdjustment) *g_pfnGetSystemTimeAdjustment;
247extern decltype(SetSystemTimeAdjustment) *g_pfnSetSystemTimeAdjustment;
[76557]248# ifdef IPRT_INCLUDED_nt_nt_h
[70171]249extern decltype(ZwQuerySystemInformation) *g_pfnZwQuerySystemInformation;
250# endif
[70196]251extern ULONG (WINAPI *g_pfnGetAdaptersInfo)(struct _IP_ADAPTER_INFO *, PULONG);
252#ifdef WINSOCK_VERSION
253extern decltype(WSAStartup) *g_pfnWSAStartup;
254extern decltype(WSACleanup) *g_pfnWSACleanup;
255extern decltype(WSASocketA) *g_pfnWSASocketA;
256extern decltype(WSAIoctl) *g_pfnWSAIoctl;
257extern decltype(WSAGetLastError) *g_pfnWSAGetLastError;
258extern decltype(closesocket) *g_pfnclosesocket;
259extern decltype(inet_ntoa) *g_pfninet_ntoa;
260# endif /* WINSOCK_VERSION */
[29817]261
[70214]262#ifdef SE_INTERACTIVE_LOGON_NAME
263extern decltype(LsaNtStatusToWinError) *g_pfnLsaNtStatusToWinError;
264#endif
265
[26061]266# ifdef VBOX_WITH_GUEST_PROPS
[58029]267extern int VGSvcVMInfoWinWriteUsers(PVBOXSERVICEVEPROPCACHE pCache, char **ppszUserList, uint32_t *pcUsersInList);
268extern int VGSvcVMInfoWinGetComponentVersions(uint32_t uClientID);
[26061]269# endif /* VBOX_WITH_GUEST_PROPS */
[70196]270
[19644]271#endif /* RT_OS_WINDOWS */
[19327]272
[93022]273#ifdef VBOX_WITH_MEMBALLOON
[58029]274extern uint32_t VGSvcBalloonQueryPages(uint32_t cbPage);
[26326]275#endif
[60583]276#if defined(VBOX_WITH_VBOXSERVICE_PAGE_SHARING)
[58029]277extern RTEXITCODE VGSvcPageSharingWorkerChild(void);
[30560]278#endif
[58029]279extern int VGSvcVMInfoSignal(void);
[26326]280
[20374]281RT_C_DECLS_END
[3655]282
[76563]283#endif /* !GA_INCLUDED_SRC_common_VBoxService_VBoxServiceInternal_h */
[3655]284
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use