-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
arm: use refactored ptrace.c (see details below)
arm's register type is user_regs, while it's user_regs_struct on x86 and x86_64, so I had to do some defines in order to decide which type to use at build time. other than that, the factored ptrace code seems to work fine on all 3 architectures, as far as I can see.
- Loading branch information
Showing
4 changed files
with
16 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
CC = clang | ||
CFLAGS = -std=gnu99 -ggdb | ||
|
||
all: ../inject | ||
|
||
../inject: inject.c ../utils.c | ||
$(CC) -std=gnu99 -ggdb -ldl -o ../inject ../utils.c inject.c | ||
$(CC) -DARM -ldl -o ../inject ../utils.c ../ptrace.c inject.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
#ifdef ARM | ||
#define REG_TYPE user_regs | ||
#else | ||
#define REG_TYPE user_regs_struct | ||
#endif | ||
|
||
void ptrace_attach(pid_t target); | ||
void ptrace_detach(pid_t target); | ||
void ptrace_getregs(pid_t target, struct user_regs_struct* regs); | ||
void ptrace_getregs(pid_t target, struct REG_TYPE* regs); | ||
void ptrace_cont(pid_t target); | ||
void ptrace_setregs(pid_t target, struct user_regs_struct* regs); | ||
void ptrace_setregs(pid_t target, struct REG_TYPE* regs); | ||
siginfo_t ptrace_getsiginfo(pid_t target); | ||
void ptrace_read(int pid, unsigned long addr, void *vptr, int len); | ||
void ptrace_write(int pid, unsigned long addr, void *vptr, int len); | ||
void checktargetsig(int pid); | ||
void restoreStateAndDetach(pid_t target, unsigned long addr, void* backup, int datasize, struct user_regs_struct oldregs); | ||
void restoreStateAndDetach(pid_t target, unsigned long addr, void* backup, int datasize, struct REG_TYPE oldregs); |