Skip to content

Instantly share code, notes, and snippets.

@Mischa-Alff
Created May 14, 2014 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mischa-Alff/a5ff651c8de3c4655726 to your computer and use it in GitHub Desktop.
Save Mischa-Alff/a5ff651c8de3c4655726 to your computer and use it in GitHub Desktop.
typedef uint64_t page_t;
typedef page_t page_table_t[0x200];
typedef page_table_t *page_directory_t[0x200];
typedef page_directory_t *page_directory_pointer_t[0x200];
typedef page_directory_pointer_t *pml4_t[0x200];
pml4_t pml4;
extern "C"
void setup_paging()
{
set_cr3(static_cast<uint32_t>(*******pml4));
for(auto i = 0; i < 0x200; ++i)
pml4[i] = 0;
******pml4[0] |= 3;
*****pml4[0][0] |= 3;
****pml4[0][0][0] |= 3;
for(auto t = 0; t < 0x2; ++t)
for(auto p = 0; p < 0x200; ++p)
***pml4[0][0][t][p] = 3 + t*0x200*0x1000 + p * 0x1000;
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment