Skip to content

Commit 9b4183e

Browse files
committed
[Rust] Add FileMetadata::forget_undo_actions
Need this for WARP, see next commit
1 parent c953977 commit 9b4183e

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

rust/src/file_metadata.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ use crate::rc::*;
1818
use crate::string::*;
1919
use binaryninjacore_sys::{
2020
BNBeginUndoActions, BNCloseFile, BNCommitUndoActions, BNCreateDatabase, BNCreateFileMetadata,
21-
BNFileMetadata, BNFileMetadataGetSessionId, BNFreeFileMetadata, BNGetCurrentOffset,
22-
BNGetCurrentView, BNGetExistingViews, BNGetFileMetadataDatabase, BNGetFileViewOfType,
23-
BNGetFilename, BNGetProjectFile, BNIsAnalysisChanged, BNIsBackedByDatabase, BNIsFileModified,
24-
BNMarkFileModified, BNMarkFileSaved, BNNavigate, BNNewFileReference,
25-
BNOpenDatabaseForConfiguration, BNOpenExistingDatabase, BNRedo, BNRevertUndoActions,
26-
BNSaveAutoSnapshot, BNSetFilename, BNUndo,
21+
BNFileMetadata, BNFileMetadataGetSessionId, BNForgetUndoActions, BNFreeFileMetadata,
22+
BNGetCurrentOffset, BNGetCurrentView, BNGetExistingViews, BNGetFileMetadataDatabase,
23+
BNGetFileViewOfType, BNGetFilename, BNGetProjectFile, BNIsAnalysisChanged,
24+
BNIsBackedByDatabase, BNIsFileModified, BNMarkFileModified, BNMarkFileSaved, BNNavigate,
25+
BNNewFileReference, BNOpenDatabaseForConfiguration, BNOpenExistingDatabase, BNRedo,
26+
BNRevertUndoActions, BNSaveAutoSnapshot, BNSetFilename, BNUndo,
2727
};
2828
use binaryninjacore_sys::{BNCreateDatabaseWithProgress, BNOpenExistingDatabaseWithProgress};
2929
use std::ffi::c_void;
@@ -180,6 +180,20 @@ impl FileMetadata {
180180
}
181181
}
182182

183+
/// Forgets the undo actions committed in the undo entry.
184+
///
185+
/// NOTE: This is **NOT** thread safe, if you are holding any locks that might be held by both the main thread
186+
/// and the thread executing this function, you can deadlock. You should also never call this function
187+
/// on multiple threads at a time. See the following issues:
188+
/// - <https://github.com/Vector35/binaryninja-api/issues/6289>
189+
/// - <https://github.com/Vector35/binaryninja-api/issues/6325>
190+
pub fn forget_undo_actions(&self, id: &str) {
191+
let id = id.to_cstr();
192+
unsafe {
193+
BNForgetUndoActions(self.handle, id.as_ref().as_ptr() as *const _);
194+
}
195+
}
196+
183197
pub fn undo(&self) {
184198
unsafe {
185199
BNUndo(self.handle);

0 commit comments

Comments
 (0)