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.

270 lines
5.8 KiB

  1. page ,132
  2. .listall
  3. ;Thunk Compiler Version 1.8 Dec 14 1994 14:53:05
  4. ;File Compiled Fri Jun 20 10:27:33 1997
  5. ;Command Line: thunk -P2 -NC ddraw -t thk1632 ..\16to32.thk -o 16to32.asm
  6. TITLE $16to32.asm
  7. .386
  8. OPTION READONLY
  9. IFNDEF IS_16
  10. IFNDEF IS_32
  11. %out command line error: specify one of -DIS_16 -DIS_32
  12. .err
  13. ENDIF
  14. ENDIF
  15. IFDEF IS_16
  16. IFDEF IS_32
  17. %out command line error: you can't specify both -DIS_16 and -DIS_32
  18. .err
  19. ENDIF
  20. OPTION SEGMENT:USE16
  21. .model LARGE,PASCAL
  22. f32ptr typedef ptr far32
  23. externDef DDHAL32_VidMemFree:far16
  24. externDef DDHAL32_VidMemAlloc:far16
  25. externDef C16ThkSL01:far16
  26. externDef __FLATCS:ABS
  27. externDef __FLATDS:ABS
  28. .data
  29. public thk1632_ThunkData16 ;This symbol must be exported.
  30. thk1632_ThunkData16 dd 31304c53h ;Protocol 'SL01'
  31. dd 0fa1h ;Checksum
  32. dd 0 ;Flags.
  33. dd 0 ;RESERVED. MUST BE ZERO.
  34. dd 0 ;RESERVED. MUST BE ZERO.
  35. dd 0 ;RESERVED. MUST BE ZERO.
  36. dd 0 ;RESERVED. MUST BE ZERO.
  37. dd 3130424ch ;Late-binding signature 'LB01'
  38. dd 080000000h ;More flags.
  39. dd 0 ;RESERVED. MUST BE ZERO.
  40. dw offset thk1632_ThunkData16ApiDatabase
  41. dw seg thk1632_ThunkData16ApiDatabase
  42. ;; Api database. Each entry == 8 bytes:
  43. ;; byte 0: # of argument bytes.
  44. ;; byte 1,2,3: Reserved: Must initialize to 0.
  45. ;; dword 4: error return value.
  46. public thk1632_ThunkData16ApiDatabase
  47. thk1632_ThunkData16ApiDatabase label dword
  48. db 10
  49. db 0,0,0
  50. dd -1
  51. db 14
  52. db 0,0,0
  53. dd 0
  54. .code ddraw
  55. externDef ThunkConnect16:far16
  56. public thk1632_ThunkConnect16
  57. thk1632_ThunkConnect16:
  58. pop ax
  59. pop dx
  60. push seg thk1632_ThunkData16
  61. push offset thk1632_ThunkData16
  62. push seg thk1632_TD32Label
  63. push offset thk1632_TD32Label
  64. push cs
  65. push dx
  66. push ax
  67. jmp ThunkConnect16
  68. thk1632_TD32Label label byte
  69. db "thk1632_ThunkData32",0
  70. DDHAL32_VidMemFree label far16
  71. mov cx,0 ; offset in jump table
  72. jmp thk1632EntryCommon
  73. DDHAL32_VidMemAlloc label far16
  74. mov cx,4 ; offset in jump table
  75. jmp thk1632EntryCommon
  76. ;===========================================================================
  77. ; This is the common setup code for 16=>32 thunks.
  78. ;
  79. ; Entry: cx = offset in flat jump table
  80. ;
  81. ; Don't optimize this code: C16ThkSL01 overwrites it
  82. ; after each discard.
  83. align
  84. thk1632EntryCommon:
  85. db 0ebh, 030 ;Jump short forward 30 bytes.
  86. ;;; Leave at least 30 bytes for C16ThkSL01's code patching.
  87. db 30 dup(0cch) ;Patch space.
  88. push seg thk1632_ThunkData16
  89. push offset thk1632_ThunkData16
  90. pop edx
  91. push cs
  92. push offset thk1632EntryCommon
  93. pop eax
  94. jmp C16ThkSL01
  95. ELSE ; IS_32
  96. .model FLAT,STDCALL
  97. include thk.inc
  98. include 16to32.inc
  99. externDef STDCALL DDHAL32_VidMemFree@12:near32
  100. externDef STDCALL DDHAL32_VidMemAlloc@16:near32
  101. externDef C DebugPrintf:near32
  102. MapSLFix proto STDCALL :DWORD
  103. MapSL proto STDCALL :DWORD
  104. UnMapSLFixArray proto STDCALL :DWORD, :DWORD
  105. LocalAlloc proto STDCALL :DWORD, :DWORD
  106. LocalFree proto STDCALL :DWORD
  107. externDef MapHInstSL:near32
  108. externDef MapHInstSL_PN:near32
  109. externDef MapHInstLS:near32
  110. externDef MapHInstLS_PN:near32
  111. externDef T_DDHAL32_VIDMEMFREE:near32
  112. externDef T_DDHAL32_VIDMEMALLOC:near32
  113. ;===========================================================================
  114. .code
  115. ; This is a jump table to API-specific flat thunk code.
  116. align
  117. thk1632_JumpTable label dword
  118. dd offset FLAT:T_DDHAL32_VIDMEMFREE
  119. dd offset FLAT:T_DDHAL32_VIDMEMALLOC
  120. thk1632_ThunkDataName label byte
  121. db "thk1632_ThunkData16",0
  122. .data
  123. public thk1632_ThunkData32 ;This symbol must be exported.
  124. thk1632_ThunkData32 dd 31304c53h ;Protocol 'SL01'
  125. dd 0fa1h ;Checksum
  126. dd 0 ;Reserved (MUST BE 0)
  127. dd 0 ;Flat address of ThunkData16
  128. dd 3130424ch ;'LB01'
  129. dd 0 ;Flags
  130. dd 0 ;Reserved (MUST BE 0)
  131. dd 0 ;Reserved (MUST BE 0)
  132. dd offset thk1632_JumpTable - offset thk1632_ThunkDataName
  133. .code
  134. externDef ThunkConnect32@24:near32
  135. public thk1632_ThunkConnect32@16
  136. thk1632_ThunkConnect32@16:
  137. pop edx
  138. push offset thk1632_ThunkDataName
  139. push offset thk1632_ThunkData32
  140. push edx
  141. jmp ThunkConnect32@24
  142. ;===========================================================================
  143. ; Common routines to restore the stack and registers
  144. ; and return to 16-bit code. There is one for each
  145. ; size of 16-bit parameter list in this script.
  146. align
  147. ExitFlat_10:
  148. mov cl,10 ; parameter byte count
  149. mov esp,ebp ; point to return address
  150. retn ; return to dispatcher
  151. align
  152. ExitFlat_14:
  153. mov cl,14 ; parameter byte count
  154. mov esp,ebp ; point to return address
  155. retn ; return to dispatcher
  156. ;===========================================================================
  157. T_DDHAL32_VIDMEMFREE label near32
  158. ; ebx+28 this
  159. ; ebx+26 heap
  160. ; ebx+22 ptr
  161. APILOGSL DDHAL32_VidMemFree
  162. ;-------------------------------------
  163. ; create new call frame and make the call
  164. ; ptr from: unsigned long
  165. push dword ptr [ebx+22] ; to unsigned long
  166. ; heap from: short
  167. movsx eax,word ptr [ebx+26]
  168. push eax ; to: long
  169. ; this from: unsigned long
  170. push dword ptr [ebx+28] ; to unsigned long
  171. call DDHAL32_VidMemFree@12 ; call 32-bit version
  172. ; return code unsigned long --> unsigned long
  173. mov edx,eax
  174. rol edx,16
  175. ;-------------------------------------
  176. jmp ExitFlat_10
  177. ;===========================================================================
  178. T_DDHAL32_VIDMEMALLOC label near32
  179. ; ebx+32 this
  180. ; ebx+30 heap
  181. ; ebx+26 width
  182. ; ebx+22 height
  183. APILOGSL DDHAL32_VidMemAlloc
  184. ;-------------------------------------
  185. ; create new call frame and make the call
  186. ; height from: unsigned long
  187. push dword ptr [ebx+22] ; to unsigned long
  188. ; width from: unsigned long
  189. push dword ptr [ebx+26] ; to unsigned long
  190. ; heap from: short
  191. movsx eax,word ptr [ebx+30]
  192. push eax ; to: long
  193. ; this from: unsigned long
  194. push dword ptr [ebx+32] ; to unsigned long
  195. call DDHAL32_VidMemAlloc@16 ; call 32-bit version
  196. ; return code unsigned long --> unsigned long
  197. mov edx,eax
  198. rol edx,16
  199. ;-------------------------------------
  200. jmp ExitFlat_14
  201. ENDIF
  202. END