Skip to content

Commit fa35d66

Browse files
committed
windows/esrt: Decode firmware type
Signed-off-by: Daniel Schaefer <[email protected]>
1 parent c83ebec commit fa35d66

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

framework_lib/src/esrt/mod.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,10 @@ pub fn get_esrt() -> Option<Esrt> {
346346
use std::collections::HashMap;
347347
use wmi::Variant;
348348
debug!("Querying WMI");
349-
let results: Vec<HashMap<String, Variant>> = wmi_con.raw_query("SELECT HardwareID FROM Win32_PnPEntity WHERE ClassGUID = '{f2e7dd72-6468-4e36-b6f1-6488f42c1b52}'").unwrap();
349+
let results: Vec<HashMap<String, Variant>> = wmi_con.raw_query("SELECT HardwareID, Name FROM Win32_PnPEntity WHERE ClassGUID = '{f2e7dd72-6468-4e36-b6f1-6488f42c1b52}'").unwrap();
350350

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

369+
let fw_type = if let Variant::String(name) = &val["Name"] {
370+
match name.as_str() {
371+
"System Firmware" => 1,
372+
"Device Firmware" => 2,
373+
_ => 0,
374+
}
375+
} else {
376+
0
377+
};
378+
379+
// TODO: The missing fields are present in Device Manager
380+
// So there must be a way to get at them
369381
let esrt = EsrtResourceEntry {
370382
fw_class: guid,
371-
// TODO: 0 is Unknown, see if Windows exposes it
372-
fw_type: 0,
383+
fw_type,
373384
fw_version: ver,
374385
// TODO: Not exposed by windows
375386
lowest_supported_fw_version: 0,

0 commit comments

Comments
 (0)