1 | /* $Id: VBoxTray.h 62865 2016-08-02 10:11:36Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxTray - Guest Additions Tray, Internal Header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2016 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 <iprt/win/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;
|
---|
91 | /** Pointer to a VBoxTray service env info structure. */
|
---|
92 | typedef VBOXSERVICEENV *PVBOXSERVICEENV;
|
---|
93 | /** Pointer to a const VBoxTray service env info structure. */
|
---|
94 | typedef VBOXSERVICEENV const *PCVBOXSERVICEENV;
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * A service descriptor.
|
---|
98 | */
|
---|
99 | typedef struct _VBOXSERVICEDESC
|
---|
100 | {
|
---|
101 | /** The service's name. RTTHREAD_NAME_LEN maximum characters. */
|
---|
102 | char *pszName;
|
---|
103 | /** The service description. */
|
---|
104 | char *pszDesc;
|
---|
105 |
|
---|
106 | /** Callbacks. */
|
---|
107 |
|
---|
108 | /**
|
---|
109 | * Initializes a service.
|
---|
110 | * @returns VBox status code.
|
---|
111 | * @param pEnv
|
---|
112 | * @param ppInstance Where to return the thread-specific instance data.
|
---|
113 | * @todo r=bird: The pEnv type is WRONG! Please check all your const pointers.
|
---|
114 | */
|
---|
115 | DECLCALLBACKMEMBER(int, pfnInit) (const PVBOXSERVICEENV pEnv, void **ppInstance);
|
---|
116 |
|
---|
117 | /** Called from the worker thread.
|
---|
118 | *
|
---|
119 | * @returns VBox status code.
|
---|
120 | * @retval VINF_SUCCESS if exitting because *pfShutdown was set.
|
---|
121 | * @param pInstance Pointer to thread-specific instance data.
|
---|
122 | * @param pfShutdown Pointer to a per service termination flag to check
|
---|
123 | * before and after blocking.
|
---|
124 | */
|
---|
125 | DECLCALLBACKMEMBER(int, pfnWorker) (void *pInstance, bool volatile *pfShutdown);
|
---|
126 |
|
---|
127 | /**
|
---|
128 | * Stops a service.
|
---|
129 | */
|
---|
130 | DECLCALLBACKMEMBER(int, pfnStop) (void *pInstance);
|
---|
131 |
|
---|
132 | /**
|
---|
133 | * Does termination cleanups.
|
---|
134 | *
|
---|
135 | * @remarks This may be called even if pfnInit hasn't been called!
|
---|
136 | */
|
---|
137 | DECLCALLBACKMEMBER(void, pfnDestroy)(void *pInstance);
|
---|
138 | } VBOXSERVICEDESC, *PVBOXSERVICEDESC;
|
---|
139 |
|
---|
140 | extern VBOXSERVICEDESC g_SvcDescDisplay;
|
---|
141 | extern VBOXSERVICEDESC g_SvcDescClipboard;
|
---|
142 | extern VBOXSERVICEDESC g_SvcDescSeamless;
|
---|
143 | extern VBOXSERVICEDESC g_SvcDescVRDP;
|
---|
144 | extern VBOXSERVICEDESC g_SvcDescIPC;
|
---|
145 | extern VBOXSERVICEDESC g_SvcDescLA;
|
---|
146 | #ifdef VBOX_WITH_DRAG_AND_DROP
|
---|
147 | extern VBOXSERVICEDESC g_SvcDescDnD;
|
---|
148 | #endif
|
---|
149 |
|
---|
150 | /**
|
---|
151 | * The service initialization info and runtime variables.
|
---|
152 | */
|
---|
153 | typedef struct _VBOXSERVICEINFO
|
---|
154 | {
|
---|
155 | /** Pointer to the service descriptor. */
|
---|
156 | PVBOXSERVICEDESC pDesc;
|
---|
157 | /** Thread handle. */
|
---|
158 | RTTHREAD hThread;
|
---|
159 | /** Pointer to service-specific instance data.
|
---|
160 | * Must be free'd by the service itself. */
|
---|
161 | void *pInstance;
|
---|
162 | /** Whether Pre-init was called. */
|
---|
163 | bool fPreInited;
|
---|
164 | /** Shutdown indicator. */
|
---|
165 | bool volatile fShutdown;
|
---|
166 | /** Indicator set by the service thread exiting. */
|
---|
167 | bool volatile fStopped;
|
---|
168 | /** Whether the service was started or not. */
|
---|
169 | bool fStarted;
|
---|
170 | /** Whether the service is enabled or not. */
|
---|
171 | bool fEnabled;
|
---|
172 | } VBOXSERVICEINFO, *PVBOXSERVICEINFO;
|
---|
173 |
|
---|
174 | /* Globally unique (system wide) message registration. */
|
---|
175 | typedef struct _VBOXGLOBALMESSAGE
|
---|
176 | {
|
---|
177 | /** Message name. */
|
---|
178 | char *pszName;
|
---|
179 | /** Function pointer for handling the message. */
|
---|
180 | int (* pfnHandler) (WPARAM wParam, LPARAM lParam);
|
---|
181 |
|
---|
182 | /* Variables. */
|
---|
183 |
|
---|
184 | /** Message ID;
|
---|
185 | * to be filled in when registering the actual message. */
|
---|
186 | UINT uMsgID;
|
---|
187 | } VBOXGLOBALMESSAGE, *PVBOXGLOBALMESSAGE;
|
---|
188 |
|
---|
189 | extern HWND g_hwndToolWindow;
|
---|
190 | extern HINSTANCE g_hInstance;
|
---|
191 | extern uint32_t g_fGuestDisplaysChanged;
|
---|
192 |
|
---|
193 | #endif /* !___VBOXTRAY_H */
|
---|
194 |
|
---|