summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2023-05-31 20:55:14 -0400
committerGlenn Smith <glenn@vector35.com>2023-06-08 17:18:30 -0400
commit8804952612609239040025330591356571302187 (patch)
tree5cb3e3eaf6216758b825c3581d6702ef62a24bdb
parent1509435163893916647427200437885127141494 (diff)
API to read raw undo buffer (for DHView)
-rw-r--r--binaryninjaapi.h1
-rw-r--r--binaryninjacore.h1
-rw-r--r--database.cpp11
3 files changed, 13 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 5f4f6d16..63293812 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -1909,6 +1909,7 @@ namespace BinaryNinja {
std::vector<Ref<Snapshot>> GetChildren();
DataBuffer GetFileContents();
DataBuffer GetFileContentsHash();
+ DataBuffer GetUndoData();
std::vector<UndoEntry> GetUndoEntries();
std::vector<UndoEntry> GetUndoEntries(const std::function<bool(size_t, size_t)>& progress);
Ref<KeyValueStore> ReadData();
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 210a4322..e1e9a830 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -3244,6 +3244,7 @@ extern "C"
BINARYNINJACOREAPI BNKeyValueStore* BNReadSnapshotData(BNSnapshot* snapshot);
BINARYNINJACOREAPI BNKeyValueStore* BNReadSnapshotDataWithProgress(
BNSnapshot* snapshot, void* ctxt, bool (*progress)(void* ctxt, size_t progress, size_t total));
+ BINARYNINJACOREAPI BNDataBuffer* BNGetSnapshotUndoData(BNSnapshot* snapshot);
BINARYNINJACOREAPI BNUndoEntry* BNGetSnapshotUndoEntries(BNSnapshot* snapshot, size_t* count);
BINARYNINJACOREAPI BNUndoEntry* BNGetSnapshotUndoEntriesWithProgress(
BNSnapshot* snapshot, void* ctxt, bool (*progress)(void* ctxt, size_t progress, size_t total), size_t* count);
diff --git a/database.cpp b/database.cpp
index 887cdea7..dd258967 100644
--- a/database.cpp
+++ b/database.cpp
@@ -276,6 +276,17 @@ DataBuffer Snapshot::GetFileContentsHash()
}
+DataBuffer Snapshot::GetUndoData()
+{
+ BNDataBuffer* buffer = BNGetSnapshotUndoData(m_object);
+ if (buffer == nullptr)
+ {
+ throw DatabaseException("BNGetSnapshotUndoData");
+ }
+ return DataBuffer(buffer);
+}
+
+
vector<UndoEntry> Snapshot::GetUndoEntries()
{
return GetUndoEntries([](size_t, size_t) { return true; });