Skip to content

Commit 3520262

Browse files
committed
Add TypeLibrary::Register, to allow loading type libraries from script
1 parent 9b03ef6 commit 3520262

5 files changed

Lines changed: 23 additions & 0 deletions

File tree

binaryninjaapi.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20233,6 +20233,11 @@ namespace BinaryNinja {
2023320233

2023420234
*/
2023520235
void Finalize();
20236+
20237+
/*! Make a created or loaded Type Library available for Platforms to use when loading binaries.
20238+
20239+
*/
20240+
void Register();
2023620241
};
2023720242

2023820243
class TypeArchive;

binaryninjacore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6829,6 +6829,7 @@ extern "C"
68296829
BINARYNINJACOREAPI void BNFreeTypeLibraryList(BNTypeLibrary** lib, size_t count);
68306830

68316831
BINARYNINJACOREAPI bool BNFinalizeTypeLibrary(BNTypeLibrary* lib);
6832+
BINARYNINJACOREAPI void BNRegisterTypeLibrary(BNTypeLibrary* lib);
68326833

68336834
BINARYNINJACOREAPI BNArchitecture* BNGetTypeLibraryArchitecture(BNTypeLibrary* lib);
68346835

python/typelibrary.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ def finalize(self) -> bool:
241241
"""
242242
return core.BNFinalizeTypeLibrary(self.handle)
243243

244+
def register(self) -> None:
245+
"""
246+
Make a created or loaded Type Library available for Platforms to use when loading binaries.
247+
"""
248+
core.BNRegisterTypeLibrary(self.handle)
249+
244250
def query_metadata(self, key: str) -> 'metadata.MetadataValueType':
245251
"""
246252
`query_metadata` retrieves a metadata associated with the given key stored in the type library

rust/src/types/library.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ impl TypeLibrary {
217217
unsafe { BNFinalizeTypeLibrary(self.as_raw()) }
218218
}
219219

220+
/// Make a created or loaded Type Library available for Platforms to use when loading binaries.
221+
pub fn register(&self) {
222+
unsafe { BNRegisterTypeLibrary(self.as_raw()) }
223+
}
224+
220225
/// Retrieves the metadata associated with the given key stored in the type library.
221226
pub fn query_metadata(&self, key: &str) -> Option<Ref<Metadata>> {
222227
let key = key.to_cstr();

typelibrary.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,9 @@ void TypeLibrary::Finalize()
259259
{
260260
BNFinalizeTypeLibrary(m_object);
261261
}
262+
263+
264+
void TypeLibrary::Register()
265+
{
266+
BNRegisterTypeLibrary(m_object);
267+
}

0 commit comments

Comments
 (0)