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
//! Extract the embedded `ProductVersion` / `FileVersion` string from
//! a Windows PE binary's `VERSIONINFO` resource — the same data
//! File Explorer's Details tab shows.
//!
//! Used by:
//! * `kanade-backend`'s `POST /api/agents/publish` — auto-derives
//! the Object-Store key from the uploaded bytes, so the operator
//! can't typo a label that disagrees with the binary (the failure
//! mode that caused the "rollout to 1.0.0 → endless self-update"
//! incident on v0.13.0).
//! * `kanade agent publish` on the CLI — replaces the spawn-based
//! `--version` probe (which only worked on hosts that could
//! execute the binary).
//!
//! Pure-`pelite`, no spawn / no OS-specific deps — works from any
//! host (Linux operator uploading a Windows .exe is fine).
use ;
/// Read the `ProductVersion` (falling back to `FileVersion`) from
/// the VS_VERSIONINFO resource of a Windows PE. Returns `None` when:
/// * the bytes aren't a valid PE32 / PE32+,
/// * there's no `.rsrc` section,
/// * there's no `VS_VERSIONINFO` resource, or
/// * neither version string is set.
/// Trim trailing nulls + whitespace. `winres`-written strings often
/// have a single embedded NUL terminator the resource compiler keeps
/// in the payload; pelite returns it raw.