1 | /* $Id: VBoxServiceInternal.h 19352 2009-05-05 08:01:39Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxService - Guest Additions Services.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007-2009 Sun Microsystems, Inc.
|
---|
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 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef ___VBoxServiceInternal_h
|
---|
23 | #define ___VBoxServiceInternal_h
|
---|
24 |
|
---|
25 | #ifdef RT_OS_WINDOWS
|
---|
26 | # include <Windows.h>
|
---|
27 | # include <tchar.h> /**@todo just drop this, this will be compiled as UTF-8/ANSI. */
|
---|
28 | # include <process.h> /**@todo what's this here for? */
|
---|
29 | #endif
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * A service descriptor.
|
---|
33 | */
|
---|
34 | typedef struct
|
---|
35 | {
|
---|
36 | /** The short service name. */
|
---|
37 | const char *pszName;
|
---|
38 | /** The longer service name. */
|
---|
39 | const char *pszDescription;
|
---|
40 | /** The usage options stuff for the --help screen. */
|
---|
41 | const char *pszUsage;
|
---|
42 | /** The option descriptions for the --help screen. */
|
---|
43 | const char *pszOptions;
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * Called before parsing arguments.
|
---|
47 | * @returns VBox status code.
|
---|
48 | */
|
---|
49 | DECLCALLBACKMEMBER(int, pfnPreInit)(void);
|
---|
50 |
|
---|
51 | /**
|
---|
52 | * Tries to parse the given command line option.
|
---|
53 | *
|
---|
54 | * @returns 0 if we parsed, -1 if it didn't and anything else means exit.
|
---|
55 | * @param ppszShort If not NULL it points to the short option iterator. a short argument.
|
---|
56 | * If NULL examine argv[*pi].
|
---|
57 | * @param argc The argument count.
|
---|
58 | * @param argv The argument vector.
|
---|
59 | * @param pi The argument vector index. Update if any value(s) are eaten.
|
---|
60 | */
|
---|
61 | DECLCALLBACKMEMBER(int, pfnOption)(const char **ppszShort, int argc, char **argv, int *pi);
|
---|
62 |
|
---|
63 | /**
|
---|
64 | * Called before parsing arguments.
|
---|
65 | * @returns VBox status code.
|
---|
66 | */
|
---|
67 | DECLCALLBACKMEMBER(int, pfnInit)(void);
|
---|
68 |
|
---|
69 | /** Called from the worker thread.
|
---|
70 | *
|
---|
71 | * @returns VBox status code.
|
---|
72 | * @retval VINF_SUCCESS if exitting because *pfTerminate was set.
|
---|
73 | * @param pfTerminate Pointer to a per service termination flag to check
|
---|
74 | * before and after blocking.
|
---|
75 | */
|
---|
76 | DECLCALLBACKMEMBER(int, pfnWorker)(bool volatile *pfTerminate);
|
---|
77 |
|
---|
78 | /**
|
---|
79 | * Stop an service.
|
---|
80 | */
|
---|
81 | DECLCALLBACKMEMBER(void, pfnStop)(void);
|
---|
82 |
|
---|
83 | /**
|
---|
84 | * Does termination cleanups.
|
---|
85 | */
|
---|
86 | DECLCALLBACKMEMBER(void, pfnTerm)(void);
|
---|
87 | } VBOXSERVICE;
|
---|
88 | /** Pointer to a VBOXSERVICE. */
|
---|
89 | typedef VBOXSERVICE *PVBOXSERVICE;
|
---|
90 | /** Pointer to a const VBOXSERVICE. */
|
---|
91 | typedef VBOXSERVICE const *PCVBOXSERVICE;
|
---|
92 |
|
---|
93 | #ifdef RT_OS_WINDOWS
|
---|
94 | /** The service name (needed for mutex creation on Windows). */
|
---|
95 | #define VBOXSERVICE_NAME L"VBoxService"
|
---|
96 | /** The friendly service name. */
|
---|
97 | #define VBOXSERVICE_FRIENDLY_NAME L"VBoxService"
|
---|
98 | /** The following constant may be defined by including NtStatus.h. */
|
---|
99 | #define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
|
---|
100 | /** Structure for storing the looked up user information. */
|
---|
101 | typedef struct
|
---|
102 | {
|
---|
103 | TCHAR szUser [_MAX_PATH];
|
---|
104 | TCHAR szAuthenticationPackage [_MAX_PATH];
|
---|
105 | TCHAR szLogonDomain [_MAX_PATH];
|
---|
106 | } VBOXSERVICEVMINFOUSER;
|
---|
107 | /** Structure for the file information lookup. */
|
---|
108 | typedef struct
|
---|
109 | {
|
---|
110 | TCHAR* pszFilePath;
|
---|
111 | TCHAR* pszFileName;
|
---|
112 | } VBOXSERVICEVMINFOFILE;
|
---|
113 | /** Function prototypes for dynamic loading. */
|
---|
114 | typedef DWORD (WINAPI* fnWTSGetActiveConsoleSessionId)();
|
---|
115 | #endif
|
---|
116 |
|
---|
117 | __BEGIN_DECLS
|
---|
118 |
|
---|
119 | extern char *g_pszProgName;
|
---|
120 | extern int g_cVerbosity;
|
---|
121 | extern uint32_t g_DefaultInterval;
|
---|
122 |
|
---|
123 | extern int VBoxServiceSyntax(const char *pszFormat, ...);
|
---|
124 | extern int VBoxServiceError(const char *pszFormat, ...);
|
---|
125 | extern void VBoxServiceVerbose(int iLevel, const char *pszFormat, ...);
|
---|
126 | extern int VBoxServiceArgUInt32(int argc, char **argv, const char *psz, int *pi, uint32_t *pu32, uint32_t u32Min, uint32_t u32Max);
|
---|
127 | extern unsigned VBoxServiceGetStartedServices(void);
|
---|
128 | extern int VBoxServiceStartServices(unsigned iMain);
|
---|
129 | extern int VBoxServiceStopServices(void);
|
---|
130 |
|
---|
131 | extern VBOXSERVICE g_TimeSync;
|
---|
132 | extern VBOXSERVICE g_Clipboard;
|
---|
133 | extern VBOXSERVICE g_Control;
|
---|
134 | extern VBOXSERVICE g_VMInfo;
|
---|
135 |
|
---|
136 | #ifdef RT_OS_WINDOWS
|
---|
137 | extern DWORD g_rcWinService;
|
---|
138 | extern SERVICE_STATUS_HANDLE g_hWinServiceStatus;
|
---|
139 | extern SERVICE_TABLE_ENTRY const g_aServiceTable[]; /** @todo generate on the fly, see comment in main() from the enabled sub services. */
|
---|
140 |
|
---|
141 | /** Installs the service into the registry. */
|
---|
142 | extern int VBoxServiceWinInstall(void);
|
---|
143 | /** Uninstalls the service from the registry. */
|
---|
144 | extern int VBoxServiceWinUninstall(void);
|
---|
145 | /** Detects wheter a user is logged on based on the enumerated processes. */
|
---|
146 | extern BOOL VboxServiceVMInfoWinIsLoggedIn(VBOXSERVICEVMINFOUSER* a_pUserInfo,
|
---|
147 | PLUID a_pSession,
|
---|
148 | PLUID a_pLuid,
|
---|
149 | DWORD a_dwNumOfProcLUIDs);
|
---|
150 | /** Gets logon user IDs from enumerated processes. */
|
---|
151 | extern DWORD VboxServiceVMInfoWinGetLUIDsFromProcesses(PLUID *ppLuid);
|
---|
152 | #endif
|
---|
153 |
|
---|
154 | __END_DECLS
|
---|
155 |
|
---|
156 | #endif
|
---|
157 |
|
---|