1 | /* $Id: VBoxGINA.cpp 96407 2022-08-22 17:43:14Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxGINA -- Windows Logon DLL for VirtualBox
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2022 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 |
|
---|
29 | /*********************************************************************************************************************************
|
---|
30 | * Header Files *
|
---|
31 | *********************************************************************************************************************************/
|
---|
32 | #include <iprt/win/windows.h>
|
---|
33 |
|
---|
34 | #include <iprt/buildconfig.h>
|
---|
35 | #include <iprt/initterm.h>
|
---|
36 | #include <iprt/ldr.h>
|
---|
37 | #include <iprt/errcore.h>
|
---|
38 |
|
---|
39 | #include <VBox/VBoxGuestLib.h>
|
---|
40 |
|
---|
41 | #include "winwlx.h"
|
---|
42 | #include "VBoxGINA.h"
|
---|
43 | #include "Helper.h"
|
---|
44 | #include "Dialog.h"
|
---|
45 |
|
---|
46 |
|
---|
47 | /*********************************************************************************************************************************
|
---|
48 | * Global Variables *
|
---|
49 | *********************************************************************************************************************************/
|
---|
50 | /** DLL instance handle. */
|
---|
51 | HINSTANCE hDllInstance;
|
---|
52 |
|
---|
53 | /** Version of Winlogon. */
|
---|
54 | DWORD wlxVersion;
|
---|
55 |
|
---|
56 | /** Handle to Winlogon service. */
|
---|
57 | HANDLE hGinaWlx;
|
---|
58 | /** Winlog function dispatch table. */
|
---|
59 | PWLX_DISPATCH_VERSION_1_1 pWlxFuncs;
|
---|
60 |
|
---|
61 | /**
|
---|
62 | * Function pointers to MSGINA entry points.
|
---|
63 | */
|
---|
64 | PGWLXNEGOTIATE GWlxNegotiate;
|
---|
65 | PGWLXINITIALIZE GWlxInitialize;
|
---|
66 | PGWLXDISPLAYSASNOTICE GWlxDisplaySASNotice;
|
---|
67 | PGWLXLOGGEDOUTSAS GWlxLoggedOutSAS;
|
---|
68 | PGWLXACTIVATEUSERSHELL GWlxActivateUserShell;
|
---|
69 | PGWLXLOGGEDONSAS GWlxLoggedOnSAS;
|
---|
70 | PGWLXDISPLAYLOCKEDNOTICE GWlxDisplayLockedNotice;
|
---|
71 | PGWLXWKSTALOCKEDSAS GWlxWkstaLockedSAS;
|
---|
72 | PGWLXISLOCKOK GWlxIsLockOk;
|
---|
73 | PGWLXISLOGOFFOK GWlxIsLogoffOk;
|
---|
74 | PGWLXLOGOFF GWlxLogoff;
|
---|
75 | PGWLXSHUTDOWN GWlxShutdown;
|
---|
76 | /* GINA 1.1. */
|
---|
77 | PGWLXSTARTAPPLICATION GWlxStartApplication;
|
---|
78 | PGWLXSCREENSAVERNOTIFY GWlxScreenSaverNotify;
|
---|
79 | /* GINA 1.3. */
|
---|
80 | PGWLXNETWORKPROVIDERLOAD GWlxNetworkProviderLoad;
|
---|
81 | PGWLXDISPLAYSTATUSMESSAGE GWlxDisplayStatusMessage;
|
---|
82 | PGWLXGETSTATUSMESSAGE GWlxGetStatusMessage;
|
---|
83 | PGWLXREMOVESTATUSMESSAGE GWlxRemoveStatusMessage;
|
---|
84 | /* GINA 1.4. */
|
---|
85 | PGWLXGETCONSOLESWITCHCREDENTIALS GWlxGetConsoleSwitchCredentials;
|
---|
86 | PGWLXRECONNECTNOTIFY GWlxReconnectNotify;
|
---|
87 | PGWLXDISCONNECTNOTIFY GWlxDisconnectNotify;
|
---|
88 |
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * DLL entry point.
|
---|
92 | */
|
---|
93 | BOOL WINAPI DllMain(HINSTANCE hInstance,
|
---|
94 | DWORD dwReason,
|
---|
95 | LPVOID pReserved)
|
---|
96 | {
|
---|
97 | RT_NOREF(pReserved);
|
---|
98 | switch (dwReason)
|
---|
99 | {
|
---|
100 | case DLL_PROCESS_ATTACH:
|
---|
101 | {
|
---|
102 | RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
|
---|
103 | VbglR3Init();
|
---|
104 |
|
---|
105 | VBoxGINALoadConfiguration();
|
---|
106 |
|
---|
107 | VBoxGINAVerbose(0, "VBoxGINA: v%s r%s (%s %s) loaded\n",
|
---|
108 | RTBldCfgVersion(), RTBldCfgRevisionStr(),
|
---|
109 | __DATE__, __TIME__);
|
---|
110 |
|
---|
111 | DisableThreadLibraryCalls(hInstance);
|
---|
112 | hDllInstance = hInstance;
|
---|
113 | break;
|
---|
114 | }
|
---|
115 |
|
---|
116 | case DLL_PROCESS_DETACH:
|
---|
117 | {
|
---|
118 | VBoxGINAVerbose(0, "VBoxGINA: Unloaded\n");
|
---|
119 | VbglR3Term();
|
---|
120 | /// @todo RTR3Term();
|
---|
121 | break;
|
---|
122 | }
|
---|
123 |
|
---|
124 | default:
|
---|
125 | break;
|
---|
126 | }
|
---|
127 | return TRUE;
|
---|
128 | }
|
---|
129 |
|
---|
130 |
|
---|
131 | BOOL WINAPI WlxNegotiate(DWORD dwWinlogonVersion,
|
---|
132 | DWORD *pdwDllVersion)
|
---|
133 | {
|
---|
134 | VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: dwWinlogonVersion: %ld\n", dwWinlogonVersion);
|
---|
135 |
|
---|
136 | /* Load the standard Microsoft GINA DLL. */
|
---|
137 | RTLDRMOD hLdrMod;
|
---|
138 | int rc = RTLdrLoadSystem("MSGINA.DLL", true /*fNoUnload*/, &hLdrMod);
|
---|
139 | if (RT_FAILURE(rc))
|
---|
140 | {
|
---|
141 | VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: failed loading MSGINA! rc=%Rrc\n", rc);
|
---|
142 | return FALSE;
|
---|
143 | }
|
---|
144 |
|
---|
145 | /*
|
---|
146 | * Now get the entry points of the MSGINA
|
---|
147 | */
|
---|
148 | GWlxNegotiate = (PGWLXNEGOTIATE)RTLdrGetFunction(hLdrMod, "WlxNegotiate");
|
---|
149 | if (!GWlxNegotiate)
|
---|
150 | {
|
---|
151 | VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: failed resolving WlxNegotiate\n");
|
---|
152 | return FALSE;
|
---|
153 | }
|
---|
154 | GWlxInitialize = (PGWLXINITIALIZE)RTLdrGetFunction(hLdrMod, "WlxInitialize");
|
---|
155 | if (!GWlxInitialize)
|
---|
156 | {
|
---|
157 | VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: failed resolving WlxInitialize\n");
|
---|
158 | return FALSE;
|
---|
159 | }
|
---|
160 | GWlxDisplaySASNotice =
|
---|
161 | (PGWLXDISPLAYSASNOTICE)RTLdrGetFunction(hLdrMod, "WlxDisplaySASNotice");
|
---|
162 | if (!GWlxDisplaySASNotice)
|
---|
163 | {
|
---|
164 | VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: failed resolving WlxDisplaySASNotice\n");
|
---|
165 | return FALSE;
|
---|
166 | }
|
---|
167 | GWlxLoggedOutSAS =
|
---|
168 | (PGWLXLOGGEDOUTSAS)RTLdrGetFunction(hLdrMod, "WlxLoggedOutSAS");
|
---|
169 | if (!GWlxLoggedOutSAS)
|
---|
170 | {
|
---|
171 | VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: failed resolving WlxLoggedOutSAS\n");
|
---|
172 | return FALSE;
|
---|
173 | }
|
---|
174 | GWlxActivateUserShell =
|
---|
175 | (PGWLXACTIVATEUSERSHELL)RTLdrGetFunction(hLdrMod, "WlxActivateUserShell");
|
---|
176 | if (!GWlxActivateUserShell)
|
---|
177 | {
|
---|
178 | VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: failed resolving WlxActivateUserShell\n");
|
---|
179 | return FALSE;
|
---|
180 | }
|
---|
181 | GWlxLoggedOnSAS =
|
---|
182 | (PGWLXLOGGEDONSAS)RTLdrGetFunction(hLdrMod, "WlxLoggedOnSAS");
|
---|
183 | if (!GWlxLoggedOnSAS)
|
---|
184 | {
|
---|
185 | VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: failed resolving WlxLoggedOnSAS\n");
|
---|
186 | return FALSE;
|
---|
187 | }
|
---|
188 | GWlxDisplayLockedNotice =
|
---|
189 | (PGWLXDISPLAYLOCKEDNOTICE)RTLdrGetFunction(hLdrMod, "WlxDisplayLockedNotice");
|
---|
190 | if (!GWlxDisplayLockedNotice)
|
---|
191 | {
|
---|
192 | VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: failed resolving WlxDisplayLockedNotice\n");
|
---|
193 | return FALSE;
|
---|
194 | }
|
---|
195 | GWlxIsLockOk = (PGWLXISLOCKOK)RTLdrGetFunction(hLdrMod, "WlxIsLockOk");
|
---|
196 | if (!GWlxIsLockOk)
|
---|
197 | {
|
---|
198 | VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: failed resolving WlxIsLockOk\n");
|
---|
199 | return FALSE;
|
---|
200 | }
|
---|
201 | GWlxWkstaLockedSAS =
|
---|
202 | (PGWLXWKSTALOCKEDSAS)RTLdrGetFunction(hLdrMod, "WlxWkstaLockedSAS");
|
---|
203 | if (!GWlxWkstaLockedSAS)
|
---|
204 | {
|
---|
205 | VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: failed resolving WlxWkstaLockedSAS\n");
|
---|
206 | return FALSE;
|
---|
207 | }
|
---|
208 | GWlxIsLogoffOk = (PGWLXISLOGOFFOK)RTLdrGetFunction(hLdrMod, "WlxIsLogoffOk");
|
---|
209 | if (!GWlxIsLogoffOk)
|
---|
210 | {
|
---|
211 | VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: failed resolving WlxIsLogoffOk\n");
|
---|
212 | return FALSE;
|
---|
213 | }
|
---|
214 | GWlxLogoff = (PGWLXLOGOFF)RTLdrGetFunction(hLdrMod, "WlxLogoff");
|
---|
215 | if (!GWlxLogoff)
|
---|
216 | {
|
---|
217 | VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: failed resolving WlxLogoff\n");
|
---|
218 | return FALSE;
|
---|
219 | }
|
---|
220 | GWlxShutdown = (PGWLXSHUTDOWN)RTLdrGetFunction(hLdrMod, "WlxShutdown");
|
---|
221 | if (!GWlxShutdown)
|
---|
222 | {
|
---|
223 | VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: failed resolving WlxShutdown\n");
|
---|
224 | return FALSE;
|
---|
225 | }
|
---|
226 | /* GINA 1.1, optional */
|
---|
227 | GWlxStartApplication = (PGWLXSTARTAPPLICATION)RTLdrGetFunction(hLdrMod, "WlxStartApplication");
|
---|
228 | GWlxScreenSaverNotify = (PGWLXSCREENSAVERNOTIFY)RTLdrGetFunction(hLdrMod, "WlxScreenSaverNotify");
|
---|
229 | /* GINA 1.3, optional */
|
---|
230 | GWlxNetworkProviderLoad = (PGWLXNETWORKPROVIDERLOAD)RTLdrGetFunction(hLdrMod, "WlxNetworkProviderLoad");
|
---|
231 | GWlxDisplayStatusMessage = (PGWLXDISPLAYSTATUSMESSAGE)RTLdrGetFunction(hLdrMod, "WlxDisplayStatusMessage");
|
---|
232 | GWlxGetStatusMessage = (PGWLXGETSTATUSMESSAGE)RTLdrGetFunction(hLdrMod, "WlxGetStatusMessage");
|
---|
233 | GWlxRemoveStatusMessage = (PGWLXREMOVESTATUSMESSAGE)RTLdrGetFunction(hLdrMod, "WlxRemoveStatusMessage");
|
---|
234 | /* GINA 1.4, optional */
|
---|
235 | GWlxGetConsoleSwitchCredentials =
|
---|
236 | (PGWLXGETCONSOLESWITCHCREDENTIALS)RTLdrGetFunction(hLdrMod, "WlxGetConsoleSwitchCredentials");
|
---|
237 | GWlxReconnectNotify = (PGWLXRECONNECTNOTIFY)RTLdrGetFunction(hLdrMod, "WlxReconnectNotify");
|
---|
238 | GWlxDisconnectNotify = (PGWLXDISCONNECTNOTIFY)RTLdrGetFunction(hLdrMod, "WlxDisconnectNotify");
|
---|
239 | VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: optional function pointers:\n"
|
---|
240 | " WlxStartApplication: %p\n"
|
---|
241 | " WlxScreenSaverNotify: %p\n"
|
---|
242 | " WlxNetworkProviderLoad: %p\n"
|
---|
243 | " WlxDisplayStatusMessage: %p\n"
|
---|
244 | " WlxGetStatusMessage: %p\n"
|
---|
245 | " WlxRemoveStatusMessage: %p\n"
|
---|
246 | " WlxGetConsoleSwitchCredentials: %p\n"
|
---|
247 | " WlxReconnectNotify: %p\n"
|
---|
248 | " WlxDisconnectNotify: %p\n",
|
---|
249 | GWlxStartApplication, GWlxScreenSaverNotify, GWlxNetworkProviderLoad,
|
---|
250 | GWlxDisplayStatusMessage, GWlxGetStatusMessage, GWlxRemoveStatusMessage,
|
---|
251 | GWlxGetConsoleSwitchCredentials, GWlxReconnectNotify, GWlxDisconnectNotify);
|
---|
252 |
|
---|
253 | wlxVersion = dwWinlogonVersion;
|
---|
254 |
|
---|
255 | /* Acknowledge interface version. */
|
---|
256 | if (pdwDllVersion)
|
---|
257 | *pdwDllVersion = dwWinlogonVersion;
|
---|
258 |
|
---|
259 | return TRUE; /* We're ready to rumble! */
|
---|
260 | }
|
---|
261 |
|
---|
262 |
|
---|
263 | BOOL WINAPI WlxInitialize(LPWSTR lpWinsta, HANDLE hWlx, PVOID pvReserved,
|
---|
264 | PVOID pWinlogonFunctions, PVOID *pWlxContext)
|
---|
265 | {
|
---|
266 | VBoxGINAVerbose(0, "VBoxGINA::WlxInitialize\n");
|
---|
267 |
|
---|
268 | /* Store Winlogon function table */
|
---|
269 | pWlxFuncs = (PWLX_DISPATCH_VERSION_1_1)pWinlogonFunctions;
|
---|
270 |
|
---|
271 | /* Store handle to Winlogon service*/
|
---|
272 | hGinaWlx = hWlx;
|
---|
273 |
|
---|
274 | VBoxGINAReportStatus(VBoxGuestFacilityStatus_Init);
|
---|
275 |
|
---|
276 | /* Hook the dialogs */
|
---|
277 | hookDialogBoxes(pWlxFuncs, wlxVersion);
|
---|
278 |
|
---|
279 | /* Forward call */
|
---|
280 | if (GWlxInitialize)
|
---|
281 | return GWlxInitialize(lpWinsta, hWlx, pvReserved, pWinlogonFunctions, pWlxContext);
|
---|
282 | return TRUE;
|
---|
283 | }
|
---|
284 |
|
---|
285 |
|
---|
286 | VOID WINAPI WlxDisplaySASNotice(PVOID pWlxContext)
|
---|
287 | {
|
---|
288 | VBoxGINAVerbose(0, "VBoxGINA::WlxDisplaySASNotice\n");
|
---|
289 |
|
---|
290 | /* Check if there are credentials for us, if so simulate C-A-D */
|
---|
291 | int rc = VbglR3CredentialsQueryAvailability();
|
---|
292 | if (RT_SUCCESS(rc))
|
---|
293 | {
|
---|
294 | VBoxGINAVerbose(0, "VBoxGINA::WlxDisplaySASNotice: simulating C-A-D\n");
|
---|
295 | /* Wutomatic C-A-D */
|
---|
296 | pWlxFuncs->WlxSasNotify(hGinaWlx, WLX_SAS_TYPE_CTRL_ALT_DEL);
|
---|
297 | }
|
---|
298 | else
|
---|
299 | {
|
---|
300 | VBoxGINAVerbose(0, "VBoxGINA::WlxDisplaySASNotice: starting credentials poller\n");
|
---|
301 | /* start the credentials poller thread */
|
---|
302 | VBoxGINACredentialsPollerCreate();
|
---|
303 | /* Forward call to MSGINA. */
|
---|
304 | if (GWlxDisplaySASNotice)
|
---|
305 | GWlxDisplaySASNotice(pWlxContext);
|
---|
306 | }
|
---|
307 | }
|
---|
308 |
|
---|
309 |
|
---|
310 | int WINAPI WlxLoggedOutSAS(PVOID pWlxContext, DWORD dwSasType, PLUID pAuthenticationId,
|
---|
311 | PSID pLogonSid, PDWORD pdwOptions, PHANDLE phToken,
|
---|
312 | PWLX_MPR_NOTIFY_INFO pMprNotifyInfo, PVOID *pProfile)
|
---|
313 | {
|
---|
314 | VBoxGINAVerbose(0, "VBoxGINA::WlxLoggedOutSAS\n");
|
---|
315 |
|
---|
316 | /* When performing a direct logon without C-A-D, our poller might not be running */
|
---|
317 | int rc = VbglR3CredentialsQueryAvailability();
|
---|
318 | if (RT_FAILURE(rc))
|
---|
319 | VBoxGINACredentialsPollerCreate();
|
---|
320 |
|
---|
321 | if (GWlxLoggedOutSAS)
|
---|
322 | {
|
---|
323 | int iRet;
|
---|
324 | iRet = GWlxLoggedOutSAS(pWlxContext, dwSasType, pAuthenticationId, pLogonSid,
|
---|
325 | pdwOptions, phToken, pMprNotifyInfo, pProfile);
|
---|
326 |
|
---|
327 | if (iRet == WLX_SAS_ACTION_LOGON)
|
---|
328 | {
|
---|
329 | //
|
---|
330 | // Copy pMprNotifyInfo and pLogonSid for later use
|
---|
331 | //
|
---|
332 |
|
---|
333 | // pMprNotifyInfo->pszUserName
|
---|
334 | // pMprNotifyInfo->pszDomain
|
---|
335 | // pMprNotifyInfo->pszPassword
|
---|
336 | // pMprNotifyInfo->pszOldPassword
|
---|
337 | }
|
---|
338 |
|
---|
339 | return iRet;
|
---|
340 | }
|
---|
341 |
|
---|
342 | return WLX_SAS_ACTION_NONE;
|
---|
343 | }
|
---|
344 |
|
---|
345 |
|
---|
346 | /**
|
---|
347 | * WinLogon calls this function following a successful logon to request that the GINA activate the user's shell program.
|
---|
348 | */
|
---|
349 | BOOL WINAPI WlxActivateUserShell(PVOID pWlxContext, PWSTR pszDesktopName,
|
---|
350 | PWSTR pszMprLogonScript, PVOID pEnvironment)
|
---|
351 | {
|
---|
352 | VBoxGINAVerbose(0, "VBoxGINA::WlxActivateUserShell\n");
|
---|
353 |
|
---|
354 | /*
|
---|
355 | * Report status "terminated" to the host -- this means that a user
|
---|
356 | * got logged in (either manually or automatically using the provided credentials).
|
---|
357 | */
|
---|
358 | VBoxGINAReportStatus(VBoxGuestFacilityStatus_Terminated);
|
---|
359 |
|
---|
360 | /* Forward call to MSGINA. */
|
---|
361 | if (GWlxActivateUserShell)
|
---|
362 | return GWlxActivateUserShell(pWlxContext, pszDesktopName, pszMprLogonScript, pEnvironment);
|
---|
363 | return TRUE; /* Activate the user shell. */
|
---|
364 | }
|
---|
365 |
|
---|
366 |
|
---|
367 | int WINAPI WlxLoggedOnSAS(PVOID pWlxContext, DWORD dwSasType, PVOID pReserved)
|
---|
368 | {
|
---|
369 | VBoxGINAVerbose(0, "VBoxGINA::WlxLoggedOnSAS: dwSasType=%ld\n", dwSasType);
|
---|
370 |
|
---|
371 | /*
|
---|
372 | * We don't want to do anything special here since the OS should behave
|
---|
373 | * as VBoxGINA wouldn't have been installed. So pass all calls down
|
---|
374 | * to the original MSGINA.
|
---|
375 | */
|
---|
376 |
|
---|
377 | /* Forward call to MSGINA. */
|
---|
378 | VBoxGINAVerbose(0, "VBoxGINA::WlxLoggedOnSAS: Forwarding call to MSGINA ...\n");
|
---|
379 | if (GWlxLoggedOnSAS)
|
---|
380 | return GWlxLoggedOnSAS(pWlxContext, dwSasType, pReserved);
|
---|
381 | return WLX_SAS_ACTION_NONE;
|
---|
382 | }
|
---|
383 |
|
---|
384 | VOID WINAPI WlxDisplayLockedNotice(PVOID pWlxContext)
|
---|
385 | {
|
---|
386 | VBoxGINAVerbose(0, "VBoxGINA::WlxDisplayLockedNotice\n");
|
---|
387 |
|
---|
388 | /* Check if there are credentials for us, if so simulate C-A-D */
|
---|
389 | int rc = VbglR3CredentialsQueryAvailability();
|
---|
390 | if (RT_SUCCESS(rc))
|
---|
391 | {
|
---|
392 | VBoxGINAVerbose(0, "VBoxGINA::WlxDisplayLockedNotice: simulating C-A-D\n");
|
---|
393 | /* Automatic C-A-D */
|
---|
394 | pWlxFuncs->WlxSasNotify(hGinaWlx, WLX_SAS_TYPE_CTRL_ALT_DEL);
|
---|
395 | }
|
---|
396 | else
|
---|
397 | {
|
---|
398 | VBoxGINAVerbose(0, "VBoxGINA::WlxDisplayLockedNotice: starting credentials poller\n");
|
---|
399 | /* start the credentials poller thread */
|
---|
400 | VBoxGINACredentialsPollerCreate();
|
---|
401 | /* Forward call to MSGINA. */
|
---|
402 | if (GWlxDisplayLockedNotice)
|
---|
403 | GWlxDisplayLockedNotice(pWlxContext);
|
---|
404 | }
|
---|
405 | }
|
---|
406 |
|
---|
407 |
|
---|
408 | /*
|
---|
409 | * Winlogon calls this function before it attempts to lock the workstation.
|
---|
410 | */
|
---|
411 | BOOL WINAPI WlxIsLockOk(PVOID pWlxContext)
|
---|
412 | {
|
---|
413 | VBoxGINAVerbose(0, "VBoxGINA::WlxIsLockOk\n");
|
---|
414 |
|
---|
415 | /* Forward call to MSGINA. */
|
---|
416 | if (GWlxIsLockOk)
|
---|
417 | return GWlxIsLockOk(pWlxContext);
|
---|
418 | return TRUE; /* Locking is OK. */
|
---|
419 | }
|
---|
420 |
|
---|
421 |
|
---|
422 | int WINAPI WlxWkstaLockedSAS(PVOID pWlxContext, DWORD dwSasType)
|
---|
423 | {
|
---|
424 | VBoxGINAVerbose(0, "VBoxGINA::WlxWkstaLockedSAS, dwSasType=%ld\n", dwSasType);
|
---|
425 |
|
---|
426 | /* When performing a direct logon without C-A-D, our poller might not be running */
|
---|
427 | int rc = VbglR3CredentialsQueryAvailability();
|
---|
428 | if (RT_FAILURE(rc))
|
---|
429 | VBoxGINACredentialsPollerCreate();
|
---|
430 |
|
---|
431 | /* Forward call to MSGINA. */
|
---|
432 | if (GWlxWkstaLockedSAS)
|
---|
433 | return GWlxWkstaLockedSAS(pWlxContext, dwSasType);
|
---|
434 | return WLX_SAS_ACTION_NONE;
|
---|
435 | }
|
---|
436 |
|
---|
437 |
|
---|
438 | BOOL WINAPI WlxIsLogoffOk(PVOID pWlxContext)
|
---|
439 | {
|
---|
440 | VBoxGINAVerbose(0, "VBoxGINA::WlxIsLogoffOk\n");
|
---|
441 |
|
---|
442 | if (GWlxIsLogoffOk)
|
---|
443 | return GWlxIsLogoffOk(pWlxContext);
|
---|
444 | return TRUE; /* Log off is OK. */
|
---|
445 | }
|
---|
446 |
|
---|
447 |
|
---|
448 | /*
|
---|
449 | * Winlogon calls this function to notify the GINA of a logoff operation on this
|
---|
450 | * workstation. This allows the GINA to perform any logoff operations that may be required.
|
---|
451 | */
|
---|
452 | VOID WINAPI WlxLogoff(PVOID pWlxContext)
|
---|
453 | {
|
---|
454 | VBoxGINAVerbose(0, "VBoxGINA::WlxLogoff\n");
|
---|
455 |
|
---|
456 | /* No need to report the "active" status to the host here -- this will be done
|
---|
457 | * when VBoxGINA gets the chance to hook the dialogs (again). */
|
---|
458 |
|
---|
459 | /* Forward call to MSGINA. */
|
---|
460 | if (GWlxLogoff)
|
---|
461 | GWlxLogoff(pWlxContext);
|
---|
462 | }
|
---|
463 |
|
---|
464 |
|
---|
465 | /*
|
---|
466 | * Winlogon calls this function just before shutting down.
|
---|
467 | * This allows the GINA to perform any necessary shutdown tasks.
|
---|
468 | * Will be called *after* WlxLogoff!
|
---|
469 | */
|
---|
470 | VOID WINAPI WlxShutdown(PVOID pWlxContext, DWORD ShutdownType)
|
---|
471 | {
|
---|
472 | VBoxGINAVerbose(0, "VBoxGINA::WlxShutdown\n");
|
---|
473 |
|
---|
474 | /*
|
---|
475 | * Report status "inactive" to the host -- this means the
|
---|
476 | * auto-logon feature won't be active anymore at this point
|
---|
477 | * (until it maybe gets loaded again after a reboot).
|
---|
478 | */
|
---|
479 | VBoxGINAReportStatus(VBoxGuestFacilityStatus_Inactive);
|
---|
480 |
|
---|
481 | /* Forward call to MSGINA. */
|
---|
482 | if (GWlxShutdown)
|
---|
483 | GWlxShutdown(pWlxContext, ShutdownType);
|
---|
484 | }
|
---|
485 |
|
---|
486 |
|
---|
487 | /*
|
---|
488 | * GINA 1.1 entry points
|
---|
489 | */
|
---|
490 | BOOL WINAPI WlxScreenSaverNotify(PVOID pWlxContext, BOOL *pSecure)
|
---|
491 | {
|
---|
492 | RT_NOREF(pWlxContext);
|
---|
493 | VBoxGINAVerbose(0, "VBoxGINA::WlxScreenSaverNotify, pSecure=%d\n",
|
---|
494 | pSecure ? *pSecure : 0);
|
---|
495 |
|
---|
496 | /* Report the status to "init" since the screensaver
|
---|
497 | * (Winlogon) does not give VBoxGINA yet the chance to hook into dialogs
|
---|
498 | * which only then in turn would set the status to "active" -- so
|
---|
499 | * at least set some status here. */
|
---|
500 | VBoxGINAReportStatus(VBoxGuestFacilityStatus_Init);
|
---|
501 |
|
---|
502 | /* Note: Disabling the screensaver's grace period is necessary to get
|
---|
503 | * VBoxGINA loaded and set the status to "terminated" again properly
|
---|
504 | * after the logging-in handling was done. To do this:
|
---|
505 | * - on a non-domain machine, set:
|
---|
506 | * HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\ScreenSaverGracePeriod (REG_SZ)
|
---|
507 | * to "0"
|
---|
508 | * - on a machine joined a domain:
|
---|
509 | * use the group policy preferences and/or the registry key above,
|
---|
510 | * depending on the domain's policies.
|
---|
511 | */
|
---|
512 |
|
---|
513 | /* Indicate that the workstation should be locked. */
|
---|
514 | *pSecure = TRUE;
|
---|
515 |
|
---|
516 | return TRUE; /* Screensaver should be activated. */
|
---|
517 | }
|
---|
518 |
|
---|
519 |
|
---|
520 | BOOL WINAPI WlxStartApplication(PVOID pWlxContext, PWSTR pszDesktopName,
|
---|
521 | PVOID pEnvironment, PWSTR pszCmdLine)
|
---|
522 | {
|
---|
523 | VBoxGINAVerbose(0, "VBoxGINA::WlxStartApplication: pWlxCtx=%p, pszDesktopName=%ls, pEnvironment=%p, pszCmdLine=%ls\n",
|
---|
524 | pWlxContext, pszDesktopName, pEnvironment, pszCmdLine);
|
---|
525 |
|
---|
526 | /* Forward to MSGINA if present. */
|
---|
527 | if (GWlxStartApplication)
|
---|
528 | return GWlxStartApplication(pWlxContext, pszDesktopName, pEnvironment, pszCmdLine);
|
---|
529 | return FALSE;
|
---|
530 | }
|
---|
531 |
|
---|
532 |
|
---|
533 | /*
|
---|
534 | * GINA 1.3 entry points
|
---|
535 | */
|
---|
536 | BOOL WINAPI WlxNetworkProviderLoad(PVOID pWlxContext, PWLX_MPR_NOTIFY_INFO pNprNotifyInfo)
|
---|
537 | {
|
---|
538 | VBoxGINAVerbose(0, "VBoxGINA::WlxNetworkProviderLoad\n");
|
---|
539 |
|
---|
540 | /* Forward to MSGINA if present. */
|
---|
541 | if (GWlxNetworkProviderLoad)
|
---|
542 | return GWlxNetworkProviderLoad(pWlxContext, pNprNotifyInfo);
|
---|
543 | return FALSE;
|
---|
544 | }
|
---|
545 |
|
---|
546 |
|
---|
547 | BOOL WINAPI WlxDisplayStatusMessage(PVOID pWlxContext, HDESK hDesktop, DWORD dwOptions,
|
---|
548 | PWSTR pTitle, PWSTR pMessage)
|
---|
549 | {
|
---|
550 | VBoxGINAVerbose(0, "VBoxGINA::WlxDisplayStatusMessage\n");
|
---|
551 |
|
---|
552 | /* Forward to MSGINA if present. */
|
---|
553 | if (GWlxDisplayStatusMessage)
|
---|
554 | return GWlxDisplayStatusMessage(pWlxContext, hDesktop, dwOptions, pTitle, pMessage);
|
---|
555 | return FALSE;
|
---|
556 | }
|
---|
557 |
|
---|
558 |
|
---|
559 | BOOL WINAPI WlxGetStatusMessage(PVOID pWlxContext, DWORD *pdwOptions,
|
---|
560 | PWSTR pMessage, DWORD dwBufferSize)
|
---|
561 | {
|
---|
562 | VBoxGINAVerbose(0, "VBoxGINA::WlxGetStatusMessage\n");
|
---|
563 |
|
---|
564 | /* Forward to MSGINA if present. */
|
---|
565 | if (GWlxGetStatusMessage)
|
---|
566 | return GWlxGetStatusMessage(pWlxContext, pdwOptions, pMessage, dwBufferSize);
|
---|
567 | return FALSE;
|
---|
568 | }
|
---|
569 |
|
---|
570 |
|
---|
571 | BOOL WINAPI WlxRemoveStatusMessage(PVOID pWlxContext)
|
---|
572 | {
|
---|
573 | VBoxGINAVerbose(0, "VBoxGINA::WlxRemoveStatusMessage\n");
|
---|
574 |
|
---|
575 | /* Forward to MSGINA if present. */
|
---|
576 | if (GWlxRemoveStatusMessage)
|
---|
577 | return GWlxRemoveStatusMessage(pWlxContext);
|
---|
578 | return FALSE;
|
---|
579 | }
|
---|
580 |
|
---|
581 |
|
---|
582 | /*
|
---|
583 | * GINA 1.4 entry points
|
---|
584 | */
|
---|
585 | BOOL WINAPI WlxGetConsoleSwitchCredentials(PVOID pWlxContext,PVOID pCredInfo)
|
---|
586 | {
|
---|
587 | VBoxGINAVerbose(0, "VBoxGINA::WlxGetConsoleSwitchCredentials\n");
|
---|
588 |
|
---|
589 | /* Forward call to MSGINA if present */
|
---|
590 | if (GWlxGetConsoleSwitchCredentials)
|
---|
591 | return GWlxGetConsoleSwitchCredentials(pWlxContext,pCredInfo);
|
---|
592 | return FALSE;
|
---|
593 | }
|
---|
594 |
|
---|
595 |
|
---|
596 | VOID WINAPI WlxReconnectNotify(PVOID pWlxContext)
|
---|
597 | {
|
---|
598 | VBoxGINAVerbose(0, "VBoxGINA::WlxReconnectNotify\n");
|
---|
599 |
|
---|
600 | /* Forward to MSGINA if present. */
|
---|
601 | if (GWlxReconnectNotify)
|
---|
602 | GWlxReconnectNotify(pWlxContext);
|
---|
603 | }
|
---|
604 |
|
---|
605 |
|
---|
606 | VOID WINAPI WlxDisconnectNotify(PVOID pWlxContext)
|
---|
607 | {
|
---|
608 | VBoxGINAVerbose(0, "VBoxGINA::WlxDisconnectNotify\n");
|
---|
609 |
|
---|
610 | /* Forward to MSGINA if present. */
|
---|
611 | if (GWlxDisconnectNotify)
|
---|
612 | GWlxDisconnectNotify(pWlxContext);
|
---|
613 | }
|
---|
614 |
|
---|
615 |
|
---|
616 | /*
|
---|
617 | * Windows Notification Package callbacks
|
---|
618 | */
|
---|
619 | void WnpScreenSaverStop(PWLX_NOTIFICATION_INFO pInfo)
|
---|
620 | {
|
---|
621 | RT_NOREF(pInfo);
|
---|
622 | VBoxGINAVerbose(0, "VBoxGINA::WnpScreenSaverStop\n");
|
---|
623 |
|
---|
624 | /*
|
---|
625 | * Because we set the status to "init" in WlxScreenSaverNotify when
|
---|
626 | * the screensaver becomes active we also have to take into account
|
---|
627 | * that in case the screensaver terminates (either within the grace
|
---|
628 | * period or because the lock screen appears) we have to set the
|
---|
629 | * status accordingly.
|
---|
630 | */
|
---|
631 | VBoxGINAReportStatus(VBoxGuestFacilityStatus_Terminated);
|
---|
632 | }
|
---|
633 |
|
---|
634 |
|
---|
635 | DWORD WINAPI VBoxGINADebug(void)
|
---|
636 | {
|
---|
637 | #ifdef DEBUG
|
---|
638 | DWORD dwVersion;
|
---|
639 | BOOL fRes = WlxNegotiate(WLX_VERSION_1_4, &dwVersion);
|
---|
640 | if (!fRes)
|
---|
641 | return 1;
|
---|
642 |
|
---|
643 | void* pWlxContext = NULL;
|
---|
644 | WLX_DISPATCH_VERSION_1_4 wlxDispatch;
|
---|
645 | ZeroMemory(&wlxDispatch, sizeof(WLX_DISPATCH_VERSION_1_4));
|
---|
646 |
|
---|
647 | fRes = WlxInitialize(0, 0,
|
---|
648 | NULL /* Reserved */,
|
---|
649 | NULL /* Winlogon functions */,
|
---|
650 | &pWlxContext);
|
---|
651 | if (!fRes)
|
---|
652 | return 2;
|
---|
653 |
|
---|
654 | WlxDisplaySASNotice(pWlxContext);
|
---|
655 |
|
---|
656 | char szSID[MAX_PATH];
|
---|
657 | LUID luidAuth;
|
---|
658 | DWORD dwOpts;
|
---|
659 | WLX_MPR_NOTIFY_INFO wlxNotifyInfo;
|
---|
660 | void* pvProfile;
|
---|
661 | HANDLE hToken;
|
---|
662 | int iRes = WlxLoggedOutSAS(pWlxContext, WLX_SAS_TYPE_CTRL_ALT_DEL,
|
---|
663 | &luidAuth, szSID,
|
---|
664 | &dwOpts, &hToken, &wlxNotifyInfo, &pvProfile);
|
---|
665 | return iRes;
|
---|
666 | #else
|
---|
667 | return 0;
|
---|
668 | #endif
|
---|
669 | }
|
---|
670 |
|
---|