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.

698 lines
16 KiB

  1. page ,132
  2. ;Thunk Compiler Version 1.8 Dec 14 1994 14:53:05
  3. ;File Compiled Thu Aug 29 16:36:45 1996
  4. ;Command Line: ..\..\..\dev\tools\binr\thunk.exe -NC THUNK16B -o dlgthk ..\dlgthk.thk
  5. TITLE $dlgthk.asm
  6. .386
  7. OPTION READONLY
  8. OPTION OLDSTRUCTS
  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_32
  16. IFDEF IS_16
  17. %out command line error: you can't specify both -DIS_16 and -DIS_32
  18. .err
  19. ENDIF
  20. .model FLAT,STDCALL
  21. externDef STDCALL DlgThunkInit@4:near32
  22. externDef STDCALL ThkPathQualify@4:near32
  23. externDef STDCALL ThkParseFile@8:near32
  24. externDef STDCALL GetFileTitleI@16:near32
  25. externDef STDCALL ThkCommDlgExtendedError@0:near32
  26. externDef STDCALL ThkChooseFont@4:near32
  27. externDef STDCALL ThkChooseColor@4:near32
  28. externDef STDCALL ThkGetSaveFileName@4:near32
  29. externDef STDCALL ThkGetOpenFileName@4:near32
  30. externDef C Common32ThkLS:near32
  31. .data
  32. pfndlgthkCommon equ <pfndlgthkTable>
  33. public pfndlgthkTable
  34. pfndlgthkTable dword 0 ; segmented common entry point
  35. dlgthkConnectionNameLS db 'dlgthkConnectionDataLS',0
  36. public dlgthkLSChecksum32
  37. dlgthkLSChecksum32 equ 0b53eh
  38. .code
  39. ;===========================================================================
  40. ; Worker routine to pass additional, internal params to the
  41. ; init routine in kernel32.
  42. ;
  43. ; Calling sequence:
  44. ;
  45. ; dlgthkConnectPeerLS proto near pszDll16:dword, pszDll32:dword
  46. ;
  47. ; pszDll16 db 'foo16.dll',0
  48. ; pszDll32 db 'foo32.dll',0
  49. ;
  50. ; invoke dlgthkConnectPeerLS, ADDR pszDll16, ADDR pszDll32
  51. ; or eax,eax
  52. ; jz failed
  53. ; ;success
  54. ;
  55. public dlgthkConnectPeerLS@8
  56. dlgthkConnectPeerLS@8:
  57. externDef ThunkInitLS@20:near32
  58. pop edx ;Shift return address
  59. push dword ptr 0b53eh ;Checksum
  60. push offset dlgthkConnectionNameLS ;Exported from peer
  61. push offset pfndlgthkCommon ;Output param
  62. push edx
  63. jmp ThunkInitLS@20
  64. ;===========================================================================
  65. ; This is the table of 32-bit entry points.
  66. DlgThunkInit@4 label near32
  67. mov cl,0 ; offset in jump table
  68. mov edx, (1 SHL 16) + 0
  69. PreEntryCommon32_1:
  70. mov ch,0
  71. jmp EntryCommon32
  72. ThkPathQualify@4 label near32
  73. mov cl,2 ; offset in jump table
  74. mov edx, (1 SHL 16) + 0
  75. jmp PreEntryCommon32_1
  76. ThkParseFile@8 label near32
  77. mov cl,4 ; offset in jump table
  78. mov edx, (2 SHL 16) + 0
  79. jmp PreEntryCommon32_1
  80. GetFileTitleI@16 label near32
  81. mov cl,6 ; offset in jump table
  82. mov edx, (4 SHL 16) + 65535
  83. jmp PreEntryCommon32_1
  84. ThkCommDlgExtendedError@0 label near32
  85. mov cl,8 ; offset in jump table
  86. mov edx, (0 SHL 16) + 0
  87. jmp PreEntryCommon32_1
  88. ThkChooseFont@4 label near32
  89. mov cl,10 ; offset in jump table
  90. mov edx, (1 SHL 16) + 0
  91. jmp PreEntryCommon32_1
  92. ThkChooseColor@4 label near32
  93. mov cl,12 ; offset in jump table
  94. mov edx, (1 SHL 16) + 0
  95. jmp PreEntryCommon32_1
  96. ThkGetSaveFileName@4 label near32
  97. mov cl,14 ; offset in jump table
  98. mov edx, (1 SHL 16) + 0
  99. jmp PreEntryCommon32_1
  100. ThkGetOpenFileName@4 label near32
  101. mov cl,16 ; offset in jump table
  102. mov edx, (1 SHL 16) + 0
  103. jmp PreEntryCommon32_1
  104. ;===========================================================================
  105. ; This is the common setup code for 32=>16 thunks.
  106. ;
  107. ; Entry: cx = offset in thunk table
  108. ; dx = signed error return value
  109. ; edx.hi = # of parameters (4 bytes per parameter)
  110. ;
  111. ; Exit: eax = 16:16 address of target common entry point
  112. ;
  113. align
  114. EntryCommon32:
  115. ifdef FSAVEALL
  116. .err ;32->16 thunks require FSAVEALL, else don't use -r
  117. endif
  118. mov eax, pfndlgthkCommon
  119. jmp Common32ThkLS
  120. THK_CODE32_SIZE label byte
  121. ELSE ; IS_16
  122. OPTION SEGMENT:USE16
  123. .model LARGE,PASCAL
  124. include thk.inc
  125. include winerror.inc
  126. include win31err.inc
  127. include dlgthk.inc
  128. externDef DlgThunkInit:far16
  129. externDef PathQualify:far16
  130. externDef ParseFileFrom32:far16
  131. externDef GetFileTitleI:far16
  132. externDef CommDlgExtendedError:far16
  133. externDef ChooseFont:far16
  134. externDef ChooseColor:far16
  135. externDef GetSaveFileName:far16
  136. externDef GetOpenFileName:far16
  137. externDef UnMapStackAndMakeFlat:far16
  138. externDef LinearToSelectorOffset:far16
  139. externDef MapLS:far16
  140. externDef UnmapLS:far16
  141. externDef StackLinearToSegmented:far16
  142. externDef SelectorOffsetToLinear:far16
  143. externDef MapSL:far16
  144. externDef AllocCallback:far16
  145. externDef GetCSAlias:far16
  146. externDef FreeCSAlias:far16
  147. externDef OutputDebugString:far16
  148. externDef SetLastError:far16
  149. externDef THUNK16BCodeData:word
  150. externDef FlatData:word
  151. externDef dlgthkTable:dword
  152. externDef dlgthkCommon:far16
  153. externDef LocalAlloc:far16
  154. externDef LocalLock:far16
  155. externDef LocalUnlock:far16
  156. externDef LocalFree:far16
  157. MYLOCALLOCK macro x
  158. push ecx
  159. push ebx
  160. push x
  161. call LocalLock
  162. pop ebx
  163. pop ecx
  164. endm
  165. externDef T_DlgThunkInit:near16
  166. externDef T_ThkPathQualify:near16
  167. externDef T_ThkParseFile:near16
  168. externDef T_GetFileTitleI:near16
  169. externDef T_ThkCommDlgExtendedError:near16
  170. externDef T_ThkChooseFont:near16
  171. externDef T_ThkChooseColor:near16
  172. externDef T_ThkGetSaveFileName:near16
  173. externDef T_ThkGetOpenFileName:near16
  174. DATA16 SEGMENT WORD USE16 PUBLIC 'DATA'
  175. DATA16 ENDS
  176. .code THUNK16B
  177. public dlgthkConnectionDataLS ; export in def file
  178. dlgthkConnectionDataLS dd 0b53eh ;Checksum
  179. dw offset dlgthkCommon
  180. dw seg dlgthkCommon
  181. ;===========================================================================
  182. ; This is a jump table to API-specific 16-bit thunk code.
  183. ; Each entry is a word.
  184. align
  185. dlgthkTable16 label word
  186. dw offset T_DlgThunkInit
  187. dw offset T_ThkPathQualify
  188. dw offset T_ThkParseFile
  189. dw offset T_GetFileTitleI
  190. dw offset T_ThkCommDlgExtendedError
  191. dw offset T_ThkChooseFont
  192. dw offset T_ThkChooseColor
  193. dw offset T_ThkGetSaveFileName
  194. dw offset T_ThkGetOpenFileName
  195. ;===========================================================================
  196. ; This is the common 16-bit entry point for 32=>16 thunks. It:
  197. ; 1. saves sp in bp
  198. ; 2. sets ds
  199. ; 3. jumps to API-specific thunk code
  200. ;
  201. ; Entry: di == jump table offset
  202. ; ss:sp == 16-bit stack pointer
  203. align
  204. dlgthkCommon label far16
  205. mov bp,sp ; save sp in bp
  206. mov ax,seg DATA16 ; set ds
  207. mov ds,ax
  208. jmp word ptr cs:dlgthkTable16[di] ; select specific thunk
  209. ;===========================================================================
  210. ; Macro sets extended error code if Win16 API returned an
  211. ; error value.
  212. ;
  213. ; Inputs:
  214. ; errret: 32-bit API return value that signals an error
  215. ; errle: 32-bit extended error code to pass to SetLastError()
  216. ; exitlbl: The Exit_n label to jump to.
  217. ; eax: The 32-bit API return value.
  218. ;
  219. ERRCHK_EXIT macro errret,errle,exitlbl
  220. cmp eax,&errret&
  221. jne &exitlbl&
  222. push eax ;Save return value.
  223. pushd &errle& ;ARG: SetLastError(errorcode)
  224. call SetLastError
  225. pop eax ;Restore return value.
  226. jmp &exitlbl&
  227. endm ;ERRCHK_EXIT
  228. ;===========================================================================
  229. ; Common routines to restore the stack and registers
  230. ; and return to 32-bit code. There is one for each
  231. ; size of 32-bit parameter list in this script.
  232. align
  233. Exit_0:
  234. ;--- No error checking.
  235. mov bl,0 ; parameter byte count
  236. mov sp,bp ; point to ret addr
  237. retd ; 16:32 ret to dispatcher
  238. align
  239. Exit_4:
  240. ;--- No error checking.
  241. mov bl,4 ; parameter byte count
  242. mov sp,bp ; point to ret addr
  243. retd ; 16:32 ret to dispatcher
  244. align
  245. Exit_8:
  246. ;--- No error checking.
  247. mov bl,8 ; parameter byte count
  248. mov sp,bp ; point to ret addr
  249. retd ; 16:32 ret to dispatcher
  250. align
  251. Exit_16:
  252. ;--- No error checking.
  253. mov bl,16 ; parameter byte count
  254. mov sp,bp ; point to ret addr
  255. retd ; 16:32 ret to dispatcher
  256. ;===========================================================================
  257. T_DlgThunkInit label near16
  258. ; bp+40 pCB32Tab
  259. APILOGLS DlgThunkInit
  260. ;-------------------------------------
  261. ; create new call frame and make the call
  262. ; pCB32Tab from: unsigned long
  263. push dword ptr [bp+40] ; to unsigned long
  264. call DlgThunkInit ; call 16-bit version
  265. ; return code void --> void
  266. ; no conversion needed
  267. ;-------------------------------------
  268. ;--- No error checking.
  269. jmp Exit_4
  270. ;===========================================================================
  271. T_ThkPathQualify label near16
  272. ; bp+40 lpszFile
  273. APILOGLS ThkPathQualify
  274. ;-------------------------------------
  275. ; Temp storage
  276. xor eax,eax
  277. push eax ; ptr param #1 lpszFile
  278. ;-------------------------------------
  279. ; *** BEGIN parameter packing
  280. ; lpszFile
  281. ; pointer char --> char
  282. ; same pointer types
  283. mov eax,[bp+40] ; base address
  284. push eax
  285. call MapLS
  286. mov [bp-4],eax
  287. L0:
  288. ; *** END parameter packing
  289. ;-------------------------------------
  290. ; create new call frame and make the call
  291. ; lpszFile from: char
  292. push dword ptr [bp-4] ; to: char
  293. call PathQualify ; call 16-bit version
  294. ; return code unsigned long --> unsigned long
  295. rol eax,16
  296. xchg ax,dx
  297. rol eax,16
  298. push eax
  299. push dword ptr [bp - 4]
  300. call UnmapLS
  301. pop eax
  302. ;-------------------------------------
  303. ;--- No error checking.
  304. jmp Exit_4
  305. ;===========================================================================
  306. T_ThkParseFile label near16
  307. ; bp+40 lpszFile
  308. ; bp+44 dwFlags
  309. APILOGLS ThkParseFile
  310. ;-------------------------------------
  311. ; Temp storage
  312. xor eax,eax
  313. push eax ; ptr param #1 lpszFile
  314. ;-------------------------------------
  315. ; *** BEGIN parameter packing
  316. ; lpszFile
  317. ; pointer char --> char
  318. ; same pointer types
  319. mov eax,[bp+40] ; base address
  320. push eax
  321. call MapLS
  322. mov [bp-4],eax
  323. L1:
  324. ; *** END parameter packing
  325. ;-------------------------------------
  326. ; create new call frame and make the call
  327. ; lpszFile from: char
  328. push dword ptr [bp-4] ; to: char
  329. ; dwFlags from: unsigned long
  330. push dword ptr [bp+44] ; to unsigned long
  331. call ParseFileFrom32 ; call 16-bit version
  332. ; return code unsigned long --> unsigned long
  333. rol eax,16
  334. xchg ax,dx
  335. rol eax,16
  336. push eax
  337. push dword ptr [bp - 4]
  338. call UnmapLS
  339. pop eax
  340. ;-------------------------------------
  341. ;--- No error checking.
  342. jmp Exit_8
  343. ;===========================================================================
  344. T_GetFileTitleI label near16
  345. ; bp+40 lpszFile
  346. ; bp+44 lpszTitle
  347. ; bp+48 wBufSize
  348. ; bp+52 dwFlags
  349. APILOGLS GetFileTitleI
  350. ;-------------------------------------
  351. ; Temp storage
  352. xor eax,eax
  353. push eax ; ptr param #1 lpszFile
  354. push eax ; ptr param #2 lpszTitle
  355. ;-------------------------------------
  356. ; *** BEGIN parameter packing
  357. ; lpszFile
  358. ; pointer char --> char
  359. ; same pointer types
  360. mov eax,[bp+40] ; base address
  361. push eax
  362. call MapLS
  363. mov [bp-4],eax
  364. L2:
  365. ; lpszTitle
  366. ; pointer char --> char
  367. ; same pointer types
  368. mov eax,[bp+44] ; base address
  369. push eax
  370. call MapLS
  371. mov [bp-8],eax
  372. L3:
  373. ; *** END parameter packing
  374. ;-------------------------------------
  375. ; create new call frame and make the call
  376. ; lpszFile from: char
  377. push dword ptr [bp-4] ; to: char
  378. ; lpszTitle from: char
  379. push dword ptr [bp-8] ; to: char
  380. ; wBufSize from: unsigned short
  381. push word ptr [bp+48] ; to unsigned short
  382. ; dwFlags from: unsigned long
  383. push dword ptr [bp+52] ; to unsigned long
  384. call GetFileTitleI ; call 16-bit version
  385. ; return code short --> long
  386. cwde
  387. push eax
  388. push dword ptr [bp - 4]
  389. call UnmapLS
  390. push dword ptr [bp - 8]
  391. call UnmapLS
  392. pop eax
  393. ;-------------------------------------
  394. ;--- No error checking.
  395. jmp Exit_16
  396. ;===========================================================================
  397. T_ThkCommDlgExtendedError label near16
  398. APILOGLS ThkCommDlgExtendedError
  399. ;-------------------------------------
  400. ; create new call frame and make the call
  401. call CommDlgExtendedError ; call 16-bit version
  402. ; return code unsigned long --> unsigned long
  403. rol eax,16
  404. xchg ax,dx
  405. rol eax,16
  406. ;-------------------------------------
  407. ;--- No error checking.
  408. jmp Exit_0
  409. ;===========================================================================
  410. T_ThkChooseFont label near16
  411. ; bp+40 lpcf
  412. APILOGLS ThkChooseFont
  413. ;-------------------------------------
  414. ; Temp storage
  415. xor eax,eax
  416. push eax ;Storage for lpszStyleTemp
  417. LOCAL__THKCHOOSEFONT_lpszStyleTemp equ <[bp-4]>
  418. push eax ;Storage for lpTemplateNameTemp
  419. LOCAL__THKCHOOSEFONT_lpTemplateNameTemp equ <[bp-8]>
  420. push eax ;Storage for Flags
  421. LOCAL__THKCHOOSEFONT_Flags equ <[bp-12]>
  422. push eax ; ptr param #1 lpcf
  423. ;-------------------------------------
  424. ; *** BEGIN parameter packing
  425. ; lpcf
  426. ; pointer struct --> struct
  427. RAWPACK__THKCHOOSEFONT_lpcf 40, 16
  428. L4:
  429. ; *** END parameter packing
  430. ;-------------------------------------
  431. ; create new call frame and make the call
  432. ; lpcf from: struct
  433. push dword ptr [bp-16] ; to: struct
  434. call ChooseFont ; call 16-bit version
  435. ; return code short --> long
  436. cwde
  437. ;-------------------------------------
  438. ; *** BEGIN parameter unpacking
  439. push eax ; save return code
  440. ; lpcf
  441. RAWUNPACK__THKCHOOSEFONT_lpcf 40, 16
  442. L5:
  443. pop eax ; restore return code
  444. ; *** END parameter unpacking
  445. ;-------------------------------------
  446. ;--- No error checking.
  447. jmp Exit_4
  448. ;===========================================================================
  449. T_ThkChooseColor label near16
  450. ; bp+40 lpcc
  451. APILOGLS ThkChooseColor
  452. ;-------------------------------------
  453. ; Temp storage
  454. xor eax,eax
  455. push eax ;Storage for lpTemplateNameSeg
  456. LOCAL__THKCHOOSECOLOR_lpTemplateNameSeg equ <[bp-4]>
  457. push eax ;Storage for lpCustColorsSeg
  458. LOCAL__THKCHOOSECOLOR_lpCustColorsSeg equ <[bp-8]>
  459. push eax ;Storage for Flags
  460. LOCAL__THKCHOOSECOLOR_Flags equ <[bp-12]>
  461. push eax ; ptr param #1 lpcc
  462. ;-------------------------------------
  463. ; *** BEGIN parameter packing
  464. ; lpcc
  465. ; pointer struct --> struct
  466. RAWPACK__THKCHOOSECOLOR_lpcc 40, 16
  467. L6:
  468. ; *** END parameter packing
  469. ;-------------------------------------
  470. ; create new call frame and make the call
  471. ; lpcc from: struct
  472. push dword ptr [bp-16] ; to: struct
  473. call ChooseColor ; call 16-bit version
  474. ; return code short --> long
  475. cwde
  476. ;-------------------------------------
  477. ; *** BEGIN parameter unpacking
  478. push eax ; save return code
  479. ; lpcc
  480. RAWUNPACK__THKCHOOSECOLOR_lpcc 40, 16
  481. L7:
  482. pop eax ; restore return code
  483. ; *** END parameter unpacking
  484. ;-------------------------------------
  485. ;--- No error checking.
  486. jmp Exit_4
  487. ;===========================================================================
  488. T_ThkGetSaveFileName label near16
  489. ; bp+40 lpOfn
  490. APILOGLS ThkGetSaveFileName
  491. ;-------------------------------------
  492. ; Temp storage
  493. xor eax,eax
  494. push eax ;Storage for Flags
  495. LOCAL__THKGETSAVEFILENAME_Flags equ <[bp-4]>
  496. push eax ; ptr param #1 lpOfn
  497. ;-------------------------------------
  498. ; *** BEGIN parameter packing
  499. ; lpOfn
  500. ; pointer struct --> struct
  501. RAWPACK__THKGETSAVEFILENAME_lpOfn 40, 8
  502. L8:
  503. ; *** END parameter packing
  504. ;-------------------------------------
  505. ; create new call frame and make the call
  506. ; lpOfn from: struct
  507. push dword ptr [bp-8] ; to: struct
  508. call GetSaveFileName ; call 16-bit version
  509. ; return code short --> long
  510. cwde
  511. ;-------------------------------------
  512. ; *** BEGIN parameter unpacking
  513. push eax ; save return code
  514. ; lpOfn
  515. RAWUNPACK__THKGETSAVEFILENAME_lpOfn 40, 8
  516. L9:
  517. pop eax ; restore return code
  518. ; *** END parameter unpacking
  519. ;-------------------------------------
  520. ;--- No error checking.
  521. jmp Exit_4
  522. ;===========================================================================
  523. T_ThkGetOpenFileName label near16
  524. ; bp+40 lpOfn
  525. APILOGLS ThkGetOpenFileName
  526. ;-------------------------------------
  527. ; Temp storage
  528. xor eax,eax
  529. push eax ;Storage for Flags
  530. LOCAL__THKGETOPENFILENAME_Flags equ <[bp-4]>
  531. push eax ; ptr param #1 lpOfn
  532. ;-------------------------------------
  533. ; *** BEGIN parameter packing
  534. ; lpOfn
  535. ; pointer struct --> struct
  536. RAWPACK__THKGETOPENFILENAME_lpOfn 40, 8
  537. L10:
  538. ; *** END parameter packing
  539. ;-------------------------------------
  540. ; create new call frame and make the call
  541. ; lpOfn from: struct
  542. push dword ptr [bp-8] ; to: struct
  543. call GetOpenFileName ; call 16-bit version
  544. ; return code short --> long
  545. cwde
  546. ;-------------------------------------
  547. ; *** BEGIN parameter unpacking
  548. push eax ; save return code
  549. ; lpOfn
  550. RAWUNPACK__THKGETOPENFILENAME_lpOfn 40, 8
  551. L11:
  552. pop eax ; restore return code
  553. ; *** END parameter unpacking
  554. ;-------------------------------------
  555. ;--- No error checking.
  556. jmp Exit_4
  557. THK_CODE16_SIZE label byte
  558. ENDIF
  559. END