VBoxServiceInternal.h revision 348188d7b4dbc0e8fccd10c903eba81e068dfe87
083dd76e9fd7a829b1ed67ffc9003276643e7db1vboxsync * VBoxService - Guest Additions Services.
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync * Copyright (C) 2007-2011 Oracle Corporation
bd8e360cd1db83dcb2694ea9122ce3bc5bae678avboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
bd8e360cd1db83dcb2694ea9122ce3bc5bae678avboxsync * available from http://www.virtualbox.org. This file is free software;
bd8e360cd1db83dcb2694ea9122ce3bc5bae678avboxsync * you can redistribute it and/or modify it under the terms of the GNU
bd8e360cd1db83dcb2694ea9122ce3bc5bae678avboxsync * General Public License (GPL) as published by the Free Software
bd8e360cd1db83dcb2694ea9122ce3bc5bae678avboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
bd8e360cd1db83dcb2694ea9122ce3bc5bae678avboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
bd8e360cd1db83dcb2694ea9122ce3bc5bae678avboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
85c594c1140f082dd862abde9dc7825137a3d51avboxsync# include <process.h> /* Needed for file version information. */
11a862be79fe123488bccca60c06e92cdbfec6e8vboxsync * A service descriptor.
e38719852d98638514dba23fbacf53ad11361d6avboxsynctypedef struct
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** The short service name. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync const char *pszName;
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** The longer service name. */
463d00559e51c6e08ccc9f5a77d2ee6d122b6e8cvboxsync /** The usage options stuff for the --help screen. */
463d00559e51c6e08ccc9f5a77d2ee6d122b6e8cvboxsync const char *pszUsage;
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** The option descriptions for the --help screen. */
463d00559e51c6e08ccc9f5a77d2ee6d122b6e8cvboxsync * Called before parsing arguments.
463d00559e51c6e08ccc9f5a77d2ee6d122b6e8cvboxsync * @returns VBox status code.
8ab60c04baaf509b2aaae2a260adaf1281aaac03vboxsync * Tries to parse the given command line option.
463d00559e51c6e08ccc9f5a77d2ee6d122b6e8cvboxsync * @returns 0 if we parsed, -1 if it didn't and anything else means exit.
6edb4183bc898fddcd0987b6c5c3903b8246fe45vboxsync * @param ppszShort If not NULL it points to the short option iterator. a short argument.
85c594c1140f082dd862abde9dc7825137a3d51avboxsync * If NULL examine argv[*pi].
85c594c1140f082dd862abde9dc7825137a3d51avboxsync * @param argc The argument count.
85c594c1140f082dd862abde9dc7825137a3d51avboxsync * @param argv The argument vector.
85c594c1140f082dd862abde9dc7825137a3d51avboxsync * @param pi The argument vector index. Update if any value(s) are eaten.
34822e8b7d00c04a0bc98c0d1a565a00d9bb1fd9vboxsync DECLCALLBACKMEMBER(int, pfnOption)(const char **ppszShort, int argc, char **argv, int *pi);
34822e8b7d00c04a0bc98c0d1a565a00d9bb1fd9vboxsync * Called before parsing arguments.
507ebf9b3b77c84000a55645867db6617b5324bcvboxsync * @returns VBox status code.
34822e8b7d00c04a0bc98c0d1a565a00d9bb1fd9vboxsync /** Called from the worker thread.
507ebf9b3b77c84000a55645867db6617b5324bcvboxsync * @returns VBox status code.
4ad933b349952e43d0b6ce21b3f5e2833ca04e85vboxsync * @retval VINF_SUCCESS if exitting because *pfTerminate was set.
85c594c1140f082dd862abde9dc7825137a3d51avboxsync * @param pfTerminate Pointer to a per service termination flag to check
85c594c1140f082dd862abde9dc7825137a3d51avboxsync * before and after blocking.
507ebf9b3b77c84000a55645867db6617b5324bcvboxsync DECLCALLBACKMEMBER(int, pfnWorker)(bool volatile *pfTerminate);
507ebf9b3b77c84000a55645867db6617b5324bcvboxsync * Stop an service.
507ebf9b3b77c84000a55645867db6617b5324bcvboxsync * Does termination cleanups.
507ebf9b3b77c84000a55645867db6617b5324bcvboxsync * @remarks This may be called even if pfnInit hasn't been called!
98da2c2cca8786e117ad93a31c6b2c6c1c3cdc78vboxsync/** Pointer to a VBOXSERVICE. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync/** Pointer to a const VBOXSERVICE. */
507ebf9b3b77c84000a55645867db6617b5324bcvboxsync/** The service name.
507ebf9b3b77c84000a55645867db6617b5324bcvboxsync * @note Used on windows to name the service as well as the global mutex. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync/** The friendly service name. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync# define VBOXSERVICE_FRIENDLY_NAME "VirtualBox Guest Additions Service"
85c594c1140f082dd862abde9dc7825137a3d51avboxsync/** The service description (only W2K+ atm) */
e38719852d98638514dba23fbacf53ad11361d6avboxsync# define VBOXSERVICE_DESCRIPTION "Manages VM runtime information, time synchronization, remote sysprep execution and miscellaneous utilities for guest operating systems."
e38719852d98638514dba23fbacf53ad11361d6avboxsync/** The following constant may be defined by including NtStatus.h. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync#endif /* RT_OS_WINDOWS */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync * Structure for holding buffered pipe data.
85c594c1140f082dd862abde9dc7825137a3d51avboxsynctypedef struct
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** The data buffer. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** The amount of allocated buffer space. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** The actual used/occupied buffer space. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** Helper variable for keeping track of what
85c594c1140f082dd862abde9dc7825137a3d51avboxsync * already was processed and what not. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** Critical section protecting this buffer structure. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** Flag indicating whether this pipe buffer accepts new
85c594c1140f082dd862abde9dc7825137a3d51avboxsync * data to be written to or not. If not enabled, already
85c594c1140f082dd862abde9dc7825137a3d51avboxsync * (allocated) buffered data still can be read out. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** Set if it's necessary to write to the notification pipe. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** Set if the pipe needs to be closed after the next read/write. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** The notification pipe associated with this buffer.
85c594c1140f082dd862abde9dc7825137a3d51avboxsync * This is NIL_RTPIPE for output pipes. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** The other end of hNotificationPipeW. */
463d00559e51c6e08ccc9f5a77d2ee6d122b6e8cvboxsync /** The event semaphore for getting notified whether something
507ebf9b3b77c84000a55645867db6617b5324bcvboxsync * has changed, e.g. written or read from this buffer. */
34822e8b7d00c04a0bc98c0d1a565a00d9bb1fd9vboxsync/** Pointer to buffered pipe data. */
6edb4183bc898fddcd0987b6c5c3903b8246fe45vboxsynctypedef VBOXSERVICECTRLEXECPIPEBUF *PVBOXSERVICECTRLEXECPIPEBUF;
6edb4183bc898fddcd0987b6c5c3903b8246fe45vboxsync * Structure for holding guest exection relevant data.
85c594c1140f082dd862abde9dc7825137a3d51avboxsynctypedef struct
85c594c1140f082dd862abde9dc7825137a3d51avboxsync/** Pointer to thread data. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsynctypedef VBOXSERVICECTRLTHREADDATAEXEC *PVBOXSERVICECTRLTHREADDATAEXEC;
34822e8b7d00c04a0bc98c0d1a565a00d9bb1fd9vboxsync/* Structure for holding thread relevant data. */
507ebf9b3b77c84000a55645867db6617b5324bcvboxsync /** Node. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** The worker thread. */
507ebf9b3b77c84000a55645867db6617b5324bcvboxsync /** Shutdown indicator. */
34822e8b7d00c04a0bc98c0d1a565a00d9bb1fd9vboxsync bool volatile fShutdown;
34822e8b7d00c04a0bc98c0d1a565a00d9bb1fd9vboxsync /** Indicator set by the service thread exiting. */
34822e8b7d00c04a0bc98c0d1a565a00d9bb1fd9vboxsync bool volatile fStopped;
507ebf9b3b77c84000a55645867db6617b5324bcvboxsync /** Whether the service was started or not. */
34822e8b7d00c04a0bc98c0d1a565a00d9bb1fd9vboxsync /** Client ID. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** Context ID. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** Type of thread. See VBOXSERVICECTRLTHREADDATATYPE for more info. */
34822e8b7d00c04a0bc98c0d1a565a00d9bb1fd9vboxsync /** Pointer to actual thread data, depending on enmType. */
507ebf9b3b77c84000a55645867db6617b5324bcvboxsync/** Pointer to thread data. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsynctypedef VBOXSERVICECTRLTHREAD *PVBOXSERVICECTRLTHREAD;
85c594c1140f082dd862abde9dc7825137a3d51avboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync * A guest property cache.
e38719852d98638514dba23fbacf53ad11361d6avboxsync /** The client ID for HGCM communication. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** Head in a list of VBOXSERVICEVEPROPCACHEENTRY nodes. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** Critical section for thread-safe use. */
e38719852d98638514dba23fbacf53ad11361d6avboxsync/** Pointer to a guest property cache. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsynctypedef VBOXSERVICEVEPROPCACHE *PVBOXSERVICEVEPROPCACHE;
85c594c1140f082dd862abde9dc7825137a3d51avboxsync * An entry in the property cache (VBOXSERVICEVEPROPCACHE).
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** Node to successor.
85c594c1140f082dd862abde9dc7825137a3d51avboxsync * @todo r=bird: This is not really the node to the successor, but
85c594c1140f082dd862abde9dc7825137a3d51avboxsync * rather the OUR node in the list. If it helps, remember that
e38719852d98638514dba23fbacf53ad11361d6avboxsync * its a doubly linked list. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** Name (and full path) of guest property. */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** The last value stored (for reference). */
85c594c1140f082dd862abde9dc7825137a3d51avboxsync /** Reset value to write if property is temporary. If NULL, it will be
b29e03c9044019d9c77222336e8f8616052824f5vboxsync * deleted. */
1c8130d3c423590046a8ed4f3059de38ac5dcc14vboxsync /** Flags. */
1c8130d3c423590046a8ed4f3059de38ac5dcc14vboxsync/** Pointer to a cached guest property. */
507ebf9b3b77c84000a55645867db6617b5324bcvboxsynctypedef VBOXSERVICEVEPROPCACHEENTRY *PVBOXSERVICEVEPROPCACHEENTRY;
1c8130d3c423590046a8ed4f3059de38ac5dcc14vboxsync#endif /* VBOX_WITH_GUEST_PROPS */
85c594c1140f082dd862abde9dc7825137a3d51avboxsyncextern RTEXITCODE VBoxServiceSyntax(const char *pszFormat, ...);
85c594c1140f082dd862abde9dc7825137a3d51avboxsyncextern RTEXITCODE VBoxServiceError(const char *pszFormat, ...);
85c594c1140f082dd862abde9dc7825137a3d51avboxsyncextern void VBoxServiceVerbose(int iLevel, const char *pszFormat, ...);
extern int VBoxServiceStartServices(void);
extern int VBoxServiceStopServices(void);
extern void VBoxServiceMainWait(void);
#ifdef RT_OS_WINDOWS
#ifdef VBOXSERVICE_TOOLBOX
#ifdef RT_OS_WINDOWS
# ifdef VBOX_WITH_GUEST_PROPS
#ifdef VBOX_WITH_GUEST_CONTROL
extern int VBoxServiceControlExecHandleCmdSetInput(uint32_t u32ClientId, uint32_t uNumParms, size_t cbMaxBufSize);
#ifdef VBOXSERVICE_MANAGEMENT