@@ -191,31 +191,37 @@ type Word = usize;
191
191
192
192
/// Makes the `PTRACE_SYSCALL` request to ptrace
193
193
pub fn syscall ( pid : Pid ) -> Result < ( ) > {
194
- ptrace ( ptrace:: PTRACE_SYSCALL , pid, ptr:: null_mut ( ) , ptr:: null_mut ( ) ) . map ( |_| ( ) ) // ignore the useless return value
194
+ unsafe {
195
+ ptrace ( ptrace:: PTRACE_SYSCALL , pid, ptr:: null_mut ( ) , ptr:: null_mut ( ) ) . map ( |_| ( ) ) // ignore the useless return value
196
+ }
195
197
}
196
198
197
199
/// Makes the `PTRACE_PEEKUSER` request to ptrace
198
200
pub fn peekuser ( pid : Pid , reg : Register ) -> Result < Word > {
199
201
let reg_arg = ( reg as i32 ) as * mut c_void ;
200
- ptrace ( ptrace:: PTRACE_PEEKUSER , pid, reg_arg, ptr:: null_mut ( ) )
201
- }
202
+ unsafe {
203
+ ptrace ( ptrace:: PTRACE_PEEKUSER , pid, reg_arg, ptr:: null_mut ( ) ) . map ( |r| r as Word )
204
+ }
205
+ }
202
206
203
207
/// Sets the process as traceable with `PTRACE_TRACEME`
204
208
pub fn traceme ( ) -> Result < ( ) > {
205
- ptrace (
206
- ptrace:: PTRACE_TRACEME ,
207
- Pid :: from_raw ( 0 ) ,
208
- ptr:: null_mut ( ) ,
209
- ptr:: null_mut ( ) ,
210
- ) . map ( |_| ( ) ) // ignore the useless return value
209
+ unsafe {
210
+ ptrace (
211
+ ptrace:: PTRACE_TRACEME ,
212
+ Pid :: from_raw ( 0 ) ,
213
+ ptr:: null_mut ( ) ,
214
+ ptr:: null_mut ( ) ,
215
+ ) . map ( |_| ( ) ) // ignore the useless return value
216
+ }
211
217
}
212
218
213
219
/// Makes the `PTRACE_PEEKDATA` request to ptrace
214
220
///
215
221
/// This function allows to access arbitrary data in the traced process
216
222
/// and may crash the inferior if used incorrectly and is thus marked `unsafe`.
217
223
pub unsafe fn peekdata ( pid : Pid , addr : usize ) -> Result < Word > {
218
- ptrace ( ptrace:: PTRACE_PEEKDATA , pid, addr as * mut c_void , ptr:: null_mut ( ) )
224
+ ptrace ( ptrace:: PTRACE_PEEKDATA , pid, addr as * mut c_void , ptr:: null_mut ( ) ) . map ( |r| r as Word )
219
225
}
220
226
221
227
/// Makes the `PTRACE_PEEKDATA` request to ptrace
0 commit comments