From cde44b938fea0fb5aa9004203a48d7e1f33f267a Mon Sep 17 00:00:00 2001 From: Bradley Fernandez Date: Tue, 11 Aug 2026 16:45:20 -0400 Subject: [PATCH 1/2] Add new API call to remove alternative names from a loaded type library. --- binaryninjacore.h | 1 + python/typelibrary.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/binaryninjacore.h b/binaryninjacore.h index 4c288df839..3ac055f86a 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -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); diff --git a/python/typelibrary.py b/python/typelibrary.py index dc33fe3ee3..c20318e174 100644 --- a/python/typelibrary.py +++ b/python/typelibrary.py @@ -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]: """ From 2e4526f1b879378f8f6042bce36ff46e951d9e4c Mon Sep 17 00:00:00 2001 From: Bradley Fernandez Date: Wed, 12 Aug 2026 09:19:21 -0400 Subject: [PATCH 2/2] Add C++ and Rust bindings for RemoveAlternateNames, add unit tests for them, bump ABI verison --- binaryninjaapi.h | 6 ++++++ binaryninjacore.h | 2 +- rust/src/types/library.rs | 6 ++++++ rust/tests/type_library.rs | 2 ++ typelibrary.cpp | 6 ++++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 6200425561..131f5ad25c 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -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 diff --git a/binaryninjacore.h b/binaryninjacore.h index 3ac055f86a..181129f022 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -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 diff --git a/rust/src/types/library.rs b/rust/src/types/library.rs index 9b543362ab..643fe9c231 100644 --- a/rust/src/types/library.rs +++ b/rust/src/types/library.rs @@ -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. /// diff --git a/rust/tests/type_library.rs b/rust/tests/type_library.rs index 559aae7c19..4a112f8402 100644 --- a/rust/tests/type_library.rs +++ b/rust/tests/type_library.rs @@ -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)); diff --git a/typelibrary.cpp b/typelibrary.cpp index bea52459f7..09ef0b2f09 100644 --- a/typelibrary.cpp +++ b/typelibrary.cpp @@ -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());