diff --git a/src/runtime/process.rs b/src/runtime/process.rs index ccbfb313..da7c856e 100644 --- a/src/runtime/process.rs +++ b/src/runtime/process.rs @@ -161,6 +161,20 @@ impl Process { } } + /// Gets the name of the process. + #[cfg(feature = "alloc")] + #[inline] + pub fn get_name(&self) -> Result { + let mut path = self.get_path()?; + + // remove everything before the / on path to avoid an allocation + let (before, _) = path.rsplit_once('/').ok_or(Error {})?; + let index = before.len() + 1; + path.drain(..index); + + Ok(path) + } + /// Gets the address of a module in the process. #[inline] pub fn get_module_address(&self, name: &str) -> Result { @@ -247,6 +261,14 @@ impl Process { }) } + /// 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]