From 74bfa451be69a79986653e4dfa43bb12c9527f1f Mon Sep 17 00:00:00 2001 From: collider83 Date: Sat, 28 Jan 2023 17:39:28 -0800 Subject: [PATCH] Fix incorrect definition for UEFI.OneOfOption.Flags --- src/main.rs | 42 ++++++++++++++++++++---------------------- src/uefi_parser.rs | 8 +++++++- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5367567..84a1595 100644 --- a/src/main.rs +++ b/src/main.rs @@ -910,11 +910,17 @@ fn uefi_ifr_extract( cb.VarStoreInfo, cb.Flags).unwrap(); - if cb.Flags & (uefi_parser::IfrDefaultFlags::Default as u8) > 0 { - write!(&mut text, ", Default").unwrap(); + if cb.Flags & (uefi_parser::IfrCheckBoxDefaultFlags::Default as u8) > 0 { + write!(&mut text, ", Default: Enabled").unwrap(); } - if cb.Flags & (uefi_parser::IfrDefaultFlags::MfgDefault as u8) > 0 { - write!(&mut text, ", MfgDefault").unwrap(); + else { + write!(&mut text, ", Default: Disabled").unwrap(); + } + if cb.Flags & (uefi_parser::IfrCheckBoxDefaultFlags::MfgDefault as u8) > 0 { + write!(&mut text, ", MfgDefault: Enabled").unwrap(); + } + else { + write!(&mut text, ", MfgDefault: Disabled").unwrap(); } } Err(e) => { @@ -1043,10 +1049,10 @@ fn uefi_ifr_extract( } } - if opt.Flags & (uefi_parser::IfrDefaultFlags::Default as u8) > 0 { + if opt.Flags & (uefi_parser::IfrOneOfOptionDefaultFlags::Default as u8) > 0 { write!(&mut text, ", Default").unwrap(); } - if opt.Flags & (uefi_parser::IfrDefaultFlags::MfgDefault as u8) > 0 { + if opt.Flags & (uefi_parser::IfrOneOfOptionDefaultFlags::MfgDefault as u8) > 0 { write!(&mut text, ", MfgDefault").unwrap(); } } @@ -3275,45 +3281,37 @@ Usage: ifrextractor file.bin list - list all string and form packages in the inp } else if collected_args.len() == 3 && collected_args[2] == "list" { if uefi_ifr_found { println!("UEFI HII form packages:"); - let mut num = 0; - for form in &uefi_forms { + for (form_num, form) in uefi_forms.iter().enumerate() { println!("Index: {}, Offset: 0x{:X}, Length: 0x{:X}, Used strings: {}, Min StringId: 0x{:X}, Max StringId: 0x{:X}", - num, form.offset, form.length, form.used_strings, form.min_string_id, form.max_string_id); - num += 1; + form_num, form.offset, form.length, form.used_strings, form.min_string_id, form.max_string_id); } println!("UEFI HII string packages:"); - num = 0; - for string in &uefi_strings { + for (string_num, string) in uefi_strings.iter().enumerate() { println!( "Index: {}, Offset: 0x{:X}, Length: 0x{:X}, Language: {}, Total strings: {}", - num, + string_num, string.offset, string.length, string.language, string.string_id_map.len() ); - num += 1; } } else if framework_ifr_found { println!("Framework HII form packages:"); - let mut num = 0; - for form in &framework_forms { + for (form_num, form) in framework_forms.iter().enumerate() { println!("Index: {}, Offset: 0x{:X}, Length: 0x{:X}, Used strings: {}, Min StringId: 0x{:X}, Max StringId: 0x{:X}", - num, form.offset, form.length, form.used_strings, form.min_string_id, form.max_string_id); - num += 1; + form_num, form.offset, form.length, form.used_strings, form.min_string_id, form.max_string_id); } println!("Framework HII string packages:"); - num = 0; - for string in &framework_strings { + for (string_num, string) in framework_strings.iter().enumerate() { println!( "Index: {}, Offset: 0x{:X}, Length: 0x{:X}, Language: {}, Total strings: {}", - num, + string_num, string.offset, string.length, string.language, string.string_id_map.len() ); - num += 1; } } } else if collected_args.len() == 3 && collected_args[2] == "all" { diff --git a/src/uefi_parser.rs b/src/uefi_parser.rs index 5e18517..ea9f9cd 100644 --- a/src/uefi_parser.rs +++ b/src/uefi_parser.rs @@ -925,7 +925,7 @@ pub struct IfrCheckBox { } #[derive(Debug, Eq, PartialEq, Copy, Clone)] -pub enum IfrDefaultFlags { +pub enum IfrCheckBoxDefaultFlags { Default = 0x01, MfgDefault = 0x02, } @@ -1050,6 +1050,12 @@ pub fn ifr_password(input: &[u8]) -> IResult<&[u8], IfrPassword> { // //0x09 => IfrOpcode::OneOfOption // +#[derive(Debug, Eq, PartialEq, Copy, Clone)] +pub enum IfrOneOfOptionDefaultFlags { + Default = 0x10, + MfgDefault = 0x20, +} + #[derive(Debug, PartialEq, Eq, Copy, Clone)] pub struct HiiTime { pub Hour: u8,