BinaryView

Struct BinaryView 

Source
pub struct BinaryView {
    pub handle: *mut BNBinaryView,
}
Expand description

Represents the “whole view” of the binary and its analysis.

Analysis information:

Annotation information:

Data representation and binary information:

§Cleaning up

BinaryView has a cyclic relationship with the associated FileMetadata, each holds a strong reference to one another, so to properly clean up/free the BinaryView, you must manually close the file using FileMetadata::close, this is not fixable in the general case, until FileMetadata has only a weak reference to the BinaryView.

Fields§

§handle: *mut BNBinaryView

Implementations§

Source§

impl BinaryView

Source

pub unsafe fn from_raw(handle: *mut BNBinaryView) -> Self

Source

pub fn from_custom<C: CustomBinaryView>( view_type_name: &str, file: &FileMetadata, parent_view: &BinaryView, view: C, ) -> Result<Ref<Self>, ()>

Create a core instance of the CustomBinaryView.

Source

pub fn from_metadata(meta: &FileMetadata) -> Result<Ref<Self>, ()>

Construct the raw binary view from the given metadata.

Before calling this, make sure you have a valid file path set for the FileMetadata. It is required that the FileMetadata::file_path exist in the local filesystem.

Source

pub fn from_path( meta: &FileMetadata, file_path: impl AsRef<Path>, ) -> Result<Ref<Self>, ()>

Construct the raw binary view from the given file_path and metadata.

This will implicitly set the metadata file path and then construct the view. If the metadata already has the desired file path, use BinaryView::from_metadata instead.

Source

pub unsafe fn from_accessor<A: Accessor>( meta: &FileMetadata, accessor: &mut FileAccessor<A>, ) -> Result<Ref<Self>, ()>

Construct the raw binary view from the given accessor and metadata.

It is the responsibility of the caller to keep the accessor alive for the lifetime of the view; because of this, we mark the function as unsafe.

Source

pub fn from_data(meta: &FileMetadata, data: &[u8]) -> Ref<Self>

Construct the raw binary view from the given data and metadata.

The data will be copied into the view, so the caller does not need to keep the data alive.

Source

pub fn save_to_path(&self, file_path: impl AsRef<Path>) -> bool

Save the original binary file to the provided file_path along with any modifications.

WARNING: Currently, there is a possibility to deadlock if the analysis has queued up a main thread action that tries to take the FileMetadata lock of the current view and is executed while we are executing in this function.

To avoid the above issue, use crate::main_thread::execute_on_main_thread_and_wait to verify there are no queued up main thread actions.

Source

pub fn save_to_accessor<A: Accessor>(&self, file: &mut FileAccessor<A>) -> bool

Save the original binary file to the provided FileAccessor along with any modifications.

WARNING: Currently, there is a possibility to deadlock if the analysis has queued up a main thread action that tries to take the FileMetadata lock of the current view and is executed while we are executing in this function.

To avoid the above issue, use crate::main_thread::execute_on_main_thread_and_wait to verify there are no queued up main thread actions.

Source

pub fn file(&self) -> Ref<FileMetadata>

Source

pub fn parent_view(&self) -> Option<Ref<BinaryView>>

Source

pub fn raw_view(&self) -> Option<Ref<BinaryView>>

Source

pub fn view_type(&self) -> String

Source

pub fn read_vec(&self, offset: u64, len: usize) -> Vec<u8>

Reads up to len bytes from address offset

Source

pub fn read_into_vec( &self, dest: &mut Vec<u8>, offset: u64, len: usize, ) -> usize

Appends up to len bytes from address offset into dest

Source

pub fn read_c_string_at(&self, offset: u64, len: usize) -> Option<CString>

Reads up to len bytes from the address offset returning a CString if available.

Source

pub fn read_utf8_string_at(&self, offset: u64, len: usize) -> Option<String>

Reads up to len bytes from the address offset returning a String if available.

Source

pub fn search<C: FnMut(u64, &DataBuffer) -> bool>( &self, query: &SearchQuery, on_match: C, ) -> bool

Search the view using the query options.

In the on_match callback return false to stop searching.

Source

pub fn search_with_progress<P: ProgressCallback, C: FnMut(u64, &DataBuffer) -> bool>( &self, query: &SearchQuery, on_match: C, progress: P, ) -> bool

Search the view using the query options.

In the on_match callback return false to stop searching.

Source

pub fn find_next_data( &self, start: u64, end: u64, data: &DataBuffer, ) -> Option<u64>

Source

pub fn find_next_data_with_opts<P: ProgressCallback>( &self, start: u64, end: u64, data: &DataBuffer, flag: FindFlag, progress: P, ) -> Option<u64>

§Warning

This function is likely to be changed to take in a “query” structure. Or deprecated entirely.

Source

pub fn find_next_constant( &self, start: u64, end: u64, constant: u64, view_type: FunctionViewType, ) -> Option<u64>

Source

pub fn find_next_constant_with_opts<P: ProgressCallback>( &self, start: u64, end: u64, constant: u64, disasm_settings: &DisassemblySettings, view_type: FunctionViewType, progress: P, ) -> Option<u64>

§Warning

This function is likely to be changed to take in a “query” structure.

Source

pub fn find_next_text( &self, start: u64, end: u64, text: &str, view_type: FunctionViewType, ) -> Option<u64>

Source

pub fn find_next_text_with_opts<P: ProgressCallback>( &self, start: u64, end: u64, text: &str, disasm_settings: &DisassemblySettings, flag: FindFlag, view_type: FunctionViewType, progress: P, ) -> Option<u64>

§Warning

This function is likely to be changed to take in a “query” structure.

Source

pub fn notify_data_written(&self, offset: u64, len: usize)

Source

pub fn notify_data_inserted(&self, offset: u64, len: usize)

Source

pub fn notify_data_removed(&self, offset: u64, len: usize)

Source

pub fn offset_has_code_semantics(&self, offset: u64) -> bool

Consults the Section’s current crate::section::Semantics to determine if the offset has code semantics.

Source

pub fn offset_has_extern_semantics(&self, offset: u64) -> bool

Check if the offset is within a Section with crate::section::Semantics::External.

Source

pub fn offset_has_writable_semantics(&self, offset: u64) -> bool

Consults the Section’s current crate::section::Semantics to determine if the offset has writable semantics.

Source

pub fn offset_has_read_only_semantics(&self, offset: u64) -> bool

Consults the Section’s current crate::section::Semantics to determine if the offset has read only semantics.

Source

pub fn image_base(&self) -> u64

Source

pub fn original_image_base(&self) -> u64

Source

pub fn set_original_image_base(&self, image_base: u64)

Source

pub fn end(&self) -> u64

The highest address in the view.

Source

pub fn add_analysis_option(&self, name: &str)

Source

pub fn has_initial_analysis(&self) -> bool

Source

pub fn set_analysis_hold(&self, enable: bool)

Source

pub fn update_analysis(&self)

Runs the analysis pipeline, analyzing any data that has been marked for updates.

You can explicitly mark a function to be updated with:

NOTE: This is a non-blocking call, use BinaryView::update_analysis_and_wait if you require analysis to have completed before moving on.

Source

pub fn update_analysis_and_wait(&self)

Runs the analysis pipeline, analyzing any data that has been marked for updates.

You can explicitly mark a function to be updated with:

NOTE: This is a blocking call, use BinaryView::update_analysis if you do not need to wait for the analysis update to finish.

Source

pub fn reanalyze(&self)

Causes all functions to be reanalyzed.

Use BinaryView::update_analysis or BinaryView::update_analysis_and_wait instead if you want to incrementally update analysis.

NOTE: This function does not wait for the analysis to finish.

Source

pub fn abort_analysis(&self)

Source

pub fn analysis_is_aborted(&self) -> bool

Source

pub fn workflow(&self) -> Ref<Workflow>

Source

pub fn analysis_info(&self) -> AnalysisInfo

Source

pub fn analysis_progress(&self) -> AnalysisProgress

Source

pub fn default_arch(&self) -> Option<CoreArchitecture>

Source

pub fn set_default_arch<A: Architecture>(&self, arch: &A)

Source

pub fn default_platform(&self) -> Option<Ref<Platform>>

Source

pub fn set_default_platform(&self, plat: &Platform)

Source

pub fn base_address_detection(&self) -> Option<BaseAddressDetection>

Source

pub fn instruction_len<A: Architecture>( &self, arch: &A, addr: u64, ) -> Option<usize>

Source

pub fn symbol_by_address(&self, addr: u64) -> Option<Ref<Symbol>>

Source

pub fn symbol_by_raw_name(&self, raw_name: impl IntoCStr) -> Option<Ref<Symbol>>

Source

pub fn symbols(&self) -> Array<Symbol>

Source

pub fn symbols_by_name(&self, name: impl IntoCStr) -> Array<Symbol>

Source

pub fn symbols_in_range(&self, range: Range<u64>) -> Array<Symbol>

Source

pub fn symbols_of_type(&self, ty: SymbolType) -> Array<Symbol>

Source

pub fn symbols_of_type_in_range( &self, ty: SymbolType, range: Range<u64>, ) -> Array<Symbol>

Source

pub fn define_auto_symbol(&self, sym: &Symbol)

Source

pub fn define_auto_symbol_with_type<'a, T: Into<Option<&'a Type>>>( &self, sym: &Symbol, plat: &Platform, ty: T, ) -> Ref<Symbol>

Defines the symbol as well as the analysis object associated with the given symbol type, such as the data variable for a SymbolType::Data, or the function for a SymbolType::Function. Returns the symbol, as it was applied to the binary view.

Source

pub fn undefine_auto_symbol(&self, sym: &Symbol)

Source

pub fn define_user_symbol(&self, sym: &Symbol)

Source

pub fn undefine_user_symbol(&self, sym: &Symbol)

Source

pub fn data_variables(&self) -> Array<DataVariable>

Source

pub fn data_variable_at_address(&self, addr: u64) -> Option<DataVariable>

Source

pub fn define_auto_data_var<'a, T: Into<Conf<&'a Type>>>( &self, addr: u64, ty: T, )

Source

pub fn define_user_data_var<'a, T: Into<Conf<&'a Type>>>( &self, addr: u64, ty: T, )

You likely would also like to call BinaryView::define_user_symbol to bind this data variable with a name

Source

pub fn undefine_auto_data_var(&self, addr: u64, blacklist: Option<bool>)

Source

pub fn undefine_user_data_var(&self, addr: u64)

Source

pub fn define_auto_type<T: Into<QualifiedName>>( &self, name: T, source: &str, type_obj: &Type, ) -> QualifiedName

Source

pub fn define_auto_type_with_id<T: Into<QualifiedName>>( &self, name: T, id: &str, type_obj: &Type, ) -> QualifiedName

Source

pub fn define_user_type<T: Into<QualifiedName>>(&self, name: T, type_obj: &Type)

Source

pub fn define_auto_types<T, I>( &self, names_sources_and_types: T, ) -> HashMap<String, QualifiedName>
where T: Iterator<Item = I>, I: Into<QualifiedNameTypeAndId>,

Source

pub fn define_auto_types_with_progress<T, I, P>( &self, names_sources_and_types: T, progress: P, ) -> HashMap<String, QualifiedName>

Source

pub fn define_user_types<T, I>(&self, names_and_types: T)
where T: Iterator<Item = I>, I: Into<QualifiedNameAndType>,

Source

pub fn define_user_types_with_progress<T, I, P>( &self, names_and_types: T, progress: P, )
where T: Iterator<Item = I>, I: Into<QualifiedNameAndType>, P: ProgressCallback,

Source

pub fn undefine_auto_type(&self, id: &str)

Source

pub fn undefine_user_type<T: Into<QualifiedName>>(&self, name: T)

Source

pub fn types(&self) -> Array<QualifiedNameAndType>

Source

pub fn dependency_sorted_types(&self) -> Array<QualifiedNameAndType>

Source

pub fn type_by_name<T: Into<QualifiedName>>(&self, name: T) -> Option<Ref<Type>>

Source

pub fn type_by_ref(&self, ref_: &NamedTypeReference) -> Option<Ref<Type>>

Source

pub fn type_by_id(&self, id: &str) -> Option<Ref<Type>>

Source

pub fn type_name_by_id(&self, id: &str) -> Option<QualifiedName>

Source

pub fn type_id_by_name<T: Into<QualifiedName>>(&self, name: T) -> Option<String>

Source

pub fn is_type_auto_defined<T: Into<QualifiedName>>(&self, name: T) -> bool

Source

pub fn segments(&self) -> Array<Segment>

Source

pub fn segment_at(&self, addr: u64) -> Option<Ref<Segment>>

Source

pub fn add_segment(&self, segment: SegmentBuilder)

Adds a segment to the view.

NOTE: Consider using BinaryView::begin_bulk_add_segments and BinaryView::end_bulk_add_segments if you plan on adding a number of segments all at once, to avoid unnecessary MemoryMap updates.

Source

pub fn begin_bulk_add_segments(&self)

Start adding segments in bulk. Useful for adding large numbers of segments.

After calling this any call to BinaryView::add_segment will be uncommitted until a call to BinaryView::end_bulk_add_segments

If you wish to discard the uncommitted segments you can call BinaryView::cancel_bulk_add_segments.

NOTE: This must be paired with a later call to BinaryView::end_bulk_add_segments or BinaryView::cancel_bulk_add_segments, otherwise segments added after this call will stay uncommitted.

Source

pub fn end_bulk_add_segments(&self)

Commit all auto and user segments that have been added since the call to Self::begin_bulk_add_segments.

NOTE: This must be paired with a prior call to Self::begin_bulk_add_segments, otherwise this does nothing and segments are added individually.

Source

pub fn cancel_bulk_add_segments(&self)

Flushes the auto and user segments that have yet to be committed.

This is to be used in conjunction with Self::begin_bulk_add_segments and Self::end_bulk_add_segments, where the latter will commit the segments which have been added since Self::begin_bulk_add_segments, this function will discard them so that they do not get added to the view.

Source

pub fn add_section(&self, section: SectionBuilder)

Source

pub fn remove_auto_section(&self, name: impl IntoCStr)

Source

pub fn remove_user_section(&self, name: impl IntoCStr)

Source

pub fn section_by_name(&self, name: impl IntoCStr) -> Option<Ref<Section>>

Source

pub fn sections(&self) -> Array<Section>

Source

pub fn sections_at(&self, addr: u64) -> Array<Section>

Source

pub fn memory_map(&self) -> MemoryMap

Source

pub fn add_auto_function(&self, address: u64) -> Option<Ref<Function>>

Add an auto function at the given address with the views default platform.

Use BinaryView::add_auto_function_with_platform if you wish to specify a platform.

NOTE: The default platform must be set for this view!

Source

pub fn add_auto_function_with_platform( &self, address: u64, platform: &Platform, ) -> Option<Ref<Function>>

Add an auto function at the given address with the platform.

Use BinaryView::add_auto_function_ext if you wish to specify a function type.

NOTE: If the view’s default platform is not set, this will set it to platform.

Source

pub fn add_auto_function_ext( &self, address: u64, platform: &Platform, func_type: Option<&Type>, ) -> Option<Ref<Function>>

Add an auto function at the given address with the platform and function type.

NOTE: If the view’s default platform is not set, this will set it to platform.

Source

pub fn remove_auto_function(&self, func: &Function, update_refs: bool)

Remove an auto function from the view.

Pass true for update_refs to update all references of the function.

NOTE: Unlike BinaryView::remove_user_function, this will NOT prohibit the function from being re-added in the future, use BinaryView::remove_user_function to blacklist the function from being automatically created.

Source

pub fn add_user_function(&self, addr: u64) -> Option<Ref<Function>>

Add a user function at the given address with the views default platform.

Use BinaryView::add_user_function_with_platform if you wish to specify a platform.

NOTE: The default platform must be set for this view!

Source

pub fn add_user_function_with_platform( &self, addr: u64, platform: &Platform, ) -> Option<Ref<Function>>

Add an auto function at the given address with the platform.

NOTE: If the view’s default platform is not set, this will set it to platform.

Source

pub fn remove_user_function(&self, func: &Function)

Removes the function from the view and blacklists it from being created automatically.

NOTE: If you call BinaryView::add_user_function, it will override the blacklist.

Source

pub fn has_functions(&self) -> bool

Source

pub fn add_entry_point(&self, addr: u64)

Add an entry point at the given address with the view’s default platform.

NOTE: The default platform must be set for this view!

Source

pub fn add_entry_point_with_platform(&self, addr: u64, platform: &Platform)

Add an entry point at the given address with the platform.

NOTE: If the view’s default platform is not set, this will set it to platform.

Source

pub fn entry_point_function(&self) -> Option<Ref<Function>>

Source

pub fn entry_point_functions(&self) -> Array<Function>

This list contains the analysis entry function, and functions like init_array, fini_array, and TLS callbacks etc.

We see entry_functions as good starting points for analysis, these functions normally don’t have internal references. Exported functions in a dll/so file are not included.

Source

pub fn functions(&self) -> Array<Function>

Source

pub fn functions_at(&self, addr: u64) -> Array<Function>

List of functions starting at addr

Source

pub fn functions_containing(&self, addr: u64) -> Array<Function>

List of functions containing addr

Source

pub fn functions_by_name( &self, name: impl IntoCStr, plat: Option<&Platform>, ) -> Vec<Ref<Function>>

List of functions with the given name.

There is one special case where if you pass a string of the form sub_[0-9a-f]+ then it will lookup all functions defined at the address matched by the regular expression if that symbol is not defined in the database.

§Params
  • name: Name that the function should have
  • plat: Optional platform that the function should be defined for. Defaults to all platforms if None passed.
Source

pub fn function_at( &self, platform: &Platform, addr: u64, ) -> Option<Ref<Function>>

Source

pub fn function_start_before(&self, addr: u64) -> u64

Source

pub fn function_start_after(&self, addr: u64) -> u64

Source

pub fn basic_blocks_containing( &self, addr: u64, ) -> Array<BasicBlock<NativeBlock>>

Source

pub fn basic_blocks_starting_at( &self, addr: u64, ) -> Array<BasicBlock<NativeBlock>>

Source

pub fn is_new_auto_function_analysis_suppressed(&self) -> bool

Source

pub fn set_new_auto_function_analysis_suppressed(&self, suppress: bool)

Source

pub fn should_skip_target_analysis( &self, src_loc: impl Into<Location>, src_func: &Function, src_end: u64, target: impl Into<Location>, ) -> bool

Source

pub fn read_buffer(&self, offset: u64, len: usize) -> Option<DataBuffer>

Source

pub fn debug_info(&self) -> Ref<DebugInfo>

Source

pub fn set_debug_info(&self, debug_info: &DebugInfo)

Source

pub fn apply_debug_info(&self, debug_info: &DebugInfo)

Source

pub fn show_plaintext_report(&self, title: &str, plaintext: &str)

Source

pub fn show_markdown_report(&self, title: &str, contents: &str, plaintext: &str)

Source

pub fn show_html_report(&self, title: &str, contents: &str, plaintext: &str)

Source

pub fn show_graph_report(&self, raw_name: &str, graph: &FlowGraph)

Source

pub fn load_settings(&self, view_type_name: &str) -> Option<Ref<Settings>>

Source

pub fn set_load_settings(&self, view_type_name: &str, settings: &Settings)

Source

pub fn create_tag_type(&self, name: &str, icon: &str) -> Ref<TagType>

Creates a new TagType and adds it to the view.

§Arguments
  • name - the name for the tag
  • icon - the icon (recommended 1 emoji or 2 chars) for the tag
Source

pub fn remove_tag_type(&self, tag_type: &TagType)

Removes a TagType and all tags that use it

Source

pub fn tag_type_by_name(&self, name: &str) -> Option<Ref<TagType>>

Get a tag type by its name.

Source

pub fn tags_all_scopes(&self) -> Array<TagReference>

Get all tags in all scopes

Source

pub fn tag_types(&self) -> Array<TagType>

Get all tag types present for the view

Source

pub fn tags_by_type(&self, tag_type: &TagType) -> Array<TagReference>

Get all tag references of a specific type

Source

pub fn tag_by_id(&self, id: &str) -> Option<Ref<Tag>>

Get a tag by its id.

Note this does not tell you anything about where it is used.

Source

pub fn add_tag(&self, addr: u64, t: &TagType, data: &str, user: bool)

Creates and adds a tag to an address

User tag creations will be added to the undo buffer

Source

pub fn remove_auto_data_tag(&self, addr: u64, tag: &Tag)

removes a Tag object at a data address.

Source

pub fn remove_user_data_tag(&self, addr: u64, tag: &Tag)

removes a Tag object at a data address. Since this removes a user tag, it will be added to the current undo buffer.

Source

pub fn comment_references(&self) -> Array<CommentReference>

Retrieves a list of comment addresses, the comments themselves can then be queried with the function BinaryView::comment_at.

If you would rather retrieve the contents of all comments at once you can do so with the helper function BinaryView::comments.

Source

pub fn comments(&self) -> BTreeMap<u64, String>

Retrieves a map of comment addresses to their contents.

This is a helper function that eagerly reads the contents of all comments within the view, use BinaryView::comment_references instead if you do not wish to read all the comments.

Source

pub fn comment_at(&self, addr: u64) -> Option<String>

Source

pub fn set_comment_at(&self, addr: u64, comment: &str)

Sets a comment for the BinaryView at the address specified.

NOTE: This is different from setting a comment at the function-level. To set a comment in a function use Function::set_comment_at

Source

pub fn get_next_linear_disassembly_lines( &self, pos: &mut LinearViewCursor, ) -> Array<LinearDisassemblyLine>

Retrieves a list of the next disassembly lines.

Retrieves an Array over LinearDisassemblyLine objects for the next disassembly lines, and updates the LinearViewCursor passed in. This function can be called repeatedly to get more lines of linear disassembly.

§Arguments
  • pos - Position to retrieve linear disassembly lines from
Source

pub fn get_previous_linear_disassembly_lines( &self, pos: &mut LinearViewCursor, ) -> Array<LinearDisassemblyLine>

Retrieves a list of the previous disassembly lines.

get_previous_linear_disassembly_lines retrieves an Array over LinearDisassemblyLine objects for the previous disassembly lines, and updates the LinearViewCursor passed in. This function can be called repeatedly to get more lines of linear disassembly.

§Arguments
  • pos - Position to retrieve linear disassembly lines relative to
Source

pub fn query_metadata(&self, key: &str) -> Option<Ref<Metadata>>

Source

pub fn get_metadata<T>(&self, key: &str) -> Option<T>
where T: for<'a> TryFrom<&'a Metadata>,

Retrieve the metadata as the type T.

Fails if the metadata does not exist, or if the metadata failed to coerce to type T.

Source

pub fn store_metadata<V>(&self, key: &str, value: V, is_auto: bool)
where V: Into<Ref<Metadata>>,

Source

pub fn remove_metadata(&self, key: &str)

Source

pub fn code_refs_to_addr(&self, addr: u64) -> Array<CodeReference>

Retrieves a list of CodeReferences pointing to a given address.

Source

pub fn code_refs_into_range(&self, range: Range<u64>) -> Array<CodeReference>

Retrieves a list of CodeReferences pointing into a given Range.

Source

pub fn code_refs_from_addr( &self, addr: u64, func: Option<&Function>, ) -> Vec<u64>

Retrieves a list of addresses pointed to by a given address.

Source

pub fn data_refs_to_addr(&self, addr: u64) -> Array<DataReference>

Retrieves a list of DataReferences pointing to a given address.

Source

pub fn data_refs_into_range(&self, range: Range<u64>) -> Array<DataReference>

Retrieves a list of DataReferences pointing into a given Range.

Source

pub fn data_refs_from_addr(&self, addr: u64) -> Array<DataReference>

Retrieves a list of DataReferences originating from a given address.

Source

pub fn code_refs_using_type_name<T: Into<QualifiedName>>( &self, name: T, ) -> Array<CodeReference>

Retrieves a list of CodeReferences for locations in code that use a given named type.

Source

pub fn data_refs_using_type_name<T: Into<QualifiedName>>( &self, name: T, ) -> Array<DataReference>

Retrieves a list of DataReferences for locations in data that use a given named type.

Source

pub fn relocations_at(&self, addr: u64) -> Array<Relocation>

Source

pub fn relocation_ranges(&self) -> Vec<Range<u64>>

Source

pub fn component_by_guid(&self, guid: &str) -> Option<Ref<Component>>

Source

pub fn root_component(&self) -> Option<Ref<Component>>

Source

pub fn component_by_path(&self, path: &str) -> Option<Ref<Component>>

Source

pub fn remove_component(&self, component: &Component) -> bool

Source

pub fn remove_component_by_guid(&self, guid: &str) -> bool

Source

pub fn data_variable_parent_components( &self, data_variable: &DataVariable, ) -> Array<Component>

Source

pub fn external_libraries(&self) -> Array<ExternalLibrary>

Source

pub fn external_library(&self, name: &str) -> Option<Ref<ExternalLibrary>>

Source

pub fn remove_external_library(&self, name: &str)

Source

pub fn add_external_library( &self, name: &str, backing_file: Option<&ProjectFile>, auto: bool, ) -> Option<Ref<ExternalLibrary>>

Source

pub fn external_locations(&self) -> Array<ExternalLocation>

Source

pub fn external_location_from_symbol( &self, symbol: &Symbol, ) -> Option<Ref<ExternalLocation>>

Source

pub fn remove_external_location(&self, location: &ExternalLocation)

Source

pub fn remove_external_location_from_symbol(&self, symbol: &Symbol)

Source

pub fn add_external_location( &self, symbol: &Symbol, library: &ExternalLibrary, target_symbol_name: &str, target_address: Option<u64>, target_is_auto: bool, ) -> Option<Ref<ExternalLocation>>

Source

pub fn type_container(&self) -> TypeContainer

Type container for all types (user and auto) in the Binary View.

NOTE: Modifying an auto type will promote it to a user type.

Source

pub fn user_type_container(&self) -> TypeContainer

Type container for user types in the Binary View.

Source

pub fn auto_type_container(&self) -> TypeContainer

Type container for auto types in the Binary View.

NOTE: Unlike Self::type_container modification of auto types will NOT promote it to a user type.

Source

pub fn type_libraries(&self) -> Array<TypeLibrary>

Source

pub fn add_type_library(&self, library: &TypeLibrary)

Make the contents of a type library available for type/import resolution

Source

pub fn type_library_by_name(&self, name: &str) -> Option<Ref<TypeLibrary>>

Source

pub fn record_imported_object_library<T: Into<QualifiedName>>( &self, lib: &TypeLibrary, name: T, addr: u64, platform: &Platform, )

Should be called by custom BinaryView implementations when they have successfully imported an object from a type library (eg a symbol’s type). Values recorded with this function will then be queryable via BinaryView::lookup_imported_object_library.

  • lib - Type Library containing the imported type
  • name - Name of the object in the type library
  • addr - address of symbol at import site
  • platform - Platform of symbol at import site
Source

pub fn import_type_library_type<T: Into<QualifiedName>>( &self, name: T, lib: Option<&TypeLibrary>, ) -> Option<Ref<Type>>

Recursively imports a type from the specified type library, or, if no library was explicitly provided, the first type library associated with the current BinaryView that provides the name requested.

This may have the impact of loading other type libraries as dependencies on other type libraries are lazily resolved when references to types provided by them are first encountered.

Note that the name actually inserted into the view may not match the name as it exists in the type library in the event of a name conflict. To aid in this, the Type object returned is a NamedTypeReference to the deconflicted name used.

Source

pub fn import_type_library_object<T: Into<QualifiedName>>( &self, name: T, lib: Option<&TypeLibrary>, ) -> Option<Ref<Type>>

Recursively imports an object (function) from the specified type library, or, if no library was explicitly provided, the first type library associated with the current BinaryView that provides the name requested.

This may have the impact of loading other type libraries as dependencies on other type libraries are lazily resolved when references to types provided by them are first encountered.

NOTE: If you are implementing a custom BinaryView and use this method to import object types, you should then call BinaryView::record_imported_object_library with the details of where the object is located.

Source

pub fn import_type_by_guid(&self, guid: &str) -> Option<Ref<Type>>

Recursively imports a Type given its GUID from available type libraries.

Source

pub fn export_type_to_library<T: Into<QualifiedName>>( &self, lib: &TypeLibrary, name: T, type_obj: &Type, )

Recursively exports type_obj into lib as a type with name name.

As other referenced types are encountered, they are either copied into the destination type library or else the type library that provided the referenced type is added as a dependency for the destination library.

Source

pub fn export_object_to_library<T: Into<QualifiedName>>( &self, lib: &TypeLibrary, name: T, type_obj: &Type, )

Recursively exports type_obj into lib as a type with name name.

As other referenced types are encountered, they are either copied into the destination type library or else the type library that provided the referenced type is added as a dependency for the destination library.

Source

pub fn lookup_imported_object_library( &self, addr: u64, platform: &Platform, ) -> Option<(Ref<TypeLibrary>, QualifiedName)>

Gives you details of which type library and name was used to determine the type of a symbol at a given address

  • addr - address of symbol at import site
  • platform - Platform of symbol at import site
Source

pub fn lookup_imported_type_library<T: Into<QualifiedName>>( &self, name: T, ) -> Option<(Ref<TypeLibrary>, QualifiedName)>

Gives you details of from which type library and name a given type in the analysis was imported.

  • name - Name of type in analysis
Source

pub fn strings(&self) -> Array<StringReference>

Retrieve all known strings in the binary.

NOTE: This returns a list of StringReference as strings may not be representable as a String or even a BnString. It is the caller’s responsibility to read the underlying data and convert it to a representable form.

Some helpers for reading strings are available:

NOTE: This returns discovered strings and is therefore governed by analysis.limits.minStringLength and other settings.

Source

pub fn string_at(&self, addr: u64) -> Option<StringReference>

Retrieve the string that falls on a given virtual address.

NOTE: This returns a StringReference and since strings may not be representable as a Rust String or even a BnString. It is the caller’s responsibility to read the underlying data and convert it to a representable form.

Some helpers for reading strings are available:

NOTE: This returns discovered strings and is therefore governed by analysis.limits.minStringLength and other settings.

Source

pub fn strings_in_range(&self, range: Range<u64>) -> Array<StringReference>

Retrieve all known strings within the provided range.

NOTE: This returns a list of StringReference as strings may not be representable as a String or even a BnString. It is the caller’s responsibility to read the underlying data and convert it to a representable form.

Some helpers for reading strings are available:

NOTE: This returns discovered strings and is therefore governed by analysis.limits.minStringLength and other settings.

Source

pub fn attached_type_archives(&self) -> Vec<TypeArchiveId>

Retrieve the attached type archives as their TypeArchiveId.

Using the returned id you can retrieve the TypeArchive with BinaryView::type_archive_by_id.

Source

pub fn type_archive_by_id(&self, id: &TypeArchiveId) -> Option<Ref<TypeArchive>>

Look up a connected TypeArchive by its id.

NOTE: A TypeArchive can be attached but not connected, returning None.

Source

pub fn type_archive_path_by_id(&self, id: &TypeArchiveId) -> Option<PathBuf>

Look up the path for an attached (but not necessarily connected) TypeArchive by its id.

Trait Implementations§

Source§

impl AsRef<BinaryView> for BinaryView

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl BinaryViewBase for BinaryView

Source§

fn read(&self, buf: &mut [u8], offset: u64) -> usize

Source§

fn write(&self, offset: u64, data: &[u8]) -> usize

Source§

fn insert(&self, offset: u64, data: &[u8]) -> usize

Source§

fn remove(&self, offset: u64, len: usize) -> usize

Source§

fn offset_valid(&self, offset: u64) -> bool

Check if the offset is valid for the current view.
Source§

fn offset_readable(&self, offset: u64) -> bool

Check if the offset is readable for the current view.
Source§

fn offset_writable(&self, offset: u64) -> bool

Check if the offset is writable for the current view.
Source§

fn offset_executable(&self, offset: u64) -> bool

Check if the offset is executable for the current view.
Source§

fn offset_backed_by_file(&self, offset: u64) -> bool

Check if the offset is backed by the original file and not added after the fact.
Source§

fn next_valid_offset_after(&self, offset: u64) -> u64

Get the next valid offset after the provided offset, useful if you need to iterate over all readable offsets in the view.
Source§

fn modification_status(&self, offset: u64) -> ModificationStatus

Whether the data at the given offset been modified (patched).
Source§

fn start(&self) -> u64

The lowest address in the view.
Source§

fn len(&self) -> u64

The length of the view.
Source§

fn executable(&self) -> bool

Source§

fn relocatable(&self) -> bool

Source§

fn entry_point(&self) -> u64

Source§

fn default_endianness(&self) -> Endianness

Source§

fn address_size(&self) -> usize

Source§

fn save(&self) -> bool

Source§

impl Debug for BinaryView

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for BinaryView

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for BinaryView

Source§

fn eq(&self, other: &BinaryView) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToOwned for BinaryView

Source§

type Owned = Ref<BinaryView>

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> Self::Owned

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl Eq for BinaryView

Source§

impl Send for BinaryView

Source§

impl StructuralPartialEq for BinaryView

Source§

impl Sync for BinaryView

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more