1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! build.rs — FlashKraft GUI
//!
//! On Windows this script embeds the UAC application manifest into the
//! compiled PE binary so that Windows shows the Administrator elevation
//! prompt when the user launches FlashKraft.
//!
//! On every other platform this script does nothing — it exists only so the
//! file is present and `cargo build` does not complain.
//!
//! ## How the manifest embedding works
//!
//! The Windows linker (MSVC or GNU) accepts `.rc` resource scripts. The
//! `winres` crate compiles a resource script that references our manifest
//! file and links the resulting `.res` object into the final `.exe`.
//!
//! Without this, Windows runs FlashKraft as a standard (unprivileged) user
//! and every attempt to open `\\.\PhysicalDriveN` for writing fails
//! immediately with ERROR_ACCESS_DENIED (5), because raw physical-disk
//! access requires the `SeManageVolumePrivilege` token privilege that is
//! only present in an elevated Administrator token.
//!
//! ## Dependencies
//!
//! `winres` is a build-dependency declared in `Cargo.toml` under
//! `[build-dependencies]` — it is NOT compiled into the final binary.
/// Compile and link the UAC manifest resource into the PE binary.
///
/// Uses the `winres` crate which wraps the Windows resource compiler
/// (`rc.exe` on MSVC toolchains, `windres` on GNU toolchains).