@@ -7,6 +7,7 @@ use libc::{self, c_void, c_long, siginfo_t};
7
7
use :: unistd:: Pid ;
8
8
use sys:: signal:: Signal ;
9
9
10
+ pub type AddressType = * mut :: libc:: c_void ;
10
11
11
12
cfg_if ! {
12
13
if #[ cfg( any( all( target_os = "linux" , arch = "s390x" ) ,
@@ -170,7 +171,7 @@ libc_bitflags! {
170
171
since="0.10.0" ,
171
172
note="usages of `ptrace()` should be replaced with the specialized helper functions instead"
172
173
) ]
173
- pub unsafe fn ptrace ( request : Request , pid : Pid , addr : * mut c_void , data : * mut c_void ) -> Result < c_long > {
174
+ pub unsafe fn ptrace ( request : Request , pid : Pid , addr : AddressType , data : * mut c_void ) -> Result < c_long > {
174
175
use self :: Request :: * ;
175
176
match request {
176
177
PTRACE_PEEKTEXT | PTRACE_PEEKDATA | PTRACE_PEEKUSER | PTRACE_GETSIGINFO |
@@ -181,7 +182,7 @@ pub unsafe fn ptrace(request: Request, pid: Pid, addr: *mut c_void, data: *mut c
181
182
}
182
183
}
183
184
184
- fn ptrace_peek ( request : Request , pid : Pid , addr : * mut c_void , data : * mut c_void ) -> Result < c_long > {
185
+ fn ptrace_peek ( request : Request , pid : Pid , addr : AddressType , data : * mut c_void ) -> Result < c_long > {
185
186
let ret = unsafe {
186
187
Errno :: clear ( ) ;
187
188
libc:: ptrace ( request as RequestType , libc:: pid_t:: from ( pid) , addr, data)
@@ -209,7 +210,7 @@ fn ptrace_get_data<T>(request: Request, pid: Pid) -> Result<T> {
209
210
Ok ( data)
210
211
}
211
212
212
- unsafe fn ptrace_other ( request : Request , pid : Pid , addr : * mut c_void , data : * mut c_void ) -> Result < c_long > {
213
+ unsafe fn ptrace_other ( request : Request , pid : Pid , addr : AddressType , data : * mut c_void ) -> Result < c_long > {
213
214
Errno :: result ( libc:: ptrace ( request as RequestType , libc:: pid_t:: from ( pid) , addr, data) ) . map ( |_| 0 )
214
215
}
215
216
@@ -368,12 +369,12 @@ pub fn step<T: Into<Option<Signal>>>(pid: Pid, sig: T) -> Result<()> {
368
369
369
370
370
371
/// Reads a word from a processes memory at the given address
371
- pub fn read ( pid : Pid , addr : * mut c_void ) -> Result < c_long > {
372
+ pub fn read ( pid : Pid , addr : AddressType ) -> Result < c_long > {
372
373
ptrace_peek ( Request :: PTRACE_PEEKDATA , pid, addr, ptr:: null_mut ( ) )
373
374
}
374
375
375
376
/// Writes a word into the processes memory at the given address
376
- pub fn write ( pid : Pid , addr : * mut c_void , data : * mut c_void ) -> Result < ( ) > {
377
+ pub fn write ( pid : Pid , addr : AddressType , data : * mut c_void ) -> Result < ( ) > {
377
378
unsafe {
378
379
ptrace_other ( Request :: PTRACE_POKEDATA , pid, addr, data) . map ( |_| ( ) )
379
380
}
0 commit comments