Skip to main content

Type

Struct Type 

Source
#[repr(transparent)]
pub struct Type { pub handle: *mut BNType, }
Expand description

The core model for types in Binary Ninja.

A Type is how we model the storage of a Variable or crate::variable::DataVariable as well as propagate information such as the constness of a variable. Types are also used to declare function signatures, such as the FunctionParameter’s and return type.

Types are immutable. To change a type, you must create a new one either using TypeBuilder or one of the helper functions:

§Example

As an example, defining a named type within a BinaryView:

let bv = binaryninja::load("example.bin").unwrap();
let my_custom_type_1 = Type::named_int(5, false, "my_w");
let my_custom_type_2 = Type::int(5, false);
bv.define_user_type("int_1", &my_custom_type_1);
bv.define_user_type("int_2", &my_custom_type_2);

Fields§

§handle: *mut BNType

Implementations§

Source§

impl Type

Source

pub unsafe fn from_raw(handle: *mut BNType) -> Self

Source

pub unsafe fn ref_from_raw(handle: *mut BNType) -> Ref<Self>

Source

pub fn to_builder(&self) -> TypeBuilder

Source

pub fn type_class(&self) -> TypeClass

Source

pub fn width(&self) -> u64

The size of the type in bytes.

Source

pub fn alignment(&self) -> usize

Source

pub fn is_signed(&self) -> Conf<bool>

Source

pub fn integer_display_type(&self) -> IntegerDisplayType

Source

pub fn is_const(&self) -> Conf<bool>

Source

pub fn is_volatile(&self) -> Conf<bool>

Source

pub fn is_floating_point(&self) -> bool

Source

pub fn child_type(&self) -> Option<Conf<Ref<Type>>>

Source

pub fn target(&self) -> Option<Conf<Ref<Type>>>

This is an alias for Self::child_type.

Source

pub fn element_type(&self) -> Option<Conf<Ref<Type>>>

This is an alias for Self::child_type.

Source

pub fn return_value(&self) -> Option<Conf<Ref<Type>>>

This is an alias for Self::child_type.

Source

pub fn calling_convention(&self) -> Option<Conf<Ref<CoreCallingConvention>>>

Source

pub fn parameters(&self) -> Option<Vec<FunctionParameter>>

Source

pub fn has_variable_arguments(&self) -> Conf<bool>

Source

pub fn can_return(&self) -> Conf<bool>

Source

pub fn pure(&self) -> Conf<bool>

Source

pub fn get_structure(&self) -> Option<Ref<Structure>>

Source

pub fn get_enumeration(&self) -> Option<Ref<Enumeration>>

Source

pub fn get_named_type_reference(&self) -> Option<Ref<NamedTypeReference>>

Source

pub fn count(&self) -> u64

Source

pub fn offset(&self) -> u64

Source

pub fn stack_adjustment(&self) -> Conf<i64>

Source

pub fn registered_name(&self) -> Option<Ref<NamedTypeReference>>

Source

pub fn pointer_base_type(&self) -> BNPointerBaseType

Source

pub fn pointer_base_offset(&self) -> i64

Source

pub fn void() -> Ref<Self>

Source

pub fn bool() -> Ref<Self>

Source

pub fn char() -> Ref<Self>

Source

pub fn wide_char(width: usize) -> Ref<Self>

Source

pub fn int(width: usize, is_signed: bool) -> Ref<Self>

Source

pub fn named_int(width: usize, is_signed: bool, alt_name: &str) -> Ref<Self>

Source

pub fn float(width: usize) -> Ref<Self>

Source

pub fn named_float(width: usize, alt_name: &str) -> Ref<Self>

Source

pub fn array<'a, T: Into<Conf<&'a Type>>>(ty: T, count: u64) -> Ref<Self>

Source

pub fn enumeration<T: Into<Conf<bool>>>( enumeration: &Enumeration, width: NonZeroUsize, is_signed: T, ) -> Ref<Self>

§NOTE

The C/C++ APIs require an associated architecture, but in the core we only query the default_int_size if the given width is 0.

For simplicity’s sake, that convention isn’t followed, and you can query Architecture::default_integer_size if you need to.

Source

pub fn structure(structure: &Structure) -> Ref<Self>

Source

pub fn named_type(type_reference: &NamedTypeReference) -> Ref<Self>

Source

pub fn named_type_from_type<T: Into<QualifiedName>>( name: T, t: &Type, ) -> Ref<Self>

Source

pub fn function<T: Into<ReturnValue>>( return_value: T, parameters: Vec<FunctionParameter>, variable_arguments: bool, ) -> Ref<Self>

Source

pub fn function_with_opts<T: Into<ReturnValue>, C: Into<Conf<Ref<CoreCallingConvention>>>>( return_value: T, parameters: &[FunctionParameter], variable_arguments: bool, calling_convention: C, stack_adjust: Conf<i64>, ) -> Ref<Self>

Source

pub fn pointer<'a, A: Architecture, T: Into<Conf<&'a Type>>>( arch: &A, ty: T, ) -> Ref<Self>

Source

pub fn const_pointer<'a, A: Architecture, T: Into<Conf<&'a Type>>>( arch: &A, ty: T, ) -> Ref<Self>

Source

pub fn pointer_with_options<'a, A: Architecture, T: Into<Conf<&'a Type>>>( arch: &A, ty: T, is_const: bool, is_volatile: bool, ref_type: Option<ReferenceType>, ) -> Ref<Self>

Source

pub fn pointer_of_width<'a, T: Into<Conf<&'a Type>>>( ty: T, size: usize, is_const: bool, is_volatile: bool, ref_type: Option<ReferenceType>, ) -> Ref<Self>

Source

pub fn generate_auto_demangled_type_id<T: Into<QualifiedName>>( name: T, ) -> String

Source

pub fn deref_named_type_reference(&self, view: &BinaryView) -> Ref<Type>

Source

pub fn get_string_after_name(&self, platform: Option<&Platform>) -> String

Trait Implementations§

Source§

impl CoreArrayProvider for Type

Source§

impl Debug for Type

Source§

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

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

impl Display for Type

Source§

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

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

impl Eq for Type

Source§

impl From<&Type> for ReturnValue

Source§

fn from(value: &Type) -> ReturnValue

Converts to this type from the input type.
Source§

impl Hash for Type

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 Type

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Send for Type

Source§

impl Sync for Type

Source§

impl ToOwned for Type

Source§

type Owned = Ref<Type>

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> Self::Owned

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more

Auto Trait Implementations§

§

impl Freeze for Type

§

impl RefUnwindSafe for Type

§

impl Unpin for Type

§

impl UnsafeUnpin for Type

§

impl UnwindSafe for Type

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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>,

Source§

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more