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;
}
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 nout = 0;

View File

@@ -527,6 +527,7 @@ const SERVICE_TYPE: ServiceType = ServiceType::OWN_PROCESS;
extern "C" {
fn get_current_session(rdp: BOOL) -> DWORD;
fn is_session_locked(include_rdp: BOOL) -> BOOL;
fn LaunchProcessWin(
cmd: *const u16,
session_id: DWORD,
@@ -1129,6 +1130,10 @@ pub fn is_prelogin() -> bool {
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.
// It only check if "LogonUI.exe" exists.
//