Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
marmistrz committed Jul 19, 2017
2 parents 8a85c39 + 067f937 commit cc8e7c0
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/sys/ptrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,31 +191,37 @@ type Word = usize;

/// Makes the `PTRACE_SYSCALL` request to ptrace
pub fn syscall(pid: Pid) -> Result<()> {
ptrace(ptrace::PTRACE_SYSCALL, pid, ptr::null_mut(), ptr::null_mut()).map(|_| ()) // ignore the useless return value
unsafe {
ptrace(ptrace::PTRACE_SYSCALL, pid, ptr::null_mut(), ptr::null_mut()).map(|_| ()) // ignore the useless return value
}
}

/// Makes the `PTRACE_PEEKUSER` request to ptrace
pub fn peekuser(pid: Pid, reg: Register) -> Result<Word> {
let reg_arg = (reg as i32) as *mut c_void;
ptrace(ptrace::PTRACE_PEEKUSER, pid, reg_arg, ptr::null_mut())
}
unsafe {
ptrace(ptrace::PTRACE_PEEKUSER, pid, reg_arg, ptr::null_mut()).map(|r| r as Word)
}
}

/// Sets the process as traceable with `PTRACE_TRACEME`
pub fn traceme() -> Result<()> {
ptrace(
ptrace::PTRACE_TRACEME,
Pid::from_raw(0),
ptr::null_mut(),
ptr::null_mut(),
).map(|_| ()) // ignore the useless return value
unsafe {
ptrace(
ptrace::PTRACE_TRACEME,
Pid::from_raw(0),
ptr::null_mut(),
ptr::null_mut(),
).map(|_| ()) // ignore the useless return value
}
}

/// Makes the `PTRACE_PEEKDATA` request to ptrace
///
/// This function allows to access arbitrary data in the traced process
/// and may crash the inferior if used incorrectly and is thus marked `unsafe`.
pub unsafe fn peekdata(pid: Pid, addr: usize) -> Result<Word> {
ptrace(ptrace::PTRACE_PEEKDATA, pid, addr as *mut c_void, ptr::null_mut())
ptrace(ptrace::PTRACE_PEEKDATA, pid, addr as *mut c_void, ptr::null_mut()).map(|r| r as Word)
}

/// Makes the `PTRACE_PEEKDATA` request to ptrace
Expand Down

0 comments on commit cc8e7c0

Please sign in to comment.