/* Maks Verver July 2009 */ #define _GNU_SOURCE #include #include #include static void sig_handler(int signal, siginfo_t *info, void *context) { if (signal != SIGILL) return; if (*(char*)info->si_addr != (char)0x9f) abort(); greg_t *regs = ((ucontext_t*)context)->uc_mcontext.gregs; ((char*)®s[REG_RAX])[1] = ((char*)®s[REG_EFL])[0]; regs[REG_RIP]++; } static struct sigaction old_sa, new_sa = { .sa_flags = SA_SIGINFO, .sa_sigaction = &sig_handler }; int _init() { sigaction(SIGILL, &new_sa, &old_sa); return 0; } int _fini() { sigaction(SIGILL, &old_sa, &new_sa); return 0; }