Struct dynasmrt::components::PatchLoc

source ·
pub struct PatchLoc<R: Relocation> {
    pub location: AssemblyOffset,
    pub field_offset: u8,
    pub ref_offset: u8,
    pub relocation: R,
    pub target_offset: isize,
}
Expand description

An abstraction of a relocation of type R, located at location.

Fields§

§location: AssemblyOffset

The AssemblyOffset at which this relocation was emitted

§field_offset: u8

The offset, backwards, from location that the actual field to be modified starts at

§ref_offset: u8

The offset, backwards, to be subtracted from location to get the address that the relocation should be calculated relative to.

§relocation: R

The type of relocation to be emitted.

§target_offset: isize

A constant offset added to the destination address of this relocation when it is calculated.

Implementations§

source§

impl<R: Relocation> PatchLoc<R>

source

pub fn new( location: AssemblyOffset, target_offset: isize, field_offset: u8, ref_offset: u8, relocation: R, ) -> PatchLoc<R>

create a new PatchLoc

source

pub fn range(&self, buf_offset: usize) -> Range<usize>

Returns a range that covers the entire relocation in its assembling buffer buf_offset is a value that is subtracted from this range when the buffer you want to slice with this range is only a part of a bigger buffer.

source

pub fn value(&self, target: usize, buf_addr: usize) -> isize

Returns the actual value that should be inserted at the relocation site.

source

pub fn patch( &self, buffer: &mut [u8], buf_addr: usize, target: usize, ) -> Result<(), ImpossibleRelocation>

Patch buffer so that this relocation patch will point to target. buf_addr is the address that the assembling buffer will come to reside at when it is assembled. target is the offset that this relocation will be targetting.

source

pub fn adjust( &self, buffer: &mut [u8], adjustment: isize, ) -> Result<(), ImpossibleRelocation>

Patch buffer so that this relocation will still point to the right location due to a change in the address of the containing buffer. buffer is a subsection of a larger buffer, located at offset buf_offset in this larger buffer. adjustment is new_buf_addr - old_buf_addr.

source

pub fn needs_adjustment(&self) -> bool

Returns if this patch requires adjustment when the address of the buffer it resides in is altered.

Trait Implementations§

source§

impl<R: Clone + Relocation> Clone for PatchLoc<R>

source§

fn clone(&self) -> PatchLoc<R>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<R: Debug + Relocation> Debug for PatchLoc<R>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> Freeze for PatchLoc<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for PatchLoc<R>
where R: RefUnwindSafe,

§

impl<R> Send for PatchLoc<R>
where R: Send,

§

impl<R> Sync for PatchLoc<R>
where R: Sync,

§

impl<R> Unpin for PatchLoc<R>
where R: Unpin,

§

impl<R> UnwindSafe for PatchLoc<R>
where R: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where 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 T
where 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.