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