add a modules function to Process

This commit is contained in:
2025-12-03 13:37:57 +00:00
parent 334c4761a2
commit 30b22107a1
2 changed files with 16 additions and 1 deletions
+15
View File
@@ -88,6 +88,21 @@ impl Process {
Ok(module) Ok(module)
} }
/// get all `Module`s of a `Process`
pub fn modules(&self) -> Result<Vec<Module>, Error> {
Ok(snapshot::ModuleSnapshot::get_modules(self.id)?
.iter()
.cloned()
.map(|snapshot| Module {
process_id: self.id,
name: snapshot.name,
path: snapshot.path,
base_address: snapshot.base_address,
base_size: snapshot.base_size,
})
.collect())
}
/// follow a pointer chain to the end and return an address /// follow a pointer chain to the end and return an address
pub fn resolve_pointer_chain(&self, chain: &[usize]) -> Result<usize, Error> { pub fn resolve_pointer_chain(&self, chain: &[usize]) -> Result<usize, Error> {
let mut chain = chain.to_vec(); let mut chain = chain.to_vec();
+1 -1
View File
@@ -41,7 +41,7 @@ impl ProcessSnapshot {
} }
} }
#[derive(Debug)] #[derive(Clone, Debug)]
pub struct ModuleSnapshot { pub struct ModuleSnapshot {
pub name: String, pub name: String,
pub path: String, pub path: String,