Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
3.1 KiB

  1. ifdef WOW
  2. DPMICALL MACRO callno
  3. mov ax, callno
  4. call DPMIProc
  5. ENDM
  6. else
  7. DPMICALL MACRO func
  8. mov ax, func
  9. int 31h
  10. ENDM
  11. endif; WOW
  12. RING equ 3 ; RING 1 we be
  13. SEL_LDT equ 4
  14. SEG_RING equ (RING+SEL_LDT)
  15. SEG_RING_MASK equ 7
  16. IS_SELECTOR equ 1 ; Selectors are odd, handles even
  17. ; Bits in dsc_access
  18. DSC_PRESENT equ 80h
  19. DSC_CODEDATA equ 10h ; Code or data descriptor
  20. DSC_RING equ (RING SHL 5)
  21. DSC_CODE equ (1Bh+DSC_RING) ; Code, readable, accessed
  22. DSC_CODE_BIT equ 08h ; Identifies code
  23. DSC_RW_BIT equ 02h ; Code readable, data writable bit
  24. DSC_DATA equ (13h+DSC_RING) ; Data, writable, accessed
  25. DSC_ACCESSED equ 01h ; Segment was accessed
  26. DSC_USED equ 0Fh ; Access rights to mark descriptor used
  27. ; Bits in dsc_hlimit
  28. DSC_GRANULARITY equ 80h ; Page granularity segment
  29. DSC_DEFAULT equ 40h ; Default word size
  30. DSC_DISCARDABLE equ 10h ; Available bit in descriptor
  31. ; (using access as a word)
  32. GDT_FREEDSC equ -1
  33. GDT_NPDSC equ 07FFFh
  34. if PMODE
  35. GA_ALIGN_BYTES = (((GA_ALIGN+1) SHL 4) - 1)
  36. GA_MASK_BYTES = (NOT GA_ALIGN_BYTES)
  37. endif
  38. DscPtr struc ;Descriptor
  39. dsc_limit dw ? ;Descriptor max length
  40. dsc_lbase dw ? ;Descriptor base bits 15-0
  41. dsc_mbase db ? ;Descriptor base bits 23-16
  42. dsc_access db ? ;Descriptor access byte
  43. dsc_hlimit db ? ;High limit, granularity and 2 custom bits
  44. dsc_hbase db ? ;Descriptor base bits 31-24
  45. DscPtr ends
  46. DSC_LEN equ (size DscPtr)
  47. .ERRNZ DSC_LEN-8 ; Paranoia
  48. dsc386 equ word ptr dsc_hlimit
  49. dsc_owner equ word ptr dsc_limit
  50. if PMODE
  51. GENTER32 MACRO
  52. push esi
  53. push edi
  54. call genter
  55. mov gs, di
  56. ENDM
  57. GLEAVE32 MACRO
  58. mov es, di ; Zero ES for now
  59. mov fs, di ; And FS
  60. call gleave
  61. pop edi
  62. pop esi
  63. ENDM
  64. MIN_FREE_ARENAS equ 30h ; Minimum number of free arenas desired
  65. ARENA_INCR_BYTES equ 8192 ; Space for more arenas
  66. endif
  67. if PMODE
  68. ife RING-3
  69. ;
  70. ; Change selector or handle to a handle
  71. ; Handles are RING 2
  72. ; Selectors are RING 3
  73. ;
  74. Sel_To_Handle MACRO xsel
  75. and xsel, NOT 1
  76. ENDM
  77. ;
  78. ; Change handle or selector to a selector
  79. ;
  80. Handle_To_Sel MACRO xsel
  81. or xsel, 1
  82. ENDM
  83. ;
  84. ; Change known selector into corresponding handle
  85. ;
  86. StoH MACRO sel
  87. dec sel
  88. ENDM
  89. ;
  90. ; Change known handle into corresponding selector
  91. ;
  92. HtoS MACRO h
  93. inc h
  94. ENDM
  95. ;
  96. ; Given a segment limit, calculate the
  97. ; number of selectors in the array
  98. ;
  99. Limit_To_Selectors MACRO reg
  100. shr reg, 16 ; Now divide by 64k to get # of selectors - 1
  101. inc reg
  102. ENDM
  103. endif
  104. ife RING-1
  105. ;
  106. ; Change selector or handle to a handle
  107. ; Handles are RING 2
  108. ; Selectors are RING 1
  109. ;
  110. Sel_To_Handle MACRO xsel
  111. test xsel, 1
  112. jz short @F
  113. inc xsel
  114. @@:
  115. ENDM
  116. ;
  117. ; Change handle or selector to a selector
  118. ;
  119. Handle_To_Sel MACRO xsel
  120. test xsel, 1
  121. jnz short @F
  122. dec xsel
  123. @@:
  124. ENDM
  125. ;
  126. ; Change known selector into corresponding handle
  127. ;
  128. StoH MACRO sel
  129. inc sel
  130. ENDM
  131. ;
  132. ; Change known handle into corresponding selector
  133. ;
  134. HtoS MACRO h
  135. dec h
  136. ENDM
  137. endif
  138. IsFixed MACRO xh
  139. test xh, 1
  140. ENDM
  141. endif ; PMODE