Struct dynasmrt::Modifier

source ·
pub struct Modifier<'a, R: Relocation> { /* private fields */ }
Expand description

Allows modification of already committed assembly code. Contains an internal cursor into the emitted assembly, initialized to the start, that can be moved around either with the goto function, or just by assembling new code into this Modifier.

Implementations§

source§

impl<'a, R: Relocation> Modifier<'a, R>

source

pub fn goto(&mut self, offset: AssemblyOffset)

Move the modifier cursor to the selected location.

source

pub fn check(&self, offset: AssemblyOffset) -> Result<(), DynasmError>

Check that the modifier cursor has not moved past the specified location.

source

pub fn check_exact(&self, offset: AssemblyOffset) -> Result<(), DynasmError>

Check that the modifier cursor is exactly at the specified location.

Trait Implementations§

source§

impl<'a, R: Debug + Relocation> Debug for Modifier<'a, R>

source§

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

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

impl<'a, R: Relocation> DynasmApi for Modifier<'a, R>

source§

fn offset(&self) -> AssemblyOffset

Report the current offset into the assembling target
source§

fn push(&mut self, value: u8)

Push a byte into the assembling target
source§

fn align(&mut self, alignment: usize, with: u8)

Push filler until the assembling target end is aligned to the given alignment.
source§

fn push_i8(&mut self, value: i8)

Push a signed byte into the assembling target
source§

fn push_i16(&mut self, value: i16)

Push a signed word into the assembling target
source§

fn push_i32(&mut self, value: i32)

Push a signed doubleword into the assembling target
source§

fn push_i64(&mut self, value: i64)

Push a signed quadword into the assembling target
source§

fn push_u16(&mut self, value: u16)

Push an usigned word into the assembling target
source§

fn push_u32(&mut self, value: u32)

Push an usigned doubleword into the assembling target
source§

fn push_u64(&mut self, value: u64)

Push an usigned quadword into the assembling target
source§

fn runtime_error(&self, msg: &'static str) -> !

This function is called in when a runtime error has to be generated. It panics.
source§

impl<'a, R: Relocation> DynasmLabelApi for Modifier<'a, R>

§

type Relocation = R

The relocation info type this assembler uses.
source§

fn local_label(&mut self, name: &'static str)

Record the definition of a local label
source§

fn global_label(&mut self, name: &'static str)

Record the definition of a global label
source§

fn dynamic_label(&mut self, id: DynamicLabel)

Record the definition of a dynamic label
source§

fn global_relocation( &mut self, name: &'static str, target_offset: isize, field_offset: u8, ref_offset: u8, kind: R, )

Equivalent of global_reloc, but takes a non-encoded relocation
source§

fn dynamic_relocation( &mut self, id: DynamicLabel, target_offset: isize, field_offset: u8, ref_offset: u8, kind: R, )

Equivalent of dynamic_reloc, but takes a non-encoded relocation
source§

fn forward_relocation( &mut self, name: &'static str, target_offset: isize, field_offset: u8, ref_offset: u8, kind: R, )

Equivalent of forward_reloc, but takes a non-encoded relocation
source§

fn backward_relocation( &mut self, name: &'static str, target_offset: isize, field_offset: u8, ref_offset: u8, kind: R, )

Equivalent of backward_reloc, but takes a non-encoded relocation
source§

fn bare_relocation( &mut self, target: usize, field_offset: u8, ref_offset: u8, kind: R, )

Equivalent of bare_reloc, but takes a non-encoded relocation
source§

fn forward_reloc( &mut self, name: &'static str, target_offset: isize, field_offset: u8, ref_offset: u8, kind: <Self::Relocation as Relocation>::Encoding, )

Record a relocation spot for a forward reference to a local label
source§

fn backward_reloc( &mut self, name: &'static str, target_offset: isize, field_offset: u8, ref_offset: u8, kind: <Self::Relocation as Relocation>::Encoding, )

Record a relocation spot for a backward reference to a local label
source§

fn global_reloc( &mut self, name: &'static str, target_offset: isize, field_offset: u8, ref_offset: u8, kind: <Self::Relocation as Relocation>::Encoding, )

Record a relocation spot for a reference to a global label
source§

fn dynamic_reloc( &mut self, id: DynamicLabel, target_offset: isize, field_offset: u8, ref_offset: u8, kind: <Self::Relocation as Relocation>::Encoding, )

Record a relocation spot for a reference to a dynamic label
source§

fn bare_reloc( &mut self, target: usize, field_offset: u8, ref_offset: u8, kind: <Self::Relocation as Relocation>::Encoding, )

Record a relocation spot to an arbitrary target.
source§

impl<'a, 'b, R: Relocation> Extend<&'b u8> for Modifier<'a, R>

source§

fn extend<T>(&mut self, iter: T)
where T: IntoIterator<Item = &'b u8>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<'a, R: Relocation> Extend<u8> for Modifier<'a, R>

source§

fn extend<T>(&mut self, iter: T)
where T: IntoIterator<Item = u8>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more

Auto Trait Implementations§

§

impl<'a, R> Freeze for Modifier<'a, R>

§

impl<'a, R> RefUnwindSafe for Modifier<'a, R>
where R: RefUnwindSafe,

§

impl<'a, R> Send for Modifier<'a, R>
where R: Send,

§

impl<'a, R> Sync for Modifier<'a, R>
where R: Sync,

§

impl<'a, R> Unpin for Modifier<'a, R>

§

impl<'a, R> !UnwindSafe for Modifier<'a, R>

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.

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>,

§

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.