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.

Probe of Photos' trust warning on downloaded pictures; findings noted

gelenmedyad0ea8af706ba
diff --git a/crates/rf-win/examples/photos_motw.rs b/crates/rf-win/examples/photos_motw.rs
new file mode 100644
index 00000000..a9a4e99c
--- /dev/null
+++ b/crates/rf-win/examples/photos_motw.rs
@@ -0,0 +1,121 @@
+//! Which way of opening a downloaded picture makes Photos ask "Is this file from a trusted source?" (Discord, 2026-11-30):
+//! `photos_motw <file> launcher|explicit|activate|activate_all [wait ms] [secure]`.
+//!
+//! - `launcher`: what a double-click does (WinRT's launcher, the folder as the neighbouring files); the process waits `wait ms` (3000)
+//! after the launch and ends. `explicit`: the same with `TreatAsUntrusted` set to false by hand (it already is: no change).
+//! - `secure` (5th argument): before anything, `CoInitializeSecurity` lets interactive users, SYSTEM and packaged apps call this
+//! process's objects.
+//! - `activate` / `activate_all`: the shell's activation of Photos for the file / the whole folder.
+//!
+//! FOUND (2026-12-02, Photos 2025 on Windows 11 26H2, a picture marked ZoneId=3, read through UI Automation):
+//! - the warning shows when the launching process has ended before Photos looks at the file: 0, 150 and 300 ms after the launch it
+//! shows; 500 ms and later it does not. The app's helper (`--open-with-folder`) ends at once, so it is the one that shows it.
+//! - while the launching process lives, Photos' film strip has the one picture (the query finds all 13 here, Photos cannot use it);
+//! `secure` does not change that. So no wait gives both: neighbours need the launcher gone, trust needs it alive.
+//! - `activate`: 0x80270254 (Photos is a packaged desktop app now; it has no file contract to activate).
+use windows_collections::IIterable;
+use windows::Storage::Search::{FolderDepth, QueryOptions};
+use windows::Storage::{StorageFile, StorageFolder};
+use windows::System::{Launcher, LauncherOptions};
+use windows::core::HSTRING;
+
+fn main() -> anyhow::Result<()> {
+ let file = std::path::PathBuf::from(std::env::args().nth(1).expect("file"));
+ let mode = std::env::args().nth(2).unwrap_or_else(|| "launcher".into());
+ unsafe { windows::Win32::System::Com::CoInitializeEx(None, windows::Win32::System::Com::COINIT_MULTITHREADED).ok()? };
+ // `secure`: before anything is marshalled, this process lets the signed-in user's processes, packaged apps (AppContainer) and
+ // SYSTEM call its objects: Photos can then read the neighbouring files query while this process is alive
+ if std::env::args().nth(4).as_deref() == Some("secure") {
+ use windows::Win32::Security::Authorization::{ConvertStringSecurityDescriptorToSecurityDescriptorW, SDDL_REVISION_1};
+ use windows::Win32::Security::PSECURITY_DESCRIPTOR;
+ use windows::Win32::System::Com::{CoInitializeSecurity, EOAC_NONE, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IDENTIFY};
+ let mut sd = PSECURITY_DESCRIPTOR::default();
+ unsafe {
+ ConvertStringSecurityDescriptorToSecurityDescriptorW(
+ windows::core::w!("O:BAG:BAD:(A;;0x3;;;IU)(A;;0x3;;;SY)(A;;0x3;;;BA)(A;;0x3;;;AC)(A;;0x3;;;S-1-15-2-2)"),
+ SDDL_REVISION_1,
+ &mut sd,
+ None,
+ )?;
+ // (COM takes the absolute form: the parts of the self-relative one, pointed at from a new descriptor; both live on)
+ use windows::Win32::Security::{GetSecurityDescriptorDacl, GetSecurityDescriptorGroup, GetSecurityDescriptorOwner, InitializeSecurityDescriptor, SECURITY_DESCRIPTOR, SetSecurityDescriptorDacl, SetSecurityDescriptorGroup, SetSecurityDescriptorOwner, ACL, PSID};
+ let (mut present, mut defaulted) = (windows::core::BOOL(0), windows::core::BOOL(0));
+ let mut dacl: *mut ACL = std::ptr::null_mut();
+ GetSecurityDescriptorDacl(sd, &mut present, &mut dacl, &mut defaulted)?;
+ let (mut owner, mut group) = (PSID::default(), PSID::default());
+ GetSecurityDescriptorOwner(sd, &mut owner, &mut defaulted)?;
+ GetSecurityDescriptorGroup(sd, &mut group, &mut defaulted)?;
+ let abs: &'static mut SECURITY_DESCRIPTOR = Box::leak(Box::new(SECURITY_DESCRIPTOR::default()));
+ let pabs = PSECURITY_DESCRIPTOR(abs as *mut _ as *mut _);
+ InitializeSecurityDescriptor(pabs, 1)?;
+ SetSecurityDescriptorDacl(pabs, true, Some(dacl), false)?;
+ SetSecurityDescriptorOwner(pabs, Some(owner), false)?;
+ SetSecurityDescriptorGroup(pabs, Some(group), false)?;
+ let r = CoInitializeSecurity(Some(pabs), -1, None, None, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IDENTIFY, None, EOAC_NONE, None);
+ println!("CoInitializeSecurity: {r:?}");
+ }
+ }
+ match mode.as_str() {
+ "launcher" | "explicit" => {
+ let dir = file.parent().unwrap();
+ let f = StorageFile::GetFileFromPathAsync(&HSTRING::from(file.as_os_str()))?.join()?;
+ let folder = StorageFolder::GetFolderFromPathAsync(&HSTRING::from(dir.as_os_str()))?.join()?;
+ let no_filter: IIterable<HSTRING> = Vec::<HSTRING>::new().into();
+ let options = QueryOptions::CreateCommonFileQuery(windows::Storage::Search::CommonFileQuery::DefaultQuery, &no_filter)?;
+ options.SetFolderDepth(FolderDepth::Shallow)?;
+ let query = folder.CreateFileQueryWithOptions(&options)?;
+ println!("the query finds {} file(s) here", query.GetItemCountAsync()?.join()?);
+ let launch = LauncherOptions::new()?;
+ launch.SetNeighboringFilesQuery(&query)?;
+ println!("TreatAsUntrusted before: {:?}", launch.TreatAsUntrusted());
+ if mode == "explicit" {
+ launch.SetTreatAsUntrusted(false)?;
+ }
+ println!("launched: {:?}", Launcher::LaunchFileWithOptionsAsync(&f, &launch)?.join());
+ let wait: u64 = std::env::args().nth(3).and_then(|s| s.parse().ok()).unwrap_or(3000);
+ std::thread::sleep(std::time::Duration::from_millis(wait));
+ }
+ "activate" => {
+ use windows::Win32::System::Com::{CLSCTX_LOCAL_SERVER, CoCreateInstance};
+ use windows::Win32::UI::Shell::{ApplicationActivationManager, IApplicationActivationManager, SHCreateItemFromParsingName, SHCreateShellItemArrayFromShellItem, IShellItem};
+ let w: Vec<u16> = file.as_os_str().encode_wide_z();
+ let item: IShellItem = unsafe { SHCreateItemFromParsingName(windows::core::PCWSTR(w.as_ptr()), None)? };
+ let arr: windows::Win32::UI::Shell::IShellItemArray = unsafe { SHCreateShellItemArrayFromShellItem(&item)? };
+ let m: IApplicationActivationManager = unsafe { CoCreateInstance(&ApplicationActivationManager, None, CLSCTX_LOCAL_SERVER)? };
+ let pid = unsafe { m.ActivateForFile(windows::core::w!("Microsoft.Windows.Photos_8wekyb3d8bbwe!App"), &arr, windows::core::w!("open"))? };
+ println!("activated: pid {pid}");
+ }
+ "activate_all" => {
+ // the shell's activation with every file of the folder, the clicked one first
+ use windows::Win32::System::Com::{CLSCTX_LOCAL_SERVER, CoCreateInstance};
+ use windows::Win32::UI::Shell::{ApplicationActivationManager, IApplicationActivationManager, SHCreateShellItemArrayFromIDLists, SHParseDisplayName};
+ use windows::Win32::UI::Shell::Common::ITEMIDLIST;
+ let mut files: Vec<std::path::PathBuf> = std::fs::read_dir(file.parent().unwrap())?.flatten().map(|e| e.path()).filter(|p| p.is_file() && p != &file).collect();
+ files.sort();
+ files.insert(0, file.clone());
+ let mut pidls: Vec<*const ITEMIDLIST> = Vec::new();
+ for f in &files {
+ let w = f.as_os_str().encode_wide_z();
+ let mut pidl: *mut ITEMIDLIST = std::ptr::null_mut();
+ unsafe { SHParseDisplayName(windows::core::PCWSTR(w.as_ptr()), None, &mut pidl, 0, None)? };
+ pidls.push(pidl);
+ }
+ let arr = unsafe { SHCreateShellItemArrayFromIDLists(&pidls)? };
+ let m: IApplicationActivationManager = unsafe { CoCreateInstance(&ApplicationActivationManager, None, CLSCTX_LOCAL_SERVER)? };
+ let pid = unsafe { m.ActivateForFile(windows::core::w!("Microsoft.Windows.Photos_8wekyb3d8bbwe!App"), &arr, windows::core::w!("open"))? };
+ println!("activated {} files: pid {pid}", files.len());
+ }
+ other => anyhow::bail!("unknown mode {other}"),
+ }
+ Ok(())
+}
+
+trait WideZ {
+ fn encode_wide_z(&self) -> Vec<u16>;
+}
+impl WideZ for std::ffi::OsStr {
+ fn encode_wide_z(&self) -> Vec<u16> {
+ use std::os::windows::ffi::OsStrExt;
+ self.encode_wide().chain(std::iter::once(0)).collect()
+ }
+}
diff --git a/crates/rf-win/src/neighbours.rs b/crates/rf-win/src/neighbours.rs
index 60b34386..e20eb337 100644
--- a/crates/rf-win/src/neighbours.rs
+++ b/crates/rf-win/src/neighbours.rs
@@ -74,6 +74,11 @@ pub const ARG: &str = "--open-with-folder";
/// made it is gone, Photos lists the folder itself, and all the pictures are there (three of three, from a probe that ended 0.1 s
/// after the launch). Explorer's own process lets Photos in; ours does not, and opening COM's door for every packaged app in the
/// whole file manager is a bigger change than this. So a copy of the program is started for the launch and ends after it.
+///
+/// THE PRICE (Discord, 2026-11-30; measured 2026-12-02 with `examples/photos_motw.rs`): a picture with a mark of the web (downloaded)
+/// makes Photos ask "Is this file from a trusted source?" when the process that launched it has already ended (up to ~300 ms after
+/// the launch); alive at 500 ms it does not ask, but then the strip has the one picture again. No wait gives both, and letting
+/// packaged apps call the helper (`CoInitializeSecurity`) does not make the query readable. Open with › Photos does not ask.
pub fn launch(path: &Path, property: &str, ascending: bool) -> anyhow::Result<()> {
use std::os::windows::process::CommandExt;
let exe = std::env::current_exe()?;