summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-06-05 12:31:02 -0400
committerMason Reed <mason@vector35.com>2025-06-05 12:31:07 -0400
commitc03957c2db8ff6c57f154cb27077bbb36e8cca43 (patch)
tree2781e8e5343f3319061b886d1c52f7578aa21b5f
parentb9049f1fda24641f08c3ae6029292ba0b1b0dc53 (diff)
Fix and add code docs regarding FileMetadata view types vs view names
-rw-r--r--binaryninjaapi.h6
-rw-r--r--rust/src/file_metadata.rs18
2 files changed, 21 insertions, 3 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 6c9f8514..c36e21a2 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -3176,14 +3176,14 @@ namespace BinaryNinja {
/*! Get the BinaryView for a specific View type
- \param name View name. e.g. ``Linear:ELF``, ``Graph:PE``
+ \param name View type. e.g. ``ELF``, ``PE``
\return The BinaryView, if it exists
*/
BinaryNinja::Ref<BinaryNinja::BinaryView> GetViewOfType(const std::string& name);
- /*! List of View names that exist within the current file
+ /*! List of View types that exist within the current file
- \return List of View Names
+ \return List of View Types
*/
std::vector<std::string> GetExistingViews() const;
diff --git a/rust/src/file_metadata.rs b/rust/src/file_metadata.rs
index ed859775..6d123373 100644
--- a/rust/src/file_metadata.rs
+++ b/rust/src/file_metadata.rs
@@ -200,6 +200,15 @@ impl FileMetadata {
unsafe { BNGetCurrentOffset(self.handle) }
}
+ /// Navigate to an offset for a specific view.
+ ///
+ /// # Example
+ ///
+ /// ```no_run
+ /// use binaryninja::file_metadata::FileMetadata;
+ /// # let file: FileMetadata = unimplemented!();
+ /// file.navigate_to("Linear:Raw", 0x0).expect("Linear:Raw should always be present");
+ /// ```
pub fn navigate_to(&self, view: &str, offset: u64) -> Result<(), ()> {
let view = view.to_cstr();
@@ -212,6 +221,15 @@ impl FileMetadata {
}
}
+ /// Get the [`BinaryView`] for the view type.
+ ///
+ /// # Example
+ ///
+ /// ```no_run
+ /// use binaryninja::file_metadata::FileMetadata;
+ /// # let file: FileMetadata = unimplemented!();
+ /// file.view_of_type("Raw").expect("Raw type should always be present");
+ /// ```
pub fn view_of_type(&self, view: &str) -> Option<Ref<BinaryView>> {
let view = view.to_cstr();