pub struct TypeLibrary { /* private fields */ }

Implementations§

source§

impl TypeLibrary

source

pub fn new_reference(&self) -> Self

source

pub fn new_duplicated(&self) -> Self

source

pub fn new<S: BnStrCompatible>(arch: CoreArchitecture, name: S) -> TypeLibrary

Creates an empty type library object with a random GUID and the provided name.

source

pub fn all(arch: CoreArchitecture) -> Array<TypeLibrary>

source

pub fn decompress_to_file<P: BnStrCompatible, O: BnStrCompatible>( path: P, output: O ) -> bool

Decompresses a type library file to a file on disk.

source

pub fn load_from_file<S: BnStrCompatible>(path: S) -> Option<TypeLibrary>

Loads a finalized type library instance from file

source

pub fn write_to_file<S: BnStrCompatible>(&self, path: S) -> bool

Saves a finalized type library instance to file

source

pub fn from_name<S: BnStrCompatible>( arch: CoreArchitecture, name: S ) -> Option<TypeLibrary>

Looks up the first type library found with a matching name. Keep in mind that names are not necessarily unique.

source

pub fn from_guid<S: BnStrCompatible>( arch: CoreArchitecture, guid: S ) -> Option<TypeLibrary>

Attempts to grab a type library associated with the provided Architecture and GUID pair

source

pub fn arch(&self) -> CoreArchitecture

The Architecture this type library is associated with

source

pub fn name(&self) -> Option<BnString>

The primary name associated with this type library

source

pub fn set_name<S: BnStrCompatible>(&self, value: S)

Sets the name of a type library instance that has not been finalized

source

pub fn dependency_name(&self) -> Option<BnString>

The dependency_name of a library is the name used to record dependencies across type libraries. This allows, for example, a library with the name “musl_libc” to have dependencies on it recorded as “libc_generic”, allowing a type library to be used across multiple platforms where each has a specific libc that also provides the name “libc_generic” as an alternate_name.

source

pub fn set_dependency_name<S: BnStrCompatible>(&self, value: S)

Sets the dependency name of a type library instance that has not been finalized

source

pub fn guid(&self) -> Option<BnString>

Returns the GUID associated with the type library

source

pub fn set_guid<S: BnStrCompatible>(&self, value: S)

Sets the GUID of a type library instance that has not been finalized

source

pub fn alternate_names(&self) -> Array<BnString>

A list of extra names that will be considered a match by Platform::get_type_libraries_by_name

source

pub fn add_alternate_name<S: BnStrCompatible>(&self, value: S)

Adds an extra name to this type library used during library lookups and dependency resolution

source

pub fn platform_names(&self) -> Array<BnString>

Returns a list of all platform names that this type library will register with during platform type registration.

This returns strings, not Platform objects, as type libraries can be distributed with support for Platforms that may not be present.

source

pub fn add_platform(&self, plat: &Platform)

Associate a platform with a type library instance that has not been finalized.

This will cause the library to be searchable by Platform::get_type_libraries_by_name when loaded.

This does not have side affects until finalization of the type library.

source

pub fn clear_platforms(&self)

Clears the list of platforms associated with a type library instance that has not been finalized

source

pub fn finalize(&self) -> bool

Flags a newly created type library instance as finalized and makes it available for Platform and Architecture type library searches

source

pub fn query_metadata<S: BnStrCompatible>(&self, key: S) -> Option<Metadata>

Retrieves a metadata associated with the given key stored in the type library

source

pub fn store_metadata<S: BnStrCompatible>(&self, key: S, md: &Metadata)

Stores an object for the given key in the current type library. Objects stored using store_metadata can be retrieved from any reference to the library. Objects stored are not arbitrary python objects! The values stored must be able to be held in a Metadata object. See Metadata for more information. Python objects could obviously be serialized using pickle but this intentionally a task left to the user since there is the potential security issues.

This is primarily intended as a way to store Platform specific information relevant to BinaryView implementations; for example the PE BinaryViewType uses type library metadata to retrieve ordinal information, when available.

  • key - key value to associate the Metadata object with
  • md - object to store.
source

pub fn remove_metadata<S: BnStrCompatible>(&self, key: S)

Removes the metadata associated with key from the current type library.

source

pub fn metadata(&self) -> Metadata

Retrieves the metadata associated with the current type library.

source

pub fn add_named_object(&self, name: &QualifiedName, type_: &Type)

Directly inserts a named object into the type library’s object store. This is not done recursively, so care should be taken that types referring to other types through NamedTypeReferences are already appropriately prepared.

To add types and objects from an existing BinaryView, it is recommended to use export_object_to_library <binaryview.BinaryView.export_object_to_library>, which will automatically pull in all referenced types and record additional dependencies as needed.

source

pub fn add_named_type(&self, name: &QualifiedNameAndType, type_: &Type)

Directly inserts a named object into the type library’s object store. This is not done recursively, so care should be taken that types referring to other types through NamedTypeReferences are already appropriately prepared.

To add types and objects from an existing BinaryView, it is recommended to use export_type_to_library <binaryview.BinaryView.export_type_to_library>, which will automatically pull in all referenced types and record additional dependencies as needed.

source

pub fn add_type_source<S: BnStrCompatible>( &self, name: &QualifiedName, source: S )

Manually flag NamedTypeReferences to the given QualifiedName as originating from another source TypeLibrary with the given dependency name.

Use this api with extreme caution.

source

pub fn get_named_object(&self, name: &QualifiedName) -> Option<Ref<Type>>

Direct extracts a reference to a contained object – when attempting to extract types from a library into a BinaryView, consider using import_library_object <binaryview.BinaryView.import_library_object> instead.

source

pub fn get_named_type(&self, name: &QualifiedName) -> Option<Ref<Type>>

Direct extracts a reference to a contained type – when attempting to extract types from a library into a BinaryView, consider using import_library_type <binaryview.BinaryView.import_library_type> instead.

source

pub fn named_objects(&self) -> Array<QualifiedNameAndType>

A dict containing all named objects (functions, exported variables) provided by a type library

source

pub fn named_types(&self) -> Array<QualifiedNameAndType>

A dict containing all named types provided by a type library

Trait Implementations§

source§

impl CoreArrayProvider for TypeLibrary

§

type Raw = *mut BNTypeLibrary

§

type Context = ()

§

type Wrapped<'a> = &'a TypeLibrary

source§

impl Drop for TypeLibrary

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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.