Skip to content

Commit

Permalink
fix missing condensated bitfields in struct
Browse files Browse the repository at this point in the history
  • Loading branch information
rbran committed Aug 26, 2024
1 parent 694bbc7 commit 7f34dc3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 17 additions & 4 deletions rust/examples/idb/idb_import/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
));
}
}
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion rust/examples/idb/shared/src/til/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 7f34dc3

Please sign in to comment.