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