pub struct Process(/* private fields */);
Expand description
A process that the auto splitter is attached to.
Implementations§
Source§impl Process
impl Process
Sourcepub fn attach_by_pid(pid: ProcessId) -> Option<Self>
pub fn attach_by_pid(pid: ProcessId) -> Option<Self>
Attaches to a process based on its process id.
Sourcepub fn list_by_name_into<'buf>(
name: &str,
buf: &'buf mut [MaybeUninit<ProcessId>],
) -> Option<(&'buf mut [ProcessId], usize)>
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.
Sourcepub fn list_by_name(name: &str) -> Option<Vec<ProcessId>>
Available on crate feature alloc
only.
pub fn list_by_name(name: &str) -> Option<Vec<ProcessId>>
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.
Sourcepub fn is_open(&self) -> bool
pub fn is_open(&self) -> bool
Checks whether the process is still open. If it is not open anymore, you should drop the process.
Sourcepub fn get_path(&self) -> Result<String, Error>
Available on crate feature alloc
only.
pub fn get_path(&self) -> Result<String, Error>
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
.
Sourcepub fn get_module_address(&self, name: &str) -> Result<Address, Error>
pub fn get_module_address(&self, name: &str) -> Result<Address, Error>
Gets the address of a module in the process.
Sourcepub fn get_module_size(&self, name: &str) -> Result<u64, Error>
pub fn get_module_size(&self, name: &str) -> Result<u64, Error>
Gets the size of a module in the process.
Sourcepub fn get_module_path(&self, name: &str) -> Result<String, Error>
Available on crate feature alloc
only.
pub fn get_module_path(&self, name: &str) -> Result<String, Error>
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
.
Sourcepub fn get_module_range(&self, name: &str) -> Result<(Address, u64), Error>
pub fn get_module_range(&self, name: &str) -> Result<(Address, u64), Error>
Gets the address and size of a module in the process.
Sourcepub fn memory_ranges(&self) -> impl DoubleEndedIterator<Item = MemoryRange<'_>>
pub fn memory_ranges(&self) -> impl DoubleEndedIterator<Item = MemoryRange<'_>>
Iterates over all committed (not reserved, not free) memory ranges of the process.
Sourcepub fn read<T: CheckedBitPattern>(
&self,
address: impl Into<Address>,
) -> Result<T, Error>
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.
Sourcepub fn read_into_buf(
&self,
address: impl Into<Address>,
buf: &mut [u8],
) -> Result<(), Error>
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.
Sourcepub fn read_into_uninit_buf<'buf>(
&self,
address: impl Into<Address>,
buf: &'buf mut [MaybeUninit<u8>],
) -> Result<&'buf mut [u8], Error>
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.
Sourcepub fn read_into_slice<T: AnyBitPattern>(
&self,
address: impl Into<Address>,
slice: &mut [T],
) -> Result<(), Error>
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.
Sourcepub fn read_into_uninit_slice<T: CheckedBitPattern>(
&self,
address: impl Into<Address>,
slice: &mut [MaybeUninit<T>],
) -> Result<&mut [T], Error>
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.
Sourcepub 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.
pub fn append_to_vec<T: CheckedBitPattern>( &self, address: impl Into<Address>, vec: &mut Vec<T>, additional_elements: usize, ) -> Result<(), Error>
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.
Sourcepub fn read_vec<T: CheckedBitPattern>(
&self,
address: impl Into<Address>,
len: usize,
) -> Result<Vec<T>, Error>
Available on crate feature alloc
only.
pub fn read_vec<T: CheckedBitPattern>( &self, address: impl Into<Address>, len: usize, ) -> Result<Vec<T>, Error>
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.
Sourcepub fn read_pointer(
&self,
address: impl Into<Address>,
pointer_size: PointerSize,
) -> Result<Address, Error>
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.
Sourcepub fn read_pointer_path<T: CheckedBitPattern>(
&self,
address: impl Into<Address>,
pointer_size: PointerSize,
path: &[u64],
) -> Result<T, Error>
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
impl Process
Sourcepub async fn wait_attach(name: &str) -> Process
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.
Sourcepub const fn until_closes<F>(&self, future: F) -> UntilProcessCloses<'_, F> ⓘ
pub const fn until_closes<F>(&self, future: F) -> UntilProcessCloses<'_, F> ⓘ
Executes a future until the process closes.
Sourcepub async fn wait_module_range(&self, name: &str) -> (Address, u64)
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.