Struct binaryninja::typelibrary::TypeLibrary
source · pub struct TypeLibrary { /* private fields */ }
Implementations§
source§impl TypeLibrary
impl TypeLibrary
pub fn new_reference(&self) -> Self
pub fn new_duplicated(&self) -> Self
sourcepub fn new<S: BnStrCompatible>(arch: CoreArchitecture, name: S) -> TypeLibrary
pub fn new<S: BnStrCompatible>(arch: CoreArchitecture, name: S) -> TypeLibrary
Creates an empty type library object with a random GUID and the provided name.
pub fn all(arch: CoreArchitecture) -> Array<TypeLibrary>
sourcepub fn decompress_to_file<P: BnStrCompatible, O: BnStrCompatible>(
path: P,
output: O
) -> bool
pub fn decompress_to_file<P: BnStrCompatible, O: BnStrCompatible>( path: P, output: O ) -> bool
Decompresses a type library file to a file on disk.
sourcepub fn load_from_file<S: BnStrCompatible>(path: S) -> Option<TypeLibrary>
pub fn load_from_file<S: BnStrCompatible>(path: S) -> Option<TypeLibrary>
Loads a finalized type library instance from file
sourcepub fn write_to_file<S: BnStrCompatible>(&self, path: S) -> bool
pub fn write_to_file<S: BnStrCompatible>(&self, path: S) -> bool
Saves a finalized type library instance to file
sourcepub fn from_name<S: BnStrCompatible>(
arch: CoreArchitecture,
name: S
) -> Option<TypeLibrary>
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.
sourcepub fn from_guid<S: BnStrCompatible>(
arch: CoreArchitecture,
guid: S
) -> Option<TypeLibrary>
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
sourcepub fn arch(&self) -> CoreArchitecture
pub fn arch(&self) -> CoreArchitecture
The Architecture this type library is associated with
sourcepub fn set_name<S: BnStrCompatible>(&self, value: S)
pub fn set_name<S: BnStrCompatible>(&self, value: S)
Sets the name of a type library instance that has not been finalized
sourcepub fn dependency_name(&self) -> Option<BnString>
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
.
sourcepub fn set_dependency_name<S: BnStrCompatible>(&self, value: S)
pub fn set_dependency_name<S: BnStrCompatible>(&self, value: S)
Sets the dependency name of a type library instance that has not been finalized
sourcepub fn set_guid<S: BnStrCompatible>(&self, value: S)
pub fn set_guid<S: BnStrCompatible>(&self, value: S)
Sets the GUID of a type library instance that has not been finalized
sourcepub fn alternate_names(&self) -> Array<BnString>
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
sourcepub fn add_alternate_name<S: BnStrCompatible>(&self, value: S)
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
sourcepub fn platform_names(&self) -> Array<BnString>
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.
sourcepub fn add_platform(&self, plat: &Platform)
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.
sourcepub fn clear_platforms(&self)
pub fn clear_platforms(&self)
Clears the list of platforms associated with a type library instance that has not been finalized
sourcepub fn finalize(&self) -> bool
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
sourcepub fn query_metadata<S: BnStrCompatible>(&self, key: S) -> Option<Metadata>
pub fn query_metadata<S: BnStrCompatible>(&self, key: S) -> Option<Metadata>
Retrieves a metadata associated with the given key stored in the type library
sourcepub fn store_metadata<S: BnStrCompatible>(&self, key: S, md: &Metadata)
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 withmd
- object to store.
sourcepub fn remove_metadata<S: BnStrCompatible>(&self, key: S)
pub fn remove_metadata<S: BnStrCompatible>(&self, key: S)
Removes the metadata associated with key from the current type library.
sourcepub fn metadata(&self) -> Metadata
pub fn metadata(&self) -> Metadata
Retrieves the metadata associated with the current type library.
sourcepub fn add_named_object(&self, name: &QualifiedName, type_: &Type)
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.
sourcepub fn add_named_type(&self, name: &QualifiedNameAndType, type_: &Type)
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.
sourcepub fn add_type_source<S: BnStrCompatible>(
&self,
name: &QualifiedName,
source: S
)
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.
sourcepub fn get_named_object(&self, name: &QualifiedName) -> Option<Ref<Type>>
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.
sourcepub fn get_named_type(&self, name: &QualifiedName) -> Option<Ref<Type>>
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.
sourcepub fn named_objects(&self) -> Array<QualifiedNameAndType>
pub fn named_objects(&self) -> Array<QualifiedNameAndType>
A dict containing all named objects (functions, exported variables) provided by a type library
sourcepub fn named_types(&self) -> Array<QualifiedNameAndType>
pub fn named_types(&self) -> Array<QualifiedNameAndType>
A dict containing all named types provided by a type library