Skip to content

Commit

Permalink
windows: Try to get ESRT from WMI
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Schaefer <[email protected]>
  • Loading branch information
JohnAZoidberg committed Jul 11, 2024
1 parent 03d72f9 commit c7dca33
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion framework_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ unix = ["std", "raw_pio", "smbios", "dep:nix", "dep:libc"]
linux = ["unix", "linux_pio", "cros_ec_driver"]
freebsd = ["unix", "freebsd_pio"]
# Windows does not have the cros_ec driver nor raw port I/O access to userspace
windows = ["std", "smbios", "dep:windows", "win_driver", "raw_pio"]
windows = ["std", "smbios", "dep:windows", "win_driver", "raw_pio", "dep:wmi"]
smbios = ["dep:smbios-lib"]
std = ["dep:clap", "dep:clap-verbosity-flag", "dep:env_logger", "smbios-lib?/std", "dep:hidapi", "dep:rusb"]
uefi = [
Expand Down Expand Up @@ -60,6 +60,7 @@ hidapi = { version = "2.1.0", optional = true }
rusb = { version = "0.9.1", optional = true }
no-std-compat = { version = "0.4.1", features = [ "alloc" ] }
guid_macros = { path = "../guid_macros" }
wmi = { version = "0.13.3", optional = true }

[dependencies.smbios-lib]
git = "https://github.com/FrameworkComputer/smbios-lib.git"
Expand Down
16 changes: 16 additions & 0 deletions framework_lib/src/commandline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,19 @@ fn flash_dp_hdmi_card(pd_bin_path: &str) {
}
}

#[cfg(target_os = "windows")]
fn windows_esrt() {
use wmi::*;
let wmi_con = WMIConnection::new(COMLibrary::new()?)?;
use std::collections::HashMap;
use wmi::Variant;
let results: Vec<HashMap<String, Variant>> = wmi_con.raw_query("SELECT HardwareID FROM Win32PnPEntity WHERE ClassGUID = '{f2e7dd72-6468-4e36-b6f1-6488f42c1b52}'").unwrap();

for hardware_id in results {
println!("{:#?}", hardware_id);
}
}

fn print_versions(ec: &CrosEc) {
println!("UEFI BIOS");
if let Some(smbios) = get_smbios() {
Expand Down Expand Up @@ -386,6 +399,9 @@ fn print_versions(ec: &CrosEc) {
println!(" Unknown");
}

#[cfg(target_os = "windows")]
windows_esrt();

#[cfg(feature = "linux")]
{
println!("CSME");
Expand Down

0 comments on commit c7dca33

Please sign in to comment.