9c5819d36a747b384ba7cac0b4b3f8b5569e421b
[reactos.git] / reactos / base / system / winlogon / winlogon.h
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2003 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 /* COPYRIGHT: See COPYING in the top level directory
20 * PROJECT: ReactOS winlogon
21 * FILE: base/system/winlogon/winlogon.h
22 * PURPOSE: Winlogon
23 * PROGRAMMER:
24 */
25
26 #ifndef __WINLOGON_MAIN_H__
27 #define __WINLOGON_MAIN_H__
28
29 #include <stdarg.h>
30
31 #define USE_GETLASTINPUTINFO
32
33 #define WIN32_NO_STATUS
34 #include <windef.h>
35 #include <winbase.h>
36 #include <wingdi.h>
37 #include <winuser.h>
38 #include <winreg.h>
39 #include <winwlx.h>
40 #include <ndk/rtlfuncs.h>
41 #include <ndk/exfuncs.h>
42 #include <strsafe.h>
43
44 #include <reactos/undocuser.h>
45
46 #include <wine/debug.h>
47 WINE_DEFAULT_DEBUG_CHANNEL(winlogon);
48
49 #include "resource.h"
50
51 typedef BOOL (WINAPI * PFWLXNEGOTIATE) (DWORD, DWORD *);
52 typedef BOOL (WINAPI * PFWLXINITIALIZE) (LPWSTR, HANDLE, PVOID, PVOID, PVOID *);
53 typedef VOID (WINAPI * PFWLXDISPLAYSASNOTICE) (PVOID);
54 typedef int (WINAPI * PFWLXLOGGEDOUTSAS) (PVOID, DWORD, PLUID, PSID, PDWORD,
55 PHANDLE, PWLX_MPR_NOTIFY_INFO,
56 PVOID *);
57 typedef BOOL (WINAPI * PFWLXACTIVATEUSERSHELL) (PVOID, PWSTR, PWSTR, PVOID);
58 typedef int (WINAPI * PFWLXLOGGEDONSAS) (PVOID, DWORD, PVOID);
59 typedef VOID (WINAPI * PFWLXDISPLAYLOCKEDNOTICE) (PVOID);
60 typedef int (WINAPI * PFWLXWKSTALOCKEDSAS) (PVOID, DWORD);
61 typedef BOOL (WINAPI * PFWLXISLOCKOK) (PVOID);
62 typedef BOOL (WINAPI * PFWLXISLOGOFFOK) (PVOID);
63 typedef VOID (WINAPI * PFWLXLOGOFF) (PVOID);
64 typedef VOID (WINAPI * PFWLXSHUTDOWN) (PVOID, DWORD);
65
66 /* version 1.1 */
67
68 typedef BOOL (WINAPI * PFWLXSCREENSAVERNOTIFY) (PVOID, BOOL *);
69 typedef BOOL (WINAPI * PFWLXSTARTAPPLICATION) (PVOID, PWSTR, PVOID, PWSTR);
70
71 /* version 1.3 */
72
73 typedef BOOL (WINAPI * PFWLXNETWORKPROVIDERLOAD) (PVOID, PWLX_MPR_NOTIFY_INFO);
74 typedef BOOL (WINAPI * PFWLXDISPLAYSTATUSMESSAGE) (PVOID, HDESK, DWORD, PWSTR, PWSTR);
75 typedef BOOL (WINAPI * PFWLXGETSTATUSMESSAGE) (PVOID, DWORD *, PWSTR, DWORD);
76 typedef BOOL (WINAPI * PFWLXREMOVESTATUSMESSAGE) (PVOID);
77
78 typedef struct _GINAFUNCTIONS
79 {
80 /* Functions always available for a valid GINA */
81 PFWLXNEGOTIATE WlxNegotiate; /* optional */
82 PFWLXINITIALIZE WlxInitialize;
83
84 /* Functions available if WlxVersion >= WLX_VERSION_1_0 (MS Windows 3.5.0) */
85 PFWLXDISPLAYSASNOTICE WlxDisplaySASNotice;
86 PFWLXLOGGEDOUTSAS WlxLoggedOutSAS;
87 PFWLXACTIVATEUSERSHELL WlxActivateUserShell;
88 PFWLXLOGGEDONSAS WlxLoggedOnSAS;
89 PFWLXDISPLAYLOCKEDNOTICE WlxDisplayLockedNotice;
90 PFWLXWKSTALOCKEDSAS WlxWkstaLockedSAS;
91 PFWLXISLOCKOK WlxIsLockOk;
92 PFWLXISLOGOFFOK WlxIsLogoffOk;
93 PFWLXLOGOFF WlxLogoff;
94 PFWLXSHUTDOWN WlxShutdown;
95
96 /* Functions available if WlxVersion >= WLX_VERSION_1_1 (MS Windows 3.5.1) */
97 PFWLXSCREENSAVERNOTIFY WlxScreenSaverNotify; /* optional */
98 PFWLXSTARTAPPLICATION WlxStartApplication; /* optional */
99
100 /* Functions available if WlxVersion >= WLX_VERSION_1_2 (MS Windows NT 4.0) */
101
102 /* Functions available if WlxVersion >= WLX_VERSION_1_3 (MS Windows 2000) */
103 PFWLXNETWORKPROVIDERLOAD WlxNetworkProviderLoad; /* not called ATM */
104 PFWLXDISPLAYSTATUSMESSAGE WlxDisplayStatusMessage;
105 PFWLXGETSTATUSMESSAGE WlxGetStatusMessage; /* doesn't need to be called */
106 PFWLXREMOVESTATUSMESSAGE WlxRemoveStatusMessage;
107
108 /* Functions available if WlxVersion >= WLX_VERSION_1_4 (MS Windows XP) */
109 } GINAFUNCTIONS, *PGINAFUNCTIONS;
110
111 typedef struct _GINAINSTANCE
112 {
113 HMODULE hDllInstance;
114 GINAFUNCTIONS Functions;
115 PVOID Context;
116 DWORD Version;
117 BOOL UseCtrlAltDelete;
118 } GINAINSTANCE, *PGINAINSTANCE;
119
120
121 /*
122 * The picture Microsoft is trying to paint here
123 * (http://msdn.microsoft.com/en-us/library/windows/desktop/aa380547%28v=vs.85%29.aspx)
124 * about the Winlogon states is a little too simple.
125 *
126 * The real picture should look more like this:
127 *
128 * STATE_INIT
129 * Initial state. Required for session initialization. After intialization,
130 * the state will automatically change to STATE_LOGGED_OFF.
131 *
132 * STATE_LOGGED_OFF
133 * User is logged off. Winlogon shows the "Press Ctrl-Alt-Del for logon"
134 * dialog. The state changes to STATE_LOGGED_OFF_SAS when the user presses
135 * "Ctrl-Alt-Del". If DisableCAD is true, the state will automatically
136 * change to STATE_LOGGED_OFF_SAS without showing the dialog.
137 *
138 * STATE_LOGGED_OFF_SAS
139 * State shows the logon dialog. Entering the right credentials and pressing
140 * "OK" changes the state to STATE_LOGGED_ON. Pressing "Cancel" or a timeout
141 * changes the state back to STATE_LOGGED_OFF.
142 *
143 * STATE_LOGGED_ON
144 * User is logged on. Winlogon does not show any dialog. Pressing
145 * "Ctrl-Alt-Del" changes the state to STATE_LOGGED_ON_SAS and user
146 * inactivity changes the state to STATE_SCREENSAVER.
147 *
148 * STATE_LOGGED_ON_SAS
149 * Winlogon shows the security dialog. Pressing "Cancel" or "Task Manager"
150 * or a timeout change the state back to STATE_LOGGED_ON. Pressing "Change
151 * Password" does not change the state, because the security dialog is still
152 * visible behind the change password dialog. Pressing "Log off" changes the
153 * state to STATE_LOGGING_OFF. Pressing "Lock Computer" changes the state to
154 * STATE_LOCKED. Pressing "Shutdown" changes the state to
155 * STATE_SHUTTING_DOWN.
156 *
157 * STATE_LOCKED
158 * Winlogon shows the locked message dialog. When the user presses "Ctrl-
159 * Alt-Del" the state changes to STATE_LOCKED_SAS. If DisableCAD is true,
160 * the state will automatically change to STATE_LOCKED_SAS without showing
161 * the dialog.
162 *
163 * STATE_LOCKED_SAS
164 * Winlogon shows the unlock dialog. Presing "Cancel" or a timeout will
165 * change the state back to STATE_LOCKED. Entering the right credentials and
166 * pressing "OK" unlocks the computer and changes the state to
167 * STATE_LOGGED_ON.
168 *
169 * STATE_LOGGING_OFF
170 * Winlogon shows the logoff dialog. Pressing "Cancel" or a timeout changes
171 * the state back to STATE_LOGGED_ON_SAS. Pressing "OK" logs off the user
172 * and changes the state to STATE_LOGGED_OFF.
173 *
174 * STATE_SHUTTING_DOWN
175 * Winlogon shows the shutdown dialog. Presing "Cancel" or a timeout will
176 * change the state back to STATE_LOGGED_ON_SAS. Pressing "OK" will change
177 * the state to STATE_SHUT_DOWN.
178 *
179 * STATE_SHUT_DOWN
180 * Terminates Winlogon and initiates shut-down.
181 *
182 * STATE_SCREENSAVER
183 * Winlogon runs the screen saver. Upon user activity, the screensaver
184 * terminates and the state changes back to STATE_LOGGED_ON if the secure
185 * screen saver option is off. Otherwise, the state changes to STATE_LOCKED.
186 */
187 typedef enum _LOGON_STATE
188 {
189 STATE_INIT,
190 STATE_LOGGED_OFF,
191 STATE_LOGGED_OFF_SAS,
192 STATE_LOGGED_ON,
193 STATE_LOGGED_ON_SAS,
194 STATE_LOCKED,
195 STATE_LOCKED_SAS,
196 STATE_LOGGING_OFF, // not used yet
197 STATE_SHUTTING_DOWN, // not used yet
198 STATE_SHUT_DOWN, // not used yet
199 STATE_SCREENSAVER // not used yet
200 } LOGON_STATE, *PLOGON_STATE;
201
202 #define LockWorkstation(Session)
203 #define UnlockWorkstation(Session)
204
205 typedef struct _WLSESSION
206 {
207 GINAINSTANCE Gina;
208 DWORD SASAction;
209 BOOL SuppressStatus;
210 BOOL TaskManHotkey;
211 HWND SASWindow;
212 HWINSTA InteractiveWindowStation;
213 LPWSTR InteractiveWindowStationName;
214 HDESK ApplicationDesktop;
215 HDESK WinlogonDesktop;
216 HDESK ScreenSaverDesktop;
217 LUID LogonId;
218 HANDLE UserToken;
219 HANDLE hProfileInfo;
220 LOGON_STATE LogonState;
221 DWORD DialogTimeout; /* Timeout for dialog boxes, in seconds */
222
223 /* Screen-saver informations */
224 #ifndef USE_GETLASTINPUTINFO
225 HHOOK KeyboardHook;
226 HHOOK MouseHook;
227 #endif
228 HANDLE hEndOfScreenSaverThread;
229 HANDLE hScreenSaverParametersChanged;
230 HANDLE hUserActivity;
231 HANDLE hEndOfScreenSaver;
232 #ifndef USE_GETLASTINPUTINFO
233 DWORD LastActivity;
234 #endif
235
236 /* Logon informations */
237 DWORD Options;
238 WLX_MPR_NOTIFY_INFO MprNotifyInfo;
239 WLX_PROFILE_V2_0 *Profile;
240 } WLSESSION, *PWLSESSION;
241
242 typedef enum _NOTIFICATION_TYPE
243 {
244 LogonHandler,
245 LogoffHandler,
246 LockHandler,
247 UnlockHandler,
248 StartupHandler,
249 ShutdownHandler,
250 StartScreenSaverHandler,
251 StopScreenSaverHandler,
252 DisconnectHandler,
253 ReconnectHandler,
254 StartShellHandler,
255 PostShellHandler,
256 LastHandler
257 } NOTIFICATION_TYPE, *PNOTIFICATION_TYPE;
258
259 extern HINSTANCE hAppInstance;
260 extern PWLSESSION WLSession;
261
262 #define WLX_SHUTTINGDOWN(Status) \
263 (((Status) == WLX_SAS_ACTION_SHUTDOWN) || \
264 ((Status) == WLX_SAS_ACTION_SHUTDOWN_POWER_OFF) || \
265 ((Status) == WLX_SAS_ACTION_SHUTDOWN_REBOOT) \
266 )
267
268 #define WLX_SUSPENDING(Status) \
269 (((Status) == WLX_SAS_ACTION_SHUTDOWN_SLEEP) || \
270 ((Status) == WLX_SAS_ACTION_SHUTDOWN_SLEEP2) || \
271 ((Status) == WLX_SAS_ACTION_SHUTDOWN_HIBERNATE) \
272 )
273
274 /* environment.c */
275 BOOL
276 CreateUserEnvironment(IN PWLSESSION Session);
277
278 /* notifiy.c */
279 BOOL
280 InitNotifications(VOID);
281
282 VOID
283 CleanupNotifications(VOID);
284
285 VOID
286 CallNotificationDlls(
287 PWLSESSION pSession,
288 NOTIFICATION_TYPE Type);
289
290 /* rpcserver.c */
291 BOOL
292 StartRpcServer(VOID);
293
294 /* sas.c */
295 BOOL
296 SetDefaultLanguage(IN PWLSESSION Session);
297
298 BOOL
299 InitializeSAS(IN OUT PWLSESSION Session);
300
301 /* screensaver.c */
302 BOOL
303 InitializeScreenSaver(IN OUT PWLSESSION Session);
304
305 VOID
306 StartScreenSaver(IN PWLSESSION Session);
307
308 /* setup.c */
309 DWORD
310 GetSetupType(VOID);
311
312 BOOL
313 RunSetup(VOID);
314
315 /* winlogon.c */
316 BOOL
317 PlaySoundRoutine(IN LPCWSTR FileName,
318 IN UINT Logon,
319 IN UINT Flags);
320
321 BOOL
322 DisplayStatusMessage(IN PWLSESSION Session,
323 IN HDESK hDesktop,
324 IN UINT ResourceId);
325
326 BOOL
327 RemoveStatusMessage(IN PWLSESSION Session);
328
329 /* wlx.c */
330 VOID
331 InitDialogListHead(VOID);
332
333 HWND
334 GetTopDialogWindow(VOID);
335
336 BOOL
337 GinaInit(IN OUT PWLSESSION Session);
338
339 BOOL
340 CreateWindowStationAndDesktops(IN OUT PWLSESSION Session);
341
342 NTSTATUS
343 HandleShutdown(IN OUT PWLSESSION Session,
344 IN DWORD wlxAction);
345
346 VOID WINAPI WlxUseCtrlAltDel(HANDLE hWlx);
347 VOID WINAPI WlxSetContextPointer(HANDLE hWlx, PVOID pWlxContext);
348 VOID WINAPI WlxSasNotify(HANDLE hWlx, DWORD dwSasType);
349 BOOL WINAPI WlxSetTimeout(HANDLE hWlx, DWORD Timeout);
350 int WINAPI WlxAssignShellProtection(HANDLE hWlx, HANDLE hToken, HANDLE hProcess, HANDLE hThread);
351 int WINAPI WlxMessageBox(HANDLE hWlx, HWND hwndOwner, LPWSTR lpszText, LPWSTR lpszTitle, UINT fuStyle);
352 int WINAPI WlxDialogBox(HANDLE hWlx, HANDLE hInst, LPWSTR lpszTemplate, HWND hwndOwner, DLGPROC dlgprc);
353 int WINAPI WlxDialogBoxParam(HANDLE hWlx, HANDLE hInst, LPWSTR lpszTemplate, HWND hwndOwner, DLGPROC dlgprc, LPARAM dwInitParam);
354 int WINAPI WlxDialogBoxIndirect(HANDLE hWlx, HANDLE hInst, LPCDLGTEMPLATE hDialogTemplate, HWND hwndOwner, DLGPROC dlgprc);
355 int WINAPI WlxDialogBoxIndirectParam(HANDLE hWlx, HANDLE hInst, LPCDLGTEMPLATE hDialogTemplate, HWND hwndOwner, DLGPROC dlgprc, LPARAM dwInitParam);
356 int WINAPI WlxSwitchDesktopToUser(HANDLE hWlx);
357 int WINAPI WlxSwitchDesktopToWinlogon(HANDLE hWlx);
358 int WINAPI WlxChangePasswordNotify(HANDLE hWlx, PWLX_MPR_NOTIFY_INFO pMprInfo, DWORD dwChangeInfo);
359 BOOL WINAPI WlxGetSourceDesktop(HANDLE hWlx, PWLX_DESKTOP* ppDesktop);
360 BOOL WINAPI WlxSetReturnDesktop(HANDLE hWlx, PWLX_DESKTOP pDesktop);
361 BOOL WINAPI WlxCreateUserDesktop(HANDLE hWlx, HANDLE hToken, DWORD Flags, PWSTR pszDesktopName, PWLX_DESKTOP* ppDesktop);
362 int WINAPI WlxChangePasswordNotifyEx(HANDLE hWlx, PWLX_MPR_NOTIFY_INFO pMprInfo, DWORD dwChangeInfo, PWSTR ProviderName, PVOID Reserved);
363 BOOL WINAPI WlxCloseUserDesktop(HANDLE hWlx, PWLX_DESKTOP pDesktop, HANDLE hToken);
364 BOOL WINAPI WlxSetOption(HANDLE hWlx, DWORD Option, ULONG_PTR Value, ULONG_PTR* OldValue);
365 BOOL WINAPI WlxGetOption(HANDLE hWlx, DWORD Option, ULONG_PTR* Value);
366 VOID WINAPI WlxWin31Migrate(HANDLE hWlx);
367 BOOL WINAPI WlxQueryClientCredentials(PWLX_CLIENT_CREDENTIALS_INFO_V1_0 pCred);
368 BOOL WINAPI WlxQueryInetConnectorCredentials(PWLX_CLIENT_CREDENTIALS_INFO_V1_0 pCred);
369 DWORD WINAPI WlxQueryConsoleSwitchCredentials(PWLX_CONSOLESWITCH_CREDENTIALS_INFO_V1_0 pCred);
370 BOOL WINAPI WlxQueryTsLogonCredentials(PWLX_CLIENT_CREDENTIALS_INFO_V2_0 pCred);
371 BOOL WINAPI WlxDisconnect(VOID);
372 DWORD WINAPI WlxQueryTerminalServicesData(HANDLE hWlx, PWLX_TERMINAL_SERVICES_DATA pTSData, WCHAR* UserName, WCHAR* Domain);
373
374 #endif /* __WINLOGON_MAIN_H__ */