Skip to content

Instantly share code, notes, and snippets.

@le4ker
Last active May 28, 2017 22:07
Show Gist options
  • Save le4ker/2134037 to your computer and use it in GitHub Desktop.
Save le4ker/2134037 to your computer and use it in GitHub Desktop.
Change the page protection in Linux kernel
static void disable_page_protection(void)
{
unsigned long cr0 = read_cr0();
if(cr0 & (1 << 16))
{
cr0 &= ~ (1 << 16);
write_cr0(cr0);
}
}
static void enable_page_protection(void)
{
unsigned long cr0 = read_cr0();
if(!(cr0 & (1 << 16)))
{
cr0 |= (1 << 16);
write_cr0(cr0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment