From eb93ef5cbdbebf01f8880ed2a35291dc616aec15 Mon Sep 17 00:00:00 2001 From: Humza Khan Date: Wed, 30 Sep 2026 00:38:43 +0100 Subject: [PATCH 1/3] Harden Windows resource embedding and add exe metadata and manifest --- Cargo.lock | 45 +++++++++++++++++++++++++++++++++++------- Cargo.toml | 6 +----- build.rs | 28 +++++++++++++++++--------- resources/app.manifest | 24 ++++++++++++++++++++++ 4 files changed, 82 insertions(+), 21 deletions(-) create mode 100644 resources/app.manifest diff --git a/Cargo.lock b/Cargo.lock index 5a0fcda..22c8036 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4834,6 +4834,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26" +dependencies = [ + "serde_core", +] + [[package]] name = "sha2" version = "0.11.0" @@ -5355,11 +5364,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" dependencies = [ "serde", - "serde_spanned", + "serde_spanned 0.6.9", "toml_datetime 0.6.3", "toml_edit 0.20.2", ] +[[package]] +name = "toml" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c96ecdfa941c8fc4fcaed14f99ada8ebed502eef533015095a07e3301d4c3c" +dependencies = [ + "indexmap", + "serde_core", + "serde_spanned 1.1.1", + "toml_datetime 1.1.1+spec-1.1.0", + "toml_parser", + "toml_writer", + "winnow 1.0.4", +] + [[package]] name = "toml_datetime" version = "0.6.3" @@ -5397,7 +5421,7 @@ checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ "indexmap", "serde", - "serde_spanned", + "serde_spanned 0.6.9", "toml_datetime 0.6.3", "winnow 0.5.40", ] @@ -5423,6 +5447,12 @@ dependencies = [ "winnow 1.0.4", ] +[[package]] +name = "toml_writer" +version = "1.1.2+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2" + [[package]] name = "tracing" version = "0.1.44" @@ -6158,7 +6188,7 @@ dependencies = [ "env_logger", "libcosmic", "ui", - "winres", + "winresource", ] [[package]] @@ -6850,12 +6880,13 @@ dependencies = [ ] [[package]] -name = "winres" -version = "0.1.12" +name = "winresource" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b68db261ef59e9e52806f688020631e987592bd83619edccda9c47d42cde4f6c" +checksum = "0986a8b1d586b7d3e4fe3d9ea39fb451ae22869dcea4aa109d287a374d866087" dependencies = [ - "toml 0.5.11", + "toml 1.1.3+spec-1.1.0", + "version_check", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index d703e3a..d68f53b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,16 +15,12 @@ version.workspace = true edition.workspace = true license.workspace = true -[[bin]] -name = "windisplaymanager_rs" -path = "src/main.rs" - [profile.release] strip = true lto = "thin" [build-dependencies] -winres = "0.1" +winresource = "0.1" [dependencies] data.workspace = true diff --git a/build.rs b/build.rs index c41c661..749716d 100644 --- a/build.rs +++ b/build.rs @@ -1,11 +1,21 @@ -#[cfg(windows)] -fn main() { - let mut res = winres::WindowsResource::new(); - res.set_icon("icon.ico"); - res.compile().unwrap(); -} +const ICON: &str = "icon.ico"; +const MANIFEST: &str = "resources/app.manifest"; + +fn main() -> std::io::Result<()> { + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-changed={ICON}"); + println!("cargo:rerun-if-changed={MANIFEST}"); + + if std::env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("windows") { + return Ok(()); + } -#[cfg(not(windows))] -fn main() { - // No-op for non-Windows platforms + let mut res = winresource::WindowsResource::new(); + // data/src/tray.rs loads the tray icon from resource ID 1. + res.set_icon_with_id(ICON, "1"); + res.set("ProductName", "WinDisplayManager"); + res.set("FileDescription", "WinDisplayManager - DDC/CI monitor control"); + res.set("LegalCopyright", "Copyright (c) 2026 cyb0rg56"); + res.set_manifest_file(MANIFEST); + res.compile() } diff --git a/resources/app.manifest b/resources/app.manifest new file mode 100644 index 0000000..8ef00a8 --- /dev/null +++ b/resources/app.manifest @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + true/pm + PerMonitorV2 + UTF-8 + + + From 612521c294f4ab9ad89b31af4d772b8ad3f054bc Mon Sep 17 00:00:00 2001 From: Humza Khan Date: Wed, 30 Sep 2026 00:45:20 +0100 Subject: [PATCH 2/3] Fixed formatting issue --- build.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 749716d..255183d 100644 --- a/build.rs +++ b/build.rs @@ -14,7 +14,10 @@ fn main() -> std::io::Result<()> { // data/src/tray.rs loads the tray icon from resource ID 1. res.set_icon_with_id(ICON, "1"); res.set("ProductName", "WinDisplayManager"); - res.set("FileDescription", "WinDisplayManager - DDC/CI monitor control"); + res.set( + "FileDescription", + "WinDisplayManager - DDC/CI monitor control", + ); res.set("LegalCopyright", "Copyright (c) 2026 cyb0rg56"); res.set_manifest_file(MANIFEST); res.compile() From 8ac65878a924487733c0ce9aa9477c30ff8541af Mon Sep 17 00:00:00 2001 From: Humza Khan Date: Wed, 30 Sep 2026 00:58:49 +0100 Subject: [PATCH 3/3] Moved icon to resources folder --- build.rs | 2 +- packaging/msix/generate-assets.ps1 | 2 +- icon.ico => resources/icons/icon.ico | Bin ui/src/app.rs | 1 + ui/src/lib.rs | 1 + 5 files changed, 4 insertions(+), 2 deletions(-) rename icon.ico => resources/icons/icon.ico (100%) diff --git a/build.rs b/build.rs index 255183d..3d93ce5 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,4 @@ -const ICON: &str = "icon.ico"; +const ICON: &str = "resources/icons/icon.ico"; const MANIFEST: &str = "resources/app.manifest"; fn main() -> std::io::Result<()> { diff --git a/packaging/msix/generate-assets.ps1 b/packaging/msix/generate-assets.ps1 index 7a00004..bd280a3 100644 --- a/packaging/msix/generate-assets.ps1 +++ b/packaging/msix/generate-assets.ps1 @@ -15,7 +15,7 @@ #> [CmdletBinding()] param( - [string]$IconPath = (Join-Path $PSScriptRoot '..\..\icon.ico'), + [string]$IconPath = (Join-Path $PSScriptRoot '..\..\resources\icons\icon.ico'), [string]$OutDir = (Join-Path $PSScriptRoot 'Assets') ) diff --git a/icon.ico b/resources/icons/icon.ico similarity index 100% rename from icon.ico rename to resources/icons/icon.ico diff --git a/ui/src/app.rs b/ui/src/app.rs index e75f3cd..340e915 100644 --- a/ui/src/app.rs +++ b/ui/src/app.rs @@ -274,6 +274,7 @@ impl cosmic::Application for AppModel { } else { // Window was closed — open a new one let (new_id, open_task) = window::open(window::Settings { + size: cosmic::iced::Size::new(1920.0, 1080.0), min_size: Some(cosmic::iced::Size::new(600.0, 400.0)), decorations: false, ..window::Settings::default() diff --git a/ui/src/lib.rs b/ui/src/lib.rs index 2f7ff84..434f59e 100644 --- a/ui/src/lib.rs +++ b/ui/src/lib.rs @@ -19,6 +19,7 @@ pub fn run(minimized: bool) -> cosmic::iced::Result { .antialiasing(false) // Don't exit when the window is closed — keep running in the tray .exit_on_close(false) + .size(cosmic::iced::Size::new(1920.0, 1080.0)) .size_limits( cosmic::iced::Limits::NONE .min_width(600.0)