Skip to main content

Registers

Struct Registers 

Source
pub struct Registers { /* private fields */ }
Expand description

Helpers for reading and writing register state of the traced process.

Registers stores a snapshot of the platform user_regs_struct for a given Pid and provides convenience accessors. Currently this module assumes x86_64 register layout.

Implementations§

Source§

impl Registers

Source

pub fn read(pid: Pid) -> Result<Self>

Read the current register state for pid.

§Arguments
  • pid - The process id of the traced process to read registers from.
§Errors

Returns an error if the underlying ptrace::getregs call fails.

§Returns

A Result containing the Registers snapshot on success.

Source

pub fn write(&self) -> Result<()>

Write the locally-modified register state back to the tracee.

§Errors

Returns an error if ptrace::setregs fails.

§Returns

Returns Ok(()) on success.

Source

pub fn rip(&self) -> u64

Instruction pointer (RIP).

§Returns

The current value of the instruction pointer (RIP) for the stored register snapshot.

Source

pub fn set_rip(&mut self, value: u64)

Set the instruction pointer.

§Arguments
  • value - The new instruction pointer (RIP) value to store in the snapshot.
Source

pub fn rsp(&self) -> u64

Stack pointer (RSP).

§Returns

The current value of the stack pointer (RSP).

Source

pub fn rax(&self) -> u64

Return the RAX register value.

§Returns

The value of the rax register in the snapshot.

Source

pub fn orig_rax(&self) -> u64

Return the original RAX value saved by the kernel (useful for syscalls).

§Returns

The orig_rax register value recorded by the kernel.

Source

pub fn function_params(&self) -> [u64; 6]

Return the 6 register parameters passed in registers for x86_64 (rdi, rsi, rdx, r10, r8, r9).

§Returns

An array with the six parameter registers as u64 in calling convention order.

Trait Implementations§

Source§

impl Display for Registers

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.