pub trait ModuleSectionInfo<D> {
    // Required methods
    fn base_svma(&self) -> u64;
    fn section_svma_range(&mut self, name: &[u8]) -> Option<Range<u64>>;
    fn section_data(&mut self, name: &[u8]) -> Option<D>;

    // Provided methods
    fn segment_svma_range(&mut self, _name: &[u8]) -> Option<Range<u64>> { ... }
    fn segment_data(&mut self, _name: &[u8]) -> Option<D> { ... }
}
Expand description

Information about a module’s sections (and segments).

This trait is used as an interface to module information, and each function with &mut self is called at most once with a particular argument (e.g., section_data(b".text") will be called at most once, so it can move data out of the underlying type if desired).

Type arguments:

  • D: The type for section data. This allows carrying owned data on the module, e.g. Vec<u8>. But it could also be a wrapper around mapped memory from a file or a different process, for example.

Required Methods§

source

fn base_svma(&self) -> u64

Return the base address stated in the module.

For mach-O objects, this is the vmaddr of the __TEXT segment. For ELF objects, this is zero. For PE objects, this is the image base address.

This is used to convert between SVMAs and relative addresses.

source

fn section_svma_range(&mut self, name: &[u8]) -> Option<Range<u64>>

Get the given section’s memory range, as stated in the module.

source

fn section_data(&mut self, name: &[u8]) -> Option<D>

Get the given section’s data. This will only be called once per section.

Provided Methods§

source

fn segment_svma_range(&mut self, _name: &[u8]) -> Option<Range<u64>>

Get the given segment’s memory range, as stated in the module.

source

fn segment_data(&mut self, _name: &[u8]) -> Option<D>

Get the given segment’s data. This will only be called once per segment.

Implementors§

source§

impl<D> ModuleSectionInfo<D> for ExplicitModuleSectionInfo<D>
where D: Deref<Target = [u8]>,