adding input monitoring priviledge detect for mac

This commit is contained in:
rustdesk
2023-01-06 12:20:26 +08:00
parent 09435f43df
commit b048e5b280
6 changed files with 67 additions and 3 deletions

View File

@@ -32,6 +32,7 @@ extern "C" {
fn CGEventGetLocation(e: *const c_void) -> CGPoint;
static kAXTrustedCheckOptionPrompt: CFStringRef;
fn AXIsProcessTrustedWithOptions(options: CFDictionaryRef) -> BOOL;
fn InputMonitoringAuthStatus(_: BOOL) -> BOOL;
}
pub fn is_process_trusted(prompt: bool) -> bool {
@@ -47,6 +48,13 @@ pub fn is_process_trusted(prompt: bool) -> bool {
}
}
pub fn is_can_input_monitoring(prompt: bool) -> bool {
unsafe {
let value = if prompt { YES } else { NO };
InputMonitoringAuthStatus(value) == YES
}
}
// macOS >= 10.15
// https://stackoverflow.com/questions/56597221/detecting-screen-recording-settings-on-macos-catalina/
// remove just one app from all the permissions: tccutil reset All com.carriez.rustdesk