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