RedstoneHair

pageing.asm

Sep 24th, 2021
597
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [bits 32]
  2. page_table_entry equ 0x1000
  3.  
  4. setup_identity_paging:
  5.     mov edi, page_table_entry
  6.     mov cr3, edi
  7.     mov dword, [edi], 0x2003 ; first table
  8.     add edi, 0x1000
  9.     mov dword, [edi], 0x3003 ; second table
  10.     add edi, 0x1000
  11.     mov dword, [edi], 0x4003 ; third table
  12.     add edi, 0x1000
  13.  
  14.     mov ebx, 0x00000003
  15.     mov ecx, 512
  16.    
  17.     .set_entry:
  18.         mov dword [edi], ebx
  19.         add ebx, 0x1000
  20.         add edi, 8
  21.         loop .set_entry
  22.    
  23.     mov eax, cr4
  24.     or eax, 1 << 5
  25.     mov cr4, eax
  26.    
  27.     mov ecx, 0xc0000080
  28.     rdmsr
  29.     or eax, 1 << 8
  30.     wrmsr
  31.  
  32.     mov eax, cr0
  33.     or eax, 1 << 31
  34.     mov cr0, eax
  35.    
  36.     ret
RAW Paste Data