From 8804952612609239040025330591356571302187 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Wed, 31 May 2023 20:55:14 -0400 Subject: API to read raw undo buffer (for DHView) --- binaryninjaapi.h | 1 + binaryninjacore.h | 1 + database.cpp | 11 +++++++++++ 3 files changed, 13 insertions(+) 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> GetChildren(); DataBuffer GetFileContents(); DataBuffer GetFileContentsHash(); + DataBuffer GetUndoData(); std::vector GetUndoEntries(); std::vector GetUndoEntries(const std::function& progress); Ref 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 Snapshot::GetUndoEntries() { return GetUndoEntries([](size_t, size_t) { return true; }); -- cgit v1.3.1