From 739d5d0a7440d6d7b65f700e838c7a669067bdc5 Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Wed, 21 Oct 2026 23:12:15 -0400 Subject: [PATCH 1/7] Windows: start without prntvpt.dll; delay-load it for printing (#8272) craft-print's Windows backend sets printer options through winprint's Print Ticket calls (PTOpenProvider, PTGetPrintCapabilities, PTMergeAndValidatePrintTicket, PTConvertPrintTicketToDevMode), so photocraft.exe and photocraft-cli.exe imported prntvpt.dll at load time. Stripped Windows images without it refused to start, the same way they did for Windows.Data.Pdf.dll before #5884. Both apps now delay-load prntvpt.dll. file.print through the Windows spooler checks it loads (as well as Windows.Data.Pdf.dll) and reports an error instead of aborting; file.printers falls back to the GDI printer list without it. A new apps/photocraft test reads the built exe's PE import tables and asserts both DLLs are delay-loaded. Co-Authored-By: Claude Opus 5.5 --- apps/photocraft-cli/build.rs | 10 ++- apps/photocraft/build.rs | 10 ++- apps/photocraft/tests/windows_delay_loads.rs | 82 ++++++++++++++++++++ crates/engine/src/print_cmds.rs | 52 ++++++++++--- crates/engine/src/print_cmds/tests.rs | 27 ++++--- 5 files changed, 150 insertions(+), 31 deletions(-) create mode 100644 apps/photocraft/tests/windows_delay_loads.rs diff --git a/apps/photocraft-cli/build.rs b/apps/photocraft-cli/build.rs index 3951c46b810..f911223974f 100644 --- a/apps/photocraft-cli/build.rs +++ b/apps/photocraft-cli/build.rs @@ -12,12 +12,14 @@ fn main() -> std::io::Result<()> { if std::env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("windows") { return Ok(()); } - // Printing to PDF (winprint's `PdfCreateRenderer`) imports Windows.Data.Pdf.dll, which - // stripped Windows images (NTLite, some N/LTSC builds) lack. A load-time import stops the exe - // from starting at all ("windows.data.pdf.dll was not found", #5884), so load it on first use; - // the print command checks for it first and reports an error instead. + // Printing to PDF (winprint's `PdfCreateRenderer`) imports Windows.Data.Pdf.dll, and its + // printer options (the Print Ticket API) import prntvpt.dll; stripped Windows images (NTLite, + // some N/LTSC builds) lack them. A load-time import stops the exe from starting at all + // ("windows.data.pdf.dll was not found", #5884; "prntvpt.dll", #8272), so load them on first + // use; the print commands check for them first and report an error instead. if std::env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("msvc") { println!("cargo:rustc-link-arg-bins=/DELAYLOAD:windows.data.pdf.dll"); + println!("cargo:rustc-link-arg-bins=/DELAYLOAD:prntvpt.dll"); println!("cargo:rustc-link-arg-bins=delayimp.lib"); } let mut res = winresource::WindowsResource::new(); diff --git a/apps/photocraft/build.rs b/apps/photocraft/build.rs index 48abc9f1a51..70a14b833ee 100644 --- a/apps/photocraft/build.rs +++ b/apps/photocraft/build.rs @@ -11,12 +11,14 @@ fn main() { if std::env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("windows") { return; } - // Printing to PDF (winprint's `PdfCreateRenderer`) imports Windows.Data.Pdf.dll, which - // stripped Windows images (NTLite, some N/LTSC builds) lack. A load-time import stops the exe - // from starting at all ("windows.data.pdf.dll was not found", #5884), so load it on first use; - // the print command checks for it first and reports an error instead. + // Printing to PDF (winprint's `PdfCreateRenderer`) imports Windows.Data.Pdf.dll, and its + // printer options (the Print Ticket API) import prntvpt.dll; stripped Windows images (NTLite, + // some N/LTSC builds) lack them. A load-time import stops the exe from starting at all + // ("windows.data.pdf.dll was not found", #5884; "prntvpt.dll", #8272), so load them on first + // use; the print commands check for them first and report an error instead. if std::env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("msvc") { println!("cargo:rustc-link-arg-bins=/DELAYLOAD:windows.data.pdf.dll"); + println!("cargo:rustc-link-arg-bins=/DELAYLOAD:prntvpt.dll"); println!("cargo:rustc-link-arg-bins=delayimp.lib"); } let mut res = winresource::WindowsResource::new(); diff --git a/apps/photocraft/tests/windows_delay_loads.rs b/apps/photocraft/tests/windows_delay_loads.rs new file mode 100644 index 00000000000..737ddb5eb1c --- /dev/null +++ b/apps/photocraft/tests/windows_delay_loads.rs @@ -0,0 +1,82 @@ +//! Print-only Windows components must not be load-time imports of `photocraft.exe`: stripped +//! Windows images (NTLite, some N/LTSC builds) lack them, and a load-time import stops the app +//! from starting at all (#5884 Windows.Data.Pdf.dll, #8272 prntvpt.dll). `build.rs` delay-loads +//! them; this reads the built exe's PE import tables to prove it. +#![cfg(all(target_os = "windows", target_env = "msvc"))] + +/// Loaded on first use by the print commands, which check them first. +const PRINT_ONLY: [&str; 2] = ["windows.data.pdf.dll", "prntvpt.dll"]; + +#[test] +fn print_only_system_dlls_are_delay_loaded() { + let exe = std::fs::read(env!("CARGO_BIN_EXE_photocraft")).unwrap(); + let pe = Pe::parse(&exe); + let imports = pe.dll_names(1, 20, 12); + let delayed = pe.dll_names(13, 32, 4); + assert!(imports.iter().any(|d| d == "kernel32.dll"), "the import table parses: {imports:?}"); + for dll in PRINT_ONLY { + assert!(!imports.iter().any(|d| d == dll), "{dll} is a load-time import: {imports:?}"); + assert!(delayed.iter().any(|d| d == dll), "{dll} is not delay-loaded: {delayed:?}"); + } +} + +/// Just enough of a PE32+ image to list the DLLs its import directories name. +struct Pe<'a> { + bytes: &'a [u8], + /// Virtual address, virtual size, file offset of each section. + sections: Vec<(u32, u32, u32)>, + /// Offset of the optional header's data directories. + directories: usize, +} + +impl<'a> Pe<'a> { + fn parse(bytes: &'a [u8]) -> Self { + let pe = u32_at(bytes, 0x3c) as usize; + assert_eq!(&bytes[pe..pe + 4], b"PE\0\0"); + let coff = pe + 4; + let sections = u16_at(bytes, coff + 2) as usize; + let optional = coff + 20; + let optional_size = u16_at(bytes, coff + 16) as usize; + assert_eq!(u16_at(bytes, optional), 0x20b, "a PE32+ image"); + let table = optional + optional_size; + let sections = (0..sections) + .map(|i| { + let s = table + i * 40; + (u32_at(bytes, s + 12), u32_at(bytes, s + 8), u32_at(bytes, s + 20)) + }) + .collect(); + Pe { bytes, sections, directories: optional + 112 } + } + + fn offset(&self, rva: u32) -> usize { + let &(va, _, raw) = self.sections.iter().find(|&&(va, size, _)| rva >= va && rva < va + size).unwrap(); + (rva - va + raw) as usize + } + + /// The DLL names of data directory `index`: an array of `entry`-byte descriptors, ended by an + /// all-zero one, with the name's RVA at `name_at`. + fn dll_names(&self, index: usize, entry: usize, name_at: usize) -> Vec { + let rva = u32_at(self.bytes, self.directories + index * 8); + if rva == 0 { + return Vec::new(); + } + let start = self.offset(rva); + (0..) + .map(|i| start + i * entry) + .take_while(|&d| self.bytes[d..d + entry].iter().any(|&b| b != 0)) + .map(|d| { + let name = self.offset(u32_at(self.bytes, d + name_at)); + let end = name + self.bytes[name..].iter().position(|&b| b == 0).unwrap(); + String::from_utf8_lossy(&self.bytes[name..end]).to_ascii_lowercase() + }) + .collect() + } +} + +fn u16_at(b: &[u8], at: usize) -> u16 { + u16::from_le_bytes([b[at], b[at + 1]]) +} + +fn u32_at(b: &[u8], at: usize) -> u32 { + u32::from_le_bytes([b[at], b[at + 1], b[at + 2], b[at + 3]]) +} diff --git a/crates/engine/src/print_cmds.rs b/crates/engine/src/print_cmds.rs index 9b264f0611d..bebc12e6241 100644 --- a/crates/engine/src/print_cmds.rs +++ b/crates/engine/src/print_cmds.rs @@ -193,9 +193,15 @@ fn cups_spool(job: &PrintJob) -> std::result::Result { fn system_printers(_s: &mut Session, p: &Value) -> Result { let named = p.get("printServer").and_then(Value::as_str).filter(|v| !v.is_empty()); if named.is_none() && system_spooler().is_some() { - let list = craft_print::printers(); - let default = list.iter().find(|p| p.default).map(|p| p.name.clone()); - let printers: Vec = list.into_iter().map(|p| json!({"name": p.name, "default": p.default})).collect(); + // craft-print asks each Windows driver about two-sided printing through prntvpt.dll; + // without it, list the spooler's printers through GDI instead (#8272). + let list: Vec<(String, bool)> = if require_print_tickets().is_ok() { + craft_print::printers().into_iter().map(|p| (p.name, p.default)).collect() + } else { + craft_print::rgb::printers().map_err(other)?.into_iter().map(|p| (p.name, p.default)).collect() + }; + let default = list.iter().find(|p| p.1).map(|p| p.0.clone()); + let printers: Vec = list.into_iter().map(|(name, default)| json!({"name": name, "default": default})).collect(); return Ok(json!({"server": Value::Null, "default": default, "printers": printers})); } #[cfg(all(not(target_arch = "wasm32"), not(target_os = "windows")))] @@ -646,31 +652,55 @@ fn render_and_spool(doc: &Document, p: &Value, cmd: &str, spooler: Option<&Spool ) } -/// Windows prints a PDF through Windows.Data.Pdf.dll, which the apps delay-load (see their -/// `build.rs`) so a Windows image without it still starts. Calling into it when it cannot load -/// would abort the process, so check that it loads first (#5884). +/// Windows prints a PDF through Windows.Data.Pdf.dll and sets its options through the Print +/// Ticket API in prntvpt.dll, which the apps delay-load (see their `build.rs`) so a Windows image +/// without them still starts. Calling into one that cannot load would abort the process, so check +/// that both load first (#5884, #8272). fn require_windows_pdf() -> Result<()> { #[cfg(target_os = "windows")] { - let root = std::env::var_os("SystemRoot").unwrap_or_else(|| std::ffi::OsString::from(r"C:\Windows")); - if !windows_pdf_loads(&windows_pdf_dll(std::path::Path::new(&root))) { + if !system_dll_loads(WINDOWS_PDF_DLL) { return Err(other( "printing this page needs the Windows PDF component (Windows.Data.Pdf.dll), which is missing or cannot load. Save as PDF and print it from another app, or print an RGB image without page text or labels to print directly.", )); } + require_print_tickets()?; + } + Ok(()) +} + +/// `craft-print` reads and sets Windows printer options through prntvpt.dll (the Print Ticket +/// API), which stripped Windows images can lack; the apps delay-load it (#8272). +fn require_print_tickets() -> Result<()> { + #[cfg(target_os = "windows")] + if !system_dll_loads(PRINT_TICKET_DLL) { + return Err(other( + "printing this page needs the Windows Print Ticket component (prntvpt.dll), which is missing or cannot load. Save as PDF and print it from another app, or print an RGB image without page text or labels to print directly.", + )); } Ok(()) } #[cfg(target_os = "windows")] -fn windows_pdf_dll(system_root: &std::path::Path) -> std::path::PathBuf { - system_root.join("System32").join("Windows.Data.Pdf.dll") +const WINDOWS_PDF_DLL: &str = "Windows.Data.Pdf.dll"; +#[cfg(target_os = "windows")] +const PRINT_TICKET_DLL: &str = "prntvpt.dll"; + +#[cfg(target_os = "windows")] +fn system_dll_loads(name: &str) -> bool { + let root = std::env::var_os("SystemRoot").unwrap_or_else(|| std::ffi::OsString::from(r"C:\Windows")); + dll_loads(&system_dll(std::path::Path::new(&root), name)) +} + +#[cfg(target_os = "windows")] +fn system_dll(system_root: &std::path::Path, name: &str) -> std::path::PathBuf { + system_root.join("System32").join(name) } /// Loads the DLL rather than checking the file exists: one that is present but cannot load (a /// dependency stripped too) would still abort at the delay-load stub. #[cfg(target_os = "windows")] -fn windows_pdf_loads(dll: &std::path::Path) -> bool { +fn dll_loads(dll: &std::path::Path) -> bool { dll.to_str().is_some_and(|p| winsafe::HINSTANCE::LoadLibrary(p).is_ok()) } diff --git a/crates/engine/src/print_cmds/tests.rs b/crates/engine/src/print_cmds/tests.rs index 38567ffb6dd..318d6c71873 100644 --- a/crates/engine/src/print_cmds/tests.rs +++ b/crates/engine/src/print_cmds/tests.rs @@ -848,24 +848,27 @@ mod cups { #[cfg(target_os = "windows")] #[test] -fn windows_pdf_component_is_detected_by_loading_its_dll() { - // #5884: a Windows image without a loadable Windows.Data.Pdf.dll reports an error instead of - // aborting at the delay-load stub. +fn windows_print_components_are_detected_by_loading_their_dlls() { + // #5884, #8272: a Windows image without a loadable Windows.Data.Pdf.dll or prntvpt.dll reports + // an error instead of aborting at the delay-load stub. let dir = tempfile::tempdir().unwrap(); - let dll = windows_pdf_dll(dir.path()); - assert!(!windows_pdf_loads(&dll)); - // Present but not loadable counts as missing. std::fs::create_dir(dir.path().join("System32")).unwrap(); - std::fs::write(&dll, b"MZ").unwrap(); - assert!(!windows_pdf_loads(&dll)); - let root = std::env::var_os("SystemRoot").unwrap(); - // The real DLL may be missing or unloadable on a stripped image; the check follows the loader. - let system = windows_pdf_dll(std::path::Path::new(&root)); - assert_eq!(require_windows_pdf().is_ok(), windows_pdf_loads(&system)); + for name in [WINDOWS_PDF_DLL, PRINT_TICKET_DLL] { + let dll = system_dll(dir.path(), name); + assert!(!dll_loads(&dll), "{name}: missing"); + // Present but not loadable counts as missing. + std::fs::write(&dll, b"MZ").unwrap(); + assert!(!dll_loads(&dll), "{name}: not loadable"); + } + // The real DLLs may be missing or unloadable on a stripped image; the checks follow the loader. + let tickets = system_dll_loads(PRINT_TICKET_DLL); + assert_eq!(require_print_tickets().is_ok(), tickets); + assert_eq!(require_windows_pdf().is_ok(), system_dll_loads(WINDOWS_PDF_DLL) && tickets); } #[cfg(not(target_os = "windows"))] #[test] fn the_windows_pdf_check_is_a_no_op_elsewhere() { assert!(require_windows_pdf().is_ok()); + assert!(require_print_tickets().is_ok()); } From 3286781a6d3aa4c578e2f8f11da0756dd94b9f43 Mon Sep 17 00:00:00 2001 From: Michael Higgins <55243596+Higgs32584@users.noreply.github.com> Date: Thu, 22 Oct 2026 10:55:40 -0400 Subject: [PATCH 2/7] Update apps/photocraft/tests/windows_delay_loads.rs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- apps/photocraft/tests/windows_delay_loads.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/photocraft/tests/windows_delay_loads.rs b/apps/photocraft/tests/windows_delay_loads.rs index 737ddb5eb1c..4cf6572a446 100644 --- a/apps/photocraft/tests/windows_delay_loads.rs +++ b/apps/photocraft/tests/windows_delay_loads.rs @@ -2,7 +2,11 @@ //! Windows images (NTLite, some N/LTSC builds) lack them, and a load-time import stops the app //! from starting at all (#5884 Windows.Data.Pdf.dll, #8272 prntvpt.dll). `build.rs` delay-loads //! them; this reads the built exe's PE import tables to prove it. -#![cfg(all(target_os = "windows", target_env = "msvc"))] +#![cfg(all( + target_os = "windows", + target_env = "msvc", + target_pointer_width = "64", +))] /// Loaded on first use by the print commands, which check them first. const PRINT_ONLY: [&str; 2] = ["windows.data.pdf.dll", "prntvpt.dll"]; From d0a5971617637c21de7d88d44ebdca45b443929f Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Thu, 22 Oct 2026 19:09:41 -0400 Subject: [PATCH 3/7] fix cargo fmt --- apps/photocraft/tests/windows_delay_loads.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/apps/photocraft/tests/windows_delay_loads.rs b/apps/photocraft/tests/windows_delay_loads.rs index 4cf6572a446..b047614dd11 100644 --- a/apps/photocraft/tests/windows_delay_loads.rs +++ b/apps/photocraft/tests/windows_delay_loads.rs @@ -2,11 +2,7 @@ //! Windows images (NTLite, some N/LTSC builds) lack them, and a load-time import stops the app //! from starting at all (#5884 Windows.Data.Pdf.dll, #8272 prntvpt.dll). `build.rs` delay-loads //! them; this reads the built exe's PE import tables to prove it. -#![cfg(all( - target_os = "windows", - target_env = "msvc", - target_pointer_width = "64", -))] +#![cfg(all(target_os = "windows", target_env = "msvc", target_pointer_width = "64",))] /// Loaded on first use by the print commands, which check them first. const PRINT_ONLY: [&str; 2] = ["windows.data.pdf.dll", "prntvpt.dll"]; From 1e00b7e91c7ef864deb457ea4cd4cffe7b079eee Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Tue, 3 Nov 2026 10:07:45 -0500 Subject: [PATCH 4/7] Check the print DLLs against a fixture Windows directory in the test The final assertions read the host SystemRoot, so they never exercised the temporary System32 the test builds. require_*_at take the root; the production wrappers pass the real one. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/print_cmds.rs | 38 ++++++++++++++++------- crates/engine/src/cmd/print_cmds/tests.rs | 25 +++++++++++---- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/crates/engine/src/cmd/print_cmds.rs b/crates/engine/src/cmd/print_cmds.rs index 56bad41ec69..3a63a770be7 100644 --- a/crates/engine/src/cmd/print_cmds.rs +++ b/crates/engine/src/cmd/print_cmds.rs @@ -930,6 +930,8 @@ fn driver_printable(p: &Value) -> Option { Some(json!([pg.printable.0, pg.printable.1, pg.printable.2, pg.printable.3])) } +/// Lays out and renders the print page as a PDF for `cmd` and, when the params ask for it, sends +/// it to the printer through `spooler`; returns the job summary (paper, image rect, spooler). fn render_and_spool(doc: &Document, p: &Value, cmd: &str, spooler: Option<&Spooler>) -> Result { let fit = p.get("scaleToFit").and_then(Value::as_bool).unwrap_or(false); let driver = (fit && native_route(p, spooler)).then(|| with_driver_printable(p)); @@ -1012,14 +1014,7 @@ fn render_and_spool(doc: &Document, p: &Value, cmd: &str, spooler: Option<&Spool /// that both load first (#5884, #8272). fn require_windows_pdf() -> Result<()> { #[cfg(target_os = "windows")] - { - if !system_dll_loads(WINDOWS_PDF_DLL) { - return Err(other( - "printing this page needs the Windows PDF component (Windows.Data.Pdf.dll), which is missing or cannot load. Save as PDF and print it from another app, or print an RGB image without page text or labels to print directly.", - )); - } - require_print_tickets()?; - } + require_windows_pdf_at(&system_root())?; Ok(()) } @@ -1027,7 +1022,25 @@ fn require_windows_pdf() -> Result<()> { /// API), which stripped Windows images can lack; the apps delay-load it (#8272). fn require_print_tickets() -> Result<()> { #[cfg(target_os = "windows")] - if !system_dll_loads(PRINT_TICKET_DLL) { + require_print_tickets_at(&system_root())?; + Ok(()) +} + +/// [`require_windows_pdf`] against the Windows directory `system_root` (tests pass a fixture). +#[cfg(target_os = "windows")] +fn require_windows_pdf_at(system_root: &std::path::Path) -> Result<()> { + if !dll_loads(&system_dll(system_root, WINDOWS_PDF_DLL)) { + return Err(other( + "printing this page needs the Windows PDF component (Windows.Data.Pdf.dll), which is missing or cannot load. Save as PDF and print it from another app, or print an RGB image without page text or labels to print directly.", + )); + } + require_print_tickets_at(system_root) +} + +/// [`require_print_tickets`] against the Windows directory `system_root` (tests pass a fixture). +#[cfg(target_os = "windows")] +fn require_print_tickets_at(system_root: &std::path::Path) -> Result<()> { + if !dll_loads(&system_dll(system_root, PRINT_TICKET_DLL)) { return Err(other( "printing this page needs the Windows Print Ticket component (prntvpt.dll), which is missing or cannot load. Save as PDF and print it from another app, or print an RGB image without page text or labels to print directly.", )); @@ -1040,12 +1053,13 @@ const WINDOWS_PDF_DLL: &str = "Windows.Data.Pdf.dll"; #[cfg(target_os = "windows")] const PRINT_TICKET_DLL: &str = "prntvpt.dll"; +/// The running Windows directory (`%SystemRoot%`), `C:\Windows` if the variable is unset. #[cfg(target_os = "windows")] -fn system_dll_loads(name: &str) -> bool { - let root = std::env::var_os("SystemRoot").unwrap_or_else(|| std::ffi::OsString::from(r"C:\Windows")); - dll_loads(&system_dll(std::path::Path::new(&root), name)) +fn system_root() -> std::path::PathBuf { + std::env::var_os("SystemRoot").map_or_else(|| std::path::PathBuf::from(r"C:\Windows"), std::path::PathBuf::from) } +/// Where the system DLL `name` lives under the Windows directory `system_root`. #[cfg(target_os = "windows")] fn system_dll(system_root: &std::path::Path, name: &str) -> std::path::PathBuf { system_root.join("System32").join(name) diff --git a/crates/engine/src/cmd/print_cmds/tests.rs b/crates/engine/src/cmd/print_cmds/tests.rs index 766215a10a5..816815fc33a 100644 --- a/crates/engine/src/cmd/print_cmds/tests.rs +++ b/crates/engine/src/cmd/print_cmds/tests.rs @@ -1183,11 +1183,13 @@ mod cups { } } +/// #5884, #8272: a Windows image without a loadable Windows.Data.Pdf.dll or prntvpt.dll reports +/// an error instead of aborting at the delay-load stub. The checks run against a fixture +/// `System32`, so they don't depend on what the host has installed. #[cfg(target_os = "windows")] #[test] fn windows_print_components_are_detected_by_loading_their_dlls() { - // #5884, #8272: a Windows image without a loadable Windows.Data.Pdf.dll or prntvpt.dll reports - // an error instead of aborting at the delay-load stub. + let system_dll_loads = |name| dll_loads(&system_dll(&system_root(), name)); let dir = tempfile::tempdir().unwrap(); std::fs::create_dir(dir.path().join("System32")).unwrap(); for name in [WINDOWS_PDF_DLL, PRINT_TICKET_DLL] { @@ -1197,12 +1199,23 @@ fn windows_print_components_are_detected_by_loading_their_dlls() { std::fs::write(&dll, b"MZ").unwrap(); assert!(!dll_loads(&dll), "{name}: not loadable"); } - // The real DLLs may be missing or unloadable on a stripped image; the checks follow the loader. - let tickets = system_dll_loads(PRINT_TICKET_DLL); - assert_eq!(require_print_tickets().is_ok(), tickets); - assert_eq!(require_windows_pdf().is_ok(), system_dll_loads(WINDOWS_PDF_DLL) && tickets); + // Both stubs fail to load, so both checks report the missing component. + assert!(require_print_tickets_at(dir.path()).is_err()); + assert!(require_windows_pdf_at(dir.path()).is_err()); + // With a loadable prntvpt.dll (the host's, copied in) only the PDF check still fails: it + // checks Windows.Data.Pdf.dll itself, not just the Print Ticket API. + let tickets = system_dll(dir.path(), PRINT_TICKET_DLL); + if system_dll_loads(PRINT_TICKET_DLL) && std::fs::copy(system_dll(&system_root(), PRINT_TICKET_DLL), &tickets).is_ok() { + assert_eq!(require_print_tickets_at(dir.path()).is_ok(), dll_loads(&tickets)); + assert!(require_windows_pdf_at(dir.path()).is_err(), "Windows.Data.Pdf.dll is still a stub"); + } + // The wrappers follow the loader on the real Windows directory (a stripped image may lack either). + let host_tickets = system_dll_loads(PRINT_TICKET_DLL); + assert_eq!(require_print_tickets().is_ok(), host_tickets); + assert_eq!(require_windows_pdf().is_ok(), system_dll_loads(WINDOWS_PDF_DLL) && host_tickets); } +/// Off Windows there are no Windows print components to check, so both checks pass. #[cfg(not(target_os = "windows"))] #[test] fn the_windows_pdf_check_is_a_no_op_elsewhere() { From 5272d227c6ca848ec2350e70facc04c8faeb4791 Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Tue, 3 Nov 2026 10:07:48 -0500 Subject: [PATCH 5/7] Document the functions the delay-load change touches Co-Authored-By: Claude Opus 5.5 --- apps/photocraft-cli/build.rs | 1 + apps/photocraft/build.rs | 1 + apps/photocraft/tests/windows_delay_loads.rs | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/apps/photocraft-cli/build.rs b/apps/photocraft-cli/build.rs index f911223974f..8983b9c8d62 100644 --- a/apps/photocraft-cli/build.rs +++ b/apps/photocraft-cli/build.rs @@ -5,6 +5,7 @@ //! unless `PHOTOCRAFT_REQUIRE_WINRES=1` (set by the release packaging script) turns it into a //! build error. +/// Embeds the Windows resources and delay-loads the print-only system DLLs (#8272). fn main() -> std::io::Result<()> { println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=../../assets/app-icon/photocraft.ico"); diff --git a/apps/photocraft/build.rs b/apps/photocraft/build.rs index 70a14b833ee..48ce637a529 100644 --- a/apps/photocraft/build.rs +++ b/apps/photocraft/build.rs @@ -4,6 +4,7 @@ //! cross-compile from macOS or Linux still links, unless `PHOTOCRAFT_REQUIRE_WINRES=1` (set by the //! release workflow) turns it into an error. +/// Embeds the Windows resources and delay-loads the print-only system DLLs (#5884, #8272). fn main() { println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=../../assets/app-icon/photocraft.ico"); diff --git a/apps/photocraft/tests/windows_delay_loads.rs b/apps/photocraft/tests/windows_delay_loads.rs index b047614dd11..f7b7504ced0 100644 --- a/apps/photocraft/tests/windows_delay_loads.rs +++ b/apps/photocraft/tests/windows_delay_loads.rs @@ -7,6 +7,7 @@ /// Loaded on first use by the print commands, which check them first. const PRINT_ONLY: [&str; 2] = ["windows.data.pdf.dll", "prntvpt.dll"]; +/// The built exe names each print-only DLL in its delay-load table, never its import table. #[test] fn print_only_system_dlls_are_delay_loaded() { let exe = std::fs::read(env!("CARGO_BIN_EXE_photocraft")).unwrap(); @@ -30,6 +31,7 @@ struct Pe<'a> { } impl<'a> Pe<'a> { + /// Reads the PE headers and section table of a PE32+ image, panicking (a test) on any other. fn parse(bytes: &'a [u8]) -> Self { let pe = u32_at(bytes, 0x3c) as usize; assert_eq!(&bytes[pe..pe + 4], b"PE\0\0"); @@ -48,6 +50,7 @@ impl<'a> Pe<'a> { Pe { bytes, sections, directories: optional + 112 } } + /// The file offset of relative virtual address `rva`, through the section that holds it. fn offset(&self, rva: u32) -> usize { let &(va, _, raw) = self.sections.iter().find(|&&(va, size, _)| rva >= va && rva < va + size).unwrap(); (rva - va + raw) as usize @@ -73,10 +76,12 @@ impl<'a> Pe<'a> { } } +/// The little-endian `u16` at byte offset `at`. fn u16_at(b: &[u8], at: usize) -> u16 { u16::from_le_bytes([b[at], b[at + 1]]) } +/// The little-endian `u32` at byte offset `at`. fn u32_at(b: &[u8], at: usize) -> u32 { u32::from_le_bytes([b[at], b[at + 1], b[at + 2], b[at + 3]]) } From edfdc633123e0ec1f8c17eed7cfe8edf1f25832e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 15 Nov 2026 08:28:08 -0800 Subject: [PATCH 6/7] Keyboard Shortcuts test: add the action before assigning its key by index #11674 changed `assign_shortcut` to take the action's index in the Actions list instead of its name, while #14326's `an_action_function_key_is_no_edit` still passed "Sepia". The ui-egui lib tests on main no longer compile (E0308 at shortcut_set_switch_tests.rs:168). The test now adds a "Sepia" action and assigns F2 to index 0, as the shortcut_dispatch tests do. --- crates/ui-egui/src/prefs/prefs_ui/shortcut_set_switch_tests.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/prefs/prefs_ui/shortcut_set_switch_tests.rs b/crates/ui-egui/src/prefs/prefs_ui/shortcut_set_switch_tests.rs index dafa8be560f..68a82501d92 100644 --- a/crates/ui-egui/src/prefs/prefs_ui/shortcut_set_switch_tests.rs +++ b/crates/ui-egui/src/prefs/prefs_ui/shortcut_set_switch_tests.rs @@ -165,7 +165,8 @@ fn an_unmodified_set_switches_at_once() { fn an_action_function_key_is_no_edit() { let (mut h, first) = dialog(); h.state_mut().ui.dialogs.retain(|d| d.id != first); - crate::actions::assign_shortcut(h.state_mut(), "Sepia", "F2").unwrap(); + h.state_mut().session.actions.list.push(photocraft_engine::actions_cmds::Action::new("Sepia", Vec::new())); + crate::actions::assign_shortcut(h.state_mut(), 0, "F2").unwrap(); let ctx = h.ctx.clone(); let id = crate::menus::invoke(h.state_mut(), &ctx, "edit.keyboardShortcuts", json!({})).unwrap()["dialog"].as_u64().unwrap(); h.run_steps(4); From f3419cc57511fc78d7771be7b4fd714b52415aae Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 15 Nov 2026 18:26:21 +0000 Subject: [PATCH 7/7] Keep text dependencies in canonical Cargo lock order --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index d3935c94a4e..03aadc6d205 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5859,8 +5859,8 @@ dependencies = [ name = "photocraft-text" version = "0.23.1" dependencies = [ - "craft-plist", "base64 0.23.1", + "craft-plist", "craft-psd", "flate2", "parley",