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.

199 lines
4.2 KiB

  1. .xlist
  2. include kernel.inc
  3. include protect.inc
  4. .list
  5. .386p
  6. DataBegin
  7. externB fBooting
  8. externW pGlobalHeap
  9. DataEnd
  10. sBegin CODE
  11. assumes CS,CODE
  12. if KDEBUG
  13. externNP check_lru_list
  14. externNP check_free_list
  15. externFP ValidateFreeSpaces
  16. ;-----------------------------------------------------------------------;
  17. ; CheckGlobalHeap ;
  18. ; ;
  19. ; The Global Heap is checked for consistency. First the forward links ;
  20. ; are examined to make sure they lead from the hi_first to the hi_last. ;
  21. ; Then the backward links are checked to make sure they lead from the ;
  22. ; hi_last to the hi_first. Then the arenas are sequentially checked ;
  23. ; to see that the moveable entries point to allocated handles and that ;
  24. ; said handles point back. The handle table is then checked to see ;
  25. ; that the number of used handles match the number of referenced ;
  26. ; handles, and that the number of total handles matches the sum of the ;
  27. ; free, discarded, and used handles. Finally the free list of handles ;
  28. ; is checked. ;
  29. ; ;
  30. ; Arguments: ;
  31. ; none ;
  32. ; ;
  33. ; Returns: ;
  34. ; CF = 0 everything is just fine ;
  35. ; all registers preserved ;
  36. ; ;
  37. ; Error Returns: ;
  38. ; CF = 1 ;
  39. ; DX = offending arena header ;
  40. ; AX = 01h Forward links invalid ;
  41. ; 02h Backward links invalid ;
  42. ; 04h ga_handle points to free handle ;
  43. ; 08h arena points to handle but not vice versa ;
  44. ; 80h ga_sig is bad ;
  45. ; DX = 0 ;
  46. ; AX = 10h allocated handles don't match used handles ;
  47. ; 20h total number of handles don't match up ;
  48. ; 40h total number of free handles don't match up ;
  49. ; ;
  50. ; Registers Preserved: ;
  51. ; All ;
  52. ; ;
  53. ; Registers Destroyed: ;
  54. ; ;
  55. ; Calls: ;
  56. ; ;
  57. ; History: ;
  58. ; ;
  59. ; Sat Nov 01, 1986 02:16:46p -by- David N. Weise [davidw] ;
  60. ; Rewrote it from C into assembly. ;
  61. ;-----------------------------------------------------------------------;
  62. assumes ds,nothing
  63. assumes es,nothing
  64. cProc CheckGlobalHeap,<PUBLIC,NEAR>
  65. cBegin nogen
  66. push eax
  67. push edx
  68. push ebx
  69. push ecx
  70. push edi
  71. push esi
  72. push ds
  73. push es
  74. push fs
  75. push gs
  76. xor eax,eax
  77. xor edx,edx
  78. xor edi,edi
  79. SetKernelDS es
  80. cmp pGlobalHeap,di
  81. jnz short there_is_a_GlobalHeap
  82. jmp all_done
  83. there_is_a_GlobalHeap:
  84. ;;; test fBooting, 1
  85. ;;; jnz no_check
  86. mov ds,pGlobalHeap
  87. ;;; UnSetKernelDS
  88. cmp [di].hi_check,di
  89. jnz short checking_enabled
  90. no_check:
  91. ;;; jmp all_done
  92. checking_enabled:
  93. mov cx,[di].hi_count
  94. mov esi,[di].phi_first
  95. ;;; mov es, dx
  96. forward_ho:
  97. push cx
  98. mov eax, ds:[esi].pga_address
  99. mov ecx, ds:[esi].pga_size
  100. cmp ds:[esi].pga_owner, GA_NOT_THERE
  101. je short no_limit_check
  102. cmp ds:[esi].pga_owner, GA_BURGERMASTER
  103. je short no_limit_check
  104. cmp ds:[esi].pga_owner, di
  105. je short no_limit_check
  106. cmp ds:[esi].pga_handle, di
  107. je short no_limit_check
  108. test fBooting, 1
  109. jnz short no_limit_check
  110. mov bx, ds:[esi].pga_handle
  111. dec ecx
  112. Handle_To_Sel bl
  113. lsl ebx, ebx
  114. jnz short bad_limit
  115. cmp ecx, ebx
  116. je short ok_limit
  117. bad_limit:
  118. int 3
  119. ok_limit:
  120. no_limit_check:
  121. add eax, ds:[esi].pga_size
  122. mov ebx, ds:[esi].pga_next
  123. mov edx, ds:[ebx].pga_address
  124. cmp eax, edx
  125. pop cx
  126. xchg esi, ebx
  127. jne short forward_size_mismatch
  128. cmp ebx, ds:[esi].pga_prev
  129. jz short size_and_next_match
  130. forward_size_mismatch:
  131. cmp ds:[esi].pga_owner, GA_NOT_THERE
  132. je short size_and_next_match
  133. cmp cx,1
  134. jnz short forward_links_invalid
  135. size_and_next_match:
  136. loop xxxx
  137. cmp ebx,[di].phi_last
  138. jz short forward_links_okay
  139. forward_links_invalid:
  140. int 3
  141. mov edx,ebx
  142. mov ax,1
  143. jmps all_done
  144. xxxx:
  145. jmp forward_ho
  146. UnSetKernelDS es
  147. forward_links_okay:
  148. xor ax, ax
  149. call check_lru_list
  150. call check_free_list
  151. ; push cs
  152. ; call near ptr ValidateFreeSpaces
  153. clear_dx_all_done:
  154. xor dx,dx
  155. all_done:
  156. pop gs
  157. pop fs
  158. pop es
  159. pop ds
  160. pop esi
  161. pop edi
  162. pop ecx
  163. pop ebx
  164. or ax,ax
  165. jnz short cgh_error
  166. pop edx
  167. pop eax
  168. ret
  169. cgh_error:
  170. int 3
  171. add sp,8
  172. stc
  173. ret
  174. cEnd nogen
  175. endif
  176. sEnd CODE
  177. end