Source code of Windows XP (NT5)
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.

302 lines
5.3 KiB

  1. ;-----------------------------------------------------------------------;
  2. ; add_alias
  3. ;
  4. ;
  5. ; Entry:
  6. ; AX = alias
  7. ; BX = base
  8. ;
  9. ; Returns:
  10. ; AX = 1 success
  11. ;
  12. ; Error Returns:
  13. ; AX = 0
  14. ;
  15. ; Registers Destroyed:
  16. ;
  17. ; History:
  18. ; Sat 13-May-1989 09:16:09 -by- David N. Weise [davidw]
  19. ; Stole it!
  20. ;-----------------------------------------------------------------------;
  21. assumes ds,nothing
  22. assumes es,nothing
  23. cProc add_alias,<PUBLIC,NEAR>,<ax>
  24. cBegin
  25. SetKernelDS ES
  26. mov dx,ax
  27. mov es,sel_alias_array
  28. UnSetKernelDS ES
  29. aa_look:
  30. mov cx,es:[sa_size]
  31. shr cx,1
  32. mov di, SIZE SASTRUC
  33. xor ax,ax
  34. repnz scasw
  35. jcxz aa_grow
  36. and bl,NOT 07h ; remove RPL bits
  37. and dl,NOT 07h ; remove RPL bits
  38. mov es:[di][-2].sae_sel,bx
  39. mov es:[di][-2].sae_alias,dx
  40. mov ax,1 ; return success
  41. jmps aa_exit
  42. aa_grow:
  43. xor di,di
  44. mov ax,es:[di].sa_size
  45. add ax,SIZE SASTRUC + ((SIZE SAENTRY) * 8)
  46. push ax
  47. push bx
  48. push dx
  49. push es
  50. cCall GlobalRealloc,<es,di,ax,GA_MOVEABLE>
  51. pop es
  52. pop dx
  53. pop bx
  54. or ax,ax ; did we get the memory?
  55. pop ax
  56. jz aa_exit
  57. sub ax,SIZE SASTRUC
  58. mov es:[di].sa_size,ax ; reset the size
  59. jmps aa_look
  60. aa_exit:
  61. cEnd
  62. ;-----------------------------------------------------------------------;
  63. ; delete_alias
  64. ;
  65. ; Checks to see if the passed selector is an alias, if
  66. ; so it frees the entry in the array.
  67. ;
  68. ; Entry:
  69. ; AX = selector to free
  70. ; Returns:
  71. ; ES:DI => alias struct
  72. ;
  73. ; Registers Destroyed:
  74. ;
  75. ; History:
  76. ; Sat 13-May-1989 09:16:09 -by- David N. Weise [davidw]
  77. ; Stole it!
  78. ;-----------------------------------------------------------------------;
  79. assumes ds,nothing
  80. assumes es,nothing
  81. cProc delete_alias,<PUBLIC,NEAR>
  82. cBegin
  83. ; int 3
  84. SetKernelDS ES
  85. mov es,sel_alias_array
  86. xor di,di
  87. mov cx,es:[di].sa_size
  88. shr cx,1
  89. mov di, SIZE SASTRUC
  90. and al,NOT 07h ; remove RPL bits
  91. da_keep_looking:
  92. repnz scasw
  93. jcxz da_exit
  94. .errnz sae_sel - 0
  95. .errnz sae_alias - 2
  96. .errnz (SIZE SASTRUC) - 4
  97. test di,2 ; we avoid problems this way
  98. jnz da_keep_looking
  99. sub di,4
  100. xor ax,ax
  101. mov es:[di].sae_alias,ax
  102. mov es:[di].sae_sel,ax
  103. da_exit:
  104. cEnd
  105. ;-----------------------------------------------------------------------;
  106. ; get_alias_from_original
  107. ;
  108. ;
  109. ; Entry:
  110. ; AX = original selector
  111. ;
  112. ; Returns:
  113. ; BX = alias
  114. ; = 0 if no alias
  115. ; ES:DI => alias struct
  116. ;
  117. ; Registers Destroyed:
  118. ;
  119. ; History:
  120. ; Sat 13-May-1989 09:16:09 -by- David N. Weise [davidw]
  121. ; Stole it!
  122. ;-----------------------------------------------------------------------;
  123. assumes ds,nothing
  124. assumes es,nothing
  125. cProc get_alias_from_original,<PUBLIC,NEAR>
  126. cBegin nogen
  127. ; int 3
  128. SetKernelDS ES
  129. mov es,sel_alias_array
  130. UnsetKernelDS ES
  131. xor di,di
  132. mov cx,es:[di].sa_size
  133. mov di,SIZE SASTRUC
  134. shr cx,1
  135. and al,NOT 07h ; remove RPL bits
  136. gafo_keep_looking:
  137. cld
  138. repnz scasw
  139. xor bx,bx
  140. jcxz gafo_exit
  141. .errnz sae_sel - 0
  142. .errnz sae_alias - 2
  143. .errnz (SIZE SASTRUC) - 4
  144. test di,2 ; we avoid problems this way
  145. jz gafo_keep_looking
  146. sub di,2
  147. ; int 3
  148. mov bx,es:[di].sae_alias
  149. gafo_exit:
  150. ret
  151. cEnd nogen
  152. ;-----------------------------------------------------------------------;
  153. ; get_original_from_alias
  154. ;
  155. ;
  156. ; Entry:
  157. ; AX = alias selector
  158. ;
  159. ; Returns:
  160. ; BX = original selector
  161. ; = 0 if no alias
  162. ; ES:DI => alias struct
  163. ;
  164. ; Registers Destroyed:
  165. ;
  166. ; History:
  167. ; Sat 13-May-1989 09:16:09 -by- David N. Weise [davidw]
  168. ; Stole it!
  169. ;-----------------------------------------------------------------------;
  170. assumes ds,nothing
  171. assumes es,nothing
  172. cProc get_original_from_alias,<PUBLIC,NEAR>
  173. cBegin nogen
  174. ; int 3
  175. SetKernelDS ES
  176. mov es,sel_alias_array
  177. xor di,di
  178. mov cx,es:[di].sa_size
  179. mov di,SIZE SASTRUC
  180. shr cx,1
  181. and al,NOT 07h ; remove RPL bits
  182. gofa_keep_looking:
  183. cld
  184. repnz scasw
  185. xor bx,bx
  186. jcxz gofa_exit
  187. .errnz sae_sel - 0
  188. .errnz sae_alias - 2
  189. .errnz (SIZE SASTRUC) - 4
  190. test di,2 ; we avoid problems this way
  191. jnz gofa_keep_looking
  192. sub di,4
  193. ; int 3
  194. mov bx,es:[di].sae_sel
  195. gofa_exit:
  196. ret
  197. cEnd nogen
  198. ;-----------------------------------------------------------------------;
  199. ; check_for_alias
  200. ;
  201. ;
  202. ; Entry:
  203. ; parmW selector that moved
  204. ; parmD new address
  205. ;
  206. ; Returns:
  207. ;
  208. ; Registers Destroyed:
  209. ;
  210. ; History:
  211. ; Wed 17-Jan-1990 02:07:41 -by- David N. Weise [davidw]
  212. ; Wrote it!
  213. ;-----------------------------------------------------------------------;
  214. assumes ds,nothing
  215. assumes es,nothing
  216. cProc check_for_alias,<PUBLIC,NEAR>,<ds,es>
  217. parmW selector
  218. parmD new_address
  219. cBegin
  220. ; int 3
  221. pusha
  222. pushf
  223. mov ax,selector
  224. call get_alias_from_original
  225. or bx,bx
  226. jz cfa_exit
  227. ; int 3
  228. mov dx,new_address.hi
  229. mov ax,new_address.lo
  230. cCall set_physical_address,<bx>
  231. cfa_exit:
  232. popf
  233. popa
  234. cEnd
  235. ;-----------------------------------------------------------------------;
  236. ; wipe_out_alias
  237. ;
  238. ; This little routine is called when a global memory object
  239. ; is being freed. We search for an alias, if one is found
  240. ; then it is freed.
  241. ;
  242. ; Entry:
  243. ; DX = handle that might have an alias associated with it
  244. ;
  245. ; Returns:
  246. ; nothing
  247. ;
  248. ; Registers Destroyed:
  249. ;
  250. ; History:
  251. ; Thu 18-Jan-1990 00:43:13 -by- David N. Weise [davidw]
  252. ; Wrote it!
  253. ;-----------------------------------------------------------------------;
  254. assumes ds,nothing
  255. assumes es,nothing
  256. cProc wipe_out_alias,<PUBLIC,NEAR>,<dx,di>
  257. cBegin
  258. ; int 3
  259. mov ax,dx
  260. call get_alias_from_original
  261. or bx,bx
  262. jz woa_exit
  263. ; int 3
  264. xor ax,ax
  265. mov es:[di].sae_sel,ax
  266. xchg es:[di].sae_alias,ax
  267. cCall FreeSelector,<ax>
  268. woa_exit:
  269. cEnd