VBoxServiceInternal.h revision 1d654276c270e20b6853109f5d1625c7328c3cf4
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * VBoxService - Guest Additions Services.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * Copyright (C) 2007-2010 Oracle Corporation
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * available from http://www.virtualbox.org. This file is free software;
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * you can redistribute it and/or modify it under the terms of the GNU
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * General Public License (GPL) as published by the Free Software
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync# include <process.h> /* Needed for file version information. */
a55af63ead2dcca370bfc0dfe49771d9dcc61b93vboxsync * A service descriptor.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsynctypedef struct
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync /** The short service name. */
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync const char *pszName;
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync /** The longer service name. */
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync /** The usage options stuff for the --help screen. */
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync const char *pszUsage;
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync /** The option descriptions for the --help screen. */
22d7a125fcbe8650770ac700108b6f27ca1f0dfdvboxsync * Called before parsing arguments.
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync * @returns VBox status code.
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync * Tries to parse the given command line option.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @returns 0 if we parsed, -1 if it didn't and anything else means exit.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @param ppszShort If not NULL it points to the short option iterator. a short argument.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * If NULL examine argv[*pi].
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @param argc The argument count.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @param argv The argument vector.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @param pi The argument vector index. Update if any value(s) are eaten.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync DECLCALLBACKMEMBER(int, pfnOption)(const char **ppszShort, int argc, char **argv, int *pi);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * Called before parsing arguments.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @returns VBox status code.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync /** Called from the worker thread.
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync * @returns VBox status code.
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync * @retval VINF_SUCCESS if exitting because *pfTerminate was set.
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync * @param pfTerminate Pointer to a per service termination flag to check
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync * before and after blocking.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync DECLCALLBACKMEMBER(int, pfnWorker)(bool volatile *pfTerminate);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * Stop an service.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * Does termination cleanups.
a2d9f81753c129b5e3bbe3769627dcd25a3724bdvboxsync * @remarks This may be called even if pfnInit hasn't been called!
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** Pointer to a VBOXSERVICE. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** Pointer to a const VBOXSERVICE. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** The service name (needed for mutex creation on Windows). */
a2d9f81753c129b5e3bbe3769627dcd25a3724bdvboxsync/** The friendly service name. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# define VBOXSERVICE_FRIENDLY_NAME "VirtualBox Guest Additions Service"
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** The service description (only W2K+ atm) */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# define VBOXSERVICE_DESCRIPTION "Manages VM runtime information, time synchronization, remote sysprep execution and miscellaneous utilities for guest operating systems."
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** The following constant may be defined by including NtStatus.h. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** Structure for storing the looked up user information. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsynctypedef struct
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** Structure for the file information lookup. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsynctypedef struct
7c1f498692cd2393f8ba68cb62be482495106f93vboxsync/** Structure for process information lookup. */
ffb14f6b8aefea7399c4bf70faab4c9fc26e6cd5vboxsynctypedef struct
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** Function prototypes for dynamic loading. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsynctypedef DWORD (WINAPI *PFNWTSGETACTIVECONSOLESESSIONID)(void);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync#endif /* RT_OS_WINDOWS */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsynctypedef struct
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** Pointer to thread data. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsynctypedef VBOXSERVICECTRLEXECPIPEBUF *PVBOXSERVICECTRLEXECPIPEBUF;
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync/* Structure for holding guest exection relevant data. */
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsynctypedef struct
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync/** Pointer to thread data. */
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsynctypedef VBOXSERVICECTRLTHREADDATAEXEC *PVBOXSERVICECTRLTHREADDATAEXEC;
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync/* Structure for holding thread relevant data. */
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync /** Node. */
49e54e2ffe0c10864d06e9d1ebe24a8eb1327a6bvboxsync /** The worker thread. */
49e54e2ffe0c10864d06e9d1ebe24a8eb1327a6bvboxsync /** Shutdown indicator. */
3a0bc95d0adf57baefd303e94b8f1b7b31a8f080vboxsync bool volatile fShutdown;
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync /** Indicator set by the service thread exiting. */
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync bool volatile fStopped;
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync /** Whether the service was started or not. */
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync /** Client ID. */
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync /** Context ID. */
7bf07b1592dfaab1a4fb6d497fd0ff1302fb7585vboxsync /** Type of thread. See VBOXSERVICECTRLTHREADDATATYPE for more info. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync /** Pointer to actual thread data, depending on enmType. */
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync/** Pointer to thread data. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsynctypedef VBOXSERVICECTRLTHREAD *PVBOXSERVICECTRLTHREAD;
9bb98d54790a98dad0ad6d9bdc5d319b6fdf0bffvboxsync * For buffering process input supplied by the client.
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync /** The mount of buffered data. */
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync /** The current data offset. */
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync /** The data buffer. */
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync /** The amount of allocated buffer space. */
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync /** Send further input into the bit bucket (stdin is dead). */
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync /** The CRC-32 for standard input (received part). */
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync/** Pointer to a standard input buffer. */
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsynctypedef VBOXSERVICECTRLSTDINBUF *PVBOXSERVICECTRLSTDINBUF;
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
14f3b3761dd547223728deb999e4ea962fc83280vboxsync * A guest property cache.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync /** The client ID for HGCM communication. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync /** List of VBOXSERVICEVEPROPCACHEENTRY nodes. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync /** Critical section for thread-safe use. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** Pointer to a guest property cache. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsynctypedef VBOXSERVICEVEPROPCACHE *PVBOXSERVICEVEPROPCACHE;
5704a317c3b6bdf4b59f6a6ebe45d443296b1995vboxsync * An entry in the property cache (VBOXSERVICEVEPROPCACHE).
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync /** Node. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync /** Name (and full path) of guest property. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync /** The last value stored (for reference). */
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync /** Reset value to write if property is temporary. If NULL, it will be
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync * deleted. */
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync /** Flags. */
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync/** Pointer to a cached guest property. */
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsynctypedef VBOXSERVICEVEPROPCACHEENTRY *PVBOXSERVICEVEPROPCACHEENTRY;
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync#endif /* VBOX_WITH_GUEST_PROPS */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncextern int VBoxServiceSyntax(const char *pszFormat, ...);
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsyncextern int VBoxServiceError(const char *pszFormat, ...);
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsyncextern void VBoxServiceVerbose(int iLevel, const char *pszFormat, ...);
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsyncextern int VBoxServiceArgUInt32(int argc, char **argv, const char *psz, int *pi, uint32_t *pu32, uint32_t u32Min, uint32_t u32Max);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncextern unsigned VBoxServiceGetStartedServices(void);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncextern int VBoxServiceStartServices(unsigned iMain);
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsyncextern int VBoxServiceStopServices(void);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncextern SERVICE_TABLE_ENTRY const g_aServiceTable[]; /** @todo generate on the fly, see comment in main() from the enabled sub services. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncextern PFNWTSGETACTIVECONSOLESESSIONID g_pfnWTSGetActiveConsoleSessionId; /* VBoxServiceVMInfo-win.cpp */
b8c2e8ba48bd659fa09a06770a7cedfae977d73bvboxsyncextern int VBoxServiceWinInstall(void);
b8c2e8ba48bd659fa09a06770a7cedfae977d73bvboxsyncextern int VBoxServiceWinUninstall(void);
be6a25d1b25b8692d8c035b0549e5258c6986dc5vboxsyncextern BOOL VBoxServiceWinSetStatus(DWORD dwStatus, DWORD dwCheckPoint);
b8c2e8ba48bd659fa09a06770a7cedfae977d73bvboxsyncextern bool VBoxServiceVMInfoWinSessionHasProcesses(PLUID pSession, VBOXSERVICEVMINFOPROC const *paProcs, DWORD cProcs);
b8c2e8ba48bd659fa09a06770a7cedfae977d73bvboxsyncextern bool VBoxServiceVMInfoWinIsLoggedIn(PVBOXSERVICEVMINFOUSER a_pUserInfo, PLUID a_pSession);
b8c2e8ba48bd659fa09a06770a7cedfae977d73bvboxsyncextern int VBoxServiceVMInfoWinProcessesEnumerate(PVBOXSERVICEVMINFOPROC *ppProc, DWORD *pdwCount);
b8c2e8ba48bd659fa09a06770a7cedfae977d73bvboxsyncextern void VBoxServiceVMInfoWinProcessesFree(PVBOXSERVICEVMINFOPROC paProcs);
3dd53c06fd54914761cf550503f02fce1ed5a815vboxsyncextern int VBoxServiceWinGetComponentVersions(uint32_t uiClientID);
1e289ac7f0c5324ef5712727fc61b2a322eb2e1avboxsync# endif /* VBOX_WITH_GUEST_PROPS */
1e289ac7f0c5324ef5712727fc61b2a322eb2e1avboxsync#endif /* RT_OS_WINDOWS */
1e289ac7f0c5324ef5712727fc61b2a322eb2e1avboxsyncextern int VBoxServiceControlExecProcess(uint32_t uContext, const char *pszCmd, uint32_t uFlags,
1e289ac7f0c5324ef5712727fc61b2a322eb2e1avboxsync const char *pszEnv, uint32_t cbEnv, uint32_t uNumEnvVars,
1e289ac7f0c5324ef5712727fc61b2a322eb2e1avboxsync const char *pszStdIn, const char *pszStdOut, const char *pszStdErr,
1e289ac7f0c5324ef5712727fc61b2a322eb2e1avboxsync const char *pszUser, const char *pszPassword, uint32_t uTimeLimitMS);
b8c2e8ba48bd659fa09a06770a7cedfae977d73bvboxsyncextern void VBoxServiceControlExecDestroyThreadData(PVBOXSERVICECTRLTHREADDATAEXEC pThread);
b8c2e8ba48bd659fa09a06770a7cedfae977d73bvboxsyncextern int VBoxServiceControlExecReadPipeBufferContent(PVBOXSERVICECTRLEXECPIPEBUF pBuf,
b8c2e8ba48bd659fa09a06770a7cedfae977d73bvboxsync uint8_t *pbBuffer, uint32_t cbBuffer, uint32_t *pcbToRead);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncextern int VBoxServiceControlExecWritePipeBuffer(PVBOXSERVICECTRLEXECPIPEBUF pBuf,