d489baa37c84cd1b747f2ba761aa0a5aeb2c07ec
[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: subsys/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 "setup.h"
50 #include "resource.h"
51
52 typedef BOOL (WINAPI * PFWLXNEGOTIATE) (DWORD, DWORD *);
53 typedef BOOL (WINAPI * PFWLXINITIALIZE) (LPWSTR, HANDLE, PVOID, PVOID, PVOID *);
54 typedef VOID (WINAPI * PFWLXDISPLAYSASNOTICE) (PVOID);
55 typedef int (WINAPI * PFWLXLOGGEDOUTSAS) (PVOID, DWORD, PLUID, PSID, PDWORD,
56 PHANDLE, PWLX_MPR_NOTIFY_INFO,
57 PVOID *);
58 typedef BOOL (WINAPI * PFWLXACTIVATEUSERSHELL) (PVOID, PWSTR, PWSTR, PVOID);
59 typedef int (WINAPI * PFWLXLOGGEDONSAS) (PVOID, DWORD, PVOID);
60 typedef VOID (WINAPI * PFWLXDISPLAYLOCKEDNOTICE) (PVOID);
61 typedef int (WINAPI * PFWLXWKSTALOCKEDSAS) (PVOID, DWORD);
62 typedef BOOL (WINAPI * PFWLXISLOCKOK) (PVOID);
63 typedef BOOL (WINAPI * PFWLXISLOGOFFOK) (PVOID);
64 typedef VOID (WINAPI * PFWLXLOGOFF) (PVOID);
65 typedef VOID (WINAPI * PFWLXSHUTDOWN) (PVOID, DWORD);
66
67 /* version 1.1 */
68
69 typedef BOOL (WINAPI * PFWLXSCREENSAVERNOTIFY) (PVOID, BOOL *);
70 typedef BOOL (WINAPI * PFWLXSTARTAPPLICATION) (PVOID, PWSTR, PVOID, PWSTR);
71
72 /* version 1.3 */
73
74 typedef BOOL (WINAPI * PFWLXNETWORKPROVIDERLOAD) (PVOID, PWLX_MPR_NOTIFY_INFO);
75 typedef BOOL (WINAPI * PFWLXDISPLAYSTATUSMESSAGE) (PVOID, HDESK, DWORD, PWSTR, PWSTR);
76 typedef BOOL (WINAPI * PFWLXGETSTATUSMESSAGE) (PVOID, DWORD *, PWSTR, DWORD);
77 typedef BOOL (WINAPI * PFWLXREMOVESTATUSMESSAGE) (PVOID);
78
79 typedef struct _GINAFUNCTIONS
80 {
81 /* Functions always available for a valid GINA */
82 PFWLXNEGOTIATE WlxNegotiate; /* optional */
83 PFWLXINITIALIZE WlxInitialize;
84
85 /* Functions available if WlxVersion >= WLX_VERSION_1_0 (MS Windows 3.5.0) */
86 PFWLXDISPLAYSASNOTICE WlxDisplaySASNotice;
87 PFWLXLOGGEDOUTSAS WlxLoggedOutSAS;
88 PFWLXACTIVATEUSERSHELL WlxActivateUserShell;
89 PFWLXLOGGEDONSAS WlxLoggedOnSAS;
90 PFWLXDISPLAYLOCKEDNOTICE WlxDisplayLockedNotice;
91 PFWLXWKSTALOCKEDSAS WlxWkstaLockedSAS;
92 PFWLXISLOCKOK WlxIsLockOk;
93 PFWLXISLOGOFFOK WlxIsLogoffOk;
94 PFWLXLOGOFF WlxLogoff;
95 PFWLXSHUTDOWN WlxShutdown;
96
97 /* Functions available if WlxVersion >= WLX_VERSION_1_1 (MS Windows 3.5.1) */
98 PFWLXSCREENSAVERNOTIFY WlxScreenSaverNotify; /* optional */
99 PFWLXSTARTAPPLICATION WlxStartApplication; /* optional */
100
101 /* Functions available if WlxVersion >= WLX_VERSION_1_2 (MS Windows NT 4.0) */
102
103 /* Functions available if WlxVersion >= WLX_VERSION_1_3 (MS Windows 2000) */
104 PFWLXNETWORKPROVIDERLOAD WlxNetworkProviderLoad; /* not called ATM */
105 PFWLXDISPLAYSTATUSMESSAGE WlxDisplayStatusMessage;
106 PFWLXGETSTATUSMESSAGE WlxGetStatusMessage; /* doesn't need to be called */
107 PFWLXREMOVESTATUSMESSAGE WlxRemoveStatusMessage;
108
109 /* Functions available if WlxVersion >= WLX_VERSION_1_4 (MS Windows XP) */
110 } GINAFUNCTIONS, *PGINAFUNCTIONS;
111
112 typedef struct _GINAINSTANCE
113 {
114 HMODULE hDllInstance;
115 GINAFUNCTIONS Functions;
116 PVOID Context;
117 DWORD Version;
118 BOOL UseCtrlAltDelete;
119 } GINAINSTANCE, *PGINAINSTANCE;
120
121
122 /*
123 * The picture Microsoft is trying to paint here
124 * (http://msdn.microsoft.com/en-us/library/windows/desktop/aa380547%28v=vs.85%29.aspx)
125 * about the Winlogon states is a little too simple.
126 *
127 * The real picture should look more like this:
128 *
129 * STATE_INIT
130 * Initial state. Required for session initialization. After intialization,
131 * the state will automatically change to STATE_LOGGED_OFF.
132 *
133 * STATE_LOGGED_OFF
134 * User is logged off. Winlogon shows the "Press Ctrl-Alt-Del for logon"
135 * dialog. The state changes to STATE_LOGGED_OFF_SAS when the user presses
136 * "Ctrl-Alt-Del". If DisableCAD is true, the state will automatically
137 * change to STATE_LOGGED_OFF_SAS without showing the dialog.
138 *
139 * STATE_LOGGED_OFF_SAS
140 * State shows the logon dialog. Entering the right credentials and pressing
141 * "OK" changes the state to STATE_LOGGED_ON. Pressing "Cancel" or a timeout
142 * changes the state back to STATE_LOGGED_OFF.
143 *
144 * STATE_LOGGED_ON
145 * User is logged on. Winlogon does not show any dialog. Pressing
146 * "Ctrl-Alt-Del" changes the state to STATE_LOGGED_ON_SAS and user
147 * inactivity changes the state to STATE_SCREENSAVER.
148 *
149 * STATE_LOGGED_ON_SAS
150 * Winlogon shows the security dialog. Pressing "Cancel" or "Task Manager"
151 * or a timeout change the state back to STATE_LOGGED_ON. Pressing "Change
152 * Password" does not change the state, because the security dialog is still
153 * visible behind the change password dialog. Pressing "Log off" changes the
154 * state to STATE_LOGGING_OFF. Pressing "Lock Computer" changes the state to
155 * STATE_LOCKED. Pressing "Shutdown" changes the state to
156 * STATE_SHUTTING_DOWN.
157 *
158 * STATE_SCREENSAVER
159 * Winlogon runs the screen saver. Upon user activity, the screensaver
160 * terminates and the state changes back to STATE_LOGGED_ON if the secure
161 * screen saver option is off. Otherwise, the state changes to STATE_LOCKED.
162 *
163 * STATE_LOGGING_OFF
164 * Winlogon shows the logoff dialog. Pressing "Cancel" or a timeout changes
165 * the state back to STATE_LOGGED_ON_SAS. Pressing "OK" logs off the user
166 * and changes the state to STATE_LOGGED_OFF.
167 *
168 * STATE_LOCKED
169 * Winlogon shows the locked message dialog. When the user presses "Ctrl-
170 * Alt-Del" the state changes to STATE_LOCKED_SAS. If DisableCAD is true,
171 * the state will automatically change to STATE_LOCKED_SAS without showing
172 * the dialog.
173 *
174 * STATE_LOCKED_SAS
175 * Winlogon shows the unlock dialog. Presing "Cancel" or a timeout will
176 * change the state back to STATE_LOCKED. Entering the right credentials and
177 * pressing "OK" unlocks the computer and changes the state to
178 * STATE_LOGGED_ON.
179 *
180 * STATE_SHUTTING_DOWN
181 * Winlogon shows the shutdown dialog. Presing "Cancel" or a timeout will
182 * change the state back to STATE_LOGGED_ON_SAS. Pressing "OK" will change
183 * the state to STATE_SHUT_DOWN.
184 *
185 * STATE_SHUT_DOWN
186 * Terminates Winlogon and initiates shut-down.
187 */
188 typedef enum _LOGON_STATE
189 {
190 STATE_INIT, // not used yet
191 STATE_LOGGED_OFF,
192 STATE_LOGGED_OFF_SAS, // not used yet
193 STATE_LOGGED_ON,
194 STATE_LOGGED_ON_SAS,
195 STATE_SCREENSAVER, // not used yet
196 STATE_LOCKED,
197 STATE_LOCKED_SAS, // not used yet
198 STATE_LOGGING_OFF, // not used yet
199 STATE_SHUTTING_DOWN, // not used yet
200 STATE_SHUT_DOWN // not used yet
201 } LOGON_STATE, *PLOGON_STATE;
202
203 #define LockWorkstation(Session)
204 #define UnlockWorkstation(Session)
205
206 typedef struct _WLSESSION
207 {
208 GINAINSTANCE Gina;
209 DWORD SASAction;
210 BOOL SuppressStatus;
211 BOOL TaskManHotkey;
212 HWND SASWindow;
213 HWINSTA InteractiveWindowStation;
214 LPWSTR InteractiveWindowStationName;
215 HDESK ApplicationDesktop;
216 HDESK WinlogonDesktop;
217 HDESK ScreenSaverDesktop;
218 LUID LogonId;
219 HANDLE UserToken;
220 HANDLE hProfileInfo;
221 LOGON_STATE LogonState;
222 DWORD DialogTimeout; /* Timeout for dialog boxes, in seconds */
223
224 /* Screen-saver informations */
225 #ifndef USE_GETLASTINPUTINFO
226 HHOOK KeyboardHook;
227 HHOOK MouseHook;
228 #endif
229 HANDLE hEndOfScreenSaverThread;
230 HANDLE hScreenSaverParametersChanged;
231 HANDLE hUserActivity;
232 HANDLE hEndOfScreenSaver;
233 #ifndef USE_GETLASTINPUTINFO
234 DWORD LastActivity;
235 #endif
236
237 /* Logon informations */
238 DWORD Options;
239 WLX_MPR_NOTIFY_INFO MprNotifyInfo;
240 WLX_PROFILE_V2_0 *Profile;
241 } WLSESSION, *PWLSESSION;
242
243 extern HINSTANCE hAppInstance;
244 extern PWLSESSION WLSession;
245
246 #define WLX_SHUTTINGDOWN(Status) \
247 (((Status) == WLX_SAS_ACTION_SHUTDOWN) || \
248 ((Status) == WLX_SAS_ACTION_SHUTDOWN_POWER_OFF) || \
249 ((Status) == WLX_SAS_ACTION_SHUTDOWN_REBOOT) \
250 )
251
252 #define WLX_SUSPENDING(Status) \
253 (((Status) == WLX_SAS_ACTION_SHUTDOWN_SLEEP) || \
254 ((Status) == WLX_SAS_ACTION_SHUTDOWN_SLEEP2) || \
255 ((Status) == WLX_SAS_ACTION_SHUTDOWN_HIBERNATE) \
256 )
257
258 /* environment.c */
259 BOOL
260 CreateUserEnvironment(IN PWLSESSION Session);
261
262 /* sas.c */
263 BOOL
264 SetDefaultLanguage(IN BOOL UserProfile);
265
266 BOOL
267 InitializeSAS(IN OUT PWLSESSION Session);
268
269 /* screensaver.c */
270 BOOL
271 InitializeScreenSaver(IN OUT PWLSESSION Session);
272
273 VOID
274 StartScreenSaver(IN PWLSESSION Session);
275
276 /* winlogon.c */
277
278 BOOL
279 PlaySoundRoutine(IN LPCWSTR FileName,
280 IN UINT Logon,
281 IN UINT Flags);
282
283 BOOL
284 DisplayStatusMessage(IN PWLSESSION Session,
285 IN HDESK hDesktop,
286 IN UINT ResourceId);
287
288 BOOL
289 RemoveStatusMessage(IN PWLSESSION Session);
290
291 /* wlx.c */
292 VOID
293 InitDialogListHead(VOID);
294
295 HWND
296 GetTopDialogWindow(VOID);
297
298 BOOL
299 GinaInit(IN OUT PWLSESSION Session);
300
301 BOOL
302 CreateWindowStationAndDesktops(IN OUT PWLSESSION Session);
303
304 NTSTATUS
305 HandleShutdown(IN OUT PWLSESSION Session,
306 IN DWORD wlxAction);
307
308 VOID WINAPI WlxUseCtrlAltDel(HANDLE hWlx);
309 VOID WINAPI WlxSetContextPointer(HANDLE hWlx, PVOID pWlxContext);
310 VOID WINAPI WlxSasNotify(HANDLE hWlx, DWORD dwSasType);
311 BOOL WINAPI WlxSetTimeout(HANDLE hWlx, DWORD Timeout);
312 int WINAPI WlxAssignShellProtection(HANDLE hWlx, HANDLE hToken, HANDLE hProcess, HANDLE hThread);
313 int WINAPI WlxMessageBox(HANDLE hWlx, HWND hwndOwner, LPWSTR lpszText, LPWSTR lpszTitle, UINT fuStyle);
314 int WINAPI WlxDialogBox(HANDLE hWlx, HANDLE hInst, LPWSTR lpszTemplate, HWND hwndOwner, DLGPROC dlgprc);
315 int WINAPI WlxDialogBoxParam(HANDLE hWlx, HANDLE hInst, LPWSTR lpszTemplate, HWND hwndOwner, DLGPROC dlgprc, LPARAM dwInitParam);
316 int WINAPI WlxDialogBoxIndirect(HANDLE hWlx, HANDLE hInst, LPCDLGTEMPLATE hDialogTemplate, HWND hwndOwner, DLGPROC dlgprc);
317 int WINAPI WlxDialogBoxIndirectParam(HANDLE hWlx, HANDLE hInst, LPCDLGTEMPLATE hDialogTemplate, HWND hwndOwner, DLGPROC dlgprc, LPARAM dwInitParam);
318 int WINAPI WlxSwitchDesktopToUser(HANDLE hWlx);
319 int WINAPI WlxSwitchDesktopToWinlogon(HANDLE hWlx);
320 int WINAPI WlxChangePasswordNotify(HANDLE hWlx, PWLX_MPR_NOTIFY_INFO pMprInfo, DWORD dwChangeInfo);
321 BOOL WINAPI WlxGetSourceDesktop(HANDLE hWlx, PWLX_DESKTOP* ppDesktop);
322 BOOL WINAPI WlxSetReturnDesktop(HANDLE hWlx, PWLX_DESKTOP pDesktop);
323 BOOL WINAPI WlxCreateUserDesktop(HANDLE hWlx, HANDLE hToken, DWORD Flags, PWSTR pszDesktopName, PWLX_DESKTOP* ppDesktop);
324 int WINAPI WlxChangePasswordNotifyEx(HANDLE hWlx, PWLX_MPR_NOTIFY_INFO pMprInfo, DWORD dwChangeInfo, PWSTR ProviderName, PVOID Reserved);
325 BOOL WINAPI WlxCloseUserDesktop(HANDLE hWlx, PWLX_DESKTOP pDesktop, HANDLE hToken);
326 BOOL WINAPI WlxSetOption(HANDLE hWlx, DWORD Option, ULONG_PTR Value, ULONG_PTR* OldValue);
327 BOOL WINAPI WlxGetOption(HANDLE hWlx, DWORD Option, ULONG_PTR* Value);
328 VOID WINAPI WlxWin31Migrate(HANDLE hWlx);
329 BOOL WINAPI WlxQueryClientCredentials(PWLX_CLIENT_CREDENTIALS_INFO_V1_0 pCred);
330 BOOL WINAPI WlxQueryInetConnectorCredentials(PWLX_CLIENT_CREDENTIALS_INFO_V1_0 pCred);
331 DWORD WINAPI WlxQueryConsoleSwitchCredentials(PWLX_CONSOLESWITCH_CREDENTIALS_INFO_V1_0 pCred);
332 BOOL WINAPI WlxQueryTsLogonCredentials(PWLX_CLIENT_CREDENTIALS_INFO_V2_0 pCred);
333 BOOL WINAPI WlxDisconnect(VOID);
334 DWORD WINAPI WlxQueryTerminalServicesData(HANDLE hWlx, PWLX_TERMINAL_SERVICES_DATA pTSData, WCHAR* UserName, WCHAR* Domain);
335
336 #endif /* __WINLOGON_MAIN_H__ */