fix, win privacy mode, broker process

Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
dignow 2023-07-08 15:26:24 +08:00
parent 84d7115e36
commit 1648895156
7 changed files with 33 additions and 2 deletions

View File

@ -40,6 +40,7 @@ class _DesktopServerPageState extends State<DesktopServerPage>
@override
void dispose() {
bind.cmClear();
windowManager.removeListener(this);
super.dispose();
}

View File

@ -931,6 +931,11 @@ pub mod connection_manager {
}
}
#[cfg(target_os = "windows")]
pub fn cm_clear() {
crate::privacy_win_mag::stop();
}
#[cfg(target_os = "android")]
use hbb_common::tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};

View File

@ -1453,6 +1453,11 @@ pub fn cm_start_listen_ipc_thread() {
crate::flutter::connection_manager::start_listen_ipc_thread();
}
pub fn cm_clear() {
#[cfg(target_os = "windows")]
crate::flutter::connection_manager::cm_clear();
}
/// Start an ipc server for receiving the url scheme.
///
/// * Should only be called in the main flutter window.

View File

@ -2273,6 +2273,15 @@ fn run_after_run_cmds(silent: bool) {
std::thread::sleep(std::time::Duration::from_millis(300));
}
#[inline]
pub fn try_kill_broker() {
allow_err!(run_cmds(
format!("taskkill /F /IM {}", WIN_MAG_INJECTED_PROCESS_EXE),
false,
"kill_broker"
));
}
#[cfg(test)]
mod tests {
use super::*;

View File

@ -59,6 +59,12 @@ struct WindowHandlers {
impl Drop for WindowHandlers {
fn drop(&mut self) {
self.reset();
}
}
impl WindowHandlers {
fn reset(&mut self) {
unsafe {
if self.hthread != 0 {
CloseHandle(self.hthread as _);
@ -257,6 +263,10 @@ pub fn start() -> ResultType<()> {
Ok(())
}
pub fn stop() {
WND_HANDLERS.lock().unwrap().reset();
}
unsafe fn inject_dll<'a>(hproc: HANDLE, hthread: HANDLE, dll_file: &'a str) -> ResultType<()> {
let dll_file_utf16: Vec<u16> = dll_file.encode_utf16().chain(Some(0).into_iter()).collect();

View File

@ -303,7 +303,7 @@ impl Server {
// get a new unique id
pub fn get_new_id(&mut self) -> i32 {
self.id_count += 1;
self.id_count
self.id_count
}
}
@ -389,6 +389,8 @@ pub async fn start_server(is_server: bool) {
}
#[cfg(any(target_os = "macos", target_os = "linux"))]
tokio::spawn(async { sync_and_watch_config_dir().await });
#[cfg(target_os = "windows")]
crate::platform::try_kill_broker();
crate::RendezvousMediator::start_all().await;
} else {
match crate::ipc::connect(1000, "").await {

View File

@ -533,7 +533,6 @@ pub async fn start_ipc<T: InvokeUiCM>(cm: ConnectionManager<T>) {
e
);
}
allow_err!(crate::privacy_win_mag::start());
});
#[cfg(target_os = "windows")]