Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struc TSS32
  2. {
  3. .PreviousTaskLink dw ?
  4. .Reserved0 dw ? ;--4
  5. .ESP0 dd ?
  6. .SS0 dw ?
  7. .Reserved1 dw ? ;--12
  8. .ESP1 dd ?
  9. .SS1 dw ?
  10. .Reserved2 dw ? ; 20
  11. .ESP2 dd ?
  12. .SS2 dw ?
  13. .Reserved3 dw ? ; 28
  14. .tsCR3 dd ?
  15. .tsEIP dd ? ; 36
  16. .tsEFLAGS dd ?
  17. .tsEAX dd ? ; 44
  18. .tsECX dd ?
  19. .tsEDX dd ? ; 52
  20. .tsEBX dd ?
  21. .tsESP dd ? ; 60
  22. .tsEBP dd ?
  23. .tsESI dd ?
  24. .tsEDI dd ? ; 72
  25. .tsES dw ?
  26. .Reserved4 dw ? ; 76
  27. .tsCS dw ?
  28. .Reserved5 dw ?
  29. .tsSS dw ?
  30. .Reserved6 dw ?
  31. .tsDS dw ?
  32. .Reserved7 dw ?
  33. .tsFS dw ?
  34. .Reserved8 dw ?
  35. .tsGS dw ?
  36. .Reserved9 dw ?
  37. .LDTSegmentSelector dw ?
  38. .Reserved10 dw ?
  39. .DebugByte db ?
  40. .Reserved11 db ?
  41. .IOMapBaseAddress dw ?
  42.  
  43. }
  44.  
  45.  
  46.  
  47. struc TSS {
  48.  
  49.     .limit dw 0x100
  50.     .adrlow dw ?
  51.     .adrcenter db ?
  52.     .conffield1 db ?
  53.     .conffield2 db ?
  54.     .adrhigh db ?
  55.    
  56. }
  57.  
  58. TSS_ExitProcess TSS32
  59.  
  60. mov edx,TSS_ExitProcess
  61. mov byte [Ext.conffield1],10001001b
  62. mov word [Ext.adrlow],dx
  63. shr edx,16
  64. mov byte [Ext.adrcenter],dl
  65. mov byte [Ext.conffield2],10000000b
  66. shr dx,8
  67. mov byte [Ext.adrhigh],dl
  68.  
  69. GDT:
  70.     rq 1
  71.     KCSD db 0xff,0xff,0x00,0x00,0x00,10011010b,11001111b,0x00
  72.     KDATD db 0xff,0xff,0x00,0x00,0x00,10010010b,11000000b,0x00
  73.     UCSD db 0xff,0xff,0x00,0x00,0x00,11111010b,11001111b,0x00
  74.     UDATD db 0xff,0xff,0x00,0x00,0x00,11110010b,11001111b,0x00
  75.     kernel_manager TSS  
  76.     UPROCESS1 TSS
  77.     UPROCESS2 TSS
  78.     UPROCESS3 TSS
  79.     VIDEO db 0xff,0xff,0x00,0x80,0x0b,10010010b,00001111b,0x00
  80.     Ext TSS
  81.    
  82.     len_GDT equ $ - GDT
  83. IDT:
  84.  
  85.     rq 0x30
  86.    
  87.     timer db 0x00,0x00,0x28,0x00,0x00,10000101b,0x00,0x00 ; IRQ 30
  88.     keyboard db 0x00,0x00,0x08,0x00,0x00,10001110b,0x00,0x00 ; IRQ 31
  89.     slave_PIC db 0x00,0x00,0x08,0x00,0x00,10001110b,0x00,0x00 ; IRQ 32
  90.     com24 db 0x00,0x00,0x08,0x00,0x00,10001110b,0x00,0x00 ; IRQ 33
  91.     com13 db 0x00,0x00,0x08,0x00,0x00,10001110b,0x00,0x00 ; IRQ 34
  92.     LPT2 db 0x00,0x00,0x08,0x00,0x00,10001110b,0x00,0x00 ; IRQ 35
  93.     controller_floppy db 0x00,0x00,0x08,0x00,0x00,10001110b,0x00,0x00 ; IRQ 36
  94.     LPT1 db 0x00,0x00,0x08,0x00,0x00,10001110b,0x00,0x00 ; IRQ 37
  95.     real_timer db 0x00,0x00,0x08,0x00,0x00,10001110b,0x00,0x00 ; IRQ 38
  96.     any_device db 0x00,0x00,0x08,0x00,0x00,10001110b,0x00,0x00 ; IRQ 39
  97.     any_device2 db 0x00,0x00,0x08,0x00,0x00,10001110b,0x00,0x00 ; IRQ 3a
  98.     any_device3 db 0x00,0x00,0x08,0x00,0x00,10001110b,0x00,0x00 ; IRQ 3b
  99.     any_device4 db 0x00,0x00,0x08,0x00,0x00,10001110b,0x00,0x00 ; IRQ 3c
  100.     error_fpu_operation db 0x00,0x00,0x08,0x00,0x00,10001110b,0x00,0x00 ; IRQ 3d
  101.     any_device5 db 0x00,0x00,0x08,0x00,0x00,10001110b,0x00,0x00 ; IRQ 3e
  102.     any_device6 db 0x00,0x00,0x08,0x00,0x00,10001110b,0x00,0x00 ; IRQ 3f
  103.     Hgui db 0x00,0x00,0x08,0x00,0x00,11101110b,0x00,0x00 ; IRQ 40
  104.     IExitProcess db 0x00,0x50,0x00,0x00,0x00,10000101b,0x00,0x00 ; IRQ 41
  105.     IDTlen equ $ - IDT
  106.    
  107. ExitProcess:
  108.  
  109.     mov dx,[ebx]
  110.     movzx edx,dx
  111.    
  112.     add edx,GDT
  113.     bts word [edi+6],12 ; .conffield2
  114.    
  115.     iretd
  116.     jmp near ExitProcess
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement