code wiki / _hdl_build / nx_efivarstore.nx

nx_efivarstore.nx

buildroot/runtime/_hdl_build/nx_efivarstore.nx

12745 B250 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_efivarstore.nx -- F103e RUNG 11a: READ a UEFI authenticated variable store. The enrolment rung needs PK / KEK / db entries, which means knowing the varstore layout and the EFI GUIDs. ★★★★★★I AM NOT WRITING THOSE GUIDs FROM MEMORY. `OVMF_VARS_4M.ms.fd` ships with Microsoft's keys already enrolled -- it is a WORKED EXAMPLE OF THE EXACT FORMAT, on disk, free. So: parse it, print what is really there, and take every constant from the artifact. **THE FORMAT COMES FROM THE FILE, NOT FROM RECALL** -- the same rule that has caught me three times today when I trusted a filename over a symbol table. Layout (EDK2 VariableFormat.h), all little-endian: EFI_FIRMWARE_VOLUME_HEADER : ZeroVector[16], FileSystemGuid[16], FvLength[8], Signature "_FVH", Attributes[4], HeaderLength[2], Checksum[2], ExtHeaderOffset[2], Reserved[1], Revision[1], BlockMap... VARIABLE_STORE_HEADER : Signature GUID[16], Size[4], Format[1], State[1], Reserved[6] AUTHENTICATED_VARIABLE_HEADER (60 B) : StartId[2]=0x55AA, State[1], Reserved[1], Attributes[4], MonotonicCount[8], TimeStamp[16], PubKeyIndex[4], NameSize[4], DataSize[4], VendorGuid[16] then Name(UCS-2) then Data, each entry 4-byte aligned. Usage: nx_efivarstore dump <vars.fd> -- enumerate every variable nx_efivarstore selftest <vars.fd> -- teeth against a REAL MS-key varstore Exit: 0 GREEN | 1 RED | 3 UNPROVEN (cannot read input). license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_efivarstore.nx nx_efivars_enrol.nx

imports: nx_syscalls.nx

imported by: nx_efivars_enrol.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main ev_p sys_write sys_exit ev_eq_str ev_selftest sys_mmap nxa_die sys_write ↻ sys_exit ↻ nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close ev_p ↻ sys_exit ↻ ev_first_var ev_r16 ev_r32 ev_fn sys_mmap ↻ sys_write ↻ ev_walk ev_r32 ↻ ev_r16 ↻ ev_p ↻

structs

none

consts

26const EV_HDR: i64 = 60 // AUTHENTICATED_VARIABLE_HEADER
27const EV_STARTID: i64 = 0x55AA
28const EV_ADDED: i64 = 0x3F // VAR_ADDED
29const EV_MAXVARS: i64 = 512

functions

31func ev_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 3: ev_walkev_selftestmain calls 1: sys_write
32func ev_fp(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
called by 1: ev_selftest calls 1: sys_write
33func ev_fn(fd: i64, v: i64) -> i64
43func ev_hexb(b: *u8, off: i64, n: i64) -> i64
54func ev_eq_str(a: *u8, b: *u8) -> i64
called by 1: main
60func ev_r16(b: *u8, o: i64) -> i64 { return (b[o] as i64) | ((b[o+1] as i64) << 8) }
called by 2: ev_first_varev_walk
61func ev_r32(b: *u8, o: i64) -> i64
67func ev_first_var(b: *u8, len: i64, store_off_p: *i64) -> i64
86func ev_walk(b: *u8, len: i64, first: i64, store_off: i64, verbose: i64,
157func ev_selftest(path: *u8) -> i64
227func main(argc: i64, argv: *i64) -> i64