Struct lief::dsc::DyldSharedCache

pub struct DyldSharedCache { /* private fields */ }
Expand description

This struct interfaces a dyld shared cache file.

Implementations§

§

impl DyldSharedCache

pub fn filename(&self) -> String

Filename of the dyld shared file associated with this object.

For instance: dyld_shared_cache_arm64e, dyld_shared_cache_arm64e.62.dyldlinkedit

pub fn filepath(&self) -> String

Full path to the original dyld shared cache file associated with object (e.g. /home/lief/downloads/visionos/dyld_shared_cache_arm64e.42)

pub fn load_address(&self) -> u64

Based address of this cache

pub fn version(&self) -> Version

Version of dyld used by this cache

pub fn arch_name(&self) -> String

Name of the architecture targeted by this cache (x86_64h)

pub fn platform(&self) -> Platform

Platform targeted by this cache (e.g. vision-os)

pub fn arch(&self) -> Arch

Architecture targeted by this cache

pub fn find_lib_from_va(&self, va: u64) -> Option<Dylib<'_>>

Find the Dylib that encompasses the given virtual address.

pub fn find_lib_from_path(&self, path: &str) -> Option<Dylib<'_>>

Find the Dylib whose Dylib::path matches the provided path.

pub fn find_lib_from_name(&self, name: &str) -> Option<Dylib<'_>>

Find the Dylib whose filename of Dylib::path matches the provided name.

If multiple libraries have the same name (but with a different path), the first one matching the provided name is returned.

pub fn has_subcaches(&self) -> bool

True if the subcaches are associated with this cache

pub fn libraries(&self) -> Dylibs<'_>

Return an iterator over the different Dylib libraries embedded in this dyld shared cache

pub fn mapping_info(&self) -> MappingInfoIt<'_>

Return an iterator over the different MappingInfo associated with this dyld shared cache

pub fn subcaches(&self) -> SubCacheIt<'_>

Return an interator over the subcaches associated with this (main) dyld shared cache.

pub fn disassemble(&self, address: u64) -> Instructions<'_>

Disassemble instructions at the provided virtual address.

This function returns an iterator over assembly::Instructions.

pub fn get_content_from_va(&self, address: u64, size: u64) -> Vec<u8>

Return the content at the specified virtual address

pub fn cache_for_address(&self, address: u64) -> Option<DyldSharedCache>

Find the sub-DyldSharedCache that wraps the given virtual address

pub fn main_cache(&self) -> Option<DyldSharedCache>

Return the principal dyld shared cache in the case of multiple subcaches

pub fn find_subcache(&self, filename: &str) -> Option<DyldSharedCache>

Try to find the DyldSharedCache associated with the filename given in the first parameter.

pub fn va_to_offset(&self, address: u64) -> Result<u64, Error>

Convert the given virtual address into an offset.

If the shared cache contains multiple subcaches, this function needs to be called on the targeted subcache.

See: DyldSharedCache::cache_for_address

pub fn enable_caching(&self, target_cache_dir: &str)

When enabled, this function allows to record and to keep in cache, dyld shared cache information that are costly to access.

For instance, GOT symbols, rebases information, stub symbols, …

It is highly recommended to enable this function when processing a dyld shared cache several times or when extracting a large number of Dylib with enhanced extraction options (e.g. crate::dsc::dylib::ExtractOpt::fix_memory)

One can enable caching by calling this function:

let dyld_cache = lief::dsc::load_from_path("macos-15.0.1/", "");
dyld_cache.enable_caching("/home/user/.cache/lief-dsc");

One can also enable this cache optimization globally using the function: crate::dsc::enable_cache or by setting the environment variable DYLDSC_ENABLE_CACHE to 1.

pub fn flush_cache(&self)

Flush internal information into the on-disk cache (see: enable_caching)

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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.

source§

impl<T, U> Into<U> for Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.