Guest User

Untitled

a guest
Oct 10th, 2015
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .global loadGDT
  2. //void _stdcall loadGDT(struct gdtp* ptr);
  3. loadGDT:
  4.     mov $0x4(%esp), %eax ; Load argument
  5.     mov $smallMod, %ebx  ; This is for the code manipulation coming up
  6.     mov %eax, $0x1(%ebx) ;Store it to the address
  7. .smallMod:
  8.     lgdt $0xBADB002 ;Address gets changed by instruction above
  9.     ;GDT is loaded now
  10.     mov $0x10, %ax
  11.     mov %ax, %ds
  12.     mov %ax, %es
  13.     mov %ax, %fs
  14.     mov %ax, %gs
  15.     mov %ax, %ss
  16.     ljmp $0x8, $.1
  17. .1:
  18.  
  19. /// And the same thing in NASM
  20. global loadGDT
  21. ;void _stdcall loadGDT(struct gdtp* ptr);
  22. loadGDT:
  23.     mov eax, [esp+4]
  24.     mov ebx, [smallMod]
  25.     mov [ebx+1], eax
  26. smallMod:
  27.     lgdt 0xBADB002 ;Address gets changed by instruction above
  28.     mov ax, 0x10
  29.     mov ds, ax
  30.     mov es, ax
  31.     mov fs, ax
  32.     mov gs, ax
  33.     mov ss, ax
  34.     jmp 0x8:end
  35. end:
Advertisement
Add Comment
Please, Sign In to add comment