5 * Retrieve 'len' bytes from the memory of the traced process 'pid' at address
6 * 'addr' and put the result in the buffer pointed to by 'ptr'. Return 0 on
7 * success, or otherwise -1 with errno set appropriately.
10 mem_get_data(pid_t pid
, vir_bytes addr
, void * ptr
, size_t len
)
12 struct ptrace_range pr
;
14 if (len
== 0) return 0;
16 pr
.pr_space
= TS_DATA
;
21 return ptrace(T_GETRANGE
, pid
, &pr
, 0);
25 * Retrieve 'len' bytes from the kernel structure memory of the traced process
26 * 'pid' at offset 'addr' and put the result in the buffer pointed to by 'ptr'.
27 * Return 0 on success, or otherwise -1 with errno set appropriately.
30 mem_get_user(pid_t pid
, vir_bytes addr
, void * ptr
, size_t len
)
36 if (len
== 0) return 0;
38 /* Align access to address. */
39 off
= addr
& (sizeof(data
) - 1);
46 data
= ptrace(T_GETUSER
, pid
, (void *)addr
, 0);
47 if (errno
!= 0) return -1;
49 chunk
= sizeof(data
) - off
;
53 memcpy(p
, (char *)&data
+ off
, chunk
);