summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXusheng <xusheng@vector35.com>2022-10-20 11:17:20 +0800
committerXusheng <xusheng@vector35.com>2022-10-20 11:17:20 +0800
commitb160aa0bac77a45bd7c4f39c6fe0263059239d4b (patch)
tree22be3f2fa522da713f92b58b151947df7cf34dd6
parent824aa7f7fc88713e74932c6d3230a6fb2d29df97 (diff)
Properly remove the debugger view from the FileMetadata after the target exits. Fix https://github.com/Vector35/debugger/issues/279
-rw-r--r--binaryninjaapi.h16
-rw-r--r--binaryninjacore.h4
-rw-r--r--filemetadata.cpp6
3 files changed, 25 insertions, 1 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index d8163343..1dcdc48a 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -1845,6 +1845,22 @@ namespace BinaryNinja {
\return Current Session ID
*/
size_t GetSessionId() const;
+
+ /*! Explicitly unregister a binary view of the given type from this file.
+
+ \note There is no need to unregister a binary view in ordinary situations. Binary views will be
+ automatically unregistered from the file when the file itself is about to be freed. Also, when a
+ binary view with the same type is created, the old one is automatically unregistered from the file.
+
+ Only use this function when you wish to explicitly remove the binary view from the file. For example,
+ in the debugger, this method is used to remove the Debugger view from the file after the target exits.
+
+ This also does not necessarily free the binary, because there could be other references to it.
+
+ \param type the type of the view to unregister
+ \param data the binary view to unregister
+ */
+ void UnregisterViewOfType(const std::string& type, BinaryNinja::Ref<BinaryNinja::BinaryView> data);
};
class Function;
diff --git a/binaryninjacore.h b/binaryninjacore.h
index cb0d9b10..e9f7bdca 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -36,7 +36,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 25
+#define BN_CURRENT_CORE_ABI_VERSION 26
// 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
@@ -3243,6 +3243,8 @@ extern "C"
BINARYNINJACOREAPI bool BNIsSnapshotDataAppliedWithoutError(BNFileMetadata* view);
+ BINARYNINJACOREAPI void BNUnregisterViewOfType(BNFileMetadata* file, const char* type, BNBinaryView* view);
+
// Binary view access
BINARYNINJACOREAPI BNBinaryView* BNNewViewReference(BNBinaryView* view);
BINARYNINJACOREAPI void BNFreeBinaryView(BNBinaryView* view);
diff --git a/filemetadata.cpp b/filemetadata.cpp
index 84c25e62..47190829 100644
--- a/filemetadata.cpp
+++ b/filemetadata.cpp
@@ -546,6 +546,12 @@ bool FileMetadata::IsSnapshotDataAppliedWithoutError() const
}
+void FileMetadata::UnregisterViewOfType(const std::string& type, BinaryNinja::Ref<BinaryNinja::BinaryView> data)
+{
+ BNUnregisterViewOfType(m_object, type.c_str(), data->GetObject());
+}
+
+
SaveSettings::SaveSettings()
{
m_object = BNCreateSaveSettings();