diff --git a/src/platform/windows.rs b/src/platform/windows.rs index 6e48c8e7f..b3aec8d83 100644 --- a/src/platform/windows.rs +++ b/src/platform/windows.rs @@ -41,7 +41,7 @@ use winapi::{ um::{ errhandlingapi::GetLastError, handleapi::CloseHandle, - libloaderapi::{GetProcAddress, LoadLibraryExA, LOAD_LIBRARY_SEARCH_SYSTEM32}, + libloaderapi::{GetProcAddress, LoadLibraryA, LoadLibraryExA, LOAD_LIBRARY_SEARCH_SYSTEM32}, minwinbase::STILL_ACTIVE, processthreadsapi::{ GetCurrentProcess, GetCurrentProcessId, GetExitCodeProcess, OpenProcess, @@ -1351,7 +1351,7 @@ copy /Y \"{tmp_path}\\Uninstall {app_name}.lnk\" \"{start_menu}\\\" ); reg_value_start_menu_shortcuts = "1".to_owned(); } - let install_printer = options.contains("printer") && crate::platform::is_win_10_or_greater(); + let install_printer = options.contains("printer") && is_win_10_or_greater(); if install_printer { reg_value_printer = "1".to_owned(); } @@ -1394,7 +1394,7 @@ copy /Y \"{tmp_path}\\{app_name} Tray.lnk\" \"%PROGRAMDATA%\\Microsoft\\Windows\ // No need to use `|| true` here. // The script will not exit even if `--install-remote-printer` panics. format!("\"{}\" --install-remote-printer", &src_exe) - } else if crate::platform::is_win_10_or_greater() { + } else if is_win_10_or_greater() { format!("\"{}\" --uninstall-remote-printer", &src_exe) } else { "".to_owned() @@ -1715,7 +1715,12 @@ pub fn bootstrap() -> bool { #[cfg(not(debug_assertions))] { // This function will cause `'sciter.dll' was not found neither in PATH nor near the current executable.` when debugging RustDesk. - set_safe_load_dll() + // Only call set_safe_load_dll() on Windows 10 or greater + if is_win_10_or_greater() { + set_safe_load_dll() + } else { + true + } } } @@ -2896,11 +2901,15 @@ pub fn try_kill_rustdesk_main_window_process() -> ResultType<()> { fn nt_terminate_process(process_id: DWORD) -> ResultType<()> { type NtTerminateProcess = unsafe extern "system" fn(HANDLE, DWORD) -> DWORD; unsafe { - let h_module = LoadLibraryExA( - CString::new("ntdll.dll")?.as_ptr(), - std::ptr::null_mut(), - LOAD_LIBRARY_SEARCH_SYSTEM32, - ); + let h_module = if is_win_10_or_greater() { + LoadLibraryExA( + CString::new("ntdll.dll")?.as_ptr(), + std::ptr::null_mut(), + LOAD_LIBRARY_SEARCH_SYSTEM32, + ) + } else { + LoadLibraryA(CString::new("ntdll.dll")?.as_ptr()) + }; if !h_module.is_null() { let f_nt_terminate_process: NtTerminateProcess = std::mem::transmute(GetProcAddress( h_module,