Public Member Functions | |
TypeLibrary (BNTypeLibrary *handle) | |
TypeLibrary (Ref< Architecture > arch, const std::string &name) | |
Creates an empty type library object with a random GUID and the provided name. | |
std::string | Decompress (const std::string &path) |
Decompresses a type library from a file. | |
bool | WriteToFile (const std::string &path) |
Saves a finalized type library instance to file. | |
Ref< Architecture > | GetArchitecture () |
The Architecture this type library is associated with. | |
std::string | GetGuid () |
Returns the GUID associated with the type library. | |
std::string | GetName () |
The primary name associated with this type library. | |
std::set< std::string > | GetAlternateNames () |
A list of extra names that will be considered a match by ``Platform::GetTypeLibrariesByName``. | |
std::string | GetDependencyName () |
The dependency name of a library is the name used to record dependencies across type libraries. | |
std::set< std::string > | GetPlatformNames () |
Returns a list of all platform names that this type library will register with during platform type registration. | |
Ref< Metadata > | QueryMetadata (const std::string &key) |
Retrieves a metadata associated with the given key stored in the type library. | |
void | SetGuid (const std::string &guid) |
Sets the GUID of a type library instance that has not been finalized. | |
TypeContainer | GetTypeContainer () |
Type Container for all TYPES within the Type Library. | |
Ref< Type > | GetNamedObject (const QualifiedName &name) |
Direct extracts a reference to a contained object – when attempting to extract types from a library into a BinaryView, consider using BinaryView::ImportTypeLibraryObject instead. | |
Ref< Type > | GetNamedType (const QualifiedName &name) |
Direct extracts a reference to a contained type – when attempting to extract types from a library into a BinaryView, consider using BinaryView.ImportTypeLibraryType>` instead. | |
std::vector< QualifiedNameAndType > | GetNamedObjects () |
A list containing all named objects (functions, exported variables) provided by a type library. | |
std::vector< QualifiedNameAndType > | GetNamedTypes () |
A list containing all named types provided by a type library. | |
void | SetName (const std::string &name) |
Sets the name of a type library instance that has not been finalized. | |
void | AddAlternateName (const std::string &alternate) |
Adds an extra name to this type library used during library lookups and dependency resolution. | |
void | SetDependencyName (const std::string &depName) |
Sets the dependency name of a type library instance that has not been finalized. | |
void | ClearPlatforms () |
Clears the list of platforms associated with a type library instance that has not been finalized. | |
void | AddPlatform (Ref< Platform > platform) |
Associate a platform with a type library instance that has not been finalized. | |
void | StoreMetadata (const std::string &key, Ref< Metadata > value) |
Stores an object for the given key in the current type library. | |
void | RemoveMetadata (const std::string &key) |
Removes the metadata associated with key from the current type library. | |
Ref< Metadata > | GetMetadata () |
Returns a base Metadata object associated with the current type library. | |
void | AddNamedObject (const QualifiedName &name, Ref< Type > type) |
Directly inserts a named object into the type library's object store. | |
void | AddNamedType (const QualifiedName &name, Ref< Type > type) |
Directly inserts a named object into the type library's object store. | |
void | AddNamedTypeSource (const QualifiedName &name, const std::string &source) |
Manually flag NamedTypeReferences to the given QualifiedName as originating from another source TypeLibrary with the given dependency name. | |
void | Finalize () |
Flags a newly created type library instance as finalized and makes it available for Platform and Architecture type library searches. | |
Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNTypeLibrary, BNNewTypeLibraryReference, BNFreeTypeLibrary > | |
CoreRefCountObject () | |
virtual | ~CoreRefCountObject () |
BNTypeLibrary * | GetObject () const |
void | AddRef () |
void | Release () |
void | AddRefForRegistration () |
void | ReleaseForRegistration () |
void | AddRefForCallback () |
void | ReleaseForCallback () |
Static Public Member Functions | |
static bool | DecompressToFile (const std::string &path, const std::string &output) |
Decompresses a type library from a file. | |
static Ref< TypeLibrary > | LoadFromFile (const std::string &path) |
Loads a finalized type library instance from file. | |
static Ref< TypeLibrary > | LookupByName (Ref< Architecture > arch, const std::string &name) |
Looks up the first type library found with a matching name. | |
static Ref< TypeLibrary > | LookupByGuid (Ref< Architecture > arch, const std::string &guid) |
Attempts to grab a type library associated with the provided Architecture and GUID pair. | |
Static Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNTypeLibrary, BNNewTypeLibraryReference, BNFreeTypeLibrary > | |
static BNTypeLibrary * | GetObject (CoreRefCountObject *obj) |
static BNTypeLibrary * | GetObject (const CoreRefCountObject *obj) |
Additional Inherited Members | |
Public Attributes inherited from BinaryNinja::CoreRefCountObject< BNTypeLibrary, BNNewTypeLibraryReference, BNFreeTypeLibrary > | |
std::atomic< int > | m_refs |
bool | m_registeredRef |
BNTypeLibrary * | m_object |
TypeLibrary::TypeLibrary | ( | BNTypeLibrary * | handle | ) |
TypeLibrary::TypeLibrary | ( | Ref< Architecture > | arch, |
const std::string & | name ) |
Creates an empty type library object with a random GUID and the provided name.
arch | |
name |
std::string BinaryNinja::TypeLibrary::Decompress | ( | const std::string & | path | ) |
Decompresses a type library from a file.
path |
|
static |
Decompresses a type library from a file.
path | |
output |
|
static |
Loads a finalized type library instance from file.
path |
|
static |
Looks up the first type library found with a matching name.
Keep in mind that names are not necessarily unique.
arch | |
name |
|
static |
Attempts to grab a type library associated with the provided Architecture and GUID pair.
arch | |
guid |
bool TypeLibrary::WriteToFile | ( | const std::string & | path | ) |
Saves a finalized type library instance to file.
path |
Ref< Architecture > TypeLibrary::GetArchitecture | ( | ) |
The Architecture this type library is associated with.
std::string TypeLibrary::GetGuid | ( | ) |
Returns the GUID associated with the type library.
std::string TypeLibrary::GetName | ( | ) |
The primary name associated with this type library.
std::set< std::string > TypeLibrary::GetAlternateNames | ( | ) |
A list of extra names that will be considered a match by ``Platform::GetTypeLibrariesByName``.
std::string TypeLibrary::GetDependencyName | ( | ) |
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`.
std::set< std::string > TypeLibrary::GetPlatformNames | ( | ) |
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.
Retrieves a metadata associated with the given key stored in the type library.
key | Key to query |
void TypeLibrary::SetGuid | ( | const std::string & | guid | ) |
Sets the GUID of a type library instance that has not been finalized.
guid |
TypeContainer TypeLibrary::GetTypeContainer | ( | ) |
Ref< Type > TypeLibrary::GetNamedObject | ( | const QualifiedName & | name | ) |
Direct extracts a reference to a contained object – when attempting to extract types from a library into a BinaryView, consider using BinaryView::ImportTypeLibraryObject instead.
name |
Ref< Type > TypeLibrary::GetNamedType | ( | const QualifiedName & | name | ) |
Direct extracts a reference to a contained type – when attempting to extract types from a library into a BinaryView, consider using BinaryView.ImportTypeLibraryType>` instead.
name |
std::vector< QualifiedNameAndType > TypeLibrary::GetNamedObjects | ( | ) |
A list containing all named objects (functions, exported variables) provided by a type library.
std::vector< QualifiedNameAndType > TypeLibrary::GetNamedTypes | ( | ) |
A list containing all named types provided by a type library.
void TypeLibrary::SetName | ( | const std::string & | name | ) |
Sets the name of a type library instance that has not been finalized.
name |
void TypeLibrary::AddAlternateName | ( | const std::string & | alternate | ) |
Adds an extra name to this type library used during library lookups and dependency resolution.
alternate |
void TypeLibrary::SetDependencyName | ( | const std::string & | depName | ) |
Sets the dependency name of a type library instance that has not been finalized.
depName |
void TypeLibrary::ClearPlatforms | ( | ) |
Clears the list of platforms associated with a type library instance that has not been finalized.
Associate a platform with a type library instance that has not been finalized.
This will cause the library to be searchable by Platform::GetTypeLibrariesByName when loaded.
This does not have side affects until finalization of the type library.
platform |
Stores an object for the given key in the current type library.
Objects stored using StoreMetadata can be retrieved from any reference to the library.
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 |
value | Object to store. |
void TypeLibrary::RemoveMetadata | ( | const std::string & | key | ) |
Removes the metadata associated with key from the current type library.
key | Key associated with metadata |
void TypeLibrary::AddNamedObject | ( | const QualifiedName & | name, |
Ref< 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 BinaryView::ExportObjectToLibrary, which will automatically pull in all referenced types and record additional dependencies as needed.
name | |
type |
void TypeLibrary::AddNamedType | ( | const QualifiedName & | name, |
Ref< 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 BinaryView::ExportTypeToLibrary, which will automatically pull in all referenced types and record additional dependencies as needed.
name | |
type |
void TypeLibrary::AddNamedTypeSource | ( | const QualifiedName & | name, |
const std::string & | source ) |
Manually flag NamedTypeReferences to the given QualifiedName as originating from another source TypeLibrary with the given dependency name.
name | |
source |
void TypeLibrary::Finalize | ( | ) |
Flags a newly created type library instance as finalized and makes it available for Platform and Architecture type library searches.