pub struct StructureBuilder { /* private fields */ }

Implementations§

source§

impl StructureBuilder

// Includes
use binaryninja::types::{Structure, StructureBuilder, Type, MemberAccess, MemberScope};

// Define struct, set size (in bytes)
let mut my_custom_struct = StructureBuilder::new();
let field_1 = Type::named_int(5, false, "my_weird_int_type");
let field_2 = Type::int(4, false);
let field_3 = Type::int(8, false);

// Assign those fields
my_custom_struct.insert(&field_1, "field_1", 0, false, MemberAccess::PublicAccess, MemberScope::NoScope);
my_custom_struct.insert(&field_2, "field_2", 5, false, MemberAccess::PublicAccess, MemberScope::NoScope);
my_custom_struct.insert(&field_3, "field_3", 9, false, MemberAccess::PublicAccess, MemberScope::NoScope);
my_custom_struct.append(&field_1, "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);
source

pub fn new() -> Self

source

pub fn finalize(&self) -> Ref<Structure>

source

pub fn set_width(&self, width: u64) -> &Self

source

pub fn set_alignment(&self, alignment: usize) -> &Self

source

pub fn set_packed(&self, packed: bool) -> &Self

source

pub fn set_structure_type(&self, t: StructureType) -> &Self

source

pub fn set_pointer_offset(&self, offset: i64) -> &Self

source

pub fn set_propagates_data_var_refs(&self, does: bool) -> &Self

source

pub fn set_base_structures(&self, bases: Vec<BaseStructure>) -> &Self

source

pub fn append<'a, S: BnStrCompatible, T: Into<Conf<&'a Type>>>( &self, t: T, name: S, access: MemberAccess, scope: MemberScope ) -> &Self

source

pub fn insert_member( &self, member: &StructureMember, overwrite_existing: bool ) -> &Self

source

pub fn insert<'a, S: BnStrCompatible, T: Into<Conf<&'a Type>>>( &self, t: T, name: S, offset: u64, overwrite_existing: bool, access: MemberAccess, scope: MemberScope ) -> &Self

source

pub fn with_members<'a, S: BnStrCompatible, T: Into<Conf<&'a Type>>>( &self, members: impl IntoIterator<Item = (T, S)> ) -> &Self

source

pub fn width(&self) -> u64

source

pub fn alignment(&self) -> usize

source

pub fn packed(&self) -> bool

source

pub fn structure_type(&self) -> StructureType

source

pub fn pointer_offset(&self) -> i64

source

pub fn propagates_data_var_refs(&self) -> bool

source

pub fn base_structures(&self) -> Result<Vec<BaseStructure>>

source

pub fn members(&self) -> Array<StructureMember>

source

pub fn index_by_name(&self, name: &str) -> Option<usize>

source

pub fn index_by_offset(&self, offset: u64) -> Option<usize>

source

pub fn clear_members(&self)

source

pub fn add_members<'a>( &self, members: impl IntoIterator<Item = &'a StructureMember> )

source

pub fn set_members<'a>( &self, members: impl IntoIterator<Item = &'a StructureMember> )

source

pub fn remove(&self, index: usize)

source

pub fn replace( &self, index: usize, type_: Conf<&Type>, name: &str, overwrite: bool )

Trait Implementations§

source§

impl Debug for StructureBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for StructureBuilder

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Drop for StructureBuilder

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl From<&Structure> for StructureBuilder

source§

fn from(structure: &Structure) -> StructureBuilder

Converts to this type from the input type.
source§

impl From<Vec<StructureMember>> for StructureBuilder

source§

fn from(members: Vec<StructureMember>) -> StructureBuilder

Converts to this type from the input type.
source§

impl Hash for StructureBuilder

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for StructureBuilder

source§

fn eq(&self, other: &StructureBuilder) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for StructureBuilder

source§

impl StructuralPartialEq for StructureBuilder

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.