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 /* setup.c */ 324 DWORD 325 GetSetupType(VOID); 326 327 BOOL 328 RunSetup(VOID); 329 330 /* shutdown.h */ 331 DWORD 332 TerminateSystemShutdown(VOID); 333 334 DWORD 335 StartSystemShutdown( 336 IN PUNICODE_STRING pMessage, 337 IN ULONG dwTimeout, 338 IN BOOLEAN bForceAppsClosed, 339 IN BOOLEAN bRebootAfterShutdown, 340 IN ULONG dwReason); 341 342 /* winlogon.c */ 343 BOOL 344 PlaySoundRoutine(IN LPCWSTR FileName, 345 IN UINT Logon, 346 IN UINT Flags); 347 348 BOOL 349 DisplayStatusMessage(IN PWLSESSION Session, 350 IN HDESK hDesktop, 351 IN UINT ResourceId); 352 353 BOOL 354 RemoveStatusMessage(IN PWLSESSION Session); 355 356 /* wlx.c */ 357 VOID 358 InitDialogListHead(VOID); 359 360 VOID 361 CloseAllDialogWindows(VOID); 362 363 BOOL 364 GinaInit(IN OUT PWLSESSION Session); 365 366 BOOL 367 AddAceToWindowStation( 368 IN HWINSTA WinSta, 369 IN PSID Sid); 370 371 BOOL 372 CreateWindowStationAndDesktops(IN OUT PWLSESSION Session); 373 374 375 VOID WINAPI WlxUseCtrlAltDel(HANDLE hWlx); 376 VOID WINAPI WlxSetContextPointer(HANDLE hWlx, PVOID pWlxContext); 377 VOID WINAPI WlxSasNotify(HANDLE hWlx, DWORD dwSasType); 378 BOOL WINAPI WlxSetTimeout(HANDLE hWlx, DWORD Timeout); 379 int WINAPI WlxAssignShellProtection(HANDLE hWlx, HANDLE hToken, HANDLE hProcess, HANDLE hThread); 380 int WINAPI WlxMessageBox(HANDLE hWlx, HWND hwndOwner, LPWSTR lpszText, LPWSTR lpszTitle, UINT fuStyle); 381 int WINAPI WlxDialogBox(HANDLE hWlx, HANDLE hInst, LPWSTR lpszTemplate, HWND hwndOwner, DLGPROC dlgprc); 382 int WINAPI WlxDialogBoxParam(HANDLE hWlx, HANDLE hInst, LPWSTR lpszTemplate, HWND hwndOwner, DLGPROC dlgprc, LPARAM dwInitParam); 383 int WINAPI WlxDialogBoxIndirect(HANDLE hWlx, HANDLE hInst, LPCDLGTEMPLATE hDialogTemplate, HWND hwndOwner, DLGPROC dlgprc); 384 int WINAPI WlxDialogBoxIndirectParam(HANDLE hWlx, HANDLE hInst, LPCDLGTEMPLATE hDialogTemplate, HWND hwndOwner, DLGPROC dlgprc, LPARAM dwInitParam); 385 int WINAPI WlxSwitchDesktopToUser(HANDLE hWlx); 386 int WINAPI WlxSwitchDesktopToWinlogon(HANDLE hWlx); 387 int WINAPI WlxChangePasswordNotify(HANDLE hWlx, PWLX_MPR_NOTIFY_INFO pMprInfo, DWORD dwChangeInfo); 388 BOOL WINAPI WlxGetSourceDesktop(HANDLE hWlx, PWLX_DESKTOP* ppDesktop); 389 BOOL WINAPI WlxSetReturnDesktop(HANDLE hWlx, PWLX_DESKTOP pDesktop); 390 BOOL WINAPI WlxCreateUserDesktop(HANDLE hWlx, HANDLE hToken, DWORD Flags, PWSTR pszDesktopName, PWLX_DESKTOP* ppDesktop); 391 int WINAPI WlxChangePasswordNotifyEx(HANDLE hWlx, PWLX_MPR_NOTIFY_INFO pMprInfo, DWORD dwChangeInfo, PWSTR ProviderName, PVOID Reserved); 392 BOOL WINAPI WlxCloseUserDesktop(HANDLE hWlx, PWLX_DESKTOP pDesktop, HANDLE hToken); 393 BOOL WINAPI WlxSetOption(HANDLE hWlx, DWORD Option, ULONG_PTR Value, ULONG_PTR* OldValue); 394 BOOL WINAPI WlxGetOption(HANDLE hWlx, DWORD Option, ULONG_PTR* Value); 395 VOID WINAPI WlxWin31Migrate(HANDLE hWlx); 396 BOOL WINAPI WlxQueryClientCredentials(PWLX_CLIENT_CREDENTIALS_INFO_V1_0 pCred); 397 BOOL WINAPI WlxQueryInetConnectorCredentials(PWLX_CLIENT_CREDENTIALS_INFO_V1_0 pCred); 398 DWORD WINAPI WlxQueryConsoleSwitchCredentials(PWLX_CONSOLESWITCH_CREDENTIALS_INFO_V1_0 pCred); 399 BOOL WINAPI WlxQueryTsLogonCredentials(PWLX_CLIENT_CREDENTIALS_INFO_V2_0 pCred); 400 BOOL WINAPI WlxDisconnect(VOID); 401 DWORD WINAPI WlxQueryTerminalServicesData(HANDLE hWlx, PWLX_TERMINAL_SERVICES_DATA pTSData, WCHAR* UserName, WCHAR* Domain); 402 403 #endif /* __WINLOGON_MAIN_H__ */ 404