static BOOL HandleLogon( IN OUT PWLSESSION Session) { PROFILEINFOW ProfileInfo; BOOL ret = FALSE; /* Loading personal settings */ DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_LOADINGYOURPERSONALSETTINGS); ProfileInfo.hProfile = INVALID_HANDLE_VALUE; if (0 == (Session->Options & WLX_LOGON_OPT_NO_PROFILE)) { if (Session->Profile == NULL || (Session->Profile->dwType != WLX_PROFILE_TYPE_V1_0 && Session->Profile->dwType != WLX_PROFILE_TYPE_V2_0)) { ERR("WL: Wrong profile\n"); goto cleanup; } /* Load the user profile */ ZeroMemory(&ProfileInfo, sizeof(PROFILEINFOW)); ProfileInfo.dwSize = sizeof(PROFILEINFOW); ProfileInfo.dwFlags = 0; ProfileInfo.lpUserName = Session->MprNotifyInfo.pszUserName; ProfileInfo.lpProfilePath = Session->Profile->pszProfile; if (Session->Profile->dwType >= WLX_PROFILE_TYPE_V2_0) { ProfileInfo.lpDefaultPath = Session->Profile->pszNetworkDefaultUserProfile; ProfileInfo.lpServerName = Session->Profile->pszServerName; ProfileInfo.lpPolicyPath = Session->Profile->pszPolicy; } if (!LoadUserProfileW(Session->UserToken, &ProfileInfo)) { ERR("WL: LoadUserProfileW() failed\n"); goto cleanup; } } /* Create environment block for the user */ if (!CreateUserEnvironment(Session)) { WARN("WL: SetUserEnvironment() failed\n"); goto cleanup; } CallNotificationDlls(Session, LogonHandler); DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_APPLYINGYOURPERSONALSETTINGS); UpdatePerUserSystemParameters(0, TRUE); /* Set default user language */ if (!SetDefaultLanguage(Session)) { WARN("WL: SetDefaultLanguage() failed\n"); goto cleanup; } AllowWinstaAccess(Session); /* Connect remote resources */ RestoreAllConnections(Session); if (!StartUserShell(Session)) { //WCHAR StatusMsg[256]; WARN("WL: WlxActivateUserShell() failed\n"); //LoadStringW(hAppInstance, IDS_FAILEDACTIVATEUSERSHELL, StatusMsg, sizeof(StatusMsg) / sizeof(StatusMsg[0])); //MessageBoxW(0, StatusMsg, NULL, MB_ICONERROR); goto cleanup; } CallNotificationDlls(Session, StartShellHandler); if (!InitializeScreenSaver(Session)) WARN("WL: Failed to initialize screen saver\n"); Session->hProfileInfo = ProfileInfo.hProfile; /* Logon has succeeded. Play sound. */ PlayLogonSound(Session); ret = TRUE; cleanup: if (Session->Profile) { HeapFree(GetProcessHeap(), 0, Session->Profile->pszProfile); HeapFree(GetProcessHeap(), 0, Session->Profile); } Session->Profile = NULL; if (!ret && ProfileInfo.hProfile != INVALID_HANDLE_VALUE) { UnloadUserProfile(Session->UserToken, ProfileInfo.hProfile); } RemoveStatusMessage(Session); if (!ret) { SetWindowStationUser(Session->InteractiveWindowStation, &LuidNone, NULL, 0); CloseHandle(Session->UserToken); Session->UserToken = NULL; } if (ret) { SwitchDesktop(Session->ApplicationDesktop); Session->LogonState = STATE_LOGGED_ON; } return ret; }
static VOID DispatchSAS( IN OUT PWLSESSION Session, IN DWORD dwSasType) { DWORD wlxAction = WLX_SAS_ACTION_NONE; HWND hwnd; PSID LogonSid = NULL; /* FIXME */ BOOL bSecure = TRUE; switch (dwSasType) { case WLX_SAS_TYPE_CTRL_ALT_DEL: switch (Session->LogonState) { case STATE_INIT: Session->LogonState = STATE_LOGGED_OFF; Session->Gina.Functions.WlxDisplaySASNotice(Session->Gina.Context); return; case STATE_LOGGED_OFF: Session->LogonState = STATE_LOGGED_OFF_SAS; hwnd = GetTopDialogWindow(); if (hwnd != NULL) SendMessage(hwnd, WLX_WM_SAS, 0, 0); Session->Options = 0; wlxAction = (DWORD)Session->Gina.Functions.WlxLoggedOutSAS( Session->Gina.Context, Session->SASAction, &Session->LogonId, LogonSid, &Session->Options, &Session->UserToken, &Session->MprNotifyInfo, (PVOID*)&Session->Profile); AllowWinstaAccess(Session); break; case STATE_LOGGED_OFF_SAS: /* Ignore SAS if we are already in an SAS state */ return; case STATE_LOGGED_ON: Session->LogonState = STATE_LOGGED_ON_SAS; wlxAction = (DWORD)Session->Gina.Functions.WlxLoggedOnSAS(Session->Gina.Context, dwSasType, NULL); break; case STATE_LOGGED_ON_SAS: /* Ignore SAS if we are already in an SAS state */ return; case STATE_LOCKED: Session->LogonState = STATE_LOCKED_SAS; hwnd = GetTopDialogWindow(); if (hwnd != NULL) SendMessage(hwnd, WLX_WM_SAS, 0, 0); wlxAction = (DWORD)Session->Gina.Functions.WlxWkstaLockedSAS(Session->Gina.Context, dwSasType); break; case STATE_LOCKED_SAS: /* Ignore SAS if we are already in an SAS state */ return; default: return; } break; case WLX_SAS_TYPE_TIMEOUT: return; case WLX_SAS_TYPE_SCRNSVR_TIMEOUT: if (!Session->Gina.Functions.WlxScreenSaverNotify(Session->Gina.Context, &bSecure)) { /* Skip start of screen saver */ SetEvent(Session->hEndOfScreenSaver); } else { StartScreenSaver(Session); if (bSecure) { wlxAction = WLX_SAS_ACTION_LOCK_WKSTA; // DoGenericAction(Session, WLX_SAS_ACTION_LOCK_WKSTA); } } break; case WLX_SAS_TYPE_SCRNSVR_ACTIVITY: SetEvent(Session->hUserActivity); break; } DoGenericAction(Session, wlxAction); }