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.

314 lines
6.9 KiB

  1. ;Copyright (c) 1998 - 1999 Microsoft Corporation
  2. page 85,132
  3. ;*****************************************************************************
  4. ;
  5. ; yielddos.asm
  6. ; DOS TSR to yield when too many get time request float by
  7. ;
  8. ; Copyright Citrix Systems Inc. 1993
  9. ;
  10. ;
  11. ;*****************************************************************************
  12. TEXT segment public 'CODE'
  13. assume CS:TEXT,DS:TEXT,ES:TEXT,SS:Nothing
  14. .286p
  15. ORG 100h
  16. main proc far
  17. jmp init
  18. main endp
  19. ;**************************************************************************
  20. ; Int21Hook
  21. ;
  22. ; Function: Int 21 Handler for yielddos
  23. ;
  24. ;**************************************************************************
  25. Int21Hook proc far
  26. ; move current cmd to previous cmd
  27. push ax
  28. mov ah,cs:CurrCmd
  29. mov cs:PrevCmd,ah
  30. pop ax
  31. ; save current cmd
  32. mov cs:CurrCmd,ah
  33. ; is request get time?
  34. cmp ah,2ch
  35. jne short NotMine
  36. ; move current time to previous time
  37. push ax
  38. mov ax,cs:CurrHourMin
  39. mov cs:PrevHourMin,ax
  40. mov ax,cs:CurrSec
  41. mov cs:PrevSec,ax
  42. pop ax
  43. ; get the current time
  44. pushf
  45. call dword ptr cs:[OldInt21]
  46. pushf
  47. ; save the current time
  48. push dx
  49. and dl,0f0h ; look for changes within 16/100 sec
  50. mov cs:CurrHourMin,cx
  51. mov cs:CurrSec,dx
  52. pop dx
  53. ; was the previous cmd Get Time?
  54. cmp cs:PrevCmd,2ch
  55. jne short NoYield
  56. ; are the times the same?
  57. push ax
  58. mov ax,cs:CurrHourMin
  59. cmp ax,cs:PrevHourMin
  60. pop ax
  61. jne short NoYield
  62. push ax
  63. mov ax,cs:CurrSec
  64. cmp ax,cs:PrevSec
  65. pop ax
  66. jne short NoYield
  67. ; yielding if time the same and command repeated
  68. push ax
  69. push cx
  70. mov cx, cs:YieldCount
  71. kbdJ:
  72. mov ax,1680h
  73. int 2fh
  74. dec cx
  75. jnz kbdJ
  76. pop cx
  77. pop ax
  78. NoYield:
  79. popf
  80. retf 2
  81. NotMine: ; send to previous Int 21 handler
  82. jmp dword ptr cs:[OldInt21]
  83. Int21Hook endp
  84. ;**************************************************************************
  85. ; Int33Hook
  86. ;
  87. ; Function: Int 33 Handler for yielddos
  88. ;
  89. ;**************************************************************************
  90. Int33Hook proc far
  91. ; is request get button status and mouse position
  92. cmp ax,0003h
  93. jne short NotMine33
  94. ; get the mouse information
  95. pushf
  96. call dword ptr cs:[OldInt33]
  97. pushf
  98. ; Count Int33 func 0003
  99. inc cs:Int33Func3
  100. push ax
  101. push cx
  102. mov cx, cs:YieldCount
  103. mouseJ:
  104. mov ax,1680h
  105. int 2fh
  106. dec cx
  107. jnz mouseJ
  108. pop cx
  109. pop ax
  110. popf
  111. retf 2
  112. NotMine33: ; send to previous Int 21 handler
  113. jmp dword ptr cs:[OldInt33]
  114. Int33Hook endp
  115. OldInt21 dd 0 ; Old int 21 handler
  116. OldInt33 dd 0 ; Old int 33 handler
  117. Int33Func3 dw 0 ; Int33Func3 count
  118. CurrCmd db 0 ; Current Int 21
  119. PrevCmd db 0 ; Old Int 21
  120. CurrHourMin dw 0 ; Current Hour/minutes
  121. CurrSec dw 0 ; Current Sec/100th Sec
  122. PrevHourMin dw 0 ; Previous Hour/minutes
  123. PrevSec dw 0 ; Previous Sec/100th Sec
  124. YieldCount dw 20 ; Yeild Loop Counter
  125. ORG $ + 15
  126. ;*
  127. ;* End of resident code and data
  128. ;*
  129. ResidentMark label byte
  130. ;*
  131. ;* Start of init code and data
  132. ;*
  133. init:
  134. ; save regs
  135. push ax
  136. push bx
  137. push cx
  138. push dx
  139. push si
  140. ; command line arg?
  141. mov cl, byte ptr ds:[80h]
  142. cmp cl, 0
  143. je no_arg
  144. ; set up pointer and counter
  145. mov si, 81h
  146. xor bx, bx
  147. jmp short getfirst
  148. getnum:
  149. dec cl
  150. jz done
  151. getfirst:
  152. lodsb
  153. sub al, "0"
  154. jb not_int
  155. cmp al, 9
  156. ja not_int
  157. cbw
  158. xchg ax, bx
  159. mov dx, 10
  160. mul dx
  161. add bx, ax
  162. jmp getnum
  163. not_int:
  164. cmp bx, 0
  165. je getnum
  166. done:
  167. cmp bx, 0
  168. je no_arg
  169. mov YieldCount, bx
  170. no_arg:
  171. pop si
  172. pop dx
  173. pop cx
  174. pop bx
  175. pop ax
  176. ; Hook Interrupt 21
  177. call HookInt21
  178. ; Hook Interrupt 33
  179. call HookInt33
  180. StayRes:
  181. ; Free the environment
  182. xor ax, ax
  183. xchg ax, word ptr ds:[2ch] ; get env from PSP
  184. or ax, ax
  185. jz short skipenv
  186. push es
  187. mov es, ax
  188. mov ah, 49h
  189. int 21h
  190. pop es
  191. skipenv:
  192. ; Keep program running to catch Int 21 Func 3D requests
  193. mov ax, 3100h
  194. mov dx, offset ResidentMark
  195. shr dx,4
  196. int 21h
  197. ;*****************************************************************************
  198. ;* HookInt21
  199. ;*
  200. ;* Function: Hook Interrupt 21 for yielddos
  201. ;*
  202. ;* Notes:
  203. ;* Saves the Old Int 21 handler for restoring and calling
  204. ;*****************************************************************************
  205. HookInt21 proc near
  206. push es
  207. push bx
  208. push dx
  209. mov ax,3521h ; get int 21 value
  210. int 21h
  211. mov word ptr [OldInt21],bx
  212. mov word ptr [OldInt21]+2,es
  213. mov ax,ds
  214. mov es,ax
  215. mov ax,2521h
  216. mov dx, offset Int21Hook
  217. int 21h
  218. pop dx
  219. pop bx
  220. pop es
  221. ret
  222. HookInt21 endp
  223. ;*****************************************************************************
  224. ;* HookInt33
  225. ;*
  226. ;* Function: Hook Interrupt 33 for yielddos
  227. ;*
  228. ;* Notes:
  229. ;* Saves the Old Int 33 handler for restoring and calling
  230. ;*****************************************************************************
  231. HookInt33 proc near
  232. push es
  233. push bx
  234. push dx
  235. mov ax,3533h ; get int 21 value
  236. int 21h
  237. mov word ptr [OldInt33],bx
  238. mov word ptr [OldInt33]+2,es
  239. mov ax,ds
  240. mov es,ax
  241. mov ax,2533h
  242. mov dx, offset Int33Hook
  243. int 21h
  244. pop dx
  245. pop bx
  246. pop es
  247. ret
  248. HookInt33 endp
  249. ;*
  250. ;* Init DATA
  251. ;* messages and temporary storage discarded after init
  252. ;*
  253. TEXT ends
  254. end main