4 #include <asm/ucontext.h>
6 unsigned int getMethodEntry(void *, char *);
7 void *method_map = NULL;
9 void set_mmap(void *mmap)
11 printf("set_mmap: 0x%08x\n", (unsigned int) mmap);
17 printf("get_mmap: 0x%08x\n", (unsigned int) method_map);
23 printf("mmap: 0x%08x\n", getMethodEntry(method_map, "fib"));
27 unsigned int patchme = 0;
28 void print_foo(unsigned int addr)
30 // printf("\n\nprint foo: 0x%08x\n", addr);
34 void callertrap(int nSignal, siginfo_t *info, void *ctx)
36 struct ucontext *uctx = (struct ucontext *) ctx;
38 printf("callertrap(mctx) by 0x%08x\n", uctx->uc_mcontext.eip);
39 // printf("callertrap(addr) by 0x%08x\n", info->si_addr);
40 // printf("callertrap(*esp) by 0x%08x\n", * (unsigned int *) uctx->uc_mcontext.esp);
42 unsigned int *to_patch = (unsigned int *) (uctx->uc_mcontext.eip + 2);
43 unsigned char *insn = (unsigned int *) (uctx->uc_mcontext.eip);
47 printf(" to_patch: 0x%08x\n", to_patch);
48 printf("*to_patch: 0x%08x\n", *to_patch);
49 if (*to_patch != 0x00000000) {
50 printf("something is wrong here. abort\n");
53 *to_patch = (unsigned int) patchme - ((unsigned int) insn + 5);
54 printf("*to_patch: 0x%08x\n", *to_patch);
55 uctx->uc_mcontext.eip = insn;
59 void register_signal(void)
61 struct sigaction segvaction;
62 segvaction.sa_sigaction = callertrap;
63 sigemptyset(&segvaction.sa_mask);
64 segvaction.sa_flags = SA_SIGINFO | SA_RESTART;
65 sigaction(SIGSEGV, &segvaction, NULL);
68 unsigned int getaddr(void)
70 return (unsigned int) print_foo;