morpheus_persistent::pe::reloc

Trait RelocationEngine

Source
pub trait RelocationEngine {
    // Required methods
    fn apply_relocation(
        &self,
        image_data: &mut [u8],
        entry: RelocationEntry,
        page_rva: u32,
        delta: i64,
    ) -> PeResult<()>;
    fn unapply_relocation(
        &self,
        image_data: &mut [u8],
        entry: RelocationEntry,
        page_rva: u32,
        delta: i64,
    ) -> PeResult<()>;
    fn arch(&self) -> PeArch;
}
Expand description

Trait for platform-specific relocation application

Different architectures implement this differently:

  • x86_64: Simple pointer fixups
  • ARM64: May involve ADRP/ADD instruction pairs
  • ARM32: Thumb mode considerations

Required Methods§

Source

fn apply_relocation( &self, image_data: &mut [u8], entry: RelocationEntry, page_rva: u32, delta: i64, ) -> PeResult<()>

Apply relocation (add delta to relocated values) Used when UEFI loads the image

Source

fn unapply_relocation( &self, image_data: &mut [u8], entry: RelocationEntry, page_rva: u32, delta: i64, ) -> PeResult<()>

Unapply relocation (subtract delta from relocated values) Used when creating bootable image from memory

Source

fn arch(&self) -> PeArch

Get the architecture this engine handles

Implementors§