Skip to content

Commit

Permalink
Add method to open tracee memory as File
Browse files Browse the repository at this point in the history
  • Loading branch information
ranweiler committed Sep 4, 2023
1 parent 0a7e800 commit cce330d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ptracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl Tracee {
pub fn read_memory_mut(&self, addr: u64, data: &mut [u8]) -> Result<usize> {
use std::os::unix::fs::FileExt;

let mem = fs::File::open(self.proc_mem_path())?;
let mem = self.memory()?;
let len = mem.read_at(data, addr)?;
Ok(len)
}
Expand All @@ -211,6 +211,10 @@ impl Tracee {
format!("/proc/{}/mem", tid)
}

pub fn memory(&self) -> Result<fs::File> {
Ok(fs::File::open(self.proc_mem_path())?)
}

pub fn siginfo(&self) -> Result<Option<Siginfo>> {
let info = if let Stop::SignalDelivery { .. } = self.stop {
Some(ptrace::getsiginfo(self.pid).died_if_esrch(self.pid)?)
Expand Down

0 comments on commit cce330d

Please sign in to comment.