blob: d066cf177e06a1a63d9a852ea8d8696d833a336e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#include <sys/types.h>
#include <sys/ptrace.h>
#include <asm/ptrace.h>
#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR))
# define PTRACE_PEEKUSER PTRACE_PEEKUSR
#endif
#if (!defined(PTRACE_POKEUSER) && defined(PTRACE_POKEUSR))
# define PTRACE_POKEUSER PTRACE_POKEUSR
#endif
int get_instruction_pointer(pid_t pid)
{
return ptrace(PTRACE_PEEKUSER, pid, 4*EIP, 0);
}
int get_stack_pointer(pid_t pid)
{
return ptrace(PTRACE_PEEKUSER, pid, 4*UESP, 0);
}
int get_return_addr(pid_t pid, void * stack_pointer)
{
return ptrace(PTRACE_PEEKTEXT, pid, stack_pointer, 0);
}
|