Skip to content

Commit

Permalink
Fix incorrect definition for UEFI.OneOfOption.Flags
Browse files Browse the repository at this point in the history
  • Loading branch information
collider83 committed Jan 29, 2023
1 parent 83f0edc commit 74bfa45
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
42 changes: 20 additions & 22 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -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" {
Expand Down
8 changes: 7 additions & 1 deletion src/uefi_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ pub struct IfrCheckBox {
}

#[derive(Debug, Eq, PartialEq, Copy, Clone)]
pub enum IfrDefaultFlags {
pub enum IfrCheckBoxDefaultFlags {
Default = 0x01,
MfgDefault = 0x02,
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 74bfa45

Please sign in to comment.