feat, win10, virtual display, not support message

Signed-off-by: fufesou <shuanglongchen@yeah.ne>
This commit is contained in:
fufesou 2023-11-20 21:44:25 +08:00
parent 3a6f56ebbc
commit 83dbf88ffb
47 changed files with 134 additions and 83 deletions

View File

@ -5,7 +5,7 @@ use std::{
time::Instant, time::Instant,
}; };
use winapi::{ use winapi::{
shared::minwindef::{DWORD, FALSE}, shared::minwindef::{DWORD, FALSE, TRUE},
um::{ um::{
handleapi::CloseHandle, handleapi::CloseHandle,
pdh::{ pdh::{
@ -14,7 +14,12 @@ use winapi::{
PDH_HCOUNTER, PDH_HQUERY, PDH_HCOUNTER, PDH_HQUERY,
}, },
synchapi::{CreateEventA, WaitForSingleObject}, synchapi::{CreateEventA, WaitForSingleObject},
winbase::{INFINITE, WAIT_OBJECT_0}, sysinfoapi::VerSetConditionMask,
winbase::{VerifyVersionInfoW, INFINITE, WAIT_OBJECT_0},
winnt::{
OSVERSIONINFOEXW, VER_BUILDNUMBER, VER_GREATER_EQUAL, VER_MAJORVERSION,
VER_MINORVERSION, VER_SERVICEPACKMAJOR, VER_SERVICEPACKMINOR,
},
}, },
}; };
@ -152,3 +157,43 @@ pub fn sync_cpu_usage(cpu_usage: Option<f64>) {
*CPU_USAGE_ONE_MINUTE.lock().unwrap() = v; *CPU_USAGE_ONE_MINUTE.lock().unwrap() = v;
log::info!("cpu usage synced: {:?}", cpu_usage); log::info!("cpu usage synced: {:?}", cpu_usage);
} }
// https://learn.microsoft.com/en-us/windows/win32/sysinfo/targeting-your-application-at-windows-8-1
// https://github.com/nodejs/node-convergence-archive/blob/e11fe0c2777561827cdb7207d46b0917ef3c42a7/deps/uv/src/win/util.c#L780
pub fn is_windows_version_or_greater(
os_major: u32,
os_minor: u32,
build_number: u32,
service_pack_major: u32,
service_pack_minor: u32,
) -> bool {
let mut osvi: OSVERSIONINFOEXW = unsafe { std::mem::zeroed() };
osvi.dwOSVersionInfoSize = std::mem::size_of::<OSVERSIONINFOEXW>() as DWORD;
osvi.dwMajorVersion = os_major as _;
osvi.dwMinorVersion = os_minor as _;
osvi.dwBuildNumber = build_number as _;
osvi.wServicePackMajor = service_pack_major as _;
osvi.wServicePackMinor = service_pack_minor as _;
let result = unsafe {
let mut condition_mask = 0;
let op = VER_GREATER_EQUAL;
condition_mask = VerSetConditionMask(condition_mask, VER_MAJORVERSION, op);
condition_mask = VerSetConditionMask(condition_mask, VER_MINORVERSION, op);
condition_mask = VerSetConditionMask(condition_mask, VER_BUILDNUMBER, op);
condition_mask = VerSetConditionMask(condition_mask, VER_SERVICEPACKMAJOR, op);
condition_mask = VerSetConditionMask(condition_mask, VER_SERVICEPACKMINOR, op);
VerifyVersionInfoW(
&mut osvi as *mut OSVERSIONINFOEXW,
VER_MAJORVERSION
| VER_MINORVERSION
| VER_BUILDNUMBER
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR,
condition_mask,
)
};
result == TRUE
}

View File

@ -204,7 +204,9 @@ pub fn core_main() -> Option<Vec<String>> {
#[cfg(windows)] #[cfg(windows)]
hbb_common::allow_err!(crate::platform::windows::install_cert(&args[1])); hbb_common::allow_err!(crate::platform::windows::install_cert(&args[1]));
#[cfg(all(windows, feature = "virtual_display_driver"))] #[cfg(all(windows, feature = "virtual_display_driver"))]
hbb_common::allow_err!(crate::virtual_display_manager::install_update_driver()); if crate::virtual_display_manager::is_virtual_display_supported() {
hbb_common::allow_err!(crate::virtual_display_manager::install_update_driver());
}
return None; return None;
} else if args[0] == "--uninstall-cert" { } else if args[0] == "--uninstall-cert" {
#[cfg(windows)] #[cfg(windows)]

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", "模式 2"), ("privacy_mode_impl_virtual_display_tip", "模式 2"),
("Enter privacy mode", "进入隐私模式"), ("Enter privacy mode", "进入隐私模式"),
("Exit privacy mode", "退出隐私模式"), ("Exit privacy mode", "退出隐私模式"),
("idd_not_support_tip", "不支持 Indirect Display Driver 。需要更新的 Windows 10 版本。"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -205,5 +205,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("id_input_tip", "You can input an ID, a direct IP, or a domain with a port (<domain>:<port>).\nIf you want to access a device on another server, please append the server address (<id>@<server_address>?key=<key_value>), for example,\n9123456234@192.168.16.1:21117?key=5Qbwsde3unUcJBtrx9ZkvUmwFNoExHzpryHuPUdqlWM=.\nIf you want to access a device on a public server, please input \"<id>@public\", the key is not needed for public server"), ("id_input_tip", "You can input an ID, a direct IP, or a domain with a port (<domain>:<port>).\nIf you want to access a device on another server, please append the server address (<id>@<server_address>?key=<key_value>), for example,\n9123456234@192.168.16.1:21117?key=5Qbwsde3unUcJBtrx9ZkvUmwFNoExHzpryHuPUdqlWM=.\nIf you want to access a device on a public server, please input \"<id>@public\", the key is not needed for public server"),
("privacy_mode_impl_mag_tip", "Mode 1"), ("privacy_mode_impl_mag_tip", "Mode 1"),
("privacy_mode_impl_virtual_display_tip", "Mode 2"), ("privacy_mode_impl_virtual_display_tip", "Mode 2"),
("idd_not_support_tip", "Indirect Display Driver is not supported. Newer Windows 10 version is required."),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", "Modo 2"), ("privacy_mode_impl_virtual_display_tip", "Modo 2"),
("Enter privacy mode", "Entrar al modo privado"), ("Enter privacy mode", "Entrar al modo privado"),
("Exit privacy mode", "Salir del modo privado"), ("Exit privacy mode", "Salir del modo privado"),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", "Mode 2"), ("privacy_mode_impl_virtual_display_tip", "Mode 2"),
("Enter privacy mode", "Masuk mode privasi"), ("Enter privacy mode", "Masuk mode privasi"),
("Exit privacy mode", "Keluar mode privasi"), ("Exit privacy mode", "Keluar mode privasi"),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", "Modo 2"), ("privacy_mode_impl_virtual_display_tip", "Modo 2"),
("Enter privacy mode", "Entra in modalità privacy"), ("Enter privacy mode", "Entra in modalità privacy"),
("Exit privacy mode", "Esci dalla modalità privacy"), ("Exit privacy mode", "Esci dalla modalità privacy"),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", "모드 2"), ("privacy_mode_impl_virtual_display_tip", "모드 2"),
("Enter privacy mode", "개인정보 보호 모드 사용"), ("Enter privacy mode", "개인정보 보호 모드 사용"),
("Exit privacy mode", "개인정보 보호 모드 종료"), ("Exit privacy mode", "개인정보 보호 모드 종료"),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", "2. režīms"), ("privacy_mode_impl_virtual_display_tip", "2. režīms"),
("Enter privacy mode", "Ieiet privātuma režīmā"), ("Enter privacy mode", "Ieiet privātuma režīmā"),
("Exit privacy mode", "Iziet no privātuma režīma"), ("Exit privacy mode", "Iziet no privātuma režīma"),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -154,15 +154,15 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("config_screen", "For å kunne få adgang til ditt skrivebord med fjernstyring, må du gi Rustdesk \"skjerstøtte \" tillatelser."), ("config_screen", "For å kunne få adgang til ditt skrivebord med fjernstyring, må du gi Rustdesk \"skjerstøtte \" tillatelser."),
("Installing ...", "Installerer ..."), ("Installing ...", "Installerer ..."),
("Install", "installer"), ("Install", "installer"),
("installasjon", "Installasjon"), ("Installation", ""),
("installasjon Path", "Installasjonssti"), ("Installation Path", ""),
("Create start menu shortcuts", "Oppret start meny snarvei"), ("Create start menu shortcuts", "Oppret start meny snarvei"),
("Create desktop icon", "Oppret skrivebords-snarvei"), ("Create desktop icon", "Oppret skrivebords-snarvei"),
("agreement_tip", "Hvis du starter installasjonen, må du akseptere lisensavtalen"), ("agreement_tip", "Hvis du starter installasjonen, må du akseptere lisensavtalen"),
("Accept and Install", "Aksepter og installer"), ("Accept and Install", "Aksepter og installer"),
("End-user license agreement", "Lisensavtale for sluttbrukere"), ("End-user license agreement", "Lisensavtale for sluttbrukere"),
("Generating ...", "Genererer kode ..."), ("Generating ...", "Genererer kode ..."),
("Your installasjon is lower version.", "Din installasjon er en eldre versjon."), ("Your installation is lower version.", ""),
("not_close_tcp_tip", "Ikke lukk dette vinduet, mens du bruker tunnelen."), ("not_close_tcp_tip", "Ikke lukk dette vinduet, mens du bruker tunnelen."),
("Listening ...", "Lytter ..."), ("Listening ...", "Lytter ..."),
("Remote Host", "Fjern-Host"), ("Remote Host", "Fjern-Host"),
@ -532,8 +532,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change Color", ""), ("Change Color", ""),
("Primary Color", ""), ("Primary Color", ""),
("HSV Color", ""), ("HSV Color", ""),
("installasjon Successful!", ""), ("Installation Successful!", ""),
("installasjon failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""), ("Reverse mouse wheel", ""),
("{} sessions", ""), ("{} sessions", ""),
("scam_title", ""), ("scam_title", ""),
@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", "Tryb 2"), ("privacy_mode_impl_virtual_display_tip", "Tryb 2"),
("Enter privacy mode", "Wejdź w tryb prywatności"), ("Enter privacy mode", "Wejdź w tryb prywatności"),
("Exit privacy mode", "Wyjdź z trybu prywatności"), ("Exit privacy mode", "Wyjdź z trybu prywatności"),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", "Режим 2"), ("privacy_mode_impl_virtual_display_tip", "Режим 2"),
("Enter privacy mode", "Включить режим конфиденциальности"), ("Enter privacy mode", "Включить режим конфиденциальности"),
("Exit privacy mode", "Отключить режим конфиденциальности"), ("Exit privacy mode", "Отключить режим конфиденциальности"),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", "Режим 2"), ("privacy_mode_impl_virtual_display_tip", "Режим 2"),
("Enter privacy mode", "Увійти в режим конфіденційності"), ("Enter privacy mode", "Увійти в режим конфіденційності"),
("Exit privacy mode", "Вийти з режиму конфіденційності"), ("Exit privacy mode", "Вийти з режиму конфіденційності"),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -572,5 +572,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("privacy_mode_impl_virtual_display_tip", ""), ("privacy_mode_impl_virtual_display_tip", ""),
("Enter privacy mode", ""), ("Enter privacy mode", ""),
("Exit privacy mode", ""), ("Exit privacy mode", ""),
("idd_not_support_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -634,42 +634,3 @@ extern "C"
freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stdout);
} }
} // end of extern "C" } // end of extern "C"
extern "C"
{
// https://learn.microsoft.com/en-us/windows/win32/sysinfo/targeting-your-application-at-windows-8-1
// https://github.com/nodejs/node-convergence-archive/blob/e11fe0c2777561827cdb7207d46b0917ef3c42a7/deps/uv/src/win/util.c#L780
BOOL IsWindowsVersionOrGreater(DWORD os_major,
DWORD os_minor,
DWORD build_number,
WORD service_pack_major,
WORD service_pack_minor)
{
OSVERSIONINFOEX osvi;
DWORDLONG condition_mask = 0;
int op = VER_GREATER_EQUAL;
/* Initialize the OSVERSIONINFOEX structure. */
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
osvi.dwMajorVersion = os_major;
osvi.dwMinorVersion = os_minor;
osvi.dwBuildNumber = build_number;
osvi.wServicePackMajor = service_pack_major;
osvi.wServicePackMinor = service_pack_minor;
/* Initialize the condition mask. */
VER_SET_CONDITION(condition_mask, VER_MAJORVERSION, op);
VER_SET_CONDITION(condition_mask, VER_MINORVERSION, op);
VER_SET_CONDITION(condition_mask, VER_BUILDNUMBER, op);
VER_SET_CONDITION(condition_mask, VER_SERVICEPACKMAJOR, op);
VER_SET_CONDITION(condition_mask, VER_SERVICEPACKMINOR, op);
/* Perform the test. */
return VerifyVersionInfo(
&osvi,
VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER |
VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
condition_mask);
}
}

View File

@ -460,13 +460,6 @@ extern "C" {
fn is_win_down() -> BOOL; fn is_win_down() -> BOOL;
fn is_local_system() -> BOOL; fn is_local_system() -> BOOL;
fn alloc_console_and_redirect(); fn alloc_console_and_redirect();
fn IsWindowsVersionOrGreater(
os_major: DWORD,
os_minor: DWORD,
build_number: DWORD,
service_pack_major: WORD,
service_pack_minor: WORD,
) -> BOOL;
} }
extern "system" { extern "system" {
@ -1255,25 +1248,6 @@ pub fn block_input(v: bool) -> (bool, String) {
} }
} }
#[inline]
pub fn is_windows_version_or_greater(
os_major: u32,
os_minor: u32,
build_number: u32,
service_pack_major: u32,
service_pack_minor: u32,
) -> bool {
unsafe {
IsWindowsVersionOrGreater(
os_major as _,
os_minor as _,
build_number as _,
service_pack_major as _,
service_pack_minor as _,
) == TRUE
}
}
pub fn add_recent_document(path: &str) { pub fn add_recent_document(path: &str) {
extern "C" { extern "C" {
fn AddRecentDocument(path: *const u16); fn AddRecentDocument(path: *const u16);

View File

@ -1,3 +1,5 @@
use hbb_common::platform::windows::is_windows_version_or_greater;
pub use super::win_topmost_window::PrivacyModeImpl; pub use super::win_topmost_window::PrivacyModeImpl;
pub(super) const PRIVACY_MODE_IMPL: &str = "privacy_mode_impl_exclude_from_capture"; pub(super) const PRIVACY_MODE_IMPL: &str = "privacy_mode_impl_exclude_from_capture";
@ -5,5 +7,5 @@ pub(super) const PRIVACY_MODE_IMPL: &str = "privacy_mode_impl_exclude_from_captu
pub(super) fn is_supported() -> bool { pub(super) fn is_supported() -> bool {
// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowdisplayaffinity // https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowdisplayaffinity
// https://en.wikipedia.org/wiki/Windows_10_version_history // https://en.wikipedia.org/wiki/Windows_10_version_history
crate::platform::windows::is_windows_version_or_greater(10, 0, 19041, 0, 0) is_windows_version_or_greater(10, 0, 19041, 0, 0)
} }

View File

@ -357,6 +357,10 @@ impl PrivacyMode for PrivacyModeImpl {
} }
fn turn_on_privacy(&mut self, conn_id: i32) -> ResultType<bool> { fn turn_on_privacy(&mut self, conn_id: i32) -> ResultType<bool> {
if !virtual_display_manager::is_virtual_display_supported() {
bail!("idd_not_support_tip");
}
if self.check_on_conn_id(conn_id)? { if self.check_on_conn_id(conn_id)? {
log::debug!("Privacy mode of conn {} is already on", conn_id); log::debug!("Privacy mode of conn {} is already on", conn_id);
return Ok(true); return Ok(true);

View File

@ -2371,14 +2371,19 @@ impl Connection {
}; };
if t.on { if t.on {
if let Err(e) = virtual_display_manager::plug_in_index_modes(t.display as _, Vec::new()) if !virtual_display_manager::is_virtual_display_supported() {
{ self.send(make_msg("idd_not_support_tip".to_string())).await;
log::error!("Failed to plug in virtual display: {}", e); } else {
self.send(make_msg(format!( if let Err(e) =
"Failed to plug in virtual display: {}", virtual_display_manager::plug_in_index_modes(t.display as _, Vec::new())
e {
))) log::error!("Failed to plug in virtual display: {}", e);
.await; self.send(make_msg(format!(
"Failed to plug in virtual display: {}",
e
)))
.await;
}
} }
} else { } else {
let indices = if t.display == -1 { let indices = if t.display == -1 {

View File

@ -348,7 +348,10 @@ pub fn try_get_displays() -> ResultType<Vec<Display>> {
#[cfg(all(windows, feature = "virtual_display_driver"))] #[cfg(all(windows, feature = "virtual_display_driver"))]
pub fn try_get_displays() -> ResultType<Vec<Display>> { pub fn try_get_displays() -> ResultType<Vec<Display>> {
let mut displays = Display::all()?; let mut displays = Display::all()?;
if crate::platform::is_installed() && no_displays(&displays) { if crate::platform::is_installed()
&& no_displays(&displays)
&& virtual_display_manager::is_virtual_display_supported()
{
log::debug!("no displays, create virtual display"); log::debug!("no displays, create virtual display");
if let Err(e) = virtual_display_manager::plug_in_headless() { if let Err(e) = virtual_display_manager::plug_in_headless() {
log::error!("plug in headless failed {}", e); log::error!("plug in headless failed {}", e);

View File

@ -1,3 +1,5 @@
#[cfg(target_os = "windows")]
use hbb_common::platform::windows::is_windows_version_or_greater;
use hbb_common::{allow_err, bail, lazy_static, log, ResultType}; use hbb_common::{allow_err, bail, lazy_static, log, ResultType};
use std::{ use std::{
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
@ -53,6 +55,17 @@ impl VirtualDisplayManager {
} }
} }
pub fn is_virtual_display_supported() -> bool {
#[cfg(target_os = "windows")]
{
is_windows_version_or_greater(10, 0, 19041, 0, 0)
}
#[cfg(not(target_os = "windows"))]
{
false
}
}
pub fn install_update_driver() -> ResultType<()> { pub fn install_update_driver() -> ResultType<()> {
VIRTUAL_DISPLAY_MANAGER VIRTUAL_DISPLAY_MANAGER
.lock() .lock()
@ -146,6 +159,10 @@ pub fn plug_in_index_modes(
} }
pub fn reset_all() -> ResultType<()> { pub fn reset_all() -> ResultType<()> {
if is_virtual_display_supported() {
return Ok(());
}
if let Err(e) = plug_out_peer_request(&get_virtual_displays()) { if let Err(e) = plug_out_peer_request(&get_virtual_displays()) {
log::error!("Failed to plug out virtual displays: {}", e); log::error!("Failed to plug out virtual displays: {}", e);
} }