Skip to content

Commit

Permalink
windows/esrt: Decode firmware type
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Schaefer <dhs@frame.work>
  • Loading branch information
JohnAZoidberg committed Aug 5, 2024
1 parent 9df617e commit b802422
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions framework_lib/src/esrt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,10 @@ pub fn get_esrt() -> Option<Esrt> {
use std::collections::HashMap;
use wmi::Variant;
debug!("Querying WMI");
let results: Vec<HashMap<String, Variant>> = wmi_con.raw_query("SELECT HardwareID FROM Win32_PnPEntity WHERE ClassGUID = '{f2e7dd72-6468-4e36-b6f1-6488f42c1b52}'").unwrap();
let results: Vec<HashMap<String, Variant>> = wmi_con.raw_query("SELECT HardwareID, Name FROM Win32_PnPEntity WHERE ClassGUID = '{f2e7dd72-6468-4e36-b6f1-6488f42c1b52}'").unwrap();

for (i, hardware_id) in results.iter().enumerate() {
let hwid = &hardware_id["HardwareID"];
for (i, val) in results.iter().enumerate() {
let hwid = &val["HardwareID"];
if let Variant::Array(strs) = hwid {
if let Variant::String(s) = &strs[0] {
// Sample "UEFI\\RES_{c57fd615-2ac9-4154-bf34-4dc715344408}&REV_CF"
Expand All @@ -366,10 +366,21 @@ pub fn get_esrt() -> Option<Esrt> {
debug!(" GUID: {}", guid_str);
debug!(" Version: {:X} ({})", ver, ver);

let fw_type = if let Variant::String(name) = &val["Name"] {
match name.as_str() {
"System Firmware" => 1,
"Device Firmware" => 2,
_ => 0,
}
} else {
0
};

// TODO: The missing fields are present in Device Manager
// So there must be a way to get at them
let esrt = EsrtResourceEntry {
fw_class: guid,
// TODO: 0 is Unknown, see if Windows exposes it
fw_type: 0,
fw_type,
fw_version: ver,
// TODO: Not exposed by windows
lowest_supported_fw_version: 0,
Expand Down

0 comments on commit b802422

Please sign in to comment.