Skip to content

A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.

Open/Save dialog stays out of the Windows shell's own processes (977)

gelenmedyad634440ce66a
diff --git a/crates/rf-dialog/src/lib.rs b/crates/rf-dialog/src/lib.rs
index 2bcc1901..f8a76060 100644
--- a/crates/rf-dialog/src/lib.rs
+++ b/crates/rf-dialog/src/lib.rs
@@ -935,6 +935,17 @@ mod com {
}
}
+ /// Issue 977: the shell's own processes are left to Windows' dialog, whatever the case of the name; other apps are not.
+ #[test]
+ fn the_shell_gets_windows_own_class() {
+ for exe in ["explorer.exe", "EXPLORER.EXE", "sihost.exe", "StartMenuExperienceHost.exe", "SearchHost.exe"] {
+ assert!(is_shell(exe), "{exe}");
+ }
+ for exe in ["notepad.exe", "chrome.exe", "WhatsApp.Root.exe", "rustyfiles.exe", "explorer.exe.bak", ""] {
+ assert!(!is_shell(exe), "{exe}");
+ }
+ }
+
/// Issue 625: with a DLP agent's hook module in the app, the app gets Windows' class factory itself.
#[test]
fn a_process_with_a_hook_module_gets_windows_own_class() {
@@ -1121,6 +1132,29 @@ mod com {
/// registered, and started normally without (issue 625).
const HOOKED_BY: [PCWSTR; 2] = [w!("SecurityEv_x64.dll"), w!("SecurityEv.dll")];
+ /// Windows' own shell processes: they get Windows' class straight from comdlg32.dll, so none of our code runs in them. With the
+ /// dialog registered, explorer.exe and sihost.exe crashed again and again on one PC from 1.0.7 on, which took down the Start menu, the
+ /// taskbar and packaged apps; with only the dialog turned off they ran normally (issue 977). The shell has no Open / Save dialog a
+ /// user would want rustyfiles in, so it is never wrapped there.
+ const SHELL: [&str; 12] = [
+ "explorer.exe",
+ "sihost.exe",
+ "ShellExperienceHost.exe",
+ "StartMenuExperienceHost.exe",
+ "ShellHost.exe",
+ "SearchHost.exe",
+ "SearchApp.exe",
+ "TextInputHost.exe",
+ "ApplicationFrameHost.exe",
+ "RuntimeBroker.exe",
+ "LockApp.exe",
+ "taskhostw.exe",
+ ];
+
+ fn is_shell(exe: &str) -> bool {
+ SHELL.iter().any(|s| exe.eq_ignore_ascii_case(s))
+ }
+
/// The first of [`HOOKED_BY`] loaded in this process.
fn hooked_by() -> Option<String> {
HOOKED_BY.iter().find(|m| unsafe { GetModuleHandleW(**m) }.is_ok()).map(|m| wstr(m))
@@ -1180,6 +1214,12 @@ mod com {
c if c == FileSaveDialog => true,
_ => return CLASS_E_CLASSNOTAVAILABLE,
};
+ if is_shell(&exe_name()) {
+ return match comdlg32_class_object() {
+ Ok(f) => unsafe { f(clsid, iid, out) },
+ Err(e) => e.code(),
+ };
+ }
if let Some(m) = hooked_by() {
crate::log(&format!("create: {m} is loaded, Windows' dialog class"));
return match comdlg32_class_object() {