Fix logon-screen password with click approval (#14335)

This commit is contained in:
Amirhosein Akhlaghpoor
2026-02-24 13:14:18 +00:00
committed by GitHub
parent 0016033937
commit eb239501bc
3 changed files with 34 additions and 3 deletions

View File

@@ -580,6 +580,31 @@ extern "C"
return rdp_or_console; return rdp_or_console;
} }
BOOL is_session_locked(BOOL include_rdp)
{
DWORD session_id = get_current_session(include_rdp);
if (session_id == 0xFFFFFFFF) {
return FALSE;
}
PWTSINFOEXW pInfo = NULL;
DWORD bytes = 0;
BOOL locked = FALSE;
if (WTSQuerySessionInformationW(
WTS_CURRENT_SERVER_HANDLE,
session_id,
WTSSessionInfoEx,
(LPWSTR *)&pInfo,
&bytes)) {
if (pInfo && pInfo->Level == 1) {
locked = (pInfo->Data.WTSInfoExLevel1.SessionFlags == WTS_SESSIONSTATE_LOCK);
}
if (pInfo) {
WTSFreeMemory(pInfo);
}
}
return locked;
}
uint32_t get_active_user(PWSTR bufin, uint32_t nin, BOOL rdp) uint32_t get_active_user(PWSTR bufin, uint32_t nin, BOOL rdp)
{ {
uint32_t nout = 0; uint32_t nout = 0;

View File

@@ -527,6 +527,7 @@ const SERVICE_TYPE: ServiceType = ServiceType::OWN_PROCESS;
extern "C" { extern "C" {
fn get_current_session(rdp: BOOL) -> DWORD; fn get_current_session(rdp: BOOL) -> DWORD;
fn is_session_locked(include_rdp: BOOL) -> BOOL;
fn LaunchProcessWin( fn LaunchProcessWin(
cmd: *const u16, cmd: *const u16,
session_id: DWORD, session_id: DWORD,
@@ -1129,6 +1130,10 @@ pub fn is_prelogin() -> bool {
username.is_empty() || username == "SYSTEM" username.is_empty() || username == "SYSTEM"
} }
pub fn is_locked() -> bool {
unsafe { is_session_locked(share_rdp()) == TRUE }
}
// `is_logon_ui()` is regardless of multiple sessions now. // `is_logon_ui()` is regardless of multiple sessions now.
// It only check if "LogonUI.exe" exists. // It only check if "LogonUI.exe" exists.
// //

View File

@@ -2232,11 +2232,12 @@ impl Connection {
// https://github.com/rustdesk/rustdesk-server-pro/discussions/646 // https://github.com/rustdesk/rustdesk-server-pro/discussions/646
// `is_logon` is used to check login with `OPTION_ALLOW_LOGON_SCREEN_PASSWORD` == "Y". // `is_logon` is used to check login with `OPTION_ALLOW_LOGON_SCREEN_PASSWORD` == "Y".
// `is_logon_ui()` is used on Windows, because there's no good way to detect `is_locked()`. // `is_logon_ui()` is a fallback for logon UI detection on Windows.
// Detecting `is_logon_ui()` (if `LogonUI.exe` running) is a workaround.
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
let is_logon = || { let is_logon = || {
crate::platform::is_prelogin() || { crate::platform::is_prelogin()
|| crate::platform::is_locked()
|| {
match crate::platform::is_logon_ui() { match crate::platform::is_logon_ui() {
Ok(result) => result, Ok(result) => result,
Err(e) => { Err(e) => {