Files
time-mocker/crates/time-mocker-ui/build.rs
T
tiennm99 ffab962360 fix(ui): detect PID reuse, verify delta channel, correct rule and date handling
Hold one process handle across every identity check and injection so the PID
cannot be recycled mid-inject, and prune injected entries whose start time no
longer matches. Read the delta back before reporting a successful injection
so a dead channel is no longer a silent no-op mock. Match rules
case-insensitively and skip the path arm when the path is empty, surface
invalid patterns instead of swallowing them, and stop retrying a failed
auto-inject target until its PID is reused. Restore the last fake time on
startup, reset "Now" to exactly zero delta, clamp the whole date to range so
a boundary shift no longer jumps a year, and default missing persisted fields
so one bad field cannot wipe all rules. Show a message box on release startup
failure, and cache compiled rules between scans.
2026-09-21 16:13:27 +07:00

24 lines
1.0 KiB
Rust

//! Embeds a Windows UAC manifest so the controller prompts for admin
//! elevation on launch (required for `CreateRemoteThread` into other users'
//! processes and for hooking system DLLs).
use embed_manifest::manifest::ExecutionLevel;
use embed_manifest::{embed_manifest, new_manifest};
fn main() {
println!("cargo:rerun-if-changed=build.rs");
// Only embed the UAC manifest in release builds — otherwise `cargo test`
// and other dev workflows would fail with ERROR_ELEVATION_REQUIRED (740).
let is_release = std::env::var("PROFILE").is_ok_and(|p| p == "release");
// `CARGO_CFG_WINDOWS` describes the *target*, unlike `#[cfg(windows)]`
// which in a build script describes the host and breaks cross-compiles.
let targets_windows = std::env::var_os("CARGO_CFG_WINDOWS").is_some();
if is_release && targets_windows {
let manifest = new_manifest("TimeMocker.UI")
.requested_execution_level(ExecutionLevel::RequireAdministrator);
embed_manifest(manifest).expect("failed to embed UAC manifest");
}
}