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.

818 lines
21 KiB

  1. page ,132
  2. ;-----------------------------Module-Header-----------------------------;
  3. ; Module Name: thunks.asm - Passes control to 32 bit code.
  4. ;
  5. ;
  6. ; Created: 27-09-93
  7. ; Author: Stephen Estrop [StephenE]
  8. ;
  9. ; Copyright (c) 1993 Microsoft Corporation
  10. ;
  11. ;-----------------------------------------------------------------------;
  12. ?PLM = 1
  13. ?WIN = 0
  14. PMODE = 1
  15. .xlist
  16. include cmacros.inc
  17. include windows.inc
  18. .list
  19. ;-----------------------------------------------------------------------;
  20. ;
  21. ;-----------------------------------------------------------------------;
  22. externFP MMCALLPROC32 ; in Stack.asm
  23. externFP wod32Message
  24. externFP wid32Message
  25. externFP mod32Message
  26. externFP mid32Message
  27. externFP joy32Message ; in joy.c
  28. externFP aux32Message ; in init.c
  29. externFP mci32Message ; in mci.c
  30. externFP cb32 ; in init.c
  31. externFP CheckThunkInit ; in stack.asm
  32. externFP wodMapper ; in init.c
  33. externFP widMapper ; in init.c
  34. WAVE_MAPPER equ (-1) ;
  35. ;
  36. ; The following structure should be used to access high and low
  37. ; words of a DWORD. This means that "word ptr foo[2]" -> "foo.hi".
  38. ;
  39. LONG struc
  40. lo dw ?
  41. hi dw ?
  42. LONG ends
  43. FARPOINTER struc
  44. off dw ?
  45. sel dw ?
  46. FARPOINTER ends
  47. createSeg WAVE, WaveSeg, word, public, CODE
  48. sBegin WaveSeg
  49. assumes cs,WaveSeg
  50. assumes ds,nothing
  51. assumes es,nothing
  52. ;-----------------------------------------------------------------------;
  53. ; @doc INTERNAL WAVE
  54. ;
  55. ; @func DWORD | waveOMessage | This function sends messages to the waveform
  56. ; output device drivers.
  57. ;
  58. ; @parm HWAVE | hWave | The handle to the audio device.
  59. ;
  60. ; @parm UINT | wMsg | The message to send.
  61. ;
  62. ; @parm DWORD | dwP1 | Parameter 1.
  63. ;
  64. ; @parm DWORD | dwP2 | Parameter 2.
  65. ;
  66. ; @rdesc Returns the value returned from the thunk.
  67. ;-----------------------------------------------------------------------;
  68. cProc waveOMessage, <NEAR, PUBLIC, PASCAL>, <>
  69. ParmW hWave
  70. ParmW wMsg
  71. ParmD dw1
  72. ParmD dw2
  73. cBegin
  74. call CheckThunkInit ; returns ax=0 if sucessful
  75. or ax,ax
  76. jnz waveOMessage_exit
  77. mov bx,hWave ; bx = hWave
  78. mov ax,WORD PTR [bx+8] ; ax = bx->wDeviceID
  79. cmp ax,WAVE_MAPPER ; Is this the wave mapper
  80. jnz @f ; No so thunk to the 32 bit code.
  81. cmp [wodMapper].hi,0 ; No wave mapper loaded
  82. jz @f ; so jump to 32 bit code
  83. push ax ; push device id
  84. push wMsg ; push message
  85. push WORD PTR [bx+6] ; push bx->dwDrvUser.hi
  86. push WORD PTR [bx+4] ; push bx->dwDrvUser.lo
  87. push dw1.hi
  88. push dw1.lo
  89. push dw2.hi
  90. push dw2.lo
  91. call DWORD PTR [wodMapper]
  92. jmp waveOMessage_exit
  93. @@:
  94. sub dx,dx ; dx = 0
  95. push dx
  96. push ax
  97. push dx
  98. push wMsg
  99. push WORD PTR [bx+6] ; push bx->dwDrvUser.hi
  100. push WORD PTR [bx+4] ; push bx->dwDrvUser.lo
  101. push dw1.hi
  102. push dw1.lo
  103. push dw2.hi
  104. push dw2.lo
  105. push wod32Message.sel
  106. push wod32Message.off
  107. push dx
  108. push dx ; no directory change
  109. call FAR PTR MMCALLPROC32 ; call the 32 bit code
  110. waveOMessage_exit:
  111. cEnd
  112. ;-----------------------------------------------------------------------;
  113. ; @doc INTERNAL WAVE
  114. ;
  115. ; @func UINT | waveOIDMessage | This function opens a 32 bit wave device
  116. ; on behalf of a 16 bit application.
  117. ;
  118. ; @parm UINT | wDeviceID | Device ID to send message to.
  119. ;
  120. ; @parm UINT | wMessage | The message to send.
  121. ;
  122. ; @parm DWORD | dwUser | The users private DWORD.
  123. ;
  124. ; @parm DWORD | dwParam1 | Parameter 1.
  125. ;
  126. ; @parm DWORD | dwParam2 | Parameter 2.
  127. ;
  128. ; @rdesc The return value is the low word of the returned message.
  129. ;-----------------------------------------------------------------------;
  130. cProc waveOIDMessage, <FAR, PUBLIC, PASCAL>, <>
  131. ParmW wDeviceID
  132. ParmW wMsg
  133. ParmD dwUser
  134. ParmD dw1
  135. ParmD dw2
  136. cBegin
  137. call CheckThunkInit
  138. or ax,ax
  139. jnz waveOIDMessage_exit
  140. mov ax,wDeviceID
  141. cmp ax,WAVE_MAPPER ; Is this the wave mapper
  142. jnz @f ; No so thunk to the 32 bit code.
  143. cmp [wodMapper].hi,0 ; No wave mapper loaded
  144. jz @f ; so jump to 32 bit code
  145. push ax ; push device id
  146. push wMsg ; push message
  147. push dwUser.hi
  148. push dwUser.lo
  149. push dw1.hi
  150. push dw1.lo
  151. push dw2.hi
  152. push dw2.lo
  153. call DWORD PTR [wodMapper]
  154. jmp waveOIDMessage_exit
  155. @@:
  156. sub dx,dx
  157. push dx
  158. push ax
  159. push dx
  160. push wMsg
  161. push dwUser.hi
  162. push dwUser.lo
  163. push dw1.hi
  164. push dw1.lo
  165. push dw2.hi
  166. push dw2.lo
  167. push wod32Message.sel
  168. push wod32Message.off
  169. push dx
  170. push dx ; no directory change
  171. call FAR PTR MMCALLPROC32 ; call the 32 bit code
  172. waveOIDMessage_exit:
  173. cEnd
  174. ;-----------------------------------------------------------------------;
  175. ; @doc INTERNAL WAVE
  176. ;
  177. ; @func DWORD | waveIMessage | This function sends messages to the waveform
  178. ; output device drivers.
  179. ;
  180. ; @parm HWAVE | hWave | The handle to the audio device.
  181. ;
  182. ; @parm UINT | wMsg | The message to send.
  183. ;
  184. ; @parm DWORD | dwP1 | Parameter 1.
  185. ;
  186. ; @parm DWORD | dwP2 | Parameter 2.
  187. ;
  188. ; @rdesc Returns the value returned from the thunk.
  189. ;-----------------------------------------------------------------------;
  190. cProc waveIMessage, <NEAR, PUBLIC, PASCAL>, <>
  191. ParmW hWave
  192. ParmW wMsg
  193. ParmD dw1
  194. ParmD dw2
  195. cBegin
  196. call CheckThunkInit
  197. or ax,ax
  198. jnz waveIMessage_exit
  199. mov bx,hWave ; bx = hWave
  200. mov ax,WORD PTR [bx+8] ; ax = bx->wDeviceID
  201. cmp ax,WAVE_MAPPER ; Is this the wave mapper
  202. jnz @f ; No so thunk to the 32 bit code.
  203. cmp [widMapper].hi,0 ; No wave mapper loaded
  204. jz @f ; so jump to 32 bit code
  205. push ax ; push device id
  206. push wMsg ; push message
  207. push WORD PTR [bx+6] ; push bx->dwDrvUser.hi
  208. push WORD PTR [bx+4] ; push bx->dwDrvUser.lo
  209. push dw1.hi
  210. push dw1.lo
  211. push dw2.hi
  212. push dw2.lo
  213. call DWORD PTR [widMapper]
  214. jmp waveIMessage_exit
  215. @@:
  216. sub dx,dx ; dx = 0
  217. push dx
  218. push ax
  219. push dx
  220. push wMsg
  221. push WORD PTR [bx+6] ; push bx->dwDrvUser.hi
  222. push WORD PTR [bx+4] ; push bx->dwDrvUser.lo
  223. push dw1.hi
  224. push dw1.lo
  225. push dw2.hi
  226. push dw2.lo
  227. push wid32Message.sel
  228. push wid32Message.off
  229. push dx
  230. push dx ; no directory change
  231. call FAR PTR MMCALLPROC32 ; call the 32 bit code
  232. waveIMessage_exit:
  233. cEnd
  234. ;-----------------------------------------------------------------------;
  235. ; @doc INTERNAL WAVE
  236. ;
  237. ; @func UINT | waveIIDMessage | This function opens a 32 bit wave device
  238. ; on behalf of a 16 bit application.
  239. ;
  240. ; @parm UINT | wDeviceID | Device ID to send message to.
  241. ;
  242. ; @parm UINT | wMessage | The message to send.
  243. ;
  244. ; @parm DWORD | dwUser | The users private DWORD.
  245. ;
  246. ; @parm DWORD | dwParam1 | Parameter 1.
  247. ;
  248. ; @parm DWORD | dwParam2 | Parameter 2.
  249. ;
  250. ; @rdesc The return value is the low word of the returned message.
  251. ;-----------------------------------------------------------------------;
  252. cProc waveIIDMessage, <FAR, PUBLIC, PASCAL>, <>
  253. ParmW wDeviceID
  254. ParmW wMsg
  255. ParmD dwUser
  256. ParmD dw1
  257. ParmD dw2
  258. cBegin
  259. call CheckThunkInit
  260. or ax,ax
  261. jnz waveIIDMessage_exit
  262. mov ax,wDeviceID
  263. cmp ax,WAVE_MAPPER ; Is this the wave mapper
  264. jnz @f ; No so thunk to the 32 bit code.
  265. cmp [widMapper].hi,0 ; No wave mapper loaded
  266. jz @f ; so jump to 32 bit code
  267. push ax ; push device id
  268. push wMsg ; push message
  269. push dwUser.hi
  270. push dwUser.lo
  271. push dw1.hi
  272. push dw1.lo
  273. push dw2.hi
  274. push dw2.lo
  275. call DWORD PTR [widMapper]
  276. jmp waveIIDMessage_exit
  277. @@:
  278. sub dx,dx
  279. push dx
  280. push ax
  281. push dx
  282. push wMsg
  283. push dwUser.hi
  284. push dwUser.lo
  285. push dw1.hi
  286. push dw1.lo
  287. push dw2.hi
  288. push dw2.lo
  289. push wid32Message.sel
  290. push wid32Message.off
  291. push dx
  292. push dx ; no directory change
  293. call FAR PTR MMCALLPROC32 ; call the 32 bit code
  294. waveIIDMessage_exit:
  295. cEnd
  296. sEnd
  297. createSeg FIX, CodeFix, word, public, CODE
  298. sBegin CodeFix
  299. assumes cs,CodeFix
  300. assumes ds,nothing
  301. assumes es,nothing
  302. ;-----------------------------------------------------------------------;
  303. ; @doc INTERNAL MIDI
  304. ;
  305. ; @func DWORD | midiOMessage | This function sends messages to the midiform
  306. ; output device drivers.
  307. ;
  308. ; @parm HMIDI | hMidi | The handle to the audio device.
  309. ;
  310. ; @parm UINT | wMsg | The message to send.
  311. ;
  312. ; @parm DWORD | dwP1 | Parameter 1.
  313. ;
  314. ; @parm DWORD | dwP2 | Parameter 2.
  315. ;
  316. ; @rdesc Returns the value returned from the thunk.
  317. ;-----------------------------------------------------------------------;
  318. cProc midiOMessage, <FAR, PUBLIC, PASCAL>, <>
  319. ParmW hMidi
  320. ParmW wMsg
  321. ParmD dw1
  322. ParmD dw2
  323. cBegin
  324. call CheckThunkInit
  325. or ax,ax
  326. jnz @F
  327. mov bx,hMidi ; bx = hMidi
  328. mov ax,WORD PTR [bx+8] ; ax = bx->wDeviceID
  329. sub dx,dx ; dx = 0
  330. push dx
  331. push ax
  332. push dx
  333. push wMsg
  334. push WORD PTR [bx+6] ; push bx->dwDrvUser.hi
  335. push WORD PTR [bx+4] ; push bx->dwDrvUser.lo
  336. push dw1.hi
  337. push dw1.lo
  338. push dw2.hi
  339. push dw2.lo
  340. push mod32Message.sel
  341. push mod32Message.off
  342. push dx
  343. push dx ; no directory change
  344. call FAR PTR MMCALLPROC32 ; call the 32 bit code
  345. @@:
  346. cEnd
  347. ;-----------------------------------------------------------------------;
  348. ; @doc INTERNAL MIDI
  349. ;
  350. ; @func DWORD | midiIMessage | This function sends messages to the midiform
  351. ; output device drivers.
  352. ;
  353. ; @parm HMIDI | hMidi | The handle to the audio device.
  354. ;
  355. ; @parm UINT | wMsg | The message to send.
  356. ;
  357. ; @parm DWORD | dwP1 | Parameter 1.
  358. ;
  359. ; @parm DWORD | dwP2 | Parameter 2.
  360. ;
  361. ; @rdesc Returns the value returned from the thunk.
  362. ;-----------------------------------------------------------------------;
  363. cProc midiIMessage, <FAR, PUBLIC, PASCAL>, <>
  364. ParmW hMidi
  365. ParmW wMsg
  366. ParmD dw1
  367. ParmD dw2
  368. cBegin
  369. call CheckThunkInit
  370. or ax,ax
  371. jnz @F
  372. mov bx,hMidi ; bx = hMidi
  373. mov ax,WORD PTR [bx+8] ; ax = bx->wDeviceID
  374. sub dx,dx ; dx = 0
  375. push dx
  376. push ax
  377. push dx
  378. push wMsg
  379. push WORD PTR [bx+6] ; push bx->dwDrvUser.hi
  380. push WORD PTR [bx+4] ; push bx->dwDrvUser.lo
  381. push dw1.hi
  382. push dw1.lo
  383. push dw2.hi
  384. push dw2.lo
  385. push mid32Message.sel
  386. push mid32Message.off
  387. push dx
  388. push dx ; no directory change
  389. call FAR PTR MMCALLPROC32 ; call the 32 bit code
  390. @@:
  391. cEnd
  392. sEnd
  393. createSeg MIDI, MidiSeg, word, public, CODE
  394. sBegin MidiSeg
  395. assumes cs,MidiSeg
  396. assumes ds,nothing
  397. assumes es,nothing
  398. ;-----------------------------------------------------------------------;
  399. ; @doc INTERNAL MIDI
  400. ;
  401. ; @func UINT | midiOIDMessage | This function opens a 32 bit midi device
  402. ; on behalf of a 16 bit application.
  403. ;
  404. ; @parm UINT | wDeviceID | Device ID to send message to.
  405. ;
  406. ; @parm UINT | wMessage | The message to send.
  407. ;
  408. ; @parm DWORD | dwUser | The users private DWORD.
  409. ;
  410. ; @parm DWORD | dwParam1 | Parameter 1.
  411. ;
  412. ; @parm DWORD | dwParam2 | Parameter 2.
  413. ;
  414. ; @rdesc The return value is the low word of the returned message.
  415. ;-----------------------------------------------------------------------;
  416. cProc midiOIDMessage, <FAR, PUBLIC, PASCAL>, <>
  417. ParmW wDeviceID
  418. ParmW wMsg
  419. ParmD dwUser
  420. ParmD dw1
  421. ParmD dw2
  422. cBegin
  423. call CheckThunkInit
  424. sub dx,dx
  425. push dx
  426. push wDeviceID
  427. push dx
  428. push wMsg
  429. push dwUser.hi
  430. push dwUser.lo
  431. push dw1.hi
  432. push dw1.lo
  433. push dw2.hi
  434. push dw2.lo
  435. push mod32Message.sel
  436. push mod32Message.off
  437. push dx
  438. push dx ; no directory change
  439. call FAR PTR MMCALLPROC32 ; call the 32 bit code
  440. cEnd
  441. ;-----------------------------------------------------------------------;
  442. ; @doc INTERNAL MIDI
  443. ;
  444. ; @func UINT | midiIIDMessage | This function opens a 32 bit midi device
  445. ; on behalf of a 16 bit application.
  446. ;
  447. ; @parm UINT | wDeviceID | Device ID to send message to.
  448. ;
  449. ; @parm UINT | wMessage | The message to send.
  450. ;
  451. ; @parm DWORD | dwUser | The users private DWORD.
  452. ;
  453. ; @parm DWORD | dwParam1 | Parameter 1.
  454. ;
  455. ; @parm DWORD | dwParam2 | Parameter 2.
  456. ;
  457. ; @rdesc The return value is the low word of the returned message.
  458. ;-----------------------------------------------------------------------;
  459. cProc midiIIDMessage, <FAR, PUBLIC, PASCAL>, <>
  460. ParmW wDeviceID
  461. ParmW wMsg
  462. ParmD dwUser
  463. ParmD dw1
  464. ParmD dw2
  465. cBegin
  466. call CheckThunkInit
  467. or ax,ax
  468. jnz @F
  469. sub dx,dx
  470. push dx
  471. push wDeviceID
  472. push dx
  473. push wMsg
  474. push dwUser.hi
  475. push dwUser.lo
  476. push dw1.hi
  477. push dw1.lo
  478. push dw2.hi
  479. push dw2.lo
  480. push mid32Message.sel
  481. push mid32Message.off
  482. push dx
  483. push dx ; no directory change
  484. call FAR PTR MMCALLPROC32 ; call the 32 bit code
  485. @@:
  486. cEnd
  487. sEnd
  488. createSeg MCI, MciSeg, word, public, CODE
  489. sBegin MciSeg
  490. assumes cs,MciSeg
  491. assumes ds,nothing
  492. assumes es,nothing
  493. ;-----------------------------------------------------------------------;
  494. ; mciMessage
  495. ;
  496. ;
  497. ;-----------------------------------------------------------------------;
  498. cProc mciMessage, <FAR, PUBLIC, PASCAL>, <>
  499. ParmW wMsg
  500. ParmD dw1
  501. ParmD dw2
  502. ParmD dw3
  503. ParmD dw4
  504. cBegin
  505. call CheckThunkInit
  506. or ax,ax
  507. jnz @F
  508. sub dx,dx
  509. push dx
  510. push wMsg
  511. push dw1.hi
  512. push dw1.lo
  513. push dw2.hi
  514. push dw2.lo
  515. push dw3.hi
  516. push dw3.lo
  517. push dw4.hi
  518. push dw4.lo
  519. push mci32Message.sel
  520. push mci32Message.off
  521. push dx
  522. push 1 ; set directory change
  523. call FAR PTR MMCALLPROC32 ; call the 32 bit code
  524. @@:
  525. cEnd
  526. sEnd
  527. createSeg RARE, RareSeg, word, public, CODE
  528. sBegin RareSeg
  529. assumes cs,RareSeg
  530. assumes ds,nothing
  531. assumes es,nothing
  532. ;-----------------------------------------------------------------------;
  533. ; @doc INTERNAL AUX
  534. ;
  535. ; @func UINT | auxOutMessage | This function opens a 32 bit midi device
  536. ; on behalf of a 16 bit application.
  537. ;
  538. ; @parm FARPROC | lpProc | The 32 bit function that will get called.
  539. ;
  540. ; @parm UINT | wDeviceID | Device ID to send message to.
  541. ;
  542. ; @parm UINT | wMessage | The message to send.
  543. ;
  544. ; @parm DWORD | dwParam1 | Parameter 1.
  545. ;
  546. ; @parm DWORD | dwParam2 | Parameter 2.
  547. ;
  548. ; @rdesc The return value is the low word of the returned message.
  549. ;-----------------------------------------------------------------------;
  550. cProc auxOutMessage, <FAR, PUBLIC, PASCAL, LOADDS>, <>
  551. ParmW wDeviceID
  552. ParmW wMsg
  553. ParmD dw1
  554. ParmD dw2
  555. cBegin
  556. call CheckThunkInit
  557. or ax,ax
  558. jnz @F
  559. sub dx,dx
  560. push dx
  561. push wDeviceID
  562. push dx
  563. push wMsg
  564. push dx
  565. push dx
  566. push dw1.hi
  567. push dw1.lo
  568. push dw2.hi
  569. push dw2.lo
  570. push aux32Message.sel
  571. push aux32Message.off
  572. push dx
  573. push dx ; no directory change
  574. call FAR PTR MMCALLPROC32 ; call the 32 bit code
  575. @@:
  576. cEnd
  577. ;*****************************Private*Routine******************************\
  578. ; joyMessage
  579. ;
  580. ;
  581. ;
  582. ; History:
  583. ; 27-09-93 - StephenE - Created
  584. ;
  585. ;**************************************************************************/
  586. cProc joyMessage, <FAR, PUBLIC, PASCAL>, <>
  587. ParmW hdrv,
  588. ParmW wMsg,
  589. ParmD dw1,
  590. ParmD dw2
  591. cBegin
  592. call CheckThunkInit
  593. or ax,ax
  594. jnz @F
  595. sub dx,dx
  596. push dx
  597. mov ax,hdrv
  598. dec ax ; uDevID
  599. push ax ;
  600. push dx ; uMsg
  601. push wMsg ;
  602. push dx ; dummy dwInstance
  603. push dx ;
  604. push dw1.hi ; dwParam1
  605. push dw1.lo ;
  606. push dw2.hi ; dwParam2
  607. push dw2.lo ;
  608. push joy32Message.sel ; Address of function to be called
  609. push joy32Message.off ;
  610. push dx
  611. push dx ; no directory change
  612. call FAR PTR MMCALLPROC32 ; call the 32 bit code
  613. @@:
  614. cEnd
  615. ;******************************Public*Routine******************************\
  616. ; Notify_Callback_Data
  617. ;
  618. ;
  619. ;
  620. ; History:
  621. ; 27-09-93 - StephenE - Created
  622. ;
  623. ;**************************************************************************/
  624. cProc Notify_Callback_Data, <FAR, PUBLIC, PASCAL>, <>
  625. ParmD CallbackData
  626. cBegin
  627. sub dx,dx
  628. push dx ; Dummy uDevId
  629. push dx ;
  630. push dx ; Dummy uMsg
  631. push dx ;
  632. push dx ; Dummy dwInstance
  633. push dx ;
  634. push dx ; Dummy dwParam1
  635. push dx ;
  636. push CallbackData.hi ; Real dwParam2
  637. push CallbackData.lo ;
  638. push cb32.sel ; Address of function to be called
  639. push cb32.off ;
  640. push dx
  641. push dx ; no directory change
  642. call FAR PTR MMCALLPROC32 ; call the 32 bit code
  643. cEnd
  644. sEnd
  645. end