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