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