Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions binaryninjaapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -21231,6 +21231,12 @@ namespace BinaryNinja {
*/
void AddAlternateName(const std::string& alternate);

/*! Removes an extra name from this type library used during library lookups and dependency resolution

\param alternate
*/
void RemoveAlternateName(const std::string& alternate);

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

\param depName
Expand Down
3 changes: 2 additions & 1 deletion binaryninjacore.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
// Current ABI version for linking to the core. This is incremented any time
// there are changes to the API that affect linking, including new functions,
// new types, or modifications to existing functions or types.
#define BN_CURRENT_CORE_ABI_VERSION 182
#define BN_CURRENT_CORE_ABI_VERSION 183

// Minimum ABI version that is supported for loading of plugins. Plugins that
// are linked to an ABI version less than this will not be able to load and
Expand Down Expand Up @@ -7225,6 +7225,7 @@ extern "C"
BINARYNINJACOREAPI char* BNGetTypeLibraryName(BNTypeLibrary* lib);

BINARYNINJACOREAPI void BNAddTypeLibraryAlternateName(BNTypeLibrary* lib, const char* name);
BINARYNINJACOREAPI void BNRemoveTypeLibraryAlternateName(BNTypeLibrary* lib, const char* name);
BINARYNINJACOREAPI char** BNGetTypeLibraryAlternateNames(BNTypeLibrary* lib, size_t* count); // BNFreeStringList

BINARYNINJACOREAPI void BNSetTypeLibraryDependencyName(BNTypeLibrary* lib, const char* name);
Expand Down
6 changes: 6 additions & 0 deletions python/typelibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ def add_alternate_name(self, name: str) -> None:
raise ValueError(f"Expected name to be str, got {type(name)}")
core.BNAddTypeLibraryAlternateName(self.handle, name)

def remove_alternate_name(self, name: str) -> None:
"""Removes an extra name from this type library instance that has not been finalized"""
if not isinstance(name, str):
raise ValueError(f"Expected name to be str, got {type(name)}")
core.BNRemoveTypeLibraryAlternateName(self.handle, name)

@property
def platform_names(self) -> List[str]:
"""
Expand Down
6 changes: 6 additions & 0 deletions rust/src/types/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ impl TypeLibrary {
unsafe { BNAddTypeLibraryAlternateName(self.as_raw(), value.as_ptr()) }
}

/// Removes an extra name from this type library used during library lookups and dependency resolution
pub fn remove_alternate_name(&self, value: &str) {
let value = value.to_cstr();
unsafe { BNRemoveTypeLibraryAlternateName(self.as_raw(), value.as_ptr()) }
}

/// Returns a list of all platform names that this type library will register with during platform
/// type registration.
///
Expand Down
2 changes: 2 additions & 0 deletions rust/tests/type_library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ fn test_create_type_library() {
// Create the new type library.
let my_library = TypeLibrary::new(arch, "test_type_lib");
my_library.add_alternate_name("alternate_test");
my_library.add_alternate_name("alternate_to_be_removed");
my_library.remove_alternate_name("alternate_to_be_removed");
my_library.add_platform(&platform);
my_library.add_named_type("test_type".into(), &Type::int(7, true));

Expand Down
6 changes: 6 additions & 0 deletions typelibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ void TypeLibrary::AddAlternateName(const std::string& alternate)
}


void TypeLibrary::RemoveAlternateName(const std::string& alternate)
{
BNRemoveTypeLibraryAlternateName(m_object, alternate.c_str());
}


void TypeLibrary::SetDependencyName(const std::string& depName)
{
BNSetTypeLibraryDependencyName(m_object, depName.c_str());
Expand Down
Loading