From 7f34dc3234e65d89785acc568a0b6904babcea8b Mon Sep 17 00:00:00 2001 From: Rubens Brandao Date: Mon, 26 Aug 2024 18:31:20 -0300 Subject: [PATCH] fix missing condensated bitfields in struct --- rust/examples/idb/idb_import/src/lib.rs | 21 +++++++++++++++++---- rust/examples/idb/shared/src/til/mod.rs | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/rust/examples/idb/idb_import/src/lib.rs b/rust/examples/idb/idb_import/src/lib.rs index 2b452352a..740f0d97c 100644 --- a/rust/examples/idb/idb_import/src/lib.rs +++ b/rust/examples/idb/idb_import/src/lib.rs @@ -460,12 +460,14 @@ impl TranslateIDBTypes<'_> { (_, Some(start_idx)) => { first_bitfield_seq = None; let members_bitrange = &members[start_idx..i]; - if let Err(error) = - self.translate_bitfields_into_struct(i, members_bitrange, &structure) - { + if let Err(error) = self.translate_bitfields_into_struct( + start_idx, + members_bitrange, + &structure, + ) { return TranslateTypeResult::Error(BnTypeError::StructMember( Box::new(error), - i, + start_idx, )); } } @@ -493,6 +495,17 @@ impl TranslateIDBTypes<'_> { .unwrap_or_else(|| format!("member_{i}")); structure.append(&mem, name, BNMemberAccess::NoAccess, BNMemberScope::NoScope); } + if let Some(start_idx) = first_bitfield_seq { + let members_bitrange = &members[start_idx..]; + if let Err(error) = + self.translate_bitfields_into_struct(start_idx, members_bitrange, &structure) + { + return TranslateTypeResult::Error(BnTypeError::StructMember( + Box::new(error), + start_idx, + )); + } + } let bn_ty = Type::structure(&structure.finalize()); if is_partial { TranslateTypeResult::PartialyTranslated(bn_ty) diff --git a/rust/examples/idb/shared/src/til/mod.rs b/rust/examples/idb/shared/src/til/mod.rs index 315dc6b7a..28bc31c46 100644 --- a/rust/examples/idb/shared/src/til/mod.rs +++ b/rust/examples/idb/shared/src/til/mod.rs @@ -376,7 +376,7 @@ impl TILTypeInfo { let is_u64 = (flags >> 31) != 0; let ordinal = match (header.format, is_u64) { // formats below 0x12 doesn't have 64 bits ord - (0..0x12, _) | (_, false) => bincode::deserialize_from::<_, u32>(&mut *input)?.into(), + (0..=0x11, _) | (_, false) => bincode::deserialize_from::<_, u32>(&mut *input)?.into(), (_, true) => bincode::deserialize_from(&mut *input)?, }; let tinfo_raw =