debug, win, privacy mode, broker
Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
		
							parent
							
								
									32c349dd8b
								
							
						
					
					
						commit
						e80da4af0d
					
				| @ -931,23 +931,10 @@ pub mod connection_manager { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     extern "C" fn cm_clear_hook() { |  | ||||||
|         #[cfg(target_os = "windows")] |  | ||||||
|         crate::privacy_win_mag::stop(); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     #[inline] |     #[inline] | ||||||
|     pub fn cm_init() { |     pub fn cm_init() { | ||||||
|         #[cfg(not(any(target_os = "android", target_os = "ios")))] |         #[cfg(not(any(target_os = "android", target_os = "ios")))] | ||||||
|         start_listen_ipc_thread(); |         start_listen_ipc_thread(); | ||||||
|         #[cfg(target_os = "windows")] |  | ||||||
|         shutdown_hooks::add_shutdown_hook(cm_clear_hook); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     #[inline] |  | ||||||
|     pub fn cm_clear() { |  | ||||||
|         #[cfg(target_os = "windows")] |  | ||||||
|         crate::privacy_win_mag::stop(); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     #[cfg(target_os = "android")] |     #[cfg(target_os = "android")] | ||||||
|  | |||||||
| @ -1453,11 +1453,6 @@ pub fn cm_init() { | |||||||
|     crate::flutter::connection_manager::cm_init(); |     crate::flutter::connection_manager::cm_init(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub fn cm_clear() { |  | ||||||
|     #[cfg(not(any(target_os = "android", target_os = "ios")))] |  | ||||||
|     crate::flutter::connection_manager::cm_clear(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /// Start an ipc server for receiving the url scheme.
 | /// Start an ipc server for receiving the url scheme.
 | ||||||
| ///
 | ///
 | ||||||
| /// * Should only be called in the main flutter window.
 | /// * Should only be called in the main flutter window.
 | ||||||
|  | |||||||
| @ -21,7 +21,7 @@ use winapi::{ | |||||||
|         libloaderapi::{GetModuleHandleA, GetModuleHandleExA, GetProcAddress}, |         libloaderapi::{GetModuleHandleA, GetModuleHandleExA, GetProcAddress}, | ||||||
|         memoryapi::{VirtualAllocEx, WriteProcessMemory}, |         memoryapi::{VirtualAllocEx, WriteProcessMemory}, | ||||||
|         processthreadsapi::{ |         processthreadsapi::{ | ||||||
|             CreateProcessAsUserW, GetCurrentThreadId, QueueUserAPC, ResumeThread, |             CreateProcessAsUserW, GetCurrentThreadId, QueueUserAPC, ResumeThread, TerminateProcess, | ||||||
|             PROCESS_INFORMATION, STARTUPINFOW, |             PROCESS_INFORMATION, STARTUPINFOW, | ||||||
|         }, |         }, | ||||||
|         winbase::{WTSGetActiveConsoleSessionId, CREATE_SUSPENDED, DETACHED_PROCESS}, |         winbase::{WTSGetActiveConsoleSessionId, CREATE_SUSPENDED, DETACHED_PROCESS}, | ||||||
| @ -46,7 +46,6 @@ pub const GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS: u32 = 4; | |||||||
| const WM_USER_EXIT_HOOK: u32 = WM_USER + 1; | const WM_USER_EXIT_HOOK: u32 = WM_USER + 1; | ||||||
| 
 | 
 | ||||||
| lazy_static::lazy_static! { | lazy_static::lazy_static! { | ||||||
|     static ref DLL_FOUND: Mutex<bool> = Mutex::new(false); |  | ||||||
|     static ref CONN_ID: Mutex<i32> = Mutex::new(0); |     static ref CONN_ID: Mutex<i32> = Mutex::new(0); | ||||||
|     static ref CUR_HOOK_THREAD_ID: Mutex<DWORD> = Mutex::new(0); |     static ref CUR_HOOK_THREAD_ID: Mutex<DWORD> = Mutex::new(0); | ||||||
|     static ref WND_HANDLERS: Mutex<WindowHandlers> = Mutex::new(WindowHandlers{hthread: 0, hprocess: 0}); |     static ref WND_HANDLERS: Mutex<WindowHandlers> = Mutex::new(WindowHandlers{hthread: 0, hprocess: 0}); | ||||||
| @ -66,16 +65,21 @@ impl Drop for WindowHandlers { | |||||||
| impl WindowHandlers { | impl WindowHandlers { | ||||||
|     fn reset(&mut self) { |     fn reset(&mut self) { | ||||||
|         unsafe { |         unsafe { | ||||||
|  |             if self.hprocess != 0 { | ||||||
|  |                 let _res = TerminateProcess(self.hprocess as _, 0); | ||||||
|  |                 CloseHandle(self.hprocess as _); | ||||||
|  |             } | ||||||
|  |             self.hprocess = 0; | ||||||
|             if self.hthread != 0 { |             if self.hthread != 0 { | ||||||
|                 CloseHandle(self.hthread as _); |                 CloseHandle(self.hthread as _); | ||||||
|             } |             } | ||||||
|             self.hthread = 0; |             self.hthread = 0; | ||||||
|             if self.hprocess != 0 { |  | ||||||
|                 CloseHandle(self.hprocess as _); |  | ||||||
|             } |  | ||||||
|             self.hprocess = 0; |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     fn is_default(&self) -> bool { | ||||||
|  |         self.hthread == 0 && self.hprocess == 0 | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub fn turn_on_privacy(conn_id: i32) -> ResultType<bool> { | pub fn turn_on_privacy(conn_id: i32) -> ResultType<bool> { | ||||||
| @ -91,7 +95,7 @@ pub fn turn_on_privacy(conn_id: i32) -> ResultType<bool> { | |||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if !*DLL_FOUND.lock().unwrap() { |     if WND_HANDLERS.lock().unwrap().is_default() { | ||||||
|         log::info!("turn_on_privacy, dll not found when started, try start"); |         log::info!("turn_on_privacy, dll not found when started, try start"); | ||||||
|         start()?; |         start()?; | ||||||
|         std::thread::sleep(std::time::Duration::from_millis(1_000)); |         std::thread::sleep(std::time::Duration::from_millis(1_000)); | ||||||
| @ -162,8 +166,6 @@ pub fn start() -> ResultType<()> { | |||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     *DLL_FOUND.lock().unwrap() = true; |  | ||||||
| 
 |  | ||||||
|     let hwnd = wait_find_privacy_hwnd(1_000)?; |     let hwnd = wait_find_privacy_hwnd(1_000)?; | ||||||
|     if !hwnd.is_null() { |     if !hwnd.is_null() { | ||||||
|         log::info!("Privacy window is ready"); |         log::info!("Privacy window is ready"); | ||||||
| @ -263,6 +265,7 @@ pub fn start() -> ResultType<()> { | |||||||
|     Ok(()) |     Ok(()) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #[inline] | ||||||
| pub fn stop() { | pub fn stop() { | ||||||
|     WND_HANDLERS.lock().unwrap().reset(); |     WND_HANDLERS.lock().unwrap().reset(); | ||||||
| } | } | ||||||
|  | |||||||
| @ -2559,6 +2559,10 @@ mod raii { | |||||||
|             if active_conns_lock.is_empty() { |             if active_conns_lock.is_empty() { | ||||||
|                 video_service::try_plug_out_virtual_display(); |                 video_service::try_plug_out_virtual_display(); | ||||||
|             } |             } | ||||||
|  |             #[cfg(all(windows))] | ||||||
|  |             if active_conns_lock.is_empty() { | ||||||
|  |                 crate::privacy_win_mag::stop(); | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user