Skip to content

Commit a327450

Browse files
committed
try to set variable from windows
Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 7c17569 commit a327450

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

framework_lib/src/os_specific.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,24 @@ pub fn sleep(micros: u64) {
1919
bs.stall(micros as usize);
2020
}
2121
}
22+
23+
#[cfg(windows)]
24+
pub fn set_dbx() -> bool {
25+
set_uefi_var("dbx", "d719b2cb-3d3a-4596-a3bc-dad00e67656f", &[], 0)
26+
}
27+
28+
#[cfg(windows)]
29+
pub fn set_uefi_var(name: &str, guid: &str, value: &[u8], attributes: u32) -> bool {
30+
windows_sys::Win32::System::WindowsProgramming
31+
unsafe {
32+
SetFirmwareEnvironmentVariableExW(
33+
// PCWSTR
34+
HSTRING::from(name),
35+
// PCWSTR
36+
HSTRING::from(guid),
37+
value.as_ptr(),
38+
value.len(),
39+
attributes
40+
)
41+
}
42+
}

0 commit comments

Comments
 (0)