Skip to main content

pacenotes_installer/
run_header.rs

1/// What support asks for first, at the top of every run log: which build, when,
2/// which server and which Windows.
3pub fn run_header(base_url: &str) -> Vec<String> {
4    let started =
5        pacenotes_installer::utc_time::iso_stamp(pacenotes_installer::utc_time::unix_now());
6    vec![
7        format!("Pacenotes Installer {}", env!("PACENOTES_VERSION")),
8        format!("started  {started}"),
9        format!("server   {base_url}"),
10        format!("windows  {}", windows_version()),
11    ]
12}
13
14/// `RtlGetVersion` rather than `GetVersionExW`, which reports Windows 8 to any
15/// program whose manifest does not list a newer one, as ours does not.
16fn windows_version() -> String {
17    let mut info: windows_sys::Win32::System::SystemInformation::OSVERSIONINFOW =
18        unsafe { core::mem::zeroed() };
19    info.dwOSVersionInfoSize = core::mem::size_of::<
20        windows_sys::Win32::System::SystemInformation::OSVERSIONINFOW,
21    >() as u32;
22    let status = unsafe { windows_sys::Wdk::System::SystemServices::RtlGetVersion(&mut info) };
23    if status != 0 {
24        return "unknown".to_string();
25    }
26    format!(
27        "{}.{}.{}",
28        info.dwMajorVersion, info.dwMinorVersion, info.dwBuildNumber
29    )
30}