diff options
| author | kat <kat@vector35.com> | 2024-07-25 21:34:55 -0400 |
|---|---|---|
| committer | kat <kat@vector35.com> | 2024-07-26 01:36:37 -0400 |
| commit | 85c04eac52abe3aa0c54cd079bf87e64a60b62bd (patch) | |
| tree | a19146f692a4ebd206b51a0343d903e48d9c3cc9 | |
| parent | 326cb30bfa0d8a4bc2e37d56b20b95624e85f3d8 (diff) | |
Properly check for/log failures and return status on Typelib.write_to_file
| -rw-r--r-- | binaryninjaapi.h | 2 | ||||
| -rw-r--r-- | binaryninjacore.h | 6 | ||||
| -rw-r--r-- | python/typelibrary.py | 4 | ||||
| -rw-r--r-- | rust/src/typelibrary.rs | 2 | ||||
| -rw-r--r-- | typelibrary.cpp | 4 |
5 files changed, 10 insertions, 8 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 8db9124a..4cac3ff3 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -16891,7 +16891,7 @@ namespace BinaryNinja { \param path */ - void WriteToFile(const std::string& path); + bool WriteToFile(const std::string& path); /*! The Architecture this type library is associated with diff --git a/binaryninjacore.h b/binaryninjacore.h index c9c24723..f0c7a22e 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -37,14 +37,14 @@ // 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 70 +#define BN_CURRENT_CORE_ABI_VERSION 71 // 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 // will require rebuilding. The minimum version is increased when there are // incompatible changes that break binary compatibility, such as changes to // existing types or functions. -#define BN_MINIMUM_CORE_ABI_VERSION 69 +#define BN_MINIMUM_CORE_ABI_VERSION 71 #ifdef __GNUC__ #ifdef BINARYNINJACORE_LIBRARY @@ -5807,7 +5807,7 @@ extern "C" BINARYNINJACOREAPI BNQualifiedNameAndType* BNGetTypeLibraryNamedObjects(BNTypeLibrary* lib, size_t* count); BINARYNINJACOREAPI BNQualifiedNameAndType* BNGetTypeLibraryNamedTypes(BNTypeLibrary* lib, size_t* count); - BINARYNINJACOREAPI void BNWriteTypeLibraryToFile(BNTypeLibrary* lib, const char* path); + BINARYNINJACOREAPI bool BNWriteTypeLibraryToFile(BNTypeLibrary* lib, const char* path); BINARYNINJACOREAPI void BNAddBinaryViewTypeLibrary(BNBinaryView* view, BNTypeLibrary* lib); BINARYNINJACOREAPI BNTypeLibrary* BNGetBinaryViewTypeLibrary(BNBinaryView* view, const char* name); diff --git a/python/typelibrary.py b/python/typelibrary.py index c9ddd37b..724f8c5e 100644 --- a/python/typelibrary.py +++ b/python/typelibrary.py @@ -87,8 +87,10 @@ class TypeLibrary: :param str path: :rtype: None + :raises: OSError if saving the file fails """ - core.BNWriteTypeLibraryToFile(self.handle, path) + if not core.BNWriteTypeLibraryToFile(self.handle, path): + raise OSError(f"Failed to write type library to '{path}'") @staticmethod def from_name(arch: architecture.Architecture, name: str): diff --git a/rust/src/typelibrary.rs b/rust/src/typelibrary.rs index ce0fe6f8..a0992e18 100644 --- a/rust/src/typelibrary.rs +++ b/rust/src/typelibrary.rs @@ -77,7 +77,7 @@ impl TypeLibrary { } /// Saves a finalized type library instance to file - pub fn write_to_file<S: BnStrCompatible>(&self, path: S) { + pub fn write_to_file<S: BnStrCompatible>(&self, path: S) -> bool { let path = path.into_bytes_with_nul(); unsafe { BNWriteTypeLibraryToFile(self.as_raw(), path.as_ref().as_ptr() as *const ffi::c_char) diff --git a/typelibrary.cpp b/typelibrary.cpp index b3c1293b..a56c6db3 100644 --- a/typelibrary.cpp +++ b/typelibrary.cpp @@ -38,9 +38,9 @@ Ref<TypeLibrary> TypeLibrary::LookupByGuid(Ref<Architecture> arch, const std::st } -void TypeLibrary::WriteToFile(const std::string& path) +bool TypeLibrary::WriteToFile(const std::string& path) { - BNWriteTypeLibraryToFile(m_object, path.c_str()); + return BNWriteTypeLibraryToFile(m_object, path.c_str()); } |
