prompt foreground window elevation

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2022-09-28 20:48:14 +08:00
parent ae8d97eb72
commit 02aedd234c
30 changed files with 131 additions and 30 deletions

View File

@@ -53,6 +53,7 @@ lazy_static::lazy_static! {
static ref IS_CAPTURER_MAGNIFIER_SUPPORTED: bool = is_capturer_mag_supported();
pub static ref VIDEO_QOS: Arc<Mutex<VideoQoS>> = Default::default();
pub static ref IS_UAC_RUNNING: Arc<Mutex<bool>> = Default::default();
pub static ref IS_FOREGROUND_WINDOW_ELEVATED: Arc<Mutex<bool>> = Default::default();
}
fn is_capturer_mag_supported() -> bool {
@@ -454,7 +455,7 @@ fn run(sp: GenericService) -> ResultType<()> {
#[cfg(any(target_os = "android", target_os = "ios"))]
let recorder: Arc<Mutex<Option<Recorder>>> = Default::default();
#[cfg(windows)]
start_uac_check();
start_uac_elevation_check();
while sp.ok() {
#[cfg(windows)]
@@ -838,15 +839,21 @@ fn get_current_display() -> ResultType<(usize, usize, Display)> {
}
#[cfg(windows)]
fn start_uac_check() {
fn start_uac_elevation_check() {
static START: Once = Once::new();
START.call_once(|| {
if !crate::platform::is_installed() && !crate::platform::is_root() {
if !crate::platform::is_installed()
&& !crate::platform::is_root()
&& !crate::platform::is_elevated(None).map_or(false, |b| b)
{
std::thread::spawn(|| loop {
std::thread::sleep(std::time::Duration::from_secs(1));
if let Ok(uac) = crate::ui::win_privacy::is_process_consent_running() {
*IS_UAC_RUNNING.lock().unwrap() = uac;
}
if let Ok(elevated) = crate::platform::is_foreground_window_elevated() {
*IS_FOREGROUND_WINDOW_ELEVATED.lock().unwrap() = elevated;
}
});
}
});