Guest User

Untitled

a guest
Mar 14th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. format binary
  2. use16
  3. org 0x7c00
  4.  
  5.         jmp near EntryBoot
  6. GDT:
  7.             db 0x0000000000000000 ; null descriptor
  8.     CODE_D  db 0xff,0xff,0x00,0x00,0x00,10011010b,00001111b,0x00 ; code descriptor
  9.     Data_D  db 0xff,0xff,0x00,0x00,0x00,10010010b,00001111b,0x00 ; data descriptor
  10.     VIDEO_D db 0xff,0xff,0x00,0x80,0x0b,10010010b,01000000b,0x00 ; video 0xb8000 descriptor
  11.    
  12.     len_GDT equ $ - GDT
  13.    
  14. GDTR:
  15.     dw len_GDT - 1
  16.     dd 0x00000000        
  17.  
  18. EntryBoot:
  19.        
  20. .clear_screen:
  21.        
  22.         mov ah,0x02
  23.         xor bh,bh
  24.         xor dx,dx
  25.         int 0x10
  26.        
  27.         mov ah,0x0a
  28.         mov al,' '
  29.         xor bh,bh
  30.         mov cx,0xffff
  31.         int 0x10
  32.        
  33.         cli
  34.        
  35.         in al,0x92
  36.         bts ax,1
  37.         jc .continue_boot
  38.         out 0x92,al
  39. .continue_boot:
  40.  
  41.         mov dx,cs
  42.         shl edx,4
  43.         add edx,GDT
  44.         mov [GDTR+2],edx
  45.  
  46. .set_PM:
  47.  
  48.         lgdt fword [GDTR]
  49.    
  50.         mov edx,cr0
  51.         or dl,0x01
  52.         mov cr0,edx
  53.         jmp far 0x0008:EntryProtected
  54.  
  55. use32
  56.  
  57. EntryProtected:
  58.         hlt
  59.         mov dx,0x0010
  60.         mov ds,dx
  61.         mov ss,dx
  62.         mov es,dx
  63.         mov dx,0x0018
  64.         mov fs,dx
  65.         mov esp,0xffff0000
  66.         mov ebp,esp
  67.        
  68. .print_status:        
  69.        
  70.         lea esi,[string] ; arg1
  71.         mov ecx,42 ; arg2
  72.        
  73.         call PrintStatus
  74.        
  75.         hlt
  76.        
  77. PrintStatus:
  78.        
  79.         cld
  80.         xor edi,edi
  81. .lp:
  82.         lodsb
  83.         shl ax,8
  84.         mov al,0x0f
  85.         stosw
  86.         loop .lp
  87.        
  88.         ret
  89.        
  90. string db '[+] MBR IN PROTECTED MODE',0x0a,0x0d,'[*] SYSTEM HALT'
  91.        
  92. times 510 - ($ - $$) db 0x00        
  93. dw 0xaa55
Advertisement
Add Comment
Please, Sign In to add comment