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.

3244 lines
80 KiB

  1. ;; NEWHEADER structure is used in LookupIconIdFromDir
  2. NEWHEADER struc
  3. Reserved dw ?
  4. ResType dw ?
  5. ResCount dw ?
  6. NEWHEADER ends
  7. ;; RESDIR structure is used in LookupIconIdFromDir
  8. RESDIR struc
  9. IconOrCursor dd ? ; IconDir or CursorDir structure.
  10. Planes dw ?
  11. BitCount dw ?
  12. BytesInRes dd ?
  13. idIcon dw ?
  14. RESDIR ends
  15. if 0
  16. CHECKHINULL macro x
  17. local chn_ex
  18. ifdef DEBUG
  19. push eax
  20. mov eax, x
  21. shr eax, 16
  22. jz chn_ex
  23. int 3
  24. chn_ex:
  25. pop eax
  26. endif
  27. endm
  28. CHECKHISIGN macro x
  29. local chs_ex
  30. ifdef DEBUG
  31. push eax
  32. mov eax, x
  33. shr eax, 16
  34. inc ax
  35. cmp ax, 1
  36. jbe chs_ex
  37. int 3
  38. chs_ex:
  39. pop eax
  40. endif
  41. endm
  42. endif
  43. CodeData equ <THUNK16CodeData>
  44. ifdef IS_16
  45. include thkrp.inc
  46. include k32share.inc
  47. include public.inc
  48. include cbcheck.inc
  49. include thkmacro.inc
  50. include thkframe.inc
  51. include struc.inc
  52. include cbcid.inc
  53. include usrcbid.inc
  54. fLocalFlag equ fUsrLog16
  55. WINABLE equ 1
  56. TIMERINFO_TYPE struct
  57. resolution DWORD ?
  58. TIMERINFO_TYPE ends
  59. MULTIKEYHELP32 STRUC
  60. mk32_Size dd ?
  61. mk32_Keylist db ?
  62. mk32_szKeyPhrase db ?
  63. MULTIKEYHELP32 ENDS
  64. MULTIKEYHELP16 STRUC
  65. mk16_Size dw ?
  66. mk16_Keylist db ?
  67. mk16_szKeyPhrase db ?
  68. MULTIKEYHELP16 ENDS
  69. HELPWININFO32 STRUC
  70. hwi32_wStructSize dd ?
  71. hwi32_x dd ?
  72. hwi32_y dd ?
  73. hwi32_dx dd ?
  74. hwi32_dy dd ?
  75. hwi32_wMax dd ?
  76. hwi32_rgchMember db ?
  77. HELPWININFO32 ENDS
  78. HELPWININFO16 STRUC
  79. hwi16_wStructSize dw ?
  80. hwi16_x dw ?
  81. hwi16_y dw ?
  82. hwi16_dx dw ?
  83. hwi16_dy dw ?
  84. hwi16_wMax dw ?
  85. hwi16_rgchMember db ?
  86. HELPWININFO16 ENDS
  87. FLASHWINFO16 STRUC
  88. fw16_cbSize dw ?
  89. fw16_hwnd dw ?
  90. fw16_dwFlags dd ?
  91. fw16_uCount dw ?
  92. fw16_dwTimeout dd ?
  93. FLASHWINFO16 ENDS
  94. FLASHWINFO32 STRUC
  95. fw32_cbSize dd ?
  96. fw32_hwnd dd ?
  97. fw32_dwFlags dd ?
  98. fw32_uCount dd ?
  99. fw32_dwTimeout dd ?
  100. FLASHWINFO32 ENDS
  101. externDef GetExePtr:far16
  102. ;;;externDef InsertPropAtom:far16
  103. ;;;externDef DeletePropAtom:far16
  104. externDef GlobalAddAtom:far16
  105. externDef GlobalDeleteAtom:far16
  106. externDef GlobalFindAtom:far16
  107. externDef ConvertDialogA:far16
  108. externDef ConvertDialog:far16
  109. externDef ConvertDialog32:far16
  110. externDef CountDialogA:far16
  111. externDef CountDialogU:far16
  112. externDef ConvertMenuA:far16
  113. externDef CountMenuA:far16
  114. externDef CountMenuU:far16
  115. externDef ConvertMenu32:far16
  116. externDef GetNullhInst:far16
  117. externDef GlobalAlloc:far16
  118. externDef GlobalFree:far16
  119. externDef GlobalLock:far16
  120. externDef GlobalUnlock:far16
  121. externDef GlobalFix:far16
  122. externDef GlobalUnfix:far16
  123. externDef MaphinstLS:far16
  124. externDef MaphinstSL:far16
  125. externDef IsClassNameMDICLIENT:far16
  126. externDef ConvertDDEHandleLS:far16
  127. externDef ConvertDDEHandleSL:far16
  128. externDef QueryCallbackAddress:far16
  129. externDef GetStdCBSL:far16
  130. externDef GetStdCBLS:far16
  131. externDef GetCurrentTask:far16 ;!!! temporary?
  132. externDef GetCurrentThreadID:far16
  133. externDef timerInfo:TIMERINFO_TYPE
  134. externDef CALLBACK_BODY_16:far16
  135. externDef GetCurrentHeap:far16
  136. externDef ConvertMenuItemInfoLS:far16
  137. externDef IsDialog:far16
  138. externDef IsWindowClassType:far16
  139. ;;;externDef aUserData:dword
  140. externDef Map32To16:far16
  141. externDef DelMap:far16
  142. externDef LoadLibrary32:far16
  143. externDef ConvertCFDataLS:far16
  144. externDef ConvertCFDataSL:far16
  145. externDef IsThisADDEExecuteHandle:far16
  146. externDef ConvertOleClipData:far16
  147. externDef GetHCONVWindows:far16
  148. ;-----------------------------------------------------------------------;
  149. ; DXAX2EAX
  150. ; mov dx to eax high word
  151. ;
  152. ;-----------------------------------------------------------------------;
  153. DXAX2EAX macro
  154. ror eax,16
  155. xchg ax,dx
  156. ror eax,16
  157. endm
  158. CF_LCID equ 16
  159. ;-----------------------------------------------------------------------;
  160. ; body_SETCLIPBOARDDATA
  161. ;-----------------------------------------------------------------------;
  162. body_SETCLIPBOARDDATA macro
  163. local exit
  164. local SetData
  165. bp_nFormat equ <bp_top>
  166. bp_dwData equ <bp_top+4>
  167. mov eax, dword ptr bp_dwData
  168. test eax, eax
  169. jz SetData
  170. push word ptr bp_nFormat
  171. push eax
  172. push word ptr 1 ;Nuke old copies of hData
  173. call ConvertCFDataLS
  174. movzx eax, ax
  175. test ax, ax
  176. jz exit
  177. SetData:
  178. push word ptr bp_nFormat
  179. push ax
  180. push 1
  181. call SetClipboardData32
  182. movzx eax, ax
  183. test ax, ax
  184. jz exit
  185. mov eax, bp_dwData ;Return original hData
  186. exit:
  187. endm
  188. ;-----------------------------------------------------------------------;
  189. ; body_GETCLIPBOARDDATA
  190. ;-----------------------------------------------------------------------;
  191. body_GETCLIPBOARDDATA macro
  192. local exit
  193. bp_nFormat equ <bp_top>
  194. push word ptr bp_nFormat
  195. push 1
  196. call GetClipboardData32
  197. movzx eax, ax
  198. test ax, ax
  199. jz exit
  200. push word ptr bp_nFormat
  201. push ax ;hnd16
  202. push word ptr 0 ;Don't nuke old copies of hData
  203. call ConvertCFDataSL
  204. ; Return now in eax.
  205. exit:
  206. endm
  207. ;-----------------------------------------------------------------------;
  208. ;
  209. ; body_SETWINDOWSHOOKEXA
  210. ;
  211. ;-----------------------------------------------------------------------;
  212. body_SETWINDOWSHOOKEXA macro
  213. local type_ok
  214. local get_out
  215. local inserted_ok
  216. local push_task
  217. bp_nType equ <bp_top>
  218. bp_pfn equ <bp_top+4>
  219. bp_hmod equ <bp_top+8>
  220. bp_hThread equ <bp_top+12>
  221. mov di,word ptr bp_nType ;will need more than once
  222. inc di ;make nType 0-based
  223. cmp di,CBID_WH_END-CBID_WH_START
  224. jb type_ok
  225. ;!!! SetExtendedError?
  226. sub eax,eax ;error, invalid hook type
  227. jmp get_out
  228. type_ok:
  229. dec di ;restore correct nType
  230. push di ;push for SetWindowsHookEx
  231. ;map hook type onto callback type
  232. movsx edi,di
  233. add edi,CBID_WH_START+1 ;hook type --> callback type
  234. push dword ptr bp_pfn ;32-bit callback address
  235. push edi ;callback type
  236. call GetStdCBSL ;create 16-bit callback stub
  237. push eax
  238. ;
  239. ; Use module's or task's _real_ instance/module
  240. ; We need to do this in case bp_hmod is 0L, so we get current.
  241. ;
  242. mov eax, dword ptr bp_hmod
  243. call MaphInstLS
  244. mov word ptr bp_hmod, ax
  245. call MaphInstSL
  246. push eax
  247. push dword ptr bp_hThread
  248. call SetWindowsHookEx32 ;make api call
  249. DXAX2EAX
  250. get_out:
  251. endm
  252. ;-----------------------------------------------------------------------;
  253. ; body_UNHOOKWINDOWSHOOK
  254. ;-----------------------------------------------------------------------;
  255. body_UNHOOKWINDOWSHOOK macro
  256. bp_nCode equ <bp_top>
  257. bp_pfn equ <bp_top+4>
  258. ; Save nCode in eax for CBID_ math later
  259. movsx eax, word ptr bp_nCode
  260. push ax
  261. push dword ptr bp_pfn
  262. add eax, CBID_WH_START+1
  263. push eax
  264. call QueryCallbackAddress
  265. push eax
  266. call UnhookWindowsHook
  267. cwde
  268. endm
  269. ;-----------------------------------------------------------------------;
  270. ; body_GETSETWINDOWDATA
  271. ;-----------------------------------------------------------------------;
  272. body_GETSETWINDOWDATA macro
  273. local exit
  274. local Call_GSWD
  275. local GSWD_return
  276. local SWD_wndproc
  277. local SWD_hinst
  278. local GWD_wndproc
  279. local GWD_hinst
  280. local error
  281. local apfnGet
  282. local apfnSet
  283. bp_hwnd equ <bp_top>
  284. bp_nIndex equ <bp_top+4>
  285. bp_dwValue equ <bp_top+8>
  286. bp_nFlags equ <bp_top+12>
  287. bp_isdialog equ <[bp-2]>
  288. ; Save space for bp_isdialog
  289. xor ax, ax
  290. push ax
  291. mov bx, word ptr bp_nIndex
  292. cmp bx, ax
  293. jl @F
  294. cmp bx, DWL_DLGPROC
  295. jne Call_GSWD
  296. ; Is window really a dialog? If not, skip this!
  297. push word ptr bp_hwnd
  298. call IsDialog
  299. mov word ptr bp_isdialog, ax
  300. test ax, ax
  301. jz Call_GSWD
  302. test word ptr bp_nFlags, DATA_SET
  303. jz Call_GSWD
  304. jmp SWD_wndproc
  305. @@:
  306. cmp bx,GWL_USERDATA
  307. je Call_GSWD
  308. neg bx
  309. add bx,GWL_WNDPROC
  310. .errnz GWL_WNDPROC + 4
  311. jl error
  312. cmp bx,MAX_INDEX
  313. ja error
  314. test bl, 1
  315. jnz error ;Don't allow odd indices.
  316. test word ptr bp_nFlags, DATA_SET
  317. jz Call_GSWD
  318. jmp cs:apfnSet[bx]
  319. apfnSet label word
  320. dw offset SWD_wndproc ;0 ; -4 GWL_WNDPROC
  321. dw offset SWD_hinst ;2 ; -6 GWL_HINSTANCE
  322. dw offset Call_GSWD ;4 ; -8 GWL_HWNDPARENT
  323. dw offset error ;6 ;-10
  324. dw offset Call_GSWD ;8 ;-12 GWL_ID
  325. dw offset error ;10 ;-14
  326. dw offset Call_GSWD ;12 ;-16 GWL_STYLE
  327. dw offset error ;14 ;-18
  328. dw offset Call_GSWD ;16 ;-20 GWL_EXSTYLE
  329. ;; No need to add one more entry for -21 (GWL_USERDATA) because this is
  330. ;; the only Odd index we handle it as a special case eariler.
  331. MAX_INDEX equ ($-apfnSet)
  332. .errnz GWL_WNDPROC + 4
  333. .errnz GWL_HINSTANCE + 6
  334. .errnz GWL_HWNDPARENT + 8
  335. .errnz GWL_ID + 12
  336. .errnz GWL_STYLE + 16
  337. .errnz GWL_EXSTYLE + 20
  338. .errnz GWL_USERDATA + 21
  339. .errnz GWW_HINSTANCE + 6
  340. .errnz GWW_HWNDPARENT + 8
  341. SWD_wndproc:
  342. push dword ptr bp_dwValue
  343. mov eax, CBID_WNDPROC
  344. cmp word ptr bp_nIndex, DWL_DLGPROC
  345. jne @F
  346. ; Is window really a dialog! If not, skip this.
  347. mov eax, CBID_DLGPROC
  348. @@:
  349. push eax
  350. call GetStdCBSL
  351. mov dword ptr bp_dwValue, eax
  352. jmp Call_GSWD
  353. SWD_hinst:
  354. mov eax, dword ptr bp_dwValue
  355. call MaphinstLS
  356. movzx eax, ax
  357. mov dword ptr bp_dwValue, eax
  358. ; FALL THRU
  359. Call_GSWD:
  360. push word ptr bp_hwnd
  361. push word ptr bp_nIndex
  362. push dword ptr bp_dwValue
  363. push word ptr bp_nFlags
  364. call GetSetWindowData
  365. DXAX2EAX
  366. ;
  367. ; Now thunk return value. Note that up above, we already did the
  368. ; sanity checking on indeces < 0, so we don't have to do it again.
  369. ;
  370. mov bx, word ptr bp_nIndex
  371. cmp bx, 0
  372. jl @F
  373. cmp bx, DWL_DLGPROC
  374. jne GSWD_return
  375. cmp word ptr bp_isdialog, 0
  376. jz GSWD_return
  377. jmp GWD_wndproc
  378. @@:
  379. cmp bx, GWL_USERDATA
  380. je GSWD_return
  381. neg bx
  382. add bx,GWL_WNDPROC
  383. jmp cs:apfnGet[bx]
  384. apfnGet label word
  385. dw offset GWD_wndproc ;0 ; -4 GWL_WNDPROC
  386. dw offset GWD_hinst ;2 ; -6 GWL_HINSTANCE
  387. dw offset GSWD_return ;4 ; -8 GWL_HWNDPARENT
  388. dw offset error ;6 ;-10
  389. dw offset GSWD_return ;8 ;-12 GWL_ID
  390. dw offset error ;10 ;-14
  391. dw offset GSWD_return ;12 ;-16 GWL_STYLE
  392. dw offset error ;14 ;-18
  393. dw offset GSWD_return ;16 ;-20 GWL_EXSTYLE
  394. GWD_wndproc:
  395. push eax
  396. mov eax, CBID_WNDPROC
  397. cmp word ptr bp_nIndex, DWL_DLGPROC
  398. jne @F
  399. mov eax, CBID_DLGPROC
  400. @@:
  401. push eax
  402. call GetStdCBLS
  403. jmp GSWD_return
  404. GWD_hinst:
  405. call MaphinstSL
  406. jmp GSWD_return
  407. error:
  408. xor eax, eax
  409. GSWD_return:
  410. ; Get rid of local word storage
  411. add sp, 2
  412. endm
  413. ;-----------------------------------------------------------------------;
  414. ; body_GETSETCLASSDATA
  415. ;-----------------------------------------------------------------------;
  416. body_GETSETCLASSDATA macro
  417. local exit
  418. local Call_GCSD
  419. local SCD_ptr
  420. local SCD_hinst
  421. local SCD_wndproc
  422. local GCD_ptr
  423. local GCD_hinst
  424. local GCD_wndproc
  425. local error
  426. local apfnSet
  427. local apfnGet
  428. local have_stub
  429. local MAX_INDEX
  430. bp_hwnd equ <bp_top>
  431. bp_nIndex equ <bp_top+4>
  432. bp_dwData equ <bp_top+8>
  433. bp_nFlags equ <bp_top+12>
  434. ; We do this up front for index validation.
  435. ; Is index private (>= 0) or not in system range? If so, no thunking.
  436. mov bx, word ptr bp_nIndex
  437. cmp bx, 0
  438. jge Call_GSCD
  439. neg bx
  440. add bx,GCL_MENUNAME
  441. .errnz GCL_MENUNAME + 8
  442. jl error
  443. cmp bx,MAX_INDEX
  444. jge error
  445. test bl, 1
  446. jnz error ;don't allow odd indices
  447. test word ptr bp_nFlags, DATA_SET
  448. jz Call_GSCD
  449. jmp cs:apfnSet[bx]
  450. apfnSet label word
  451. dw offset SCD_ptr ;0 ; - 8 GCL_MENUNAME
  452. dw offset Call_GSCD ;2 ; -10 GCL_HBRBACKGROUND
  453. dw offset Call_GSCD ;4 ; -12 GCL_HCURSOR
  454. dw offset Call_GSCD ;6 ; -14 GCL_HICON
  455. dw offset SCD_hinst ;8 ; -16 GCL_HMODULE
  456. dw offset Call_GSCD ;10 ; -18 GCL_CBWNDEXTRA
  457. dw offset Call_GSCD ;12 ; -20 GCL_CBCLSEXTRA
  458. dw offset error ;14
  459. dw offset SCD_wndproc ;16 ; -24 GCL_WNDPROC
  460. dw offset Call_GSCD ;18 ; -26 GCL_STYLE
  461. dw offset error ;20
  462. dw offset error ;22
  463. dw offset Call_GSCD ;24 ; -32 GCW_ATOM
  464. dw offset Call_GSCD ;26 ; -34 GCW_HICONSM
  465. MAX_INDEX equ ($ - apfnSet)
  466. .errnz 8 + GCL_MENUNAME
  467. .errnz 10 + GCW_HBRBACKGROUND
  468. .errnz 12 + GCW_HCURSOR
  469. .errnz 14 + GCW_HICON
  470. .errnz 16 + GCW_HMODULE
  471. .errnz 18 + GCW_CBWNDEXTRA
  472. .errnz 20 + GCW_CBCLSEXTRA
  473. .errnz 24 + GCL_WNDPROC
  474. .errnz 26 + GCL_STYLE
  475. .errnz 32 + GCW_ATOM
  476. .errnz 34 + GCW_HICONSM
  477. SCD_ptr:
  478. push dword ptr bp_dwData
  479. call MapLS
  480. mov dword ptr bp_dwData, eax
  481. jmp Call_GSCD
  482. SCD_wndproc:
  483. push dword ptr bp_dwData
  484. push dword ptr CBID_WNDPROC
  485. call GetStdCBSL
  486. mov dword ptr bp_dwData, eax
  487. jmp Call_GSCD
  488. SCD_hinst:
  489. mov eax, dword ptr bp_dwData
  490. call MaphinstLS
  491. movzx eax, ax
  492. mov dword ptr bp_dwData, eax
  493. ; FALL THRU
  494. Call_GSCD:
  495. push word ptr bp_hwnd
  496. push word ptr bp_nIndex
  497. push dword ptr bp_dwData
  498. push word ptr bp_nFlags
  499. call GetSetClassData
  500. DXAX2EAX
  501. ;
  502. ; Now thunk return value. Note that up above, we already did the
  503. ; sanity checking on indeces < 0, so we don't have to do it again.
  504. ;
  505. mov bx, word ptr bp_nIndex
  506. cmp bx, 0
  507. jge GSCD_return
  508. neg bx
  509. add bx,GCL_MENUNAME
  510. jmp cs:apfnGet[bx]
  511. apfnGet label word
  512. dw offset GCD_ptr ;0 ; - 8 GCL_MENUNAME
  513. dw offset GSCD_return ;2 ; -10 GCW_HBRBACKGROUND
  514. dw offset GSCD_return ;4 ; -12 GCW_HCURSOR
  515. dw offset GSCD_return ;6 ; -14 GCW_HICON
  516. dw offset GCD_hinst ;8 ; -16 GCW_HMODULE
  517. dw offset GSCD_return ;10 ; -18 GCW_CBWNDEXTRA
  518. dw offset GSCD_return ;12 ; -20 GCW_CBCLSEXTRA
  519. dw offset error ;14
  520. dw offset GCD_wndproc ;16 ; -24 GCL_WNDPROC
  521. dw offset GSCD_return ;18 ; -26 GCL_STYLE
  522. dw offset error ;20
  523. dw offset error ;22
  524. dw offset GSCD_return ;24 ; -32 GCW_ATOM
  525. dw offset GSCD_return ;26 ; -34 GCW_HICONSM
  526. GCD_ptr:
  527. ; This is OK.
  528. ; User's DS doesn't move in linear memory. And menu strings are
  529. ; LocalAlloced() out of User's DS.
  530. push eax
  531. call MapSL
  532. jmp GSCD_return
  533. GCD_hinst:
  534. call MaphinstSL
  535. jmp GSCD_return
  536. GCD_wndproc:
  537. push eax
  538. push dword ptr CBID_WNDPROC
  539. call GetStdCBLS
  540. jmp GSCD_return
  541. error:
  542. xor eax, eax
  543. GSCD_return:
  544. endm
  545. ;-------------------------------------------------------------------------
  546. ; DdeAccessData(), DdeUnAccessData()
  547. ;
  548. ; HACK! DDEML stores the data in movable Win16 global handles, so
  549. ; *we* have to fix the handle whenever the app holds a linear address to it.
  550. ; This means groveling around in ddeml's data structures to retrieve
  551. ; the global handle from the DDE data handle.
  552. ;
  553. ; No, we can't just copy the data either. DdeAccessData() returns a
  554. ; read/write pointer.
  555. ;
  556. ; BUGBUG! Doesn't repack metafiles yet. For M6, write a support routine
  557. ; inside ddeml to handle all this stuff, and get rid of this hack.
  558. ;
  559. ;-------------------------------------------------------------------------
  560. HDDEDATA_GHND equ 4
  561. PUSH__DDEACCESSDATA_hData macro iOffset, iJunk
  562. push es
  563. les bx, [bp + iOffset]
  564. mov ax, es:[bx + HDDEDATA_GHND]
  565. pop es
  566. push ax
  567. call GlobalFix
  568. push dword ptr [bp + iOffset]
  569. endm ;PUSH__DDEACCESSDATA_hData
  570. PUSH__DDEUNACCESSDATA_hData macro iOffset, iJunk
  571. push es
  572. les bx, [bp + iOffset]
  573. mov ax, es:[bx + HDDEDATA_GHND]
  574. pop es
  575. push ax
  576. call GlobalUnFix
  577. push dword ptr [bp + iOffset]
  578. endm ;PUSH__DDEUNACCESSDATA_hData
  579. ;***************************************************************************
  580. ; PackDDELParam and friends.
  581. ;
  582. ; WARNING: A lot of thunking depends on the fact that PackDDELParam requires
  583. ; no explicit cleanup whatsoever. If you're thinking of changing that,
  584. ; think again.
  585. ;
  586. ; The value returned by PackDDELParam is a ready-to-be-used Win16
  587. ; DDE lparam. The message thunks pass this through with no further
  588. ; translation (*). Through the magic of handle grouping, FreeDDELParam
  589. ; has to do absolutely nothing.
  590. ;
  591. ; (*) Except for WM_DDE_EXECUTE. It will translate the handle in the
  592. ; message thunk instead of in PackDDELParam. This allows Win32 apps
  593. ; to neglect PackDDELParam for WM_DDE_EXECUTE: which works on both
  594. ; NT and Win32s. (They can't ignore it on the WM_DDE_ACK, however.
  595. ; NT & Win32s don't allow this either.)
  596. ;
  597. ;***************************************************************************
  598. ;-----------------------------------------------------------------------;
  599. ; body_PACKDDELPARAM
  600. ;-----------------------------------------------------------------------;
  601. body_PACKDDELPARAM macro
  602. local wMsg, dwLo, dwHi
  603. local exit
  604. local pack_execute
  605. local pack_default
  606. local pack_ddeack, pack_maplo
  607. wMsg equ [bp_top]
  608. dwLo equ [bp_top+4]
  609. dwHi equ [bp_top+8]
  610. mov ax,word ptr wMsg
  611. cmp ax, WM_DDE_EXECUTE
  612. je pack_execute
  613. cmp ax, WM_DDE_ACK
  614. je pack_mapddeack
  615. cmp ax, WM_DDE_ADVISE
  616. je pack_maplo
  617. cmp ax, WM_DDE_DATA
  618. je pack_maplo
  619. cmp ax, WM_DDE_POKE
  620. je pack_maplo
  621. ; WM_DDE_REQUEST or WM_DDE_UNADVISE
  622. ;
  623. ; Both dwLo & dwHi are 16-bit significant only, so just mush them
  624. ; together. Note that a Win32 app could get away without calling
  625. ; PackDDELParam for these messages. But NT and Win32s support this,
  626. ; so we will too.
  627. pack_default:
  628. mov ax, word ptr dwHi
  629. shl eax,16
  630. mov ax, word ptr dwLo
  631. jmp exit
  632. ; WM_DDE_EXECUTE: Just pass it along. Message thunk must do handle
  633. ; conversion. We'd prefer to do the conversion here but then, an app
  634. ; is forced to use PackDDElParam. But NT and Win32s allow them to
  635. ; neglect that -- so we must too.
  636. pack_execute:
  637. mov eax, dword ptr dwHi
  638. jmp exit
  639. ; WM_DDE_ACK:
  640. ;
  641. ; Hi dword is either a Win32 global handle or an atom. Fortunately,
  642. ; we can distinguish the two by examining the high word.
  643. ;
  644. ;
  645. pack_mapddeack:
  646. cmp word ptr dwHi+2, 0 ;Handle or atom?
  647. je pack_default
  648. push word ptr wMsg
  649. push dword ptr dwHi
  650. call ConvertDDEHandleLS ;This routine requires no cleanup
  651. movzx eax,ax
  652. or ax,ax
  653. jz exit
  654. shl eax,16
  655. mov ax, word ptr dwLo ;ax == status word
  656. jmp exit
  657. ; WM_DDE_ADVISE, WM_DDE_DATA, WM_DDE_POKE
  658. pack_maplo:
  659. push word ptr wMsg
  660. push dword ptr dwLo
  661. call ConvertDDEHandleLS ;This routine requires no cleanup
  662. movzx eax,ax
  663. or ax,ax
  664. jz exit
  665. mov cx,ax
  666. mov ax, word ptr dwHi ;ax == status word
  667. shl eax,16
  668. mov ax,cx
  669. ;Fall thru to exit
  670. exit:
  671. endm ;body_PACKDDELPARAM
  672. ;-----------------------------------------------------------------------;
  673. ; body_UNPACKDDELPARAM
  674. ;-----------------------------------------------------------------------;
  675. body_UNPACKDDELPARAM macro
  676. local exit
  677. local unpack_execute
  678. local unpack_default
  679. local unpack_ddeack, unpack_maplo
  680. local storeit
  681. local didhi,didlo
  682. local wMsg,dwLParam,puLo,puHi
  683. wMsg equ [bp_top]
  684. dwLParam equ [bp_top+4]
  685. puLo equ [bp_top+8]
  686. puHi equ [bp_top+12]
  687. mov ax,word ptr wMsg
  688. cmp ax, WM_DDE_EXECUTE
  689. je unpack_execute
  690. cmp ax, WM_DDE_ACK
  691. je unpack_ddeack
  692. cmp ax, WM_DDE_ADVISE
  693. je unpack_maplo
  694. cmp ax, WM_DDE_DATA
  695. je unpack_maplo
  696. cmp ax, WM_DDE_POKE
  697. je unpack_maplo
  698. ; WM_DDE_REQUEST or WM_DDE_UNADVISE
  699. ;
  700. ; Both dwLo & dwHi are 16-bit significant only, so just mush them
  701. ; together. Note that a Win32 app could get away without calling
  702. ; PackDDELParam for these messages. But NT and Win32s support this,
  703. ; so we will too.
  704. unpack_default:
  705. mov eax,dwLParam
  706. mov edx,eax
  707. and eax,0ffffh ;EAX = lo word
  708. shr edx,16 ;EDX = hi word
  709. jmp storeit
  710. ; WM_DDE_EXECUTE: Message thunk already converted handle. Put it back
  711. ; in puHi. We'd prefer to the conversion here but then, an app
  712. ; is forced to use PackDDElParam. But NT and Win32s allow them to
  713. ; neglect that -- so we must too.
  714. unpack_execute:
  715. mov edx, dwLParam
  716. xor eax,eax
  717. jmp storeit
  718. ; WM_DDE_ACK:
  719. ; Hi-word is either a global Win16 handle or atom.
  720. ;
  721. ; No easy way tell which. Pass the buck to kernel.
  722. unpack_ddeack:
  723. push dword ptr dwLParam
  724. call IsThisADDEExecuteHandle
  725. or ax,ax
  726. jz unpack_default
  727. ; Yes, this code is unused for M5 but it's tested and we *will* be using
  728. ; it for M6 so don't you dare delete it!
  729. push word ptr wMsg
  730. push word ptr dwLParam+2
  731. call ConvertDDEHandleSL ;This routine requires no cleanup
  732. test eax,eax
  733. jz exit
  734. mov edx,eax
  735. movzx eax, word ptr dwLParam
  736. jmp storeit
  737. ; WM_DDE_ADVISE, WM_DDE_DATA, WM_DDE_POKE
  738. unpack_maplo:
  739. push word ptr wMsg
  740. push word ptr dwLParam
  741. call ConvertDDEHandleSL ;This routine requires no cleanup
  742. test eax,eax
  743. jz exit
  744. movzx edx, word ptr dwLParam+2
  745. ; Fall through to storeit
  746. storeit:
  747. mov ds,FlatData ; ds:esi == source address
  748. mov edi, puLo
  749. or edi, edi
  750. jz didlo
  751. mov [edi],eax
  752. didlo:
  753. mov edi, puHi
  754. or edi, edi
  755. jz didhi
  756. mov [edi],edx
  757. didhi:
  758. mov eax,1
  759. jmp exit
  760. unpack_badparam:
  761. xor eax,eax
  762. ;Fall thru to exit
  763. exit:
  764. endm
  765. ;-----------------------------------------------------------------------;
  766. ; body_FREEDDELPARAM
  767. ;
  768. ; Through the magic of handle grouping, no action is required here.
  769. ; If you ever change this, you'll also have to make the message thunks
  770. ; thunks clean up temporary lparams.
  771. ;-----------------------------------------------------------------------;
  772. body_FREEDDELPARAM macro
  773. xor eax,eax
  774. inc eax
  775. endm
  776. ;-----------------------------------------------------------------------;
  777. ; body_DDEQUERYCONVINFO
  778. ;-----------------------------------------------------------------------;
  779. body_DDEQUERYCONVINFO macro
  780. local next, L1, L2
  781. local bp_hConv, bp_idTransaction, bp_lpConvInfo
  782. local bp_hwnd, bp_hwndPartner;
  783. bp_hConv equ <bp_top>
  784. bp_idTransaction equ <bp_top+4>
  785. bp_lpConvInfo equ <bp_top+8>
  786. bp_hwnd equ word ptr [bp-6]
  787. bp_hwndPartner equ word ptr [bp-8]
  788. xor eax,eax
  789. push eax ; ptr param #1 pConvInfo
  790. push eax ; store hwnd field
  791. push eax ; store hwndPartner field
  792. ; pConvInfo
  793. ; pointer struct CONVINFO32 --> struct CONVINFO16
  794. cld ; esi, edi will increment
  795. sub sp,CONVINFO16_SIZE ; pConvInfo alloc space on stack
  796. ; different pointer types
  797. mov eax,DWORD ptr bp_lpConvInfo ; base address
  798. test eax,eax
  799. jz L1 ; skip if null
  800. ; structures are not identical
  801. ; structures don't have pointers
  802. mov [bp-4],sp ; save offset to buffer
  803. mov [bp-2],ss ; save selector to buffer
  804. mov di,ss
  805. mov es,di
  806. movzx edi,sp ; es:edi == destination address
  807. mov esi,eax
  808. mov ds,FlatData
  809. ncopyd 7
  810. ncopyt 5
  811. copyd
  812. lodsd ds:[esi]
  813. mov ax, CONVCONTEXT16_SIZE
  814. stosw
  815. ncopyt 3
  816. ncopyd 2
  817. L1:
  818. ; *** END parameter packing
  819. ;-------------------------------------
  820. ; create new call frame and make the call
  821. ; hConv from: unsigned long
  822. push dword ptr bp_hConv ; to unsigned long
  823. ; idTransaction from: unsigned long
  824. push dword ptr bp_idTransaction ; to unsigned long
  825. ; pConvInfo from: struct CONVINFO32
  826. mov eax,[bp-4]
  827. push eax
  828. test eax,eax
  829. jz next
  830. movzx eax,ax
  831. mov word ptr ss:[eax].ci16_cb,CONVINFO16_SIZE
  832. mov word ptr ss:[eax].ci16_ConvCtxt.cc16_cb,CONVCONTEXT16_SIZE
  833. next:
  834. call DdeQueryConvInfo ; call 16-bit version
  835. movzx eax,ax
  836. test eax,eax
  837. jz L2
  838. ;-------------------------------------
  839. ; *** BEGIN parameter unpacking
  840. cld ; esi, edi will increment
  841. ; pConvInfo
  842. ; pointer struct CONVINFO16 --> struct CONVINFO32
  843. mov eax,DWORD ptr bp_lpConvInfo ; base address
  844. test eax,eax
  845. jz L2 ; skip if null
  846. ; structures are not identical
  847. ; structures don't have pointers
  848. mov si, seg FlatData
  849. mov es, si
  850. mov es, es:[FlatData]
  851. mov edi,eax ; es:edi == destination address
  852. mov si,ss
  853. mov ds,si
  854. movzx esi,word ptr [bp-4] ; ds:esi == source address
  855. ; cb
  856. ; unsigned long --> unsigned long
  857. mov dword ptr ds:[esi], CONVINFO32_SIZE
  858. ncopyd 7
  859. ncopyzx 5
  860. copyd
  861. mov word ptr ds:[esi], CONVCONTEXT32_SIZE
  862. ncopyzx 3
  863. copysx
  864. ncopyd 2
  865. xor eax,eax
  866. ; Put dummy bytes into SECURITY_QUALITY_OF_SERVICE
  867. mov eax, 0ch ;SIZEOF(SECURITY_QUALITY_OF_SERVICE)
  868. stosd es:[edi]
  869. xor eax,eax
  870. stosd es:[edi]
  871. stosd es:[edi]
  872. push es
  873. push edi
  874. push dword ptr bp_hConv
  875. mov ax, ss
  876. push ax
  877. lea cx, bp_hwnd
  878. push cx
  879. mov ax, ss
  880. push ax
  881. lea cx, bp_hwndPartner
  882. push cx
  883. call GetHCONVWindows
  884. pop edi
  885. pop es
  886. movzx eax,ax
  887. or ax,ax
  888. jz L2
  889. movzx eax, bp_hwnd
  890. stosd es:[edi]
  891. movzx eax, bp_hwndPartner
  892. stosd es:[edi]
  893. mov eax, CONVINFO32_SIZE
  894. L2:
  895. endm
  896. ;----------------------------------------------------------------------------
  897. ;
  898. ; GetClassInfoExA()
  899. ;
  900. ;----------------------------------------------------------------------------
  901. body_GETCLASSINFOEXA macro
  902. local L238
  903. local PushInstance
  904. local PushClassName
  905. local StoreWndProc
  906. local StoreMenuName
  907. local Cleanup
  908. bp_hInstance equ <bp_top + 0>
  909. bp_lpszClassName equ <bp_top + 4>
  910. bp_lpwc32 equ <bp_top + 8>
  911. bp_lpszClassNameTemp equ <[bp - 4]>
  912. ; Skip this if lpsz32 or lpwc32 is NULL
  913. mov eax, bp_lpszClassName
  914. test eax,eax
  915. jz L238 ; skip if null
  916. mov eax, bp_lpwc32
  917. test eax, eax
  918. jz L238
  919. ; Save space for lpszClassNameTemp
  920. xor eax, eax
  921. push eax
  922. ; Get lpWndClassEx16
  923. sub sp,WNDCLASSEX16_SIZE ; lpWndClassEx alloc space on stack
  924. movzx esi,sp ; ds:esi == destination address
  925. mov dword ptr ss:[esi], WNDCLASSEX16_SIZE
  926. ;
  927. ; Push 16-bit parameters
  928. ;
  929. ; hInstance: can be NULL (for system class)
  930. mov eax, bp_hInstance
  931. test eax, eax
  932. jz PushInstance
  933. call MaphInstLS
  934. PushInstance:
  935. push ax
  936. ; lpszClassName: can be atom or string
  937. push dword ptr bp_lpszClassName
  938. call MapLS
  939. mov bp_lpszClassNameTemp, eax
  940. push eax
  941. ; lpwc16
  942. push ss
  943. push si
  944. ;
  945. ; Make 16-bit call
  946. ; ZERO-EXTEND return value. Some apps know it's not really a BOOL,
  947. ; it's an ATOM and save the entire DWORD away to compare later.
  948. ;
  949. call GetClassInfoEx
  950. movzx eax, ax
  951. ; Save return value
  952. push eax
  953. test eax, eax
  954. jz Cleanup
  955. ;
  956. ; Convert WNDCLASSEX from 16 to 32
  957. ;
  958. mov es, FlatData
  959. mov edi, bp_lpwc32
  960. push ds
  961. mov ax, ss
  962. mov ds, ax
  963. cld
  964. ;;Skip size
  965. add esi, 4
  966. add edi, 4
  967. ; style
  968. copyd
  969. ; lpfnWndProc
  970. lodsd ds:[esi]
  971. push es
  972. push eax
  973. push dword ptr CBID_WNDPROC
  974. call GetStdCBLS
  975. pop es
  976. stosd es:[edi]
  977. ; cbClsExtra, cbWndExtra
  978. ncopyzx 2
  979. ; hInstance
  980. lodsw ds:[esi] ; hInstance
  981. mov eax, bp_hInstance
  982. stosd es:[edi]
  983. ; hIcon, hCursor, hbrBackground
  984. ncopyzx 3
  985. ; lpszMenuName
  986. lodsd ds:[esi]
  987. push eax
  988. call MapSL ;BUGBUG! GetClassInfo
  989. stosd es:[edi]
  990. ; lpszClassName: Just use what was passed in, just like User16 does!
  991. lodsd ds:[esi]
  992. mov eax, dword ptr bp_lpszClassName
  993. stosd es:[edi]
  994. ; hIconSm
  995. copyzx
  996. pop ds
  997. Cleanup:
  998. pushd bp_lpszClassNameTemp
  999. call UnmapLS
  1000. pop eax
  1001. L238:
  1002. endm
  1003. ;===========================================
  1004. ; BOGUS
  1005. ; Same code for mapping instances everywhere
  1006. ;===========================================
  1007. ;-----------------------------------------------------------------------;
  1008. ; PUSH__DDECONNECT_pCC
  1009. ;-----------------------------------------------------------------------;
  1010. PUSH__DDECONNECT_pCC macro iOffset, iTempOffset
  1011. local done
  1012. mov eax,[bp-iTempOffset]
  1013. push eax
  1014. test eax,eax
  1015. jz done
  1016. movzx eax,ax
  1017. mov word ptr ss:[eax].cc16_cb,CONVCONTEXT16_SIZE
  1018. done:
  1019. endm
  1020. ;-----------------------------------------------------------------------;
  1021. ; PUSH__DDECONNECTLIST_pCC
  1022. ;-----------------------------------------------------------------------;
  1023. PUSH__DDECONNECTLIST_pCC macro iOffset, iTempOffset
  1024. local done
  1025. mov eax,[bp-iTempOffset]
  1026. push eax
  1027. test eax,eax
  1028. jz done
  1029. movzx eax,ax
  1030. mov word ptr ss:[eax].cc16_cb,CONVCONTEXT16_SIZE
  1031. done:
  1032. endm
  1033. ;-----------------------------------------------------------------------;
  1034. ; body_CREATEWINDOWEXA
  1035. ;-----------------------------------------------------------------------;
  1036. body_CREATEWINDOWEXA macro
  1037. local null_ptr1
  1038. local store_ptr1
  1039. local null_ptr2
  1040. local have_x
  1041. local have_width
  1042. local ismdi
  1043. local isnotmdi
  1044. local done_with_lpParam
  1045. BODY_PARAM_16 bp_dwExStyle, 0
  1046. BODY_PARAM_16 bp_lpClassName, 4
  1047. BODY_PARAM_16 bp_lpWindowName, 8
  1048. BODY_PARAM_16 bp_dwStyle, 12
  1049. BODY_PARAM_16 bp_X, 16
  1050. BODY_PARAM_16 bp_Y, 20
  1051. BODY_PARAM_16 bp_nWidth, 24
  1052. BODY_PARAM_16 bp_nHeight, 28
  1053. BODY_PARAM_16 bp_hWndParent, 32
  1054. BODY_PARAM_16 bp_hMenu, 36
  1055. BODY_PARAM_16 bp_hInstance, 40
  1056. BODY_PARAM_16 bp_lpParam, 44
  1057. bp_lpClassNameTemp equ <[bp-4]>
  1058. bp_lpWindowNameTemp equ <[bp-8]>
  1059. bp_lpParamTemp equ <[bp-12]>
  1060. bp_couldbemdi equ <[bp-14]>
  1061. ; temp storage
  1062. xor eax,eax
  1063. push eax ; ptr param #1 lpClassNameTemp
  1064. push eax ; ptr param #2 lpWindowNameTemp
  1065. push eax ; ptr param #3 lpParamTemp
  1066. inc ax
  1067. push ax ; wrd param #4 couldbemdi (set to 1)
  1068. mov cx, word ptr bp_lpClassName+2
  1069. jcxz notmdi ; Passed in an atom?
  1070. mov eax, dword ptr bp_lpClassName
  1071. mov es, FlatData
  1072. mov eax, es:[eax]
  1073. cmp eax, 'CIDM' ; Check for MDIC
  1074. je ismdi
  1075. cmp eax, 'cidm' ; and in lower case...
  1076. je ismdi
  1077. notmdi:
  1078. dec word ptr bp_couldbemdi ; dec to 0
  1079. ismdi:
  1080. push dword ptr bp_lpClassName
  1081. call MapLS ;PLUGGED
  1082. mov bp_lpClassNameTemp,eax
  1083. push dword ptr bp_lpWindowName
  1084. call MapLS ;PLUGGED
  1085. mov bp_lpWindowNameTemp,eax
  1086. ; lpParam is pointer to CLIENTCREATESTRUCT if class is mdiclient, otherwise
  1087. ; it's just a dword.
  1088. mov cx, word ptr bp_couldbemdi
  1089. jcxz isnotmdi
  1090. push dword ptr bp_lpClassNameTemp
  1091. call IsClassNameMDICLIENT
  1092. test ax,ax
  1093. jnz CreateMdi
  1094. isnotmdi:
  1095. push dword ptr bp_lpParam
  1096. call MapLS
  1097. mov bp_lpParamTemp, eax
  1098. mov bp_lpParam, eax
  1099. jmp done_with_lpParam
  1100. ; lpParam points to CLIENTCREATESTRUCT, so repack it and update
  1101. ; bp_lpParamTemp
  1102. CreateMdi:
  1103. ;CLIENTCREATESTRUCT:
  1104. ; HWND
  1105. ; UINT
  1106. mov es, FlatData
  1107. mov ecx,dword ptr bp_lpParam
  1108. push word ptr es:[ecx+4] ;truncate UINT
  1109. push word ptr es:[ecx] ;truncate HWND
  1110. mov bp_lpParam[0],sp ;store new pointer to struct
  1111. mov bp_lpParam[2],ss
  1112. done_with_lpParam:
  1113. push dword ptr bp_dwExStyle
  1114. push dword ptr bp_lpClassNameTemp
  1115. push dword ptr bp_lpWindowNameTemp
  1116. push dword ptr bp_dwStyle
  1117. ; x, y, cx, cy
  1118. mov eax, dword ptr bp_X
  1119. cmp eax, 80000000h ; CW_USEDEFAULT
  1120. jne have_x
  1121. ror eax,16 ; map to 8000h
  1122. have_x:
  1123. push ax
  1124. mov eax, dword ptr bp_Y
  1125. cmp eax, 80000000h
  1126. jne have_y
  1127. ror eax,16
  1128. have_y:
  1129. push ax
  1130. mov eax,dword ptr bp_nWidth
  1131. cmp eax,80000000h ; CW_USEDEFAULT
  1132. jne have_cx
  1133. ror eax,16 ; map to 8000h
  1134. have_cx:
  1135. push ax
  1136. mov eax,dword ptr bp_nHeight
  1137. cmp eax,80000000h
  1138. jne have_cy
  1139. ror eax,16
  1140. have_cy:
  1141. push ax
  1142. push word ptr bp_hWndParent
  1143. ; push LOWORD of hMenu
  1144. push word ptr bp_hMenu.lo
  1145. ; hInstance
  1146. MAP_NULL_HINST bp_hInstance
  1147. push ax
  1148. ; lpParams
  1149. push dword ptr bp_lpParam
  1150. ; push HIWORD of hMenu
  1151. push word ptr bp_hMenu.hi
  1152. call CreateWindowEx32 ; call 16-bit version
  1153. movzx eax,ax
  1154. push eax
  1155. pushd bp_lpParamTemp
  1156. call UnmapLS
  1157. pushd bp_lpClassNameTemp
  1158. call UnmapLS
  1159. pushd bp_lpWindowNameTemp
  1160. call UnmapLS
  1161. pop eax
  1162. endm
  1163. ;-----------------------------------------------------------------------;
  1164. ; body_DDECLIENTTRANSACTION
  1165. ;-----------------------------------------------------------------------;
  1166. body_DDECLIENTTRANSACTION macro
  1167. local dometafile
  1168. local null_ptr1
  1169. local null_ptr2
  1170. local dct_leave
  1171. BODY_PARAM_16 bp_pData, 0
  1172. BODY_PARAM_16 bp_cbData, 4
  1173. BODY_PARAM_16 bp_hConv, 8
  1174. BODY_PARAM_16 bp_hszItem, 12
  1175. BODY_PARAM_16 bp_wFmt, 16
  1176. BODY_PARAM_16 bp_wType, 20
  1177. BODY_PARAM_16 bp_dwTimeout, 24
  1178. BODY_PARAM_16 bp_pdwResult, 28
  1179. bp_pDataTemp equ <[bp-4]>
  1180. bp_pdwResultTemp equ <[bp-8]>
  1181. bp_pDataTempSel equ <[bp-12]>
  1182. xor eax,eax
  1183. push dword ptr bp_pData ; bp_pDataTemp: ptr param #1 pData
  1184. push eax ; bp_pdwResultTemp: ptr param #2 pdwResult
  1185. push eax ; bp_pDataTempSel: Sel for pData
  1186. ;If cbData == -1, then pData is a handle, not a pointer.
  1187. cmp dword ptr bp_cbData, -1
  1188. jz null_ptr1
  1189. cmp dword ptr bp_pData, 0
  1190. jz null_ptr1
  1191. cmp word ptr bp_wFmt, CF_METAFILEPICT
  1192. je dometafile
  1193. push dword ptr bp_pData
  1194. call MapLS ;PLUGGED
  1195. mov bp_pDataTemp,eax
  1196. mov bp_pDataTempSel,eax
  1197. jmp null_ptr1
  1198. dometafile:
  1199. mov ds, FlatData
  1200. mov esi, bp_pData
  1201. push word ptr CF_METAFILEPICT
  1202. push dword ptr [esi]
  1203. push word ptr 0
  1204. call ConvertCFDataLS
  1205. movzx eax,ax
  1206. or ax,ax
  1207. jz dct_leave
  1208. ; We'll use bp_pData as our (2-byte) substitute data buffer.
  1209. mov bp_pData,ax
  1210. mov word ptr bp_cbData,2
  1211. mov ax,ss
  1212. mov bp_pDataTemp,ax
  1213. lea di,bp_pData
  1214. mov bp_pDataTemp+2,di
  1215. null_ptr1:
  1216. push dword ptr bp_pdwResult
  1217. call MapLS ;PLUGGED
  1218. mov bp_pdwResultTemp,eax
  1219. null_ptr2:
  1220. push dword ptr bp_pDataTemp
  1221. push dword ptr bp_cbData
  1222. push dword ptr bp_hConv
  1223. push dword ptr bp_hszItem
  1224. push word ptr bp_wFmt
  1225. push word ptr bp_wType
  1226. push dword ptr bp_dwTimeout
  1227. push dword ptr bp_pdwResultTemp
  1228. call DDECLIENTTRANSACTION
  1229. DXAX2EAX
  1230. dct_leave:
  1231. ; We can safely unmap these. The api does not hold either pointer
  1232. ; after it returns.
  1233. push eax
  1234. push dword ptr bp_pDataTempSel
  1235. call UnMapLS
  1236. push dword ptr bp_pdwResultTemp
  1237. call UnMapLS
  1238. IF 0
  1239. ;!!! BUGBUG: The following is a gross M5 workaround for B#9814.
  1240. ;!!! DdeClientTransaction takes our ss and stuffs it in a long-term data
  1241. ;!!! structure. To prevent a subsequent GP fault, we'll replace ss
  1242. ;!!! with a new one so that the thunk dispatcher won't unmap the one
  1243. ;!!! that DdeClientTransaction so rudely took.
  1244. mov ax,ss
  1245. push ax
  1246. push word ptr 0
  1247. call MapSL ;This is ok: part of M5 hack anyway
  1248. push eax
  1249. call MapLS
  1250. mov ss,dx
  1251. ;!!! End of B#9814 workaround.
  1252. ENDIF
  1253. pop eax
  1254. endm
  1255. ;-----------------------------------------------------------------------;
  1256. ; body_SYSTEMPARAMETERSINFOA
  1257. ;-----------------------------------------------------------------------;
  1258. body_SYSTEMPARAMETERSINFOA macro
  1259. local exit, error_exit
  1260. local anpfnSPI, MAX_ACTION
  1261. local push_zero_0, push_fuwinini_0
  1262. local push_zero_1, push_fuwinini_1
  1263. local push_callframe_2, push_ax_2
  1264. local push_callframe_3, done_3
  1265. bp_uAction equ <bp_top>
  1266. bp_uParam equ <bp_top+4>
  1267. bp_lParam equ <bp_top+8>
  1268. bp_fuWinIni equ <bp_top+12>
  1269. ;BP=SP upon entry
  1270. bp_pTmp equ <dword ptr [bp-4]>
  1271. mov ebx,dword ptr bp_uAction
  1272. cmp ebx,MAX_ACTION
  1273. ja check_new_actions
  1274. add bx,bx
  1275. jmp word ptr cs:anpfnSPI[bx]
  1276. check_new_actions:
  1277. mov dx, bx
  1278. shr bx, 12
  1279. and bx, 2
  1280. and dx, 1
  1281. add bx, dx
  1282. cmp bx,MAX_NEWACTION
  1283. ja error_exit
  1284. add bx,bx
  1285. jmp word ptr cs:anpfnNewSPI[bx]
  1286. anpfnNewSPI label word
  1287. dw offset thk_SPI_GETBOOLUSERPREFERENCE
  1288. dw offset thk_SPI_SETBOOLUSERPREFERENCE
  1289. dw offset thk_SPI_GETDWORDUSERPREFERENCE
  1290. dw offset thk_SPI_SETDWORDUSERPREFERENCE
  1291. MAX_NEWACTION equ ($ - anpfnNewSPI)/2
  1292. anpfnSPI label word
  1293. dw offset error_exit
  1294. dw offset thk_SPI_GETBEEP
  1295. dw offset thk_SPI_SETBEEP
  1296. dw offset thk_SPI_GETMOUSE
  1297. dw offset thk_SPI_SETMOUSE
  1298. dw offset thk_SPI_GETBORDER
  1299. dw offset thk_SPI_SETBORDER
  1300. dw offset error_exit
  1301. dw offset error_exit
  1302. dw offset error_exit
  1303. dw offset thk_SPI_GETKEYBOARDSPEED
  1304. dw offset thk_SPI_SETKEYBOARDSPEED
  1305. dw offset thk_SPI_LANGDRIVER
  1306. dw offset thk_SPI_ICONHORIZONTALSPACING
  1307. dw offset thk_SPI_GETSCREENSAVETIMEOUT
  1308. dw offset thk_SPI_SETSCREENSAVETIMEOUT
  1309. dw offset thk_SPI_GETSCREENSAVEACTIVE
  1310. dw offset thk_SPI_SETSCREENSAVEACTIVE
  1311. dw offset thk_SPI_GETGRIDGRANULARITY
  1312. dw offset thk_SPI_SETGRIDGRANULARITY
  1313. dw offset thk_SPI_SETDESKWALLPAPER
  1314. dw offset thk_SPI_SETDESKPATTERN
  1315. dw offset thk_SPI_GETKEYBOARDDELAY
  1316. dw offset thk_SPI_SETKEYBOARDDELAY
  1317. dw offset thk_SPI_ICONVERTICALSPACING
  1318. dw offset thk_SPI_GETICONTITLEWRAP
  1319. dw offset thk_SPI_SETICONTITLEWRAP
  1320. dw offset thk_SPI_GETMENUDROPALIGNMENT
  1321. dw offset thk_SPI_SETMENUDROPALIGNMENT
  1322. dw offset thk_SPI_SETDOUBLECLKWIDTH
  1323. dw offset thk_SPI_SETDOUBLECLKHEIGHT
  1324. dw offset thk_SPI_GETICONTITLELOGFONT
  1325. dw offset thk_SPI_SETDOUBLECLICKTIME
  1326. dw offset thk_SPI_SETMOUSEBUTTONSWAP
  1327. dw offset thk_SPI_SETICONTITLELOGFONT
  1328. dw offset thk_SPI_GETFASTTASKSWITCH
  1329. dw offset thk_SPI_SETFASTTASKSWITCH
  1330. dw offset thk_SPI_SETDRAGFULLWINDOWS
  1331. dw offset thk_SPI_GETDRAGFULLWINDOWS
  1332. dw offset thk_SPI_GETKEYBOARDLAYOUT
  1333. dw offset thk_SPI_SETKEYBOARDLAYOUT
  1334. dw offset thk_SPI_GETNONCLIENTMETRICS
  1335. dw offset thk_SPI_SETNONCLIENTMETRICS
  1336. dw offset thk_SPI_GETMINIMIZEDMETRICS
  1337. dw offset thk_SPI_SETMINIMIZEDMETRICS
  1338. dw offset thk_SPI_GETICONMETRICS
  1339. dw offset thk_SPI_SETICONMETRICS
  1340. dw offset thk_SPI_SETWORKAREA
  1341. dw offset thk_SPI_GETWORKAREA
  1342. dw offset thk_SPI_SETPENWINDOWS
  1343. dw offset thk_SPI_GETFILTERKEYS
  1344. dw offset thk_SPI_SETFILTERKEYS
  1345. dw offset thk_SPI_GETTOGGLEKEYS
  1346. dw offset thk_SPI_SETTOGGLEKEYS
  1347. dw offset thk_SPI_GETMOUSEKEYS
  1348. dw offset thk_SPI_SETMOUSEKEYS
  1349. dw offset thk_SPI_GETSHOWSOUNDS
  1350. dw offset thk_SPI_SETSHOWSOUNDS
  1351. dw offset thk_SPI_GETSTICKYKEYS
  1352. dw offset thk_SPI_SETSTICKYKEYS
  1353. dw offset thk_SPI_GETACCESSTIMEOUT
  1354. dw offset thk_SPI_SETACCESSTIMEOUT
  1355. dw offset thk_SPI_GETSERIALKEYS
  1356. dw offset thk_SPI_SETSERIALKEYS
  1357. dw offset thk_SPI_GETSOUNDSENTRY
  1358. dw offset thk_SPI_SETSOUNDSENTRY
  1359. dw offset thk_SPI_GETHIGHCONTRAST
  1360. dw offset thk_SPI_SETHIGHCONTRAST
  1361. dw offset thk_SPI_GETKEYBOARDPREF
  1362. dw offset thk_SPI_SETKEYBOARDPREF
  1363. dw offset thk_SPI_GETSCREENREADER
  1364. dw offset thk_SPI_SETSCREENREADER
  1365. dw offset thk_SPI_GETANIMATION
  1366. dw offset thk_SPI_SETANIMATION
  1367. dw offset thk_SPI_GETFONTSMOOTHING
  1368. dw offset thk_SPI_SETFONTSMOOTHING
  1369. dw offset thk_SPI_SETDRAGWIDTH
  1370. dw offset thk_SPI_SETDRAGHEIGHT
  1371. dw offset thk_SPI_SETHANDHELD
  1372. dw offset thk_SPI_GETLOWPOWERTIMEOUT
  1373. dw offset thk_SPI_GETPOWEROFFTIMEOUT
  1374. dw offset thk_SPI_SETLOWPOWERTIMEOUT
  1375. dw offset thk_SPI_SETPOWEROFFTIMEOUT
  1376. dw offset thk_SPI_GETLOWPOWERACTIVE
  1377. dw offset thk_SPI_GETPOWEROFFACTIVE
  1378. dw offset thk_SPI_SETLOWPOWERACTIVE
  1379. dw offset thk_SPI_SETPOWEROFFACTIVE
  1380. dw offset thk_SPI_SETCURSORS
  1381. dw offset thk_SPI_SETICONS
  1382. dw offset thk_SPI_GETDEFAULTINPUTLANG
  1383. dw offset thk_SPI_SETDEFAULTINPUTLANG
  1384. dw offset thk_SPI_SETLANGTOGGLE
  1385. dw offset thk_SPI_GETWINDOWSEXTENSION
  1386. dw offset thk_SPI_SETMOUSETRAILS
  1387. dw offset thk_SPI_GETMOUSETRAILS
  1388. dw offset thk_SPI_GETSNAPTODEFBUTTON
  1389. dw offset thk_SPI_SETSNAPTODEFBUTTON
  1390. dw offset thk_SPI_SETSCREENSAVERRUNNING ; 97
  1391. dw offset thk_SPI_GETMOUSEHOVERWIDTH ; 98
  1392. dw offset thk_SPI_SETMOUSEHOVERWIDTH ; 99
  1393. dw offset thk_SPI_GETMOUSEHOVERHEIGHT ; 100
  1394. dw offset thk_SPI_SETMOUSEHOVERHEIGHT ; 101
  1395. dw offset thk_SPI_GETMOUSEHOVERTIME ; 102
  1396. dw offset thk_SPI_SETMOUSEHOVERTIME ; 103
  1397. dw offset thk_SPI_GETWHEELSCROLLLINES ; 104
  1398. dw offset thk_SPI_SETWHEELSCROLLLINES ; 105
  1399. dw offset thk_SPI_GETMENUSHOWDELAY ; 106
  1400. dw offset thk_SPI_SETMENUSHOWDELAY ; 107
  1401. dw offset thk_SPI_GETUSERPREFERENCE ; 108
  1402. dw offset thk_SPI_SETUSERPREFERENCE ; 109
  1403. ifdef FE_IME
  1404. dw offset thk_SPI_GETSHOWIMEUI ; 110
  1405. dw offset thk_SPI_SETSHOWIMEUI ; 111
  1406. else
  1407. dw offset error_exit ; 110
  1408. dw offset error_exit ; 111
  1409. endif
  1410. dw offset thk_SPI_GETMOUSESPEED ; 112
  1411. dw offset thk_SPI_SETMOUSESPEED ; 113
  1412. dw offset thk_SPI_GETSCREENSAVERRUNNING ; 114
  1413. MAX_ACTION equ ($ - anpfnSPI)/2
  1414. ;-----------------------------------------------------------------------;
  1415. ; UNIMPLEMENTED
  1416. ;-----------------------------------------------------------------------;
  1417. thk_SPI_GETMOUSEHOVERWIDTH:
  1418. thk_SPI_SETMOUSEHOVERWIDTH:
  1419. thk_SPI_GETMOUSEHOVERHEIGHT:
  1420. thk_SPI_SETMOUSEHOVERHEIGHT:
  1421. thk_SPI_GETMOUSEHOVERTIME:
  1422. thk_SPI_SETMOUSEHOVERTIME:
  1423. thk_SPI_GETUSERPREFERENCE:
  1424. thk_SPI_SETUSERPREFERENCE:
  1425. error_exit:
  1426. sub eax,eax
  1427. jmp exit
  1428. ;-----------------------------------------------------------------------;
  1429. ; uParam = UINT
  1430. ; lParam = LPINT
  1431. ;-----------------------------------------------------------------------;
  1432. thk_SPI_GETBEEP:
  1433. thk_SPI_GETBORDER:
  1434. thk_SPI_GETFASTTASKSWITCH:
  1435. thk_SPI_GETGRIDGRANULARITY:
  1436. thk_SPI_GETICONTITLEWRAP:
  1437. thk_SPI_GETKEYBOARDDELAY:
  1438. thk_SPI_GETKEYBOARDSPEED:
  1439. thk_SPI_GETMENUDROPALIGNMENT:
  1440. thk_SPI_GETSCREENSAVEACTIVE:
  1441. thk_SPI_GETSCREENSAVETIMEOUT:
  1442. thk_SPI_ICONHORIZONTALSPACING:
  1443. thk_SPI_ICONVERTICALSPACING:
  1444. thk_SPI_GETDRAGFULLWINDOWS:
  1445. thk_SPI_GETFONTSMOOTHING:
  1446. thk_SPI_GETMOUSETRAILS:
  1447. thk_SPI_GETSNAPTODEFBUTTON:
  1448. thk_SPI_SETSCREENSAVERRUNNING:
  1449. thk_SPI_GETBOOLUSERPREFERENCE:
  1450. thk_SPI_GETSCREENSAVERRUNNING:
  1451. ifdef FE_IME
  1452. thk_SPI_GETSHOWIMEUI:
  1453. endif
  1454. push byte ptr 0 ;reserve and init local var
  1455. mov ax,sp ;save addr of local var
  1456. push dword ptr bp_uAction
  1457. push word ptr bp_uParam
  1458. mov esi,bp_lParam
  1459. test esi,esi
  1460. jz push_zero_0
  1461. push ss
  1462. push ax
  1463. jmp short push_fuwinini_0
  1464. push_zero_0:
  1465. push esi
  1466. push_fuwinini_0:
  1467. push word ptr bp_fuWinIni
  1468. call SystemParametersInfo32
  1469. cwde
  1470. pop cx ;recover local var value, clean stack
  1471. mov esi,bp_lParam
  1472. test esi,esi
  1473. jz exit ;if 0, all done
  1474. mov es,FlatData
  1475. movsx ecx,cx
  1476. mov es:[esi],ecx
  1477. jmp exit
  1478. ;-----------------------------------------------------------------------;
  1479. ; uParam = UINT
  1480. ; lParam = DWORD
  1481. ;-----------------------------------------------------------------------;
  1482. thk_SPI_SETBEEP:
  1483. thk_SPI_SETBORDER:
  1484. thk_SPI_SETDOUBLECLKHEIGHT:
  1485. thk_SPI_SETDOUBLECLICKTIME:
  1486. thk_SPI_SETDOUBLECLKWIDTH:
  1487. thk_SPI_SETFASTTASKSWITCH:
  1488. thk_SPI_SETGRIDGRANULARITY:
  1489. thk_SPI_SETICONTITLEWRAP:
  1490. thk_SPI_SETKEYBOARDDELAY:
  1491. thk_SPI_SETKEYBOARDSPEED:
  1492. thk_SPI_SETMENUDROPALIGNMENT:
  1493. thk_SPI_SETMOUSEBUTTONSWAP:
  1494. thk_SPI_SETSCREENSAVEACTIVE:
  1495. thk_SPI_SETSCREENSAVETIMEOUT:
  1496. thk_SPI_SETLOWPOWERTIMEOUT:
  1497. thk_SPI_SETPOWEROFFTIMEOUT:
  1498. thk_SPI_SETLOWPOWERACTIVE:
  1499. thk_SPI_SETPOWEROFFACTIVE:
  1500. thk_SPI_SETDRAGFULLWINDOWS:
  1501. thk_SPI_SETFONTSMOOTHING:
  1502. thk_SPI_SETPENWINDOWS:
  1503. thk_SPI_SETSHOWSOUNDS:
  1504. thk_SPI_SETKEYBOARDPREF:
  1505. thk_SPI_SETSCREENREADER:
  1506. thk_SPI_SETDRAGWIDTH:
  1507. thk_SPI_SETDRAGHEIGHT:
  1508. thk_SPI_SETCURSORS:
  1509. thk_SPI_SETICONS:
  1510. thk_SPI_SETLANGTOGGLE:
  1511. thk_SPI_GETWINDOWSEXTENSION:
  1512. thk_SPI_SETMOUSETRAILS:
  1513. thk_SPI_SETSNAPTODEFBUTTON:
  1514. thk_SPI_SETWHEELSCROLLLINES:
  1515. thk_SPI_SETMENUSHOWDELAY:
  1516. ifdef FE_IME
  1517. thk_SPI_SETSHOWIMEUI:
  1518. endif
  1519. thk_SPI_SETBOOLUSERPREFERENCE:
  1520. thk_SPI_SETDWORDUSERPREFERENCE:
  1521. thk_SPI_SETMOUSESPEED:
  1522. push dword ptr bp_uAction
  1523. push word ptr bp_uParam
  1524. push dword ptr bp_lParam
  1525. push word ptr bp_fuWinIni
  1526. call SystemParametersInfo32
  1527. cwde
  1528. jmp exit
  1529. ;-----------------------------------------------------------------------;
  1530. ; uParam = WORD
  1531. ; lParam = LPRECT
  1532. ;-----------------------------------------------------------------------;
  1533. thk_SPI_SETWORKAREA:
  1534. thk_SPI_GETWORKAREA:
  1535. ; We need scratch space for RECT16
  1536. sub sp, RECT16_SIZE
  1537. mov di,sp
  1538. push dword ptr bp_uAction
  1539. push word ptr bp_uParam
  1540. mov esi,bp_lParam
  1541. test esi,esi
  1542. jnz pack_lprect
  1543. push esi
  1544. jmp after_lprect
  1545. pack_lprect:
  1546. ; Stick lprect16 address on stack first
  1547. push ss
  1548. push di
  1549. ; Convert lprect32 (ds:esi) to lprect16 (es:di) before
  1550. push ds
  1551. mov ds, FlatData
  1552. mov ax, ss
  1553. mov es, ax
  1554. cld
  1555. PACK_RECT_32_16
  1556. pop ds
  1557. after_lprect:
  1558. push word ptr bp_fuWinIni
  1559. call SystemParametersInfo32
  1560. cwde
  1561. test esi, esi
  1562. jz stack_clean
  1563. ; Save return value and DS
  1564. push eax
  1565. push ds
  1566. ; Setup lprc16 in DS:SI (remember--PACK_RECT_32_16 changed DI)
  1567. ; Setup lprc32 in ES:EDI (remember--PACK_RECT_32_16 changed ESI)
  1568. push ss
  1569. sub di, RECT16_SIZE
  1570. push di
  1571. mov edi, esi
  1572. sub edi, RECT32_SIZE
  1573. mov es, FlatData
  1574. pop si
  1575. pop ds
  1576. cld
  1577. PACK_RECT_16_32
  1578. pop ds
  1579. pop eax
  1580. stack_clean:
  1581. ; Clean the stack
  1582. add sp, RECT16_SIZE
  1583. jmp exit
  1584. ;-----------------------------------------------------------------------;
  1585. ; uParam = 0
  1586. ; lParam = INT[3]
  1587. ;-----------------------------------------------------------------------;
  1588. thk_SPI_GETMOUSE:
  1589. thk_SPI_SETMOUSE:
  1590. sub sp,6 ;make space for local array
  1591. mov bx,sp ;save addr of local var
  1592. push dword ptr bp_uAction
  1593. push word ptr bp_uParam
  1594. mov esi,bp_lParam
  1595. test esi,esi
  1596. jz push_zero_1
  1597. mov es,FlatData
  1598. mov ax,es:[esi+0]
  1599. mov ss:[bx+0],ax
  1600. mov ax,es:[esi+4]
  1601. mov ss:[bx+2],ax
  1602. mov ax,es:[esi+8]
  1603. mov ss:[bx+4],ax
  1604. push ss
  1605. push bx
  1606. jmp short push_fuwinini_1
  1607. push_zero_1:
  1608. push esi
  1609. push_fuwinini_1:
  1610. push word ptr bp_fuWinIni
  1611. call SystemParametersInfo32
  1612. cwde
  1613. pop bx ;recover local vars value, clean stack
  1614. pop cx
  1615. pop dx
  1616. mov esi,bp_lParam
  1617. test esi,esi
  1618. jz exit ;if 0, all done
  1619. mov es,FlatData
  1620. movsx ebx,bx
  1621. mov es:[esi+0],ebx
  1622. movsx ecx,cx
  1623. mov es:[esi+4],ecx
  1624. movsx edx,dx
  1625. mov es:[esi+8],edx
  1626. jmp exit
  1627. ;-----------------------------------------------------------------------;
  1628. ; uParam = 0
  1629. ; lParam = LPFN
  1630. ;-----------------------------------------------------------------------;
  1631. thk_SPI_SETHANDHELD:
  1632. push dword ptr bp_uAction ;pass uAction
  1633. push word ptr bp_uParam ;pass uParam
  1634. push dword ptr bp_lParam ;convert lParam to 16:16
  1635. push dword ptr CBID_SENDMSGCALLBACK ;sendmsg-type callback stub
  1636. call GetStdCBSL
  1637. push eax ;pass pfn16 as lParam
  1638. push word ptr bp_fuWinIni
  1639. call SystemParametersInfo32
  1640. cwde
  1641. jmp exit
  1642. ;-----------------------------------------------------------------------;
  1643. ; uParam = INT (if cbSize, 16-bit & 32-bit structs have to be ==)
  1644. ; lParam = LPVOID
  1645. ;-----------------------------------------------------------------------;
  1646. thk_SPI_LANGDRIVER:
  1647. thk_SPI_SETKEYBOARDLAYOUT:
  1648. thk_SPI_GETKEYBOARDLAYOUT:
  1649. thk_SPI_SETDESKPATTERN:
  1650. thk_SPI_SETDESKWALLPAPER:
  1651. thk_SPI_GETNONCLIENTMETRICS:
  1652. thk_SPI_SETNONCLIENTMETRICS:
  1653. thk_SPI_GETMINIMIZEDMETRICS:
  1654. thk_SPI_SETMINIMIZEDMETRICS:
  1655. thk_SPI_GETANIMATION:
  1656. thk_SPI_SETANIMATION:
  1657. thk_SPI_GETICONMETRICS:
  1658. thk_SPI_SETICONMETRICS:
  1659. thk_SPI_GETFILTERKEYS:
  1660. thk_SPI_SETFILTERKEYS:
  1661. thk_SPI_GETTOGGLEKEYS:
  1662. thk_SPI_SETTOGGLEKEYS:
  1663. thk_SPI_GETMOUSEKEYS:
  1664. thk_SPI_SETMOUSEKEYS:
  1665. thk_SPI_GETSHOWSOUNDS:
  1666. thk_SPI_GETSTICKYKEYS:
  1667. thk_SPI_SETSTICKYKEYS:
  1668. thk_SPI_GETACCESSTIMEOUT:
  1669. thk_SPI_SETACCESSTIMEOUT:
  1670. thk_SPI_GETSERIALKEYS:
  1671. thk_SPI_SETSERIALKEYS:
  1672. thk_SPI_GETSOUNDSENTRY:
  1673. thk_SPI_SETSOUNDSENTRY:
  1674. thk_SPI_GETHIGHCONTRAST:
  1675. thk_SPI_SETHIGHCONTRAST:
  1676. thk_SPI_GETKEYBOARDPREF:
  1677. thk_SPI_GETSCREENREADER:
  1678. thk_SPI_GETDEFAULTINPUTLANG:
  1679. thk_SPI_SETDEFAULTINPUTLANG:
  1680. thk_SPI_GETWHEELSCROLLLINES:
  1681. thk_SPI_GETMENUSHOWDELAY:
  1682. thk_SPI_GETLOWPOWERACTIVE:
  1683. thk_SPI_GETPOWEROFFACTIVE:
  1684. thk_SPI_GETLOWPOWERTIMEOUT:
  1685. thk_SPI_GETPOWEROFFTIMEOUT:
  1686. thk_SPI_GETDWORDUSERPREFERENCE:
  1687. thk_SPI_GETMOUSESPEED:
  1688. push dword ptr bp_uAction
  1689. push word ptr bp_uParam
  1690. push dword ptr bp_lParam
  1691. call MapLS ;PLUGGED
  1692. mov dword ptr bp_lParam,eax
  1693. push eax
  1694. push word ptr bp_fuWinIni
  1695. call SystemParametersInfo32
  1696. cwde
  1697. push eax
  1698. push dword ptr bp_lParam
  1699. call UnmapLS
  1700. pop eax
  1701. jmp exit
  1702. ;-----------------------------------------------------------------------;
  1703. ; uParam = sizeof LOGFONT or 0
  1704. ; lParam = input LPLOGFONT or 0
  1705. ;-----------------------------------------------------------------------;
  1706. thk_SPI_SETICONTITLELOGFONT:
  1707. sub eax,eax
  1708. push eax ;reserve and init bp_pTmp
  1709. mov esi,bp_lParam
  1710. test esi,esi
  1711. jz push_callframe_2
  1712. sub sp,LOGFONT16_SIZE
  1713. mov ax,sp
  1714. push ds
  1715. mov ds,FlatData ;DS:ESI --> 32-bit source
  1716. mov di,ss
  1717. mov es,di
  1718. movzx edi,ax ;ES:EDI --> 16-bit dest
  1719. mov word ptr bp_pTmp[0],di
  1720. mov word ptr bp_pTmp[2],es
  1721. cld
  1722. PACK_MLOGFONT_32_16
  1723. pop ds
  1724. push_callframe_2:
  1725. push dword ptr bp_uAction
  1726. mov ax,word ptr bp_uParam
  1727. test ax,ax
  1728. jz push_ax_2
  1729. mov ax,LOGFONT16_SIZE
  1730. push_ax_2:
  1731. push ax
  1732. push dword ptr bp_pTmp
  1733. push word ptr bp_fuWinIni
  1734. call SystemParametersInfo32
  1735. cwde
  1736. jmp short exit
  1737. ;-----------------------------------------------------------------------;
  1738. ; uParam = sizeof LOGFONT
  1739. ; lParam = output LPLOGFONT
  1740. ;-----------------------------------------------------------------------;
  1741. thk_SPI_GETICONTITLELOGFONT:
  1742. sub eax,eax
  1743. push eax ;reserve and init bp_pTmp
  1744. mov edi,bp_lParam
  1745. test edi,edi
  1746. jz push_callframe_3
  1747. sub sp,LOGFONT16_SIZE
  1748. mov word ptr bp_pTmp[0],sp
  1749. mov word ptr bp_pTmp[2],ss
  1750. push_callframe_3:
  1751. push dword ptr bp_uAction
  1752. push byte ptr LOGFONT16_SIZE
  1753. push dword ptr bp_pTmp
  1754. push word ptr bp_fuWinIni
  1755. call SystemParametersInfo32
  1756. cwde
  1757. mov edi,bp_lParam
  1758. test edi,edi
  1759. jz exit
  1760. push ds
  1761. mov es,FlatData ;ES:EDI --> 32-bit source
  1762. lds si,bp_pTmp ;DS:SI --> 16-bit dest
  1763. movzx esi,si ;DS:ESI --> 16-bit dest
  1764. cld
  1765. PACK_MLOGFONT_16_32
  1766. pop ds
  1767. exit:
  1768. mov sp,bp
  1769. endm
  1770. ;-----------------------------------------------------------------------;
  1771. ; body_LOADMENUINDIRECTA
  1772. ;-----------------------------------------------------------------------;
  1773. body_LOADMENUINDIRECTA macro
  1774. local done
  1775. bp_lpmt equ <bp_top>
  1776. bp_lpmt32Tmp equ <dword ptr [bp-4]>
  1777. bp_hmem16Tmp equ < word ptr [bp-6]>
  1778. bp_cbmt equ < word ptr [bp-8]>
  1779. bp_mem32Menu equ <dword ptr [bp-12]>
  1780. xor eax,eax
  1781. push eax
  1782. push eax
  1783. push eax
  1784. push dword ptr bp_lpmt
  1785. call MapLS ;PLUGGED
  1786. mov bp_lpmt32Tmp,eax
  1787. push eax
  1788. call CountMenuU
  1789. mov bp_cbmt,ax
  1790. push byte ptr GHND
  1791. movzx eax,ax
  1792. push eax
  1793. call GlobalAlloc ;if no scratch space, return no hmenu
  1794. movzx eax,ax ;prepare for error
  1795. test ax,ax
  1796. jz done
  1797. mov bp_hmem16Tmp,ax
  1798. push ax
  1799. push ax
  1800. call GlobalFix
  1801. call GlobalLock
  1802. push dx
  1803. push ax
  1804. call MapSL ;SAFE
  1805. mov bp_mem32Menu, eax
  1806. mov eax, bp_lpmt
  1807. push eax
  1808. mov ax, bp_cbmt
  1809. movzx eax, ax
  1810. push eax
  1811. mov eax, bp_mem32Menu
  1812. push eax
  1813. call ConvertMenu32
  1814. mov ax, bp_hmem16Tmp
  1815. GMH2Sel ax ;push this ahead of time for LoadMenuIndirect
  1816. push ax
  1817. push byte ptr 0
  1818. ;push bp_cbmt ;cbIn
  1819. ;push ax ;pOut
  1820. ;push byte ptr 0 ;
  1821. ;push bp_lpmt32Tmp ;pIn
  1822. ;call ConvertMenuA ;convert menu to win3.1 format
  1823. call LoadMenuIndirect ;param already pushed
  1824. movzx eax,ax
  1825. push eax
  1826. push bp_hmem16Tmp ;cannot be null
  1827. push bp_hmem16Tmp
  1828. push bp_hmem16Tmp
  1829. call GlobalUnlock
  1830. call GlobalUnfix
  1831. call GlobalFree
  1832. pop eax
  1833. done:
  1834. push eax
  1835. pushd bp_lpmt32Tmp
  1836. call UnmapLS
  1837. pop eax
  1838. endm
  1839. ;-----------------------------------------------------------------------;
  1840. ; body_CREATEDIALOGINDIRECTPARAMA
  1841. ;-----------------------------------------------------------------------;
  1842. body_CREATEDIALOGINDIRECTPARAMA macro
  1843. local done
  1844. local done_with_dlgproc
  1845. bp_hInstance equ <bp_top>
  1846. bp_hDialogTemplate equ <bp_top+4>
  1847. bp_hWndParent equ <bp_top+8>
  1848. bp_lpDialogFunc equ <bp_top+12>
  1849. bp_dwInitParam equ <bp_top+16>
  1850. bp_lpdt32Tmp equ <dword ptr [bp-4]>
  1851. bp_hmem16Tmp equ < word ptr [bp-6]>
  1852. bp_cbdt equ < word ptr [bp-8]>
  1853. bp_mem32Dlg equ <dword ptr [bp-12]>
  1854. xor eax,eax
  1855. push eax
  1856. push eax
  1857. push eax
  1858. push dword ptr bp_lpDialogTemplate
  1859. call MapLS ;PLUGGED
  1860. mov bp_lpdt32Tmp,eax
  1861. push eax
  1862. call CountDialogU
  1863. mov bp_cbdt,ax
  1864. push byte ptr GPTR
  1865. movzx eax,ax
  1866. push eax
  1867. call GlobalAlloc ;if no scratch space, return no hmenu
  1868. movzx eax,ax ;prepare for error
  1869. test ax,ax
  1870. jz done
  1871. mov bp_hmem16Tmp,ax
  1872. ; GPTR is GMEM_FIXED, so MapSL is safe
  1873. push ax
  1874. push 0
  1875. call MapSL
  1876. mov bp_mem32Dlg, eax
  1877. ;push bp_cbdt ;cbIn
  1878. ;push ax ;pOut
  1879. ;push byte ptr 0 ;
  1880. ;push bp_lpdt32Tmp ;pIn
  1881. ;call ConvertDialogA ;convert menu to win3.1 format
  1882. pushd bp_hDialogTemplate
  1883. push 0
  1884. push bp_cbdt
  1885. pushd bp_mem32Dlg
  1886. call ConvertDialog32
  1887. ; create new call frame and make the call
  1888. ; hInstance
  1889. MAP_NULL_HINST bp_hInstance
  1890. push ax
  1891. ; lpDlgTemplate
  1892. push word ptr bp_hmem16Tmp
  1893. push 0
  1894. ; hwndOwner
  1895. push word ptr bp_hWndParent
  1896. ; lpfnDialog
  1897. pushd bp_lpDialogFunc
  1898. pushd CBID_DLGPROC
  1899. call GetStdCBSL
  1900. push eax
  1901. push dword ptr bp_dwInitParam
  1902. call GetCurrentHeap
  1903. ; mov ds,ax ; set by func
  1904. call CreateDialogIndirectParam ; call 16-bit version
  1905. ; Save zero-extended return value
  1906. movzx eax,ax
  1907. push eax
  1908. push bp_hmem16Tmp
  1909. call GlobalFree
  1910. ; Restore return value
  1911. pop eax
  1912. done:
  1913. ; Save return value
  1914. push eax
  1915. pushd bp_lpdt32Tmp
  1916. call UnmapLS
  1917. ; Restore return value
  1918. pop eax
  1919. ;locals discarded by next instruction
  1920. endm
  1921. ;-----------------------------------------------------------------------;
  1922. ; body_DIALOGBOXINDIRECTPARAMA
  1923. ;-----------------------------------------------------------------------;
  1924. body_DIALOGBOXINDIRECTPARAMA macro
  1925. local done
  1926. local ret_ok
  1927. local cont
  1928. local done_with_dlgproc
  1929. local dlgproc_freed
  1930. bp_hInstance equ <bp_top>
  1931. bp_lpDialogTemplate equ <bp_top+4>
  1932. bp_hWndParent equ <bp_top+8>
  1933. bp_lpDialogFunc equ <bp_top+12>
  1934. bp_dwInitParam equ <bp_top+16>
  1935. bp_lpdt32Tmp equ <dword ptr [bp-4]>
  1936. bp_hmem16Tmp equ < word ptr [bp-6]>
  1937. bp_cbdt equ < word ptr [bp-8]>
  1938. bp_mem32Dlg equ <dword ptr [bp-12]>
  1939. xor eax,eax
  1940. push eax
  1941. push eax
  1942. push eax
  1943. push dword ptr bp_lpDialogTemplate
  1944. call MapLS ;PLUGGED
  1945. mov bp_lpdt32Tmp,eax
  1946. push eax
  1947. call CountDialogU
  1948. mov bp_cbdt,ax
  1949. push byte ptr GPTR
  1950. movzx eax,ax
  1951. push eax
  1952. call GlobalAlloc ;if no scratch space, return no hmenu
  1953. movzx eax,ax ;prepare for error
  1954. test ax,ax
  1955. jz done
  1956. mov bp_hmem16Tmp,ax
  1957. ; GPTR is GMEM_FIXED, so MapSL is safe
  1958. push ax
  1959. push 0
  1960. call MapSL
  1961. mov bp_mem32Dlg, eax
  1962. pushd bp_lpDialogTemplate
  1963. push 0
  1964. push bp_cbdt
  1965. pushd bp_mem32Dlg
  1966. call ConvertDialog32
  1967. ; create new call frame and make the call
  1968. ;hInst
  1969. MAP_NULL_HINST bp_hInstance
  1970. push ax
  1971. ; hTemplate
  1972. push word ptr bp_hmem16Tmp
  1973. ; hwndOwner
  1974. push word ptr bp_hWndParent
  1975. ; lpfnDialog
  1976. push dword ptr bp_lpDialogFunc
  1977. push dword ptr CBID_DLGPROC
  1978. call GetStdCBSL
  1979. push eax
  1980. push dword ptr bp_dwInitParam
  1981. call GetCurrentHeap
  1982. ; mov ds,ax ; set by func
  1983. call DialogBoxIndirectParam ; call 16-bit version
  1984. DXAX2EAX ;; 16-bit version returns in DX:AX.
  1985. ;; So, move it to EAX.
  1986. cont:
  1987. ; Save return value
  1988. push eax
  1989. push bp_hmem16Tmp ;cannot be null
  1990. call GlobalFree
  1991. ; Restore return value
  1992. pop eax
  1993. done:
  1994. ; Save return value
  1995. push eax
  1996. pushd bp_lpdt32Tmp
  1997. call UnmapLS
  1998. ; Restore return value
  1999. pop eax
  2000. ;locals discarded by next instruction
  2001. endm
  2002. ;----------------------------------------------------------------------;
  2003. ;----------------------------------------------------------------------;
  2004. ; Inputs: eax = 32-bit lpNewItem from Win32 app.
  2005. ; wFlags = MF flags passed to API (in cx for ChangeMenu!!)
  2006. ; SegVarAddr = address of thunk-created local
  2007. ;
  2008. ; Output: eax = mapped version:
  2009. ; -- input eax if MF_OWNERDRAW
  2010. ; -- hi-word zeroed if MF_BITMAP
  2011. ; -- MapLS's if MF_STRING
  2012. ;
  2013. ; SegVarAddr set to seg:offset if MF_STRING.
  2014. ;
  2015. MAP_MENU_LPNEWITEM macro wFlags,SegVarAddr
  2016. local exit,isstring
  2017. ; Assumes SegVarAddr initialized to 0.
  2018. mov dx,wFlags
  2019. test dx,MF_OWNERDRAW or MF_SEPARATOR
  2020. jnz exit
  2021. test dx,MF_BITMAP
  2022. jz isstring
  2023. movzx eax,ax
  2024. jmp exit
  2025. isstring:
  2026. push eax
  2027. call MapLS ;PLUGGED
  2028. mov dword ptr SegVarAddr,eax
  2029. exit:
  2030. endm ;MAP_MENU_LPNEWITEM
  2031. ;----------------------------------------------------------------------;
  2032. ;----------------------------------------------------------------------;
  2033. RAWPACK__MODIFYMENUA_lpNewItem macro iOffset,iOffsetTemp
  2034. mov eax,[bp+iOffset]
  2035. MAP_MENU_LPNEWITEM [bp_top+8],LOCAL__MODIFYMENUA_lpNewItemSeg
  2036. mov [bp-iOffsetTemp],eax
  2037. endm; RAWPACK__MODIFYMENUA_lpNewItem
  2038. RAWUNPACK__MODIFYMENUA_lpNewItem macro iOffset,iOffsetTemp
  2039. push dword ptr LOCAL__MODIFYMENUA_lpNewItemSeg
  2040. call UnmapLS
  2041. endm; RAWUNPACK__MODIFYMENUA_lpNewItem
  2042. ;----------------------------------------------------------------------;
  2043. ;----------------------------------------------------------------------;
  2044. RAWPACK__INSERTMENUA_lpNewItem macro iOffset,iOffsetTemp
  2045. mov eax,[bp+iOffset]
  2046. MAP_MENU_LPNEWITEM [bp_top+8],LOCAL__INSERTMENUA_lpNewItemSeg
  2047. mov [bp-iOffsetTemp],eax
  2048. endm; RAWPACK__INSERTMENUA_lpNewItem
  2049. RAWUNPACK__INSERTMENUA_lpNewItem macro iOffset,iOffsetTemp
  2050. push dword ptr LOCAL__INSERTMENUA_lpNewItemSeg
  2051. call UnmapLS
  2052. endm; RAWUNPACK__INSERTMENUA_lpNewItem
  2053. ;----------------------------------------------------------------------;
  2054. ;----------------------------------------------------------------------;
  2055. RAWPACK__CHANGEMENUA_lpNewItem macro iOffset,iOffsetTemp
  2056. mov eax,[bp+iOffset]
  2057. ; HACK: The same flag bit that means MF_OWNERDRAW for
  2058. ; every other *Menu() api means MF_APPEND for ChangeMenu(). To prevent
  2059. ; MAP_MENU_LPNEWITEM from getting confused, turn off the bit in the
  2060. ; flag we give to it.
  2061. mov cx,[bp_top+16]
  2062. and cx,not MF_OWNERDRAW
  2063. MAP_MENU_LPNEWITEM cx,LOCAL__CHANGEMENUA_lpNewItemSeg
  2064. mov [bp-iOffsetTemp],eax
  2065. endm; RAWPACK__CHANGEMENUA_lpNewItem
  2066. RAWUNPACK__CHANGEMENUA_lpNewItem macro iOffset,iOffsetTemp
  2067. push dword ptr LOCAL__CHANGEMENUA_lpNewItemSeg
  2068. call UnmapLS
  2069. endm; RAWUNPACK__CHANGEMENUA_lpNewItem
  2070. ;------------------------------------------------------------------------;
  2071. ;body_WINHELPA
  2072. ;------------------------------------------------------------------------;
  2073. body_WINHELPA macro
  2074. local its_a_pointer
  2075. local its_lpmultikeyhelp
  2076. local its_lphelpwininfo
  2077. local leave_alone
  2078. local call_winhelp
  2079. local push_with_ssdi
  2080. local loop_top
  2081. local loop_top_2
  2082. bp_hwnd equ <bp_top>
  2083. bp_lpHelpFile equ <bp_top+4>
  2084. bp_wCommand equ <bp_top+8>
  2085. bp_dwData equ <bp_top+12>
  2086. bp_lpHelpFileTmp equ <[bp-4]>
  2087. bp_dwDataTmp equ <[bp-8]>
  2088. xor eax,eax
  2089. push eax
  2090. push eax
  2091. ;;The various HELP_* constants are not arranged nicely for a jump
  2092. ;;table, so just check for each of the known types needing special
  2093. ;;thunking. If wCommand is not recognized,
  2094. mov bx,word ptr bp_wCommand
  2095. and bx, not HELP_TCARD
  2096. cmp bx, HELP_CONTEXTMENU
  2097. jb leave_alone
  2098. je its_a_pointer
  2099. cmp bx, HELP_WM_HELP
  2100. je its_a_pointer
  2101. cmp bx,HELP_KEY
  2102. je its_a_pointer
  2103. cmp bx,HELP_COMMAND
  2104. je its_a_pointer
  2105. cmp bx,HELP_PARTIALKEY
  2106. je its_a_pointer
  2107. cmp bx,HELP_MULTIKEY
  2108. je its_lpmultikeyhelp
  2109. cmp bx,HELP_SETWINPOS
  2110. je its_lphelpwininfo
  2111. ;; Push dwData as a dword.
  2112. leave_alone:
  2113. push word ptr bp_hwnd
  2114. push dword ptr bp_lpHelpFile
  2115. call MapLS ;PLUGGED
  2116. mov dword ptr bp_lpHelpFileTmp,eax
  2117. push eax
  2118. push word ptr bp_wCommand
  2119. push dword ptr bp_dwData
  2120. jmp call_winhelp
  2121. ;; Push dwData as LPSTR, so call MapLS
  2122. its_a_pointer:
  2123. push word ptr bp_hwnd
  2124. push dword ptr bp_lpHelpFile
  2125. call MapLS ;PLUGGED
  2126. mov dword ptr bp_lpHelpFileTmp,eax
  2127. push eax
  2128. push word ptr bp_wCommand
  2129. push dword ptr bp_dwData
  2130. call MapLS ;PLUGGED
  2131. mov dword ptr bp_dwDataTmp,eax
  2132. push eax
  2133. jmp call_winhelp
  2134. ;;Push dwData as LPMULTIKEYHELP, which needs to be repacked.
  2135. its_lpmultikeyhelp:
  2136. mov esi,bp_dwData
  2137. test esi,esi ;;if zero, just push it
  2138. jz leave_alone
  2139. mov es,FlatData
  2140. mov ax,word ptr es:[esi].mk32_Size
  2141. mov cx,ax ;;save for loop count
  2142. add cx,(size MULTIKEYHELP16 - size MULTIKEYHELP32)
  2143. sub sp,cx ;;subtract adjusted size for 16-bit struct
  2144. mov di,sp ;;will access 16-bit struct thru SS:DI
  2145. mov ss:[di].mk16_Size,cx
  2146. mov cl,es:[esi].mk32_Keylist
  2147. mov ss:[di].mk16_Keylist,cl
  2148. mov cx,ax ;;32-bit struct size
  2149. sub cx,mk32_szKeyphrase ;;skip header fields
  2150. add esi,mk32_szKeyphrase
  2151. add di,mk16_szKeyphrase
  2152. loop_top:
  2153. mov al,es:[esi]
  2154. mov ss:[di],al
  2155. inc esi
  2156. inc di
  2157. loop loop_top
  2158. mov di,sp ;;SP --> base of structure
  2159. jmp short push_with_ssdi
  2160. ;;Push dwData as LPHELPWININFO, which needs to be repacked.
  2161. its_lphelpwininfo:
  2162. mov esi,bp_dwData
  2163. test esi,esi ;;if zero, just push it
  2164. jz leave_alone
  2165. mov es,FlatData
  2166. mov ax,word ptr es:[esi].hwi32_wStructSize
  2167. mov cx,ax ;;save for loop count
  2168. add cx,(size HELPWININFO16 - size HELPWININFO32)
  2169. sub sp,cx ;;subtract adjusted size for 16-bit struct
  2170. mov di,sp ;;will access 16-bit struct thru SS:DI
  2171. mov ss:[di].hwi16_wStructSize,cx
  2172. ;;Truncate all fields except for rgchMember to 16-bits.
  2173. mov cx,word ptr es:[esi].hwi32_x
  2174. mov ss:[di].hwi16_x,cx
  2175. mov cx,word ptr es:[esi].hwi32_y
  2176. mov ss:[di].hwi16_y,cx
  2177. mov cx,word ptr es:[esi].hwi32_dx
  2178. mov ss:[di].hwi16_dx,cx
  2179. mov cx,word ptr es:[esi].hwi32_dy
  2180. mov ss:[di].hwi16_dy,cx
  2181. mov cx,word ptr es:[esi].hwi32_wMax
  2182. mov ss:[di].hwi16_wMax,cx
  2183. mov cx,ax ;;32-bit struct size
  2184. sub cx,hwi32_rgchMember ;;skip header fields
  2185. add esi,hwi32_rgchMember
  2186. add di,hwi16_rgchMember
  2187. loop_top_2:
  2188. mov al,es:[esi]
  2189. mov ss:[di],al
  2190. inc esi
  2191. inc di
  2192. loop loop_top_2
  2193. mov di,sp ;;SP --> base of structure
  2194. push_with_ssdi:
  2195. push word ptr bp_hwnd
  2196. push dword ptr bp_lpHelpFile
  2197. call MapLS ;PLUGGED
  2198. mov dword ptr bp_lpHelpFileTmp,eax
  2199. push eax
  2200. push word ptr bp_wCommand
  2201. push ss ;;SS:DI --> thunked structure
  2202. push di
  2203. call_winhelp:
  2204. call WinHelp
  2205. cwde
  2206. push eax
  2207. push dword ptr bp_lpHelpFileTmp
  2208. call UnmapLS
  2209. push dword ptr bp_dwDataTmp
  2210. call UnmapLS
  2211. pop eax
  2212. ;;The first instruction at Exit_16 clears temporary variables off stack.
  2213. endm
  2214. ;==============================================================================
  2215. ;
  2216. ; InsertMenuItemA()
  2217. ;
  2218. ;==============================================================================
  2219. body_INSERTMENUITEMA macro
  2220. local ConvertMiim
  2221. local MakeCall
  2222. bp_hMenu equ <bp_top+ 0>
  2223. bp_nIndex equ <bp_top+ 4>
  2224. bp_fByPosition equ <bp_top+ 8>
  2225. bp_lpMiim32 equ <bp_top+12>
  2226. bp_SavePtr equ <[bp-4]>
  2227. xor eax,eax
  2228. push eax ;bp_SavePtr
  2229. ; We need scratch space for MENUITEMINFO16
  2230. sub sp, MENUITEMINFO16_SIZE
  2231. mov di, sp
  2232. ; Push 16bit parms
  2233. push word ptr bp_hMenu ;hMenu 16
  2234. push word ptr bp_nIndex ;nIndex 16
  2235. push word ptr bp_fByPosition ;fByPosition 16
  2236. ; Is lpMenuItemInfo NULL?
  2237. mov eax, dword ptr bp_lpMiim32
  2238. test eax, eax
  2239. jnz ConvertMiim
  2240. push eax
  2241. jmp MakeCall
  2242. ConvertMiim:
  2243. push ss ;lpMenuItemInfo 16
  2244. push di
  2245. ; Convert MENUITEMINFO LS
  2246. push eax
  2247. push di
  2248. lea ax, bp_SavePtr
  2249. push ax
  2250. call ConvertMenuItemInfoLS
  2251. MakeCall:
  2252. call InsertMenuItem32
  2253. cwde
  2254. ;Save return value
  2255. push eax
  2256. ;Cleanup
  2257. push dword ptr bp_SavePtr
  2258. call UnMapLS
  2259. ;Restore return value
  2260. pop eax
  2261. endm
  2262. ;==============================================================================
  2263. ;
  2264. ; SetMenuItemInfoA()
  2265. ;
  2266. ;==============================================================================
  2267. body_SETMENUITEMINFOA macro
  2268. local ConvertMiim
  2269. local MakeCall
  2270. bp_hMenu equ <bp_top+ 0>
  2271. bp_nIndex equ <bp_top+ 4>
  2272. bp_fByPosition equ <bp_top+ 8>
  2273. bp_lpMiim32 equ <bp_top+12>
  2274. bp_SavePtr equ <[bp-4]>
  2275. xor eax,eax
  2276. push eax ;bp_SavePtr
  2277. ; We need scratch space for MENUITEMINFO16
  2278. sub sp, MENUITEMINFO16_SIZE
  2279. mov di, sp
  2280. ;Push 16bit parms
  2281. push word ptr bp_hMenu
  2282. push word ptr bp_nIndex
  2283. push word ptr bp_fByPosition
  2284. ; Is lpMenuItemInfo NULL?
  2285. mov eax, dword ptr bp_lpMiim32
  2286. test eax, eax
  2287. jnz ConvertMiim
  2288. push eax
  2289. jmp MakeCall
  2290. ConvertMiim:
  2291. push ss
  2292. push di
  2293. ;Convert MENUITEMINFO LS
  2294. push eax
  2295. push di
  2296. lea ax, bp_SavePtr
  2297. push ax
  2298. call ConvertMenuItemInfoLS
  2299. MakeCall:
  2300. call SetMenuItemInfo32
  2301. cwde
  2302. ;Save return value
  2303. push eax
  2304. ;Cleanup
  2305. push dword ptr bp_SavePtr
  2306. call UnMapLS
  2307. ;Restore return value
  2308. pop eax
  2309. endm
  2310. ;==============================================================================
  2311. ;
  2312. ; GetMenuItemInfoA()
  2313. ;
  2314. ;==============================================================================
  2315. body_GETMENUITEMINFOA macro
  2316. local ConvertMiim
  2317. local MakeCall
  2318. local GetDone
  2319. local MenuTypeData
  2320. local MenuItemCch
  2321. local MenuItemEnd
  2322. bp_hMenu equ <bp_top+ 0>
  2323. bp_nIndex equ <bp_top+ 4>
  2324. bp_fByPosition equ <bp_top+ 8>
  2325. bp_lpMiim32 equ <bp_top+12>
  2326. bp_SavePtr equ <[bp-4]>
  2327. xor eax,eax
  2328. push eax
  2329. ; We need scratch space for MENUITEMINFO16
  2330. sub sp, MENUITEMINFO16_SIZE
  2331. movzx edi, sp
  2332. ; Push 16bit parms
  2333. push word ptr bp_hMenu
  2334. push word ptr bp_nIndex
  2335. push word ptr bp_fByPosition
  2336. ; Is lpMiim32 NULL?
  2337. mov eax, dword ptr bp_lpMiim32
  2338. test eax, eax
  2339. jnz ConvertMiim
  2340. push eax
  2341. jmp MakeCall
  2342. ConvertMiim:
  2343. push ss
  2344. push di
  2345. ; HACK
  2346. ; If MIIM_TYPE is specified in the mask for a 95-sized structure, we
  2347. ; need to add MIIM_STRING and MIIM_BITMAP to the mask so that we fill
  2348. ; those fields
  2349. mov es, FlatData
  2350. mov esi, bp_lpMiim32
  2351. .errnz mii_32_fType - mii_32_cbSize - 8
  2352. mov ecx, dword ptr es:[esi+4]
  2353. test cx, 00010h ; if (fMask & MIIM_TYPE)
  2354. jz @F
  2355. or cx, 001C0h ; fMask |= MIIM_FTYPE |
  2356. mov dword ptr es:[esi+4], ecx ; MIIM_STRING | MIIM_BITMAP
  2357. @@:
  2358. ; Convert MENUITEMINFO LS
  2359. push esi
  2360. push di
  2361. lea ax, bp_SavePtr
  2362. push ax
  2363. call ConvertMenuItemInfoLS
  2364. MakeCall:
  2365. call GetMenuItemInfo32
  2366. cwde
  2367. ; Save return value
  2368. push eax
  2369. ; Is bp_lpMiim32 NULL?
  2370. mov eax, bp_lpMiim32
  2371. test eax, eax
  2372. jz GetDone
  2373. mov es, FlatData ; DO THIS FIRST: FlatData is DS-relative
  2374. push ds
  2375. mov cx, ss
  2376. mov ds, cx
  2377. mov esi, edi
  2378. mov edi, eax ; DO THIS LAST: We need to move DI to SI first
  2379. cld
  2380. ; cbSize - skip it
  2381. add esi, 4
  2382. add edi, 4
  2383. ;fMask - save it
  2384. lodsd ds:[esi]
  2385. mov ecx, eax
  2386. add edi, 4
  2387. ;fType
  2388. xor eax, eax ;Zero out HIWORD
  2389. lodsw ds:[esi]
  2390. mov edx, eax ; save fType
  2391. stosd es:[edi]
  2392. ;fState,wID,hSubMenu,hbmpChecked,hbmpUnchecked
  2393. push ecx
  2394. ncopyzx 5
  2395. pop ecx
  2396. ;dwItemData
  2397. copyd
  2398. test cx, 00010h ; if (!(fMask & MIIM_TYPE))
  2399. jz SkipTypeData ; goto SkipTypeData
  2400. mov eax,es:[edi-020h]
  2401. and ax,0FE3Fh ; fMask &= ~(MIIM_FTYPE | MIIM_STRING |
  2402. mov es:[edi-020h],eax ; MIIM_BITMAP);
  2403. xor eax,eax
  2404. mov ax,ds:[esi+006h]
  2405. or ax,ax ; if (!lpmii16->hbmpItem)
  2406. jz CheckString ; goto CheckString
  2407. stosd es:[edi] ; lpmii32->dwTypeData = lpmii16->hbmpItem
  2408. or dx, 00004h ; lpmii32->fType |= MFT_BITMAP
  2409. mov es:[edi-020h], edx
  2410. jmp MenuItemCch
  2411. CheckString:
  2412. mov ax,ds:[esi+004h]
  2413. or ax,ax ; if (!lpmii16->cch)
  2414. jz ZeroTypeData ; goto ZeroTypeData
  2415. SkipTypeData:
  2416. add esi, 4 ; it's a string -- so leave it as is
  2417. add edi, 4
  2418. jmp MenuItemCch
  2419. ZeroTypeData:
  2420. add esi, 4
  2421. xor eax,eax
  2422. stosd es:[edi]
  2423. MenuItemCch:
  2424. copyzx
  2425. ; Check hbmpItem
  2426. test cx, 00010h ; if ((fMask & MIIM_TYPE))
  2427. jnz MenuItemEnd ; skip hbmpItem
  2428. mov eax,es:[edi-02ch]
  2429. cmp eax, 030h ; if old MENUITEMINFO
  2430. jc MenuItemEnd ; skip hbmpItem
  2431. mov eax,es:[edi-028h]
  2432. test ax,080h ; if not MIIM_BITMAP
  2433. jz MenuItemEnd ; skip hbmpItem
  2434. copyzx ; copy hbmpItem
  2435. MenuItemEnd:
  2436. pop ds
  2437. ; Unmap pointer since we mapped dwTypeData no matter what!
  2438. push dword ptr bp_SavePtr
  2439. call UnmapLS
  2440. GetDone:
  2441. ; Restore return value
  2442. pop eax
  2443. endm
  2444. ;------------------------------------------------------------------------------
  2445. ; RET__GETDLGITEMINT
  2446. ;
  2447. ; Either zero-extend or sign-extend ax into eax, depending on
  2448. ; the value of the "bSigned" argument.
  2449. ;------------------------------------------------------------------------------
  2450. RET__GETDLGITEMINT macro
  2451. local exit
  2452. local unsigned
  2453. cmp word ptr [bp_top + 12],0 ; bSigned
  2454. je unsigned
  2455. cwde
  2456. jmp exit
  2457. unsigned:
  2458. movzx eax,ax
  2459. exit:
  2460. endm ;RET__GETDLGITEMINT
  2461. ;==============================================================================
  2462. ;
  2463. ; mouse_event
  2464. ;
  2465. ;==============================================================================
  2466. body_MOUSE_EVENT macro
  2467. bp_dwFlags equ <bp_top+ 0>
  2468. bp_dx equ <bp_top+ 4>
  2469. bp_dy equ <bp_top+ 8>
  2470. bp_cButtons equ <bp_top+12>
  2471. bp_dwExtraInfo equ <bp_top+16>
  2472. mov ax,word ptr bp_dwFlags
  2473. mov bx,word ptr bp_dx
  2474. mov cx,word ptr bp_dy
  2475. mov dx,word ptr bp_cButtons
  2476. mov si,word ptr bp_dwExtraInfo
  2477. mov di,word ptr bp_dwExtraInfo+2
  2478. call mouse_event
  2479. endm
  2480. ;==============================================================================
  2481. ;
  2482. ; keybd_event
  2483. ;
  2484. ;==============================================================================
  2485. body_KEYBD_EVENT macro
  2486. bp_dwVirtualKey equ <bp_top+ 0>
  2487. bp_dwScanCode equ <bp_top+ 4>
  2488. bp_dwFlags equ <bp_top+ 8>
  2489. bp_dwExtraInfo equ <bp_top+12>
  2490. xor ax,ax
  2491. xor bx,bx
  2492. mov al,byte ptr bp_dwVirtualKey
  2493. test word ptr bp_dwFlags,KEYEVENTF_KEYUP
  2494. jz keybd_keydown
  2495. mov ah,80
  2496. keybd_keydown:
  2497. mov bl,byte ptr bp_dwScanCode
  2498. test word ptr bp_dwFlags,KEYEVENTF_EXTENDEDKEY
  2499. jz keybd_notextendedkey
  2500. mov bh,1
  2501. keybd_notextendedkey:
  2502. mov si,word ptr bp_dwExtraInfo
  2503. mov di,word ptr bp_dwExtraInfo+2
  2504. call keybd_event
  2505. endm
  2506. ;==============================================================================
  2507. ;
  2508. ; AlignRects()
  2509. ;
  2510. ;==============================================================================
  2511. body_ALIGNRECTS macro
  2512. local done
  2513. local ar_loop1
  2514. local ar_loop2
  2515. bp_lprect equ <bp_top+ 0>
  2516. bp_count equ <bp_top+ 4>
  2517. bp_iPrimary equ <bp_top+ 8>
  2518. bp_flags equ <bp_top+12>
  2519. bp_hmem16Tmp equ < word ptr [bp-2]>
  2520. bp_Ret equ < word ptr [bp-4]>
  2521. bp_lprectTmp equ < dword ptr [bp-8]>
  2522. xor eax,eax
  2523. push eax
  2524. push eax
  2525. mov eax,bp_count ;prepare for error
  2526. test eax,eax
  2527. jz done
  2528. push byte ptr GPTR
  2529. shl eax, 3
  2530. push eax
  2531. call GlobalAlloc ;if no scratch space, return no hmenu
  2532. movzx eax,ax ;prepare for error
  2533. test ax,ax
  2534. jz done
  2535. mov bp_hmem16Tmp,ax
  2536. push dword ptr bp_lprect
  2537. call MapLS ;PLUGGED
  2538. mov dword ptr bp_lprectTmp,eax
  2539. movzx edi, ax
  2540. mov ax,dx
  2541. mov es, bp_hmem16Tmp
  2542. xor esi,esi
  2543. mov ecx,bp_count
  2544. shl ecx, 2
  2545. push ecx
  2546. push edi
  2547. push esi
  2548. push ax
  2549. push es
  2550. push ds
  2551. mov ds, ax
  2552. cld
  2553. ar_loop1:
  2554. lodsd ds:[esi]
  2555. stosw es:[di]
  2556. loop ar_loop1
  2557. pop ds
  2558. push bp_hmem16Tmp ;cannot be null
  2559. push 0
  2560. push word ptr bp_count
  2561. push word ptr bp_iPrimary
  2562. push word ptr bp_flags
  2563. call CleanUpDesktopRectangles
  2564. mov bp_Ret,ax
  2565. pop ax
  2566. pop es
  2567. pop edi
  2568. pop esi
  2569. pop ecx
  2570. push ds
  2571. mov ds, ax
  2572. cld
  2573. ar_loop2:
  2574. lodsw ds:[si]
  2575. cwde
  2576. stosd es:[edi]
  2577. loop ar_loop2
  2578. pop ds
  2579. push bp_hmem16Tmp ;cannot be null
  2580. call GlobalFree
  2581. push dword ptr bp_lprectTmp
  2582. call UnMapLS
  2583. movzx eax, bp_Ret
  2584. done:
  2585. endm
  2586. ;==============================================================================
  2587. ;
  2588. ; FlashWindowEx()
  2589. ;
  2590. ;==============================================================================
  2591. body_FLASHWINDOWEX macro
  2592. local done
  2593. bp_lpfw equ <bp_top+ 0>
  2594. bp_fwSave equ < word ptr [bp-2]>
  2595. xor eax,eax
  2596. push eax ; lpfw->cbSize, lpfw->hwnd
  2597. push eax ; lpfw->dwFlags
  2598. push eax ; lpfw->uCount
  2599. mov esi,bp_lpfw
  2600. test esi,esi ;;if zero, just push it
  2601. jz done
  2602. mov es,FlatData
  2603. mov ecx, es:[esi] ; get fw32_cbSize to ecx
  2604. cmp cx, size FLASHWINFO32
  2605. jnz done
  2606. add esi, 4
  2607. mov di, sp
  2608. mov ss:[di].fw16_cbSize, (size FLASHWINFO16)
  2609. lodsd es:[esi] ; get fw32_hwnd to eax
  2610. mov ss:[di].fw16_hwnd, ax
  2611. lodsd es:[esi] ; get fw32_dwFlags to eax
  2612. mov ss:[di].fw16_dwFlags, eax
  2613. lodsd es:[esi] ; get fw32_uCount to eax
  2614. mov ss:[di].fw16_uCount, ax
  2615. push ss
  2616. push di
  2617. call FlashWindowEx
  2618. done:
  2619. endm
  2620. endif ;IS_16