Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/runtime/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@
}
}

/// Gets the name of the process.
#[cfg(feature = "alloc")]
#[inline]
pub fn get_name(&self) -> Result<alloc::string::String, Error> {
let path = self.get_path()?;
Ok(path.split("/").last().ok_or(Error {})?.into())
Comment thread
mitchell-merry marked this conversation as resolved.
Outdated
}

/// Gets the address of a module in the process.
#[inline]
pub fn get_module_address(&self, name: &str) -> Result<Address, Error> {
Expand Down Expand Up @@ -247,6 +255,14 @@
})
}

/// Get the address and size of the main module in the process.
#[cfg(feature = "alloc")]
#[inline]
pub fn get_main_module_range(&self) -> Result<(Address, u64), Error> {
let main_module_name = self.get_name()?;
self.get_module_range(&main_module_name)
}

/// Reads a value of the type specified from the process at the address
/// given.
#[inline]
Expand Down Expand Up @@ -343,7 +359,7 @@
&self,
address: impl Into<Address>,
slice: &mut [MaybeUninit<T>],
) -> Result<&mut [T], Error> {

Check warning on line 362 in src/runtime/process.rs

View workflow job for this annotation

GitHub Actions / Check clippy lints

mutable borrow from immutable input(s)
// SAFETY: The process handle is guaranteed to be valid. We provide a
// valid pointer and length to the buffer. We also do proper error
// handling afterwards. The buffer is guaranteed to be initialized
Expand Down
Loading