pub struct StructureBuilder { /* private fields */ }
Implementations§
source§impl StructureBuilder
impl StructureBuilder
// Includes
use binaryninja::types::{MemberAccess, MemberScope, Structure, StructureBuilder, Type};
// Types to use in the members
let field_1_ty = Type::named_int(5, false, "my_weird_int_type");
let field_2_ty = Type::int(4, false);
let field_3_ty = Type::int(8, false);
// Assign those fields
let mut my_custom_struct = StructureBuilder::new();
my_custom_struct
.insert(
&field_1_ty,
"field_1",
0,
false,
MemberAccess::PublicAccess,
MemberScope::NoScope,
)
.insert(
&field_2_ty,
"field_2",
5,
false,
MemberAccess::PublicAccess,
MemberScope::NoScope,
)
.insert(
&field_3_ty,
"field_3",
9,
false,
MemberAccess::PublicAccess,
MemberScope::NoScope,
)
.append(
&field_1_ty,
"field_4",
MemberAccess::PublicAccess,
MemberScope::NoScope,
);
// Convert structure to type
let my_custom_structure_type = Type::structure(&my_custom_struct.finalize());
// Add the struct to the binary view to use in analysis
let bv = binaryninja::load("example").unwrap();
bv.define_user_type("my_custom_struct", &my_custom_structure_type);
pub fn new() -> Self
pub fn finalize(&mut self) -> Ref<Structure>
sourcepub fn width(&mut self, width: u64) -> &mut Self
pub fn width(&mut self, width: u64) -> &mut Self
Sets the width of the StructureBuilder
to the new width.
This will remove all previously inserted members outside the new width. This is done by computing the member access range (member offset + member width) and if it is larger than the new width it will be removed.
pub fn alignment(&mut self, alignment: usize) -> &mut Self
sourcepub fn packed(&mut self, packed: bool) -> &mut Self
pub fn packed(&mut self, packed: bool) -> &mut Self
Sets whether the StructureBuilder
is packed.
If set the alignment of the structure will be 1
. You do not need to set the alignment to 1
.
pub fn structure_type(&mut self, t: StructureType) -> &mut Self
pub fn pointer_offset(&mut self, offset: i64) -> &mut Self
pub fn propagates_data_var_refs(&mut self, propagates: bool) -> &mut Self
pub fn base_structures(&mut self, bases: &[BaseStructure]) -> &mut Self
pub fn append<'a, S: BnStrCompatible, T: Into<Conf<&'a Type>>>( &mut self, ty: T, name: S, access: MemberAccess, scope: MemberScope, ) -> &mut Self
pub fn insert_member( &mut self, member: StructureMember, overwrite_existing: bool, ) -> &mut Self
pub fn insert<'a, S: BnStrCompatible, T: Into<Conf<&'a Type>>>( &mut self, ty: T, name: S, offset: u64, overwrite_existing: bool, access: MemberAccess, scope: MemberScope, ) -> &mut Self
pub fn replace<'a, S: BnStrCompatible, T: Into<Conf<&'a Type>>>( &mut self, index: usize, ty: T, name: S, overwrite_existing: bool, ) -> &mut Self
pub fn remove(&mut self, index: usize) -> &mut Self
sourcepub fn current_width(&self) -> u64
pub fn current_width(&self) -> u64
Gets the current unaligned width of the structure.
This cannot be used to accurately get the width of a non-packed structure.
Trait Implementations§
source§impl Default for StructureBuilder
impl Default for StructureBuilder
source§impl Drop for StructureBuilder
impl Drop for StructureBuilder
source§impl From<&Structure> for StructureBuilder
impl From<&Structure> for StructureBuilder
source§fn from(structure: &Structure) -> StructureBuilder
fn from(structure: &Structure) -> StructureBuilder
Converts to this type from the input type.
source§impl From<Vec<StructureMember>> for StructureBuilder
impl From<Vec<StructureMember>> for StructureBuilder
source§fn from(members: Vec<StructureMember>) -> StructureBuilder
fn from(members: Vec<StructureMember>) -> StructureBuilder
Converts to this type from the input type.
source§impl Hash for StructureBuilder
impl Hash for StructureBuilder
source§impl PartialEq for StructureBuilder
impl PartialEq for StructureBuilder
impl Eq for StructureBuilder
impl StructuralPartialEq for StructureBuilder
Auto Trait Implementations§
impl Freeze for StructureBuilder
impl RefUnwindSafe for StructureBuilder
impl !Send for StructureBuilder
impl !Sync for StructureBuilder
impl Unpin for StructureBuilder
impl UnwindSafe for StructureBuilder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more