1 | /* $Id: VBoxTray.h 57741 2015-09-14 15:24:42Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxTray - Guest Additions Tray, Internal Header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2015 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 ___VBOXTRAY_H
|
---|
19 | #define ___VBOXTRAY_H
|
---|
20 |
|
---|
21 | # define _InterlockedExchange _InterlockedExchange_StupidDDKVsCompilerCrap
|
---|
22 | # define _InterlockedExchangeAdd _InterlockedExchangeAdd_StupidDDKVsCompilerCrap
|
---|
23 | # define _InterlockedCompareExchange _InterlockedCompareExchange_StupidDDKVsCompilerCrap
|
---|
24 | # define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap
|
---|
25 | # define _interlockedbittestandset _interlockedbittestandset_StupidDDKVsCompilerCrap
|
---|
26 | # define _interlockedbittestandreset _interlockedbittestandreset_StupidDDKVsCompilerCrap
|
---|
27 | # define _interlockedbittestandset64 _interlockedbittestandset64_StupidDDKVsCompilerCrap
|
---|
28 | # define _interlockedbittestandreset64 _interlockedbittestandreset64_StupidDDKVsCompilerCrap
|
---|
29 | # pragma warning(disable : 4163)
|
---|
30 | #include <windows.h>
|
---|
31 | # pragma warning(default : 4163)
|
---|
32 | # undef _InterlockedExchange
|
---|
33 | # undef _InterlockedExchangeAdd
|
---|
34 | # undef _InterlockedCompareExchange
|
---|
35 | # undef _InterlockedAddLargeStatistic
|
---|
36 | # undef _interlockedbittestandset
|
---|
37 | # undef _interlockedbittestandreset
|
---|
38 | # undef _interlockedbittestandset64
|
---|
39 | # undef _interlockedbittestandreset64
|
---|
40 |
|
---|
41 | #include <tchar.h>
|
---|
42 | #include <stdio.h>
|
---|
43 | #include <stdarg.h>
|
---|
44 | #include <process.h>
|
---|
45 |
|
---|
46 | #include <iprt/initterm.h>
|
---|
47 | #include <iprt/string.h>
|
---|
48 | #include <iprt/thread.h>
|
---|
49 |
|
---|
50 | #include <VBox/version.h>
|
---|
51 | #include <VBox/VBoxGuest.h> /** @todo use the VbglR3 interface! */
|
---|
52 | #include <VBox/VBoxGuestLib.h>
|
---|
53 | #include <VBoxDisplay.h>
|
---|
54 |
|
---|
55 | #include "VBoxDispIf.h"
|
---|
56 |
|
---|
57 | /*
|
---|
58 | * Windows messsages.
|
---|
59 | */
|
---|
60 |
|
---|
61 | /**
|
---|
62 | * General VBoxTray messages.
|
---|
63 | */
|
---|
64 | #define WM_VBOXTRAY_TRAY_ICON WM_APP + 40
|
---|
65 |
|
---|
66 | /* The tray icon's ID. */
|
---|
67 | #define ID_TRAYICON 2000
|
---|
68 |
|
---|
69 | /*
|
---|
70 | * Timer IDs.
|
---|
71 | */
|
---|
72 | #define TIMERID_VBOXTRAY_CHECK_HOSTVERSION 1000
|
---|
73 | #define TIMERID_VBOXTRAY_CAPS_TIMER 1001
|
---|
74 | #define TIMERID_VBOXTRAY_DT_TIMER 1002
|
---|
75 | #define TIMERID_VBOXTRAY_ST_DELAYED_INIT_TIMER 1003
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * The environment information for services.
|
---|
79 | */
|
---|
80 | typedef struct _VBOXSERVICEENV
|
---|
81 | {
|
---|
82 | /** hInstance of VBoxTray. */
|
---|
83 | HINSTANCE hInstance;
|
---|
84 | /** Handle of guest driver. */
|
---|
85 | HANDLE hDriver;
|
---|
86 | /* Display driver interface, XPDM - WDDM abstraction see VBOXDISPIF** definitions above */
|
---|
87 | /** @todo r=andy Argh. Needed by the "display" + "seamless" services (which in turn get called
|
---|
88 | * by the VBoxCaps facility. See #8037. */
|
---|
89 | VBOXDISPIF dispIf;
|
---|
90 | } VBOXSERVICEENV, *PVBOXSERVICEENV;
|
---|
91 |
|
---|
92 | /**
|
---|
93 | * A service descriptor.
|
---|
94 | */
|
---|
95 | typedef struct _VBOXSERVICEDESC
|
---|
96 | {
|
---|
97 | /** The service's name. RTTHREAD_NAME_LEN maximum characters. */
|
---|
98 | char *pszName;
|
---|
99 | /** The service description. */
|
---|
100 | char *pszDesc;
|
---|
101 |
|
---|
102 | /** Callbacks. */
|
---|
103 |
|
---|
104 | /**
|
---|
105 | * Initializes a service.
|
---|
106 | * @returns VBox status code.
|
---|
107 | * @param pEnv
|
---|
108 | * @param ppInstance Where to return the thread-specific instance data.
|
---|
109 | */
|
---|
110 | DECLCALLBACKMEMBER(int, pfnInit) (const PVBOXSERVICEENV pEnv, void **ppInstance);
|
---|
111 |
|
---|
112 | /** Called from the worker thread.
|
---|
113 | *
|
---|
114 | * @returns VBox status code.
|
---|
115 | * @retval VINF_SUCCESS if exitting because *pfShutdown was set.
|
---|
116 | * @param pInstance Pointer to thread-specific instance data.
|
---|
117 | * @param pfShutdown Pointer to a per service termination flag to check
|
---|
118 | * before and after blocking.
|
---|
119 | */
|
---|
120 | DECLCALLBACKMEMBER(int, pfnWorker) (void *pInstance, bool volatile *pfShutdown);
|
---|
121 |
|
---|
122 | /**
|
---|
123 | * Stops a service.
|
---|
124 | */
|
---|
125 | DECLCALLBACKMEMBER(int, pfnStop) (void *pInstance);
|
---|
126 |
|
---|
127 | /**
|
---|
128 | * Does termination cleanups.
|
---|
129 | *
|
---|
130 | * @remarks This may be called even if pfnInit hasn't been called!
|
---|
131 | */
|
---|
132 | DECLCALLBACKMEMBER(void, pfnDestroy)(void *pInstance);
|
---|
133 | } VBOXSERVICEDESC, *PVBOXSERVICEDESC;
|
---|
134 |
|
---|
135 | extern VBOXSERVICEDESC g_SvcDescDisplay;
|
---|
136 | extern VBOXSERVICEDESC g_SvcDescClipboard;
|
---|
137 | extern VBOXSERVICEDESC g_SvcDescSeamless;
|
---|
138 | extern VBOXSERVICEDESC g_SvcDescVRDP;
|
---|
139 | extern VBOXSERVICEDESC g_SvcDescIPC;
|
---|
140 | extern VBOXSERVICEDESC g_SvcDescLA;
|
---|
141 | #ifdef VBOX_WITH_DRAG_AND_DROP
|
---|
142 | extern VBOXSERVICEDESC g_SvcDescDnD;
|
---|
143 | #endif
|
---|
144 |
|
---|
145 | /**
|
---|
146 | * The service initialization info and runtime variables.
|
---|
147 | */
|
---|
148 | typedef struct _VBOXSERVICEINFO
|
---|
149 | {
|
---|
150 | /** Pointer to the service descriptor. */
|
---|
151 | PVBOXSERVICEDESC pDesc;
|
---|
152 | /** Thread handle. */
|
---|
153 | RTTHREAD hThread;
|
---|
154 | /** Pointer to service-specific instance data.
|
---|
155 | * Must be free'd by the service itself. */
|
---|
156 | void *pInstance;
|
---|
157 | /** Whether Pre-init was called. */
|
---|
158 | bool fPreInited;
|
---|
159 | /** Shutdown indicator. */
|
---|
160 | bool volatile fShutdown;
|
---|
161 | /** Indicator set by the service thread exiting. */
|
---|
162 | bool volatile fStopped;
|
---|
163 | /** Whether the service was started or not. */
|
---|
164 | bool fStarted;
|
---|
165 | /** Whether the service is enabled or not. */
|
---|
166 | bool fEnabled;
|
---|
167 | } VBOXSERVICEINFO, *PVBOXSERVICEINFO;
|
---|
168 |
|
---|
169 | /* Globally unique (system wide) message registration. */
|
---|
170 | typedef struct _VBOXGLOBALMESSAGE
|
---|
171 | {
|
---|
172 | /** Message name. */
|
---|
173 | char *pszName;
|
---|
174 | /** Function pointer for handling the message. */
|
---|
175 | int (* pfnHandler) (WPARAM wParam, LPARAM lParam);
|
---|
176 |
|
---|
177 | /* Variables. */
|
---|
178 |
|
---|
179 | /** Message ID;
|
---|
180 | * to be filled in when registering the actual message. */
|
---|
181 | UINT uMsgID;
|
---|
182 | } VBOXGLOBALMESSAGE, *PVBOXGLOBALMESSAGE;
|
---|
183 |
|
---|
184 | extern HWND g_hwndToolWindow;
|
---|
185 | extern HINSTANCE g_hInstance;
|
---|
186 |
|
---|
187 | #endif /* !___VBOXTRAY_H */
|
---|
188 |
|
---|