asr

Struct Process

Source
pub struct Process(/* private fields */);
Expand description

A process that the auto splitter is attached to.

Implementations§

Source§

impl Process

Source

pub fn attach(name: &str) -> Option<Self>

Attaches to a process based on its name.

Source

pub fn attach_by_pid(pid: ProcessId) -> Option<Self>

Attaches to a process based on its process id.

Source

pub fn list_by_name_into<'buf>( name: &str, buf: &'buf mut [MaybeUninit<ProcessId>], ) -> Option<(&'buf mut [ProcessId], usize)>

Lists processes based on their name. The processes are not in any specific order. Returns None if listing the processes failed. A buffer is provided that is filled with the process ids of the processes that were found. If the buffer is too small, the buffer is filled with as many process ids as possible. The length of the total amount of process ids that were found is also returned. This can be used to detect if the buffer was too small and can be used to either reallocate the buffer or to consider this an error condition.

Source

pub fn list_by_name(name: &str) -> Option<Vec<ProcessId>>

Available on crate feature alloc only.

Lists processes based on their name. The processes are not in any specific order. Returns None if listing the processes failed. A vector is returned that is filled with the process ids of the processes that were found.

Source

pub fn is_open(&self) -> bool

Checks whether the process is still open. If it is not open anymore, you should drop the process.

Source

pub fn get_path(&self) -> Result<String, Error>

Available on crate feature alloc only.

Gets the path of the executable in the file system. The path is a path that is accessible through the WASI file system, so a Windows path of C:\foo\bar.exe would be returned as /mnt/c/foo/bar.exe.

Source

pub fn get_module_address(&self, name: &str) -> Result<Address, Error>

Gets the address of a module in the process.

Source

pub fn get_module_size(&self, name: &str) -> Result<u64, Error>

Gets the size of a module in the process.

Source

pub fn get_module_path(&self, name: &str) -> Result<String, Error>

Available on crate feature alloc only.

Gets the path of a module in the file system. The path is a path that is accessible through the WASI file system, so a Windows path of C:\foo\bar.dll would be returned as /mnt/c/foo/bar.dll.

Source

pub fn get_module_range(&self, name: &str) -> Result<(Address, u64), Error>

Gets the address and size of a module in the process.

Source

pub fn memory_ranges(&self) -> impl DoubleEndedIterator<Item = MemoryRange<'_>>

Iterates over all committed (not reserved, not free) memory ranges of the process.

Source

pub fn read<T: CheckedBitPattern>( &self, address: impl Into<Address>, ) -> Result<T, Error>

Reads a value of the type specified from the process at the address given.

Source

pub fn read_into_buf( &self, address: impl Into<Address>, buf: &mut [u8], ) -> Result<(), Error>

Reads a range of bytes from the process at the address given into the buffer provided.

Source

pub fn read_into_uninit_buf<'buf>( &self, address: impl Into<Address>, buf: &'buf mut [MaybeUninit<u8>], ) -> Result<&'buf mut [u8], Error>

Reads a range of bytes from the process at the address given into the buffer provided. The buffer does not need to be initialized. After the buffer successfully got filled, the initialized buffer is returned.

Source

pub fn read_into_slice<T: AnyBitPattern>( &self, address: impl Into<Address>, slice: &mut [T], ) -> Result<(), Error>

Reads a range of bytes from the process at the address given into the buffer provided. This is a convenience method for reading into a slice of a specific type.

Source

pub fn read_into_uninit_slice<T: CheckedBitPattern>( &self, address: impl Into<Address>, slice: &mut [MaybeUninit<T>], ) -> Result<&mut [T], Error>

Reads a range of bytes from the process at the address given into the buffer provided. This is a convenience method for reading into a slice of a specific type. The buffer does not need to be initialized. After the slice successfully got filled, the initialized slice is returned.

Source

pub fn append_to_vec<T: CheckedBitPattern>( &self, address: impl Into<Address>, vec: &mut Vec<T>, additional_elements: usize, ) -> Result<(), Error>

Available on crate feature alloc only.

Reads an array from the process at the address with the length given into the Vec provided. The Vec is not cleared, all elements are appended to the end of the Vec. You may want to manually clear it beforehand.

Source

pub fn read_vec<T: CheckedBitPattern>( &self, address: impl Into<Address>, len: usize, ) -> Result<Vec<T>, Error>

Available on crate feature alloc only.

Reads an array from the process at the address with the length given into a new Vec. This is a heap allocation. It’s recommended to avoid this method if possible and either use read with a fixed size array or read_into_slice if possible. If neither of these are possible it is recommend to at least reuse the Vec with append_to_vec if that’s possible.

Source

pub fn read_pointer( &self, address: impl Into<Address>, pointer_size: PointerSize, ) -> Result<Address, Error>

Reads a pointer address from the process at the address given.

Source

pub fn read_pointer_path<T: CheckedBitPattern>( &self, address: impl Into<Address>, pointer_size: PointerSize, path: &[u64], ) -> Result<T, Error>

Follows a path of pointers from the address given and reads a value of the type specified from the process at the end of the pointer path.

Source§

impl Process

Source

pub async fn wait_attach(name: &str) -> Process

Asynchronously awaits attaching to a process with the given name, yielding back to the runtime between each try.

Source

pub const fn until_closes<F>(&self, future: F) -> UntilProcessCloses<'_, F>

Executes a future until the process closes.

Source

pub async fn wait_module_range(&self, name: &str) -> (Address, u64)

Asynchronously awaits the address and size of a module in the process, yielding back to the runtime between each try.

Trait Implementations§

Source§

impl Drop for Process

Source§

fn drop(&mut self)

Executes the destructor for this type. 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, 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.