projects
/
mate.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
trap: use SIGILL instead of SIGSEGV
[mate.git]
/
ffi
/
trap.c
diff --git
a/ffi/trap.c
b/ffi/trap.c
index 32e5217c1ae4e68f178db462db4b004c95ad83e5..2073dae2ec285afe4c1a89343654d1a189882a00 100644
(file)
--- a/
ffi/trap.c
+++ b/
ffi/trap.c
@@
-58,21
+58,17
@@
void callertrap(int nSignal, siginfo_t *info, void *ctx)
unsigned int patchme = getMethodEntry(from, method_map, caller_map);
printf("callertrap(mctx) by 0x%08x\n", from);
unsigned int patchme = getMethodEntry(from, method_map, caller_map);
printf("callertrap(mctx) by 0x%08x\n", from);
- // printf("callertrap(addr) by 0x%08x\n", info->si_addr);
- // printf("callertrap(*esp) by 0x%08x\n", * (unsigned int *) uctx->uc_mcontext.esp);
- unsigned int *to_patch = (unsigned int *) (uctx->uc_mcontext.eip + 2);
- unsigned char *insn = (unsigned char *) (uctx->uc_mcontext.eip);
- *insn = 0x90; // nop
- insn++;
- *insn = 0xe8; // call
+ unsigned int *to_patch = (unsigned int *) (from + 1);
+ unsigned char *insn = (unsigned char *) from;
+ *insn = 0xe8; // call opcode
printf(" to_patch: 0x%08x\n", (unsigned int) to_patch);
printf("*to_patch: 0x%08x\n", *to_patch);
printf(" to_patch: 0x%08x\n", (unsigned int) to_patch);
printf("*to_patch: 0x%08x\n", *to_patch);
- if (*to_patch != 0x
00000000
) {
+ if (*to_patch != 0x
90ffffff
) {
printf("something is wrong here. abort\n");
exit(0);
}
printf("something is wrong here. abort\n");
exit(0);
}
- *to_patch =
(unsigned int) patchme - ((unsigned int) insn
+ 5);
+ *to_patch =
patchme - (from
+ 5);
printf("*to_patch: 0x%08x\n", *to_patch);
uctx->uc_mcontext.eip = (unsigned long) insn;
// while (1) ;
printf("*to_patch: 0x%08x\n", *to_patch);
uctx->uc_mcontext.eip = (unsigned long) insn;
// while (1) ;
@@
-84,7
+80,7
@@
void register_signal(void)
segvaction.sa_sigaction = callertrap;
sigemptyset(&segvaction.sa_mask);
segvaction.sa_flags = SA_SIGINFO | SA_RESTART;
segvaction.sa_sigaction = callertrap;
sigemptyset(&segvaction.sa_mask);
segvaction.sa_flags = SA_SIGINFO | SA_RESTART;
- sigaction(SIG
SEGV
, &segvaction, NULL);
+ sigaction(SIG
ILL
, &segvaction, NULL);
}
unsigned int getaddr(void)
}
unsigned int getaddr(void)