Skip to content

Commit f894e01

Browse files
committed
Add peekdata and pokedata
1 parent d7b9e39 commit f894e01

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
@@ -204,3 +204,18 @@ pub fn traceme() -> Result<()> {
204204
ptr::null_mut(),
205205
).map(|_| ()) // ignore the useless return value
206206
}
207+
208+
/// Makes the `PTRACE_PEEKDATA` request to ptrace
209+
pub fn peekdata(pid: Pid, addr: c_long) -> Result<c_long> {
210+
ptrace(ptrace::PTRACE_PEEKDATA, pid, addr as *mut c_void, ptr::null_mut())
211+
}
212+
213+
/// Makes the `PTRACE_PEEKDATA` request to ptrace
214+
pub fn pokedata(pid: Pid, addr: c_long, val: c_long) -> Result<()> {
215+
ptrace(
216+
ptrace::PTRACE_POKEDATA,
217+
pid,
218+
addr as *mut c_void,
219+
val as *mut c_void,
220+
).map(|_| ()) // ignore the useless return value
221+
}

0 commit comments

Comments
 (0)