diff options
| author | Mason Reed <mason@vector35.com> | 2024-07-09 20:17:36 -0400 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2024-07-09 20:18:22 -0400 |
| commit | 283410e6209134b0980363ca297abeb7dea75001 (patch) | |
| tree | 5d80b1e929e8dc96fc6c7a2f72abe8f209d0f89d /rust/src | |
| parent | 3fa13291909144ebbd41b6f70ea4a16dee242ecf (diff) | |
Add ability to access database from rust API using FileMetadata
Diffstat (limited to 'rust/src')
| -rw-r--r-- | rust/src/filemetadata.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/rust/src/filemetadata.rs b/rust/src/filemetadata.rs index 0ef427c4..7d385a4c 100644 --- a/rust/src/filemetadata.rs +++ b/rust/src/filemetadata.rs @@ -27,6 +27,7 @@ use binaryninjacore_sys::{ BNIsAnalysisChanged, BNIsBackedByDatabase, //BNSetFileMetadataNavigationHandler, + BNGetFileMetadataDatabase, BNIsFileModified, BNMarkFileModified, BNMarkFileSaved, @@ -43,6 +44,7 @@ use binaryninjacore_sys::{ use binaryninjacore_sys::{BNCreateDatabaseWithProgress, BNOpenExistingDatabaseWithProgress}; use crate::binaryview::BinaryView; +use crate::database::Database; use crate::rc::*; use crate::string::*; @@ -283,6 +285,12 @@ impl FileMetadata { Ok(unsafe { BinaryView::from_raw(view) }) } } + + /// Get the current database + pub fn database(&self) -> Option<Database> { + let result = unsafe { BNGetFileMetadataDatabase(self.handle) }; + ptr::NonNull::new(result).map(|handle| unsafe { Database::from_raw(handle) }) + } } impl ToOwned for FileMetadata { |
