summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXusheng <xusheng@vector35.com>2021-05-19 11:50:20 +0800
committerXusheng <xusheng@vector35.com>2021-05-19 12:22:00 +0800
commit695954efd12fd336224073ada03dede782495746 (patch)
treeecbc95018828943e2ba6474d02867842bbd09c50
parent6c38e866c43e9bf12c0910ab76d8d8e3bac15b06 (diff)
Divide metadata into user and auto metadata
-rw-r--r--binaryninjaapi.h2
-rw-r--r--binaryninjacore.h7
-rw-r--r--binaryview.cpp4
-rw-r--r--python/binaryview.py8
4 files changed, 13 insertions, 8 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 8f9e8e61..89f5fd84 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -1803,7 +1803,7 @@ __attribute__ ((format (printf, 1, 2)))
std::vector<BNAddressRange> GetAllocatedRanges();
- void StoreMetadata(const std::string& key, Ref<Metadata> value);
+ void StoreMetadata(const std::string& key, Ref<Metadata> value, bool isAuto = false);
Ref<Metadata> QueryMetadata(const std::string& key);
void RemoveMetadata(const std::string& key);
std::string GetStringMetadata(const std::string& key);
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 41c3acc1..f2a487cb 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 8
+#define BN_CURRENT_CORE_ABI_VERSION 9
// 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 6
+#define BN_MINIMUM_CORE_ABI_VERSION 7
#ifdef __GNUC__
# ifdef BINARYNINJACORE_LIBRARY
@@ -5042,7 +5042,8 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI bool BNMetadataIsKeyValueStore(BNMetadata* data);
// Store/Query structured data to/from a BinaryView
- BINARYNINJACOREAPI void BNBinaryViewStoreMetadata(BNBinaryView* view, const char* key, BNMetadata* value);
+ BINARYNINJACOREAPI void BNBinaryViewStoreMetadata(BNBinaryView* view, const char* key,
+ BNMetadata* value, bool isAuto);
BINARYNINJACOREAPI BNMetadata* BNBinaryViewQueryMetadata(BNBinaryView* view, const char* key);
BINARYNINJACOREAPI void BNBinaryViewRemoveMetadata(BNBinaryView* view, const char* key);
diff --git a/binaryview.cpp b/binaryview.cpp
index ec3fc8f7..f37b60ff 100644
--- a/binaryview.cpp
+++ b/binaryview.cpp
@@ -3304,11 +3304,11 @@ vector<BNAddressRange> BinaryView::GetAllocatedRanges()
}
-void BinaryView::StoreMetadata(const std::string& key, Ref<Metadata> inValue)
+void BinaryView::StoreMetadata(const std::string& key, Ref<Metadata> inValue, bool isAuto)
{
if (!inValue)
return;
- BNBinaryViewStoreMetadata(m_object, key.c_str(), inValue->GetObject());
+ BNBinaryViewStoreMetadata(m_object, key.c_str(), inValue->GetObject(), isAuto);
}
diff --git a/python/binaryview.py b/python/binaryview.py
index e19e0a8a..7fc37287 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -6078,7 +6078,7 @@ class BinaryView(object):
raise KeyError(key)
return metadata.Metadata(handle=md_handle).value
- def store_metadata(self, key, md):
+ def store_metadata(self, key, md, isAuto = False):
"""
`store_metadata` stores an object for the given key in the current BinaryView. Objects stored using
`store_metadata` can be retrieved when the database is reopened. Objects stored are not arbitrary python
@@ -6088,6 +6088,10 @@ class BinaryView(object):
:param str key: key value to associate the Metadata object with
:param Varies md: object to store.
+ :param bool isAuto: whether the metadata is an auto metadata. Most metadata should
+ keep this as False. Only those automatically generated metadata should have this set
+ to True. Auto metadata is not saved into the database and is presumably re-genereated
+ when re-opening the database.
:rtype: None
:Example:
@@ -6103,7 +6107,7 @@ class BinaryView(object):
"""
if not isinstance(md, metadata.Metadata):
md = metadata.Metadata(md)
- core.BNBinaryViewStoreMetadata(self.handle, key, md.handle)
+ core.BNBinaryViewStoreMetadata(self.handle, key, md.handle, isAuto)
def remove_metadata(self, key):
"""