summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-07-06 17:13:27 -0400
committerMason Reed <mason@vector35.com>2025-07-06 17:13:27 -0400
commit9b4183e62ae5a2ca166fb7552d68a0e84467ca02 (patch)
treec233839ef309d794066f30e4054c490e4ed0390c
parentc953977c69ee829609debc0447fc09f3ff2b395b (diff)
[Rust] Add `FileMetadata::forget_undo_actions`
Need this for WARP, see next commit
-rw-r--r--rust/src/file_metadata.rs26
1 files changed, 20 insertions, 6 deletions
diff --git a/rust/src/file_metadata.rs b/rust/src/file_metadata.rs
index 4cbbfd0a..86e28a3e 100644
--- a/rust/src/file_metadata.rs
+++ b/rust/src/file_metadata.rs
@@ -18,12 +18,12 @@ use crate::rc::*;
use crate::string::*;
use binaryninjacore_sys::{
BNBeginUndoActions, BNCloseFile, BNCommitUndoActions, BNCreateDatabase, BNCreateFileMetadata,
- BNFileMetadata, BNFileMetadataGetSessionId, BNFreeFileMetadata, BNGetCurrentOffset,
- BNGetCurrentView, BNGetExistingViews, BNGetFileMetadataDatabase, BNGetFileViewOfType,
- BNGetFilename, BNGetProjectFile, BNIsAnalysisChanged, BNIsBackedByDatabase, BNIsFileModified,
- BNMarkFileModified, BNMarkFileSaved, BNNavigate, BNNewFileReference,
- BNOpenDatabaseForConfiguration, BNOpenExistingDatabase, BNRedo, BNRevertUndoActions,
- BNSaveAutoSnapshot, BNSetFilename, BNUndo,
+ BNFileMetadata, BNFileMetadataGetSessionId, BNForgetUndoActions, BNFreeFileMetadata,
+ BNGetCurrentOffset, BNGetCurrentView, BNGetExistingViews, BNGetFileMetadataDatabase,
+ BNGetFileViewOfType, BNGetFilename, BNGetProjectFile, BNIsAnalysisChanged,
+ BNIsBackedByDatabase, BNIsFileModified, BNMarkFileModified, BNMarkFileSaved, BNNavigate,
+ BNNewFileReference, BNOpenDatabaseForConfiguration, BNOpenExistingDatabase, BNRedo,
+ BNRevertUndoActions, BNSaveAutoSnapshot, BNSetFilename, BNUndo,
};
use binaryninjacore_sys::{BNCreateDatabaseWithProgress, BNOpenExistingDatabaseWithProgress};
use std::ffi::c_void;
@@ -180,6 +180,20 @@ impl FileMetadata {
}
}
+ /// Forgets the undo actions committed in the undo entry.
+ ///
+ /// NOTE: This is **NOT** thread safe, if you are holding any locks that might be held by both the main thread
+ /// and the thread executing this function, you can deadlock. You should also never call this function
+ /// on multiple threads at a time. See the following issues:
+ /// - <https://github.com/Vector35/binaryninja-api/issues/6289>
+ /// - <https://github.com/Vector35/binaryninja-api/issues/6325>
+ pub fn forget_undo_actions(&self, id: &str) {
+ let id = id.to_cstr();
+ unsafe {
+ BNForgetUndoActions(self.handle, id.as_ref().as_ptr() as *const _);
+ }
+ }
+
pub fn undo(&self) {
unsafe {
BNUndo(self.handle);