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