Skip to content

Commit a603a5d

Browse files
committed
Add peekdata and pokedata
1 parent 00364df commit a603a5d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/sys/ptrace.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,18 @@ pub fn traceme() -> Result<()> {
205205
ptr::null_mut(),
206206
).map(|_| ()) // ignore the useless return value
207207
}
208+
209+
/// Makes the `PTRACE_PEEKDATA` request to ptrace
210+
pub fn peekdata(pid: Pid, addr: c_long) -> Result<c_long> {
211+
ptrace(ptrace::PTRACE_PEEKDATA, pid, addr as *mut c_void, ptr::null_mut())
212+
}
213+
214+
/// Makes the `PTRACE_PEEKDATA` request to ptrace
215+
pub fn pokedata(pid: Pid, addr: c_long, val: c_long) -> Result<()> {
216+
ptrace(
217+
ptrace::PTRACE_POKEDATA,
218+
pid,
219+
addr as *mut c_void,
220+
val as *mut c_void,
221+
).map(|_| ()) // ignore the useless return value
222+
}

0 commit comments

Comments
 (0)