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.

267 lines
6.7 KiB

  1. PAGE 58,132
  2. ;*****************************************************************************
  3. TITLE MMTASK.ASM - Windows MultiMedia Systems Task Stub
  4. ;*****************************************************************************
  5. ;
  6. ; Copyright (C) Microsoft Corporation 1985-1990. All rights reserved.
  7. ;
  8. ; Title: MMTASK.asm - a windows application that acts as a
  9. ; task stub.
  10. ;
  11. ; Version: 1.00
  12. ;
  13. ; Date: 12-Mar-1990
  14. ;
  15. ; Author: ROBWI
  16. ;
  17. ;-----------------------------------------------------------------------------
  18. ;
  19. ; Change log:
  20. ;
  21. ; DATE REV DESCRIPTION
  22. ; ----------- --- --------------------------------------------------------
  23. ; 12-Mar-1990 ROBWI First Version
  24. ; 18-APR-1990 ROBWI Moved from idle.asm to mmtask.asm
  25. ;
  26. ;=============================================================================
  27. ?WIN=0
  28. ?PLM=1
  29. PMODE = 1
  30. .xlist
  31. include cmacros.inc
  32. .list
  33. wptr equ WORD PTR
  34. ; The following structure should be used to access high and low
  35. ; words of a DWORD. This means that "word ptr foo[2]" -> "foo.hi".
  36. LONG struc
  37. lo dw ?
  38. hi dw ?
  39. LONG ends
  40. FARPOINTER struc
  41. off dw ?
  42. sel dw ?
  43. FARPOINTER ends
  44. ;----------------------------------------------------------------------
  45. ;
  46. ; MMTASKSTRUC : The following structure should be passed to mmtask (in
  47. ; the command line) when it is exec'd.
  48. MMTASKSTRUC struc
  49. lpfn dd ? ; fp to function to call.
  50. inst dd ? ; instance data to pass to lpfn
  51. dwstck dd ? ; stack size.
  52. MMTASKSTRUC ends
  53. EXIT_PROCESS equ 1
  54. ;-----------------------------------------------------------------------;
  55. ;
  56. ; externals from KERNEL
  57. externFP WaitEvent
  58. externFP PostEvent
  59. externFP OldYield
  60. externFP InitTask
  61. externFP InitApp ; to get a msg q so that we can call user
  62. externFP OutputDebugString
  63. externFP SetMessageQueue
  64. sBegin DATA
  65. assumes DS,DATA
  66. ; Stuff needed to avoid the C runtime coming in
  67. DD 0 ; So null pointers get 0
  68. maxRsrvPtrs = 5
  69. DW maxRsrvPtrs
  70. usedRsrvPtrs = 0
  71. labelDP <PUBLIC,rsrvptrs>
  72. DefRsrvPtr MACRO name
  73. globalW name,0
  74. usedRsrvPtrs = usedRsrvPtrs + 1
  75. ENDM
  76. DefRsrvPtr pLocalHeap ; Local heap pointer
  77. DefRsrvPtr pAtomTable ; Atom table pointer
  78. DefRsrvPtr pStackTop ; top of stack
  79. DefRsrvPtr pStackMin ; minimum value of SP
  80. DefRsrvPtr pStackBot ; bottom of stack
  81. if maxRsrvPtrs-usedRsrvPtrs
  82. DW maxRsrvPtrs-usedRsrvPtrs DUP (0)
  83. endif
  84. public __acrtused
  85. __acrtused = 1
  86. loadparams DB (SIZE MMTASKSTRUC) DUP (0)
  87. sEnd DATA
  88. sBegin Code
  89. assumes cs, Code
  90. assumes ds, Data
  91. assumes es, nothing
  92. assumes ss, nothing
  93. ;--------------------------Private-Routine-----------------------------;
  94. ;
  95. ; @doc INTERNAL MMTASKAPP
  96. ;
  97. ; @asm AppEntry | called when the APP is loaded
  98. ;
  99. ; @reg CX | size of heap
  100. ; @reg DI | module handle
  101. ; @reg DS | automatic data segment
  102. ; @reg ES:SI | address of command line (not used)
  103. ; @reg
  104. ;
  105. ; @rdesc Register values at return
  106. ;
  107. ; @reg AX | 1 if success, 0 if error
  108. ;
  109. ; @uses AX BX CX DX FLAGS
  110. ;
  111. ; @comm Preserves: SI DI DS BP
  112. ;
  113. ; Calls: None
  114. ;
  115. ; History:
  116. ;
  117. ; 06-27-89 -by- Todd Laney [ToddLa] Created shell appentry
  118. ; routine
  119. ; 03-13-90 -stolen- Rob Williams [RobWi] Added all kinds o'
  120. ; stuff for making it an MMTASK application.
  121. ;
  122. ;-----------------------------------------------------------------------;
  123. cProc AppEntry,<FAR,PUBLIC,NODATA>,<>
  124. cBegin
  125. ; Copy the parameters out of the command line before
  126. ; InitTask gets a chance to modify them.
  127. push di
  128. push si
  129. push cx
  130. ; switch ds and es so that we can do a string move
  131. ; into the data segment
  132. push ds ; save ds o
  133. mov ax, es
  134. mov ds, ax ; ds = es 0
  135. pop es ; es = ds 0
  136. ; copy the command line if it is the correct length
  137. mov si, 81h
  138. lea di, loadparams
  139. mov cx, SIZE MMTASKSTRUC / 2
  140. xor ax, ax
  141. mov al, byte ptr ds:[80h]
  142. shr ax, 1
  143. cmp ax, cx ; Q: structure size correct
  144. jne Skip_Copy ; N: Skip the copy
  145. .ERRNZ SIZE MMTASKSTRUC MOD 2
  146. cld ; Y: Copy the structure
  147. rep movsw
  148. Skip_Copy:
  149. ; restore original es and ds
  150. push es
  151. mov ax, ds
  152. mov es, ax ; es = ds = es 0
  153. pop ds
  154. pop cx
  155. pop si
  156. pop di
  157. ; pretend the command string is 0 length.
  158. xor ax, ax
  159. mov es:[80h], ax
  160. ; initialize the task and the event queue
  161. cCall InitTask
  162. cCall InitApp, <di>
  163. cCall SetMessageQueue, <64>
  164. or ax,ax
  165. jz MMTASKexit
  166. ; DX is now the CmdShow value.
  167. ; CX is stack size.
  168. ; event count is initially one so call waitevent to clear the event count
  169. cCall WaitEvent, <0>
  170. ; check parameters
  171. mov dx, loadparams.lpfn.hi
  172. or dx, dx ; callback ok?
  173. jz MMTASKExit ; N: out'a here
  174. cCall OldYield ; be polite.
  175. mov ax, loadparams.inst.lo
  176. mov dx, loadparams.inst.hi
  177. cCall loadparams.lpfn, <dx, ax>
  178. MMTASKExit:
  179. ifdef DEBUG
  180. ; lets make sure the app did not do anything evil
  181. cmp wptr ds:[0],0
  182. jne evil
  183. cmp wptr ds:[2],0
  184. jne evil
  185. cmp wptr ds:[4],5
  186. jne evil
  187. je not_evil
  188. evil:
  189. lea ax,evil_str
  190. cCall OuputDebugString, <cs,ax>
  191. int 3
  192. jmp not_evil
  193. evil_str:
  194. db "MMTASK: NULL pointer assignment!",13,10,0
  195. not_evil:
  196. endif
  197. ; before we actualy exit lets yield, so we don't re-enter
  198. ; USERS AppExit code.....
  199. cCall OldYield
  200. cCall OldYield
  201. cCall OldYield
  202. mov ah, 4Ch
  203. int 21h
  204. cEnd
  205. sEnd
  206. end AppEntry