- 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);
- *to_patch = patchme - (from + 5);
- printf("*to_patch: 0x%08x\n", *to_patch);
- uctx->uc_mcontext.eip = (unsigned long) insn;
- // while (1) ;
-}
-
-void staticfieldtrap(int nSignal, siginfo_t *info, void *ctx)
-{
- struct ucontext *uctx = (struct ucontext *) ctx;
- unsigned int from = (unsigned int) uctx->uc_mcontext.eip;
- unsigned int *to_patch = (unsigned int *) (from + 2);
- printf("staticfieldtrap by 0x%08x\n", from);
- if (*to_patch != 0x00000000) {
- printf("staticfieldtrap: something is wrong here. abort\n");
- exit(0);
+ ptrdiff_t ret = mateHandler(eip, eax, ebx, esi);
+ if (ret == -1) {
+ dprintf("regdump @ EIP: 0x%08x\n", regs[REG_EIP]);
+ dprintf("\tEAX: 0x%08lx EBX: 0x%08lx ECX: 0x%08lx EDX: 0x%08lx\n",
+ regs[REG_EAX], regs[REG_EBX], regs[REG_ECX], regs[REG_EDX]);
+ dprintf("\tESI: 0x%08lx EDI: 0x%08lx EBP: 0x%08lx ESP: 0x%08lx\n",
+ regs[REG_ESI], regs[REG_EDI], regs[REG_EBP], regs[REG_ESP]);
+ mctx->gregs[REG_EIP] = eip + 6;
+ } else {
+ mctx->gregs[REG_EIP] = ret;