diff options
| author | Brian Potchik <brian@vector35.com> | 2021-03-30 12:08:21 -0400 |
|---|---|---|
| committer | Brian Potchik <brian@vector35.com> | 2021-03-30 12:08:21 -0400 |
| commit | ec5acd622aa48e7b87f6246e774983a7652c0acd (patch) | |
| tree | 0dc7dbd99dcdb8849d48132e4a88efcbfe8b9514 | |
| parent | 3d4c8e147c5f6a6e257ef48cfb5fe476c35b1d7b (diff) | |
Add ability to query for database backing of specific BinaryViewTypes and fix state initialization.
| -rw-r--r-- | binaryninjaapi.h | 5 | ||||
| -rw-r--r-- | binaryninjacore.h | 9 | ||||
| -rw-r--r-- | binaryview.cpp | 10 | ||||
| -rw-r--r-- | filemetadata.cpp | 4 | ||||
| -rw-r--r-- | python/filemetadata.py | 6 |
5 files changed, 14 insertions, 20 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 286d4a52..fbadbc07 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -882,7 +882,7 @@ __attribute__ ((format (printf, 1, 2))) bool IsSnapshotDataAppliedWithoutError() const; - bool IsBackedByDatabase() const; + bool IsBackedByDatabase(const std::string& binaryViewType = "") const; bool CreateDatabase(const std::string& name, BinaryView* data, Ref<SaveSettings> settings); bool CreateDatabase(const std::string& name, BinaryView* data, const std::function<void(size_t progress, size_t total)>& progressCallback, Ref<SaveSettings> settings); @@ -1486,7 +1486,6 @@ __attribute__ ((format (printf, 1, 2))) bool IsModified() const; bool IsAnalysisChanged() const; - bool IsBackedByDatabase() const; bool CreateDatabase(const std::string& path, Ref<SaveSettings> settings = new SaveSettings()); bool CreateDatabase(const std::string& path, const std::function<void(size_t progress, size_t total)>& progressCallback, Ref<SaveSettings> settings = new SaveSettings()); @@ -1599,7 +1598,7 @@ __attribute__ ((format (printf, 1, 2))) void AddUserDataReference(uint64_t fromAddr, uint64_t toAddr); void RemoveUserDataReference(uint64_t fromAddr, uint64_t toAddr); - // References to type + // References to type std::vector<ReferenceSource> GetCodeReferencesForType(const QualifiedName& type); std::vector<uint64_t> GetDataReferencesForType(const QualifiedName& type); std::vector<TypeReferenceSource> GetTypeReferencesForType(const QualifiedName& type); diff --git a/binaryninjacore.h b/binaryninjacore.h index fbac440d..b7bfa919 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -28,14 +28,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 2 +#define BN_CURRENT_CORE_ABI_VERSION 3 // 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 1 +#define BN_MINIMUM_CORE_ABI_VERSION 2 #ifdef __GNUC__ # ifdef BINARYNINJACORE_LIBRARY @@ -2673,7 +2673,8 @@ __attribute__ ((format (printf, 1, 2))) BINARYNINJACOREAPI void BNMarkFileModified(BNFileMetadata* file); BINARYNINJACOREAPI void BNMarkFileSaved(BNFileMetadata* file); - BINARYNINJACOREAPI bool BNIsBackedByDatabase(BNFileMetadata* file); + BINARYNINJACOREAPI bool BNIsBackedByDatabase(BNFileMetadata* file, const char* binaryViewType); + BINARYNINJACOREAPI bool BNCreateDatabase(BNBinaryView* data, const char* path, BNSaveSettings* settings); BINARYNINJACOREAPI bool BNCreateDatabaseWithProgress(BNBinaryView* data, const char* path, void* ctxt, void (*progress)(void* ctxt, size_t progress, size_t total), BNSaveSettings* settings); @@ -4332,7 +4333,7 @@ __attribute__ ((format (printf, 1, 2))) BINARYNINJACOREAPI BNType* BNTypeWithReplacedEnumeration(BNType* type, BNEnumeration* from, BNEnumeration* to); BINARYNINJACOREAPI BNType* BNTypeWithReplacedNamedTypeReference(BNType* type, BNNamedTypeReference* from, BNNamedTypeReference* to); - BINARYNINJACOREAPI bool BNAddTypeMemberTokens(BNType* type, BNBinaryView* data, BNInstructionTextToken** tokens, size_t* tokenCount, + BINARYNINJACOREAPI bool BNAddTypeMemberTokens(BNType* type, BNBinaryView* data, BNInstructionTextToken** tokens, size_t* tokenCount, int64_t offset, char*** nameList, size_t* nameCount, size_t size, bool indirect); BINARYNINJACOREAPI BNQualifiedName BNTypeBuilderGetTypeName(BNTypeBuilder* nt); diff --git a/binaryview.cpp b/binaryview.cpp index 86878f8c..444229c5 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -1120,12 +1120,6 @@ bool BinaryView::IsAnalysisChanged() const } -bool BinaryView::IsBackedByDatabase() const -{ - return m_file->IsBackedByDatabase(); -} - - bool BinaryView::CreateDatabase(const string& path, Ref<SaveSettings> settings) { auto parent = GetParentView(); @@ -1865,7 +1859,7 @@ void BinaryView::RemoveUserDataReference(uint64_t fromAddr, uint64_t toAddr) vector<ReferenceSource> BinaryView::GetCodeReferencesForType(const QualifiedName& type) { size_t count; - + BNQualifiedName nameObj = type.GetAPIObject(); BNReferenceSource* refs = BNGetCodeReferencesForType(m_object, &nameObj, &count); QualifiedName::FreeAPIObject(&nameObj); @@ -1902,7 +1896,7 @@ vector<uint64_t> BinaryView::GetDataReferencesForType(const QualifiedName& type) vector<TypeReferenceSource> BinaryView::GetTypeReferencesForType(const QualifiedName& type) { size_t count; - + BNQualifiedName nameObj = type.GetAPIObject(); BNTypeReferenceSource* refs = BNGetTypeReferencesForType(m_object, &nameObj, &count); QualifiedName::FreeAPIObject(&nameObj); diff --git a/filemetadata.cpp b/filemetadata.cpp index b95463b1..00711b57 100644 --- a/filemetadata.cpp +++ b/filemetadata.cpp @@ -157,9 +157,9 @@ void FileMetadata::MarkFileSaved() } -bool FileMetadata::IsBackedByDatabase() const +bool FileMetadata::IsBackedByDatabase(const string& binaryViewType) const { - return BNIsBackedByDatabase(m_object); + return BNIsBackedByDatabase(m_object, binaryViewType.c_str()); } diff --git a/python/filemetadata.py b/python/filemetadata.py index bce4301f..903a36f6 100644 --- a/python/filemetadata.py +++ b/python/filemetadata.py @@ -201,9 +201,9 @@ class FileMetadata(object): return core.BNIsAnalysisChanged(self.handle) @property - def has_database(self): - """Whether the FileMetadata is backed by a database (read-only)""" - return core.BNIsBackedByDatabase(self.handle) + def has_database(self, binary_view_type = ""): + """Whether the FileMetadata is backed by a database, or if specified, a specific BinaryViewType (read-only)""" + return core.BNIsBackedByDatabase(self.handle, binary_view_type) @property def view(self): |
