From c03957c2db8ff6c57f154cb27077bbb36e8cca43 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Thu, 5 Jun 2025 12:31:02 -0400 Subject: Fix and add code docs regarding FileMetadata view types vs view names --- binaryninjaapi.h | 6 +++--- rust/src/file_metadata.rs | 18 ++++++++++++++++++ 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 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 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> { let view = view.to_cstr(); -- cgit v1.3.1