diff options
| author | Mason Reed <mason@vector35.com> | 2026-04-21 18:10:51 -0700 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2026-05-10 17:13:08 -0700 |
| commit | c4ba6d79ae3b96d56cc6b3744e7c64e004ecd161 (patch) | |
| tree | 5762fc3ff58b57caec5f42176faf6635c464b4f3 /rust/src/types | |
| parent | 8269a8ac29e59c7949af753dac5c1f36bb700903 (diff) | |
[Rust] Refactor `binary_view` module
- Remove the "viral" `BinaryViewExt` trait and its blanket impl
- Split up the binary view type from the custom trait impl
- Simplify and fix bugs regarding custom binary view initialization
- Rewrite Minidump binary view example, parses the PE headers to create proper sections now
- Add some extra documentation
- Add unit test for custom binary view
Diffstat (limited to 'rust/src/types')
| -rw-r--r-- | rust/src/types/library.rs | 10 | ||||
| -rw-r--r-- | rust/src/types/structure.rs | 9 |
2 files changed, 8 insertions, 11 deletions
diff --git a/rust/src/types/library.rs b/rust/src/types/library.rs index 8743b896..9b543362 100644 --- a/rust/src/types/library.rs +++ b/rust/src/types/library.rs @@ -17,8 +17,6 @@ use std::ptr::NonNull; // Used for doc comments #[allow(unused_imports)] use crate::binary_view::BinaryView; -#[allow(unused_imports)] -use crate::binary_view::BinaryViewExt; // TODO: Introduce a FinalizedTypeLibrary that cannot be mutated, so we do not have APIs that are unusable. @@ -261,7 +259,7 @@ impl TypeLibrary { /// Referenced types will not automatically be added, so make sure to add referenced types to the /// library or use [`TypeLibrary::add_type_source`] to mark the references originating source. /// - /// To add objects from a binary view, prefer using [`BinaryViewExt::export_object_to_library`] which + /// To add objects from a binary view, prefer using [`BinaryView::export_object_to_library`] which /// will automatically pull in all referenced types and record additional dependencies as needed. pub fn add_named_object(&self, name: QualifiedName, type_: &Type) { let mut raw_name = QualifiedName::into_raw(name); @@ -280,7 +278,7 @@ impl TypeLibrary { /// Referenced types will not automatically be added, so make sure to add referenced types to the /// library or use [`TypeLibrary::add_type_source`] to mark the references originating source. /// - /// To add types from a binary view, prefer using [`BinaryViewExt::export_type_to_library`] which + /// To add types from a binary view, prefer using [`BinaryView::export_type_to_library`] which /// will automatically pull in all referenced types and record additional dependencies as needed. pub fn add_named_type(&self, name: QualifiedName, type_: &Type) { let mut raw_name = QualifiedName::into_raw(name); @@ -320,7 +318,7 @@ impl TypeLibrary { /// Get the object (function) associated with the given name, if any. /// - /// Prefer [`BinaryViewExt::import_type_library_object`] as it will recursively import types required. + /// Prefer [`BinaryView::import_type_library_object`] as it will recursively import types required. pub fn get_named_object(&self, name: QualifiedName) -> Option<Ref<Type>> { let mut raw_name = QualifiedName::into_raw(name); let t = unsafe { BNGetTypeLibraryNamedObject(self.as_raw(), &mut raw_name) }; @@ -330,7 +328,7 @@ impl TypeLibrary { /// Get the type associated with the given name, if any. /// - /// Prefer [`BinaryViewExt::import_type_library_type`] as it will recursively import types required. + /// Prefer [`BinaryView::import_type_library_type`] as it will recursively import types required. pub fn get_named_type(&self, name: QualifiedName) -> Option<Ref<Type>> { let mut raw_name = QualifiedName::into_raw(name); let t = unsafe { BNGetTypeLibraryNamedType(self.as_raw(), &mut raw_name) }; diff --git a/rust/src/types/structure.rs b/rust/src/types/structure.rs index 3b609287..6dd8048a 100644 --- a/rust/src/types/structure.rs +++ b/rust/src/types/structure.rs @@ -7,9 +7,9 @@ use crate::types::{ use binaryninjacore_sys::*; use std::fmt::{Debug, Formatter}; -// Needed for doc comments +// Used for documentation purposes. #[allow(unused)] -use crate::binary_view::BinaryViewExt; +use crate::binary_view::BinaryView; #[derive(PartialEq, Eq, Hash)] pub struct StructureBuilder { @@ -18,7 +18,6 @@ pub struct StructureBuilder { /// ```no_run /// // Includes -/// # use binaryninja::binary_view::BinaryViewExt; /// use binaryninja::types::{MemberAccess, MemberScope, Structure, StructureBuilder, Type}; /// /// // Types to use in the members @@ -349,7 +348,7 @@ impl Structure { /// /// We must pass a [`TypeContainer`] here so that we can resolve base structure members, as they /// are treated as members through this function. Typically, you get the [`TypeContainer`] - /// through the binary view with [`BinaryViewExt::type_container`]. + /// through the binary view with [`BinaryView::type_container`]. pub fn members_at_offset( &self, container: &TypeContainer, @@ -382,7 +381,7 @@ impl Structure { /// Returns the list of all structure members, including inherited ones. /// /// Because we must traverse through base structures, we have to provide the [`TypeContainer`]; - /// in most cases it is ok to provide the binary views container via [`BinaryViewExt::type_container`]. + /// in most cases it is ok to provide the binary views container via [`BinaryView::type_container`]. pub fn members_including_inherited( &self, container: &TypeContainer, |
