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.

2396 lines
67 KiB

  1. CodeData equ <THUNK16BCodeData>
  2. include thkrp.inc
  3. include cbcheck.inc
  4. include thkframe.inc
  5. include public.inc
  6. include thkmacro.inc
  7. include struc.inc
  8. include cbcid.inc
  9. include gdicbid.inc
  10. externDef PrivateEscape:near16
  11. externDef CALLBACK_BODY_16:far16
  12. externDef Escape:far16
  13. externDef AllocCallback:far16
  14. externDef MapLS:far16
  15. externDef UnmapLS:far16
  16. externDef GlobalAlloc:far16
  17. externDef GlobalSize:far16
  18. externDef GlobalFree:far16
  19. externDef GlobalLock:far16
  20. externDef GlobalUnlock:far16
  21. externDef GetTextExtentPoint:far16
  22. ifdef DEBUG
  23. externDef _wsprintf:far16
  24. externDef OutputDebugString:far16
  25. endif
  26. externDef AllocSelectorArray:far16
  27. externDef SetSelectorBase:far16
  28. externDef SetSelectorLimit:far16
  29. externDef FreeSelector:far16
  30. externDef SelectorAccessRights:far16
  31. externDef GetLastError:far16
  32. ilObjType equ 2
  33. ObjPrivate equ 2000H
  34. Stock equ 8000H
  35. INT_OBJ_FLAGS equ (Stock or ObjPrivate)
  36. INT_MIN_OBJ equ 4f47h
  37. INT_OBJ_PEN equ 4f47h
  38. INT_OBJ_BRUSH equ 4f48h
  39. INT_OBJ_FONT equ 4f49h
  40. INT_OBJ_PALETTE equ 4f4ah
  41. INT_OBJ_BITMAP equ 4f4bh
  42. INT_OBJ_RGN equ 4f4ch
  43. INT_OBJ_DC equ 4f4dh
  44. INT_OBJ_IC equ 4f4eh
  45. INT_OBJ_DISABLED_DC equ 4f4fh
  46. INT_OBJ_METADC equ 4f50h
  47. INT_OBJ_METAFILE equ 4f51h
  48. INT_OBJ_MF equ 4f52h
  49. INT_MAX_OBJ equ 4f52h
  50. ;; Writes message to debug port.
  51. ;;
  52. ;; Usage:
  53. ;; DPRINT "I'm feeling buggy."
  54. ;;
  55. DPRINT macro string
  56. local mes, skip_mes
  57. jmp skip_mes
  58. mes db &string&,13,10,0
  59. skip_mes:
  60. push eax ;Save all registers not preserved by PASCAL format.
  61. push ebx
  62. push ecx
  63. push edx
  64. push cs ;Arg: OutputDebugString(lpstr)
  65. push offset mes
  66. call OutputDebugString
  67. pop edx
  68. pop ecx
  69. pop ebx
  70. pop eax
  71. endm ;DPRINT
  72. RECT16_SIZE equ 8
  73. POINT16_SIZE equ 4
  74. LOGFONT32_SIZE equ 60
  75. BITMAP32_SIZE equ 24
  76. DIBSECTION32_SIZE equ 84
  77. BITMAP16 struc
  78. bm16_Type dw ?
  79. bm16_Width dw ?
  80. bm16_Height dw ?
  81. bm16_WidthBytes dw ?
  82. bm16_Planes db ?
  83. bm16_BitsPixel db ?
  84. bm16_Bits dd ?
  85. BITMAP16 ends
  86. BITMAP32 struc
  87. bm32_Type dd ?
  88. bm32_Width dd ?
  89. bm32_Height dd ?
  90. bm32_WidthBytes dd ?
  91. bm32_Planes dw ?
  92. bm32_BitsPixel dw ?
  93. bm32_Bits dd ?
  94. BITMAP32 ends
  95. ABC16 struc
  96. abcA dw ?
  97. abcB dw ?
  98. abcC dw ?
  99. ABC16 ends
  100. fLocalFlag equ fGdiLog16
  101. ; Corresponds to the 32 bit BITMAPINFOHEADER structure.
  102. BMIH32 struc
  103. bi32_Size dd ?
  104. bi32_Width dd ?
  105. bi32_Height dd ?
  106. bi32_Planes dw ?
  107. bi32_BitCount dw ?
  108. bi32_Compression dd ?
  109. bi32_SizeImage dd ?
  110. bi32_XPelsPerMeter dd ?
  111. bi32_YPelsPerMeter dd ?
  112. bi32_ClrUsed dd ?
  113. bi32_ClrImportant dd ?
  114. BMIH32 ends
  115. ; Corresponds to the 32-bit BITMAPCOREHEADER structure.
  116. BMCH32 struc
  117. bc32_Size dd ?
  118. bc32_Width dw ?
  119. bc32_Height dw ?
  120. bc32_Planes dw ?
  121. bc32_BitCount dw ?
  122. BMCH32 ends
  123. ; Corresponds to the 32-bit BITMAPV4HEADER structure.
  124. BMV4H32 struc
  125. bv432_Size dd ?
  126. bv432_Width dd ?
  127. bv432_Height dd ?
  128. bv432_Planes dw ?
  129. bv432_BitCount dw ?
  130. bv432_Compression dd ?
  131. bv432_SizeImage dd ?
  132. bv432_XPelsPerMeter dd ?
  133. bv432_YPelsPerMeter dd ?
  134. bv432_ClrUsed dd ?
  135. bv432_ClrImportant dd ?
  136. bV432_RedMask dd ?
  137. bV432_GreenMask dd ?
  138. bV432_BlueMask dd ?
  139. bV432_AlphaMask dd ?
  140. bV432_CSType dd ?
  141. bV4Endpoints db 36 dup (?)
  142. bV4GammaRed dd ?
  143. bV4GammaGreen dd ?
  144. bV4GammaBlue dd ?
  145. BMV4H32 ends
  146. BMV5H32 struc
  147. bv532_Size dd ?
  148. bv532_Width dd ?
  149. bv532_Height dd ?
  150. bv532_Planes dw ?
  151. bv532_BitCount dw ?
  152. bv532_Compression dd ?
  153. bv532_SizeImage dd ?
  154. bv532_XPelsPerMeter dd ?
  155. bv532_YPelsPerMeter dd ?
  156. bv532_ClrUsed dd ?
  157. bv532_ClrImportant dd ?
  158. bV532_RedMask dd ?
  159. bV532_GreenMask dd ?
  160. bV532_BlueMask dd ?
  161. bV532_AlphaMask dd ?
  162. bV532_CSType dd ?
  163. bV5Endpoints db 36 dup (?)
  164. bV5GammaRed dd ?
  165. bV5GammaGreen dd ?
  166. bV5GammaBlue dd ?
  167. bV5Intent dd ?
  168. bV5ProfileData dd ?
  169. bV5ProfileSize dd ?
  170. bV5Reserved dd ?
  171. BMV5H32 ends
  172. THUNK16B SEGMENT WORD USE16 PUBLIC 'CODE'
  173. IF 0
  174. REPACK_DEVMODE_32_16 macro
  175. externDef Repack_Devmode_32_16_Proc:near16
  176. call Repack_Devmode_32_16_Proc
  177. endm
  178. ;-----------------------------------------------------------------------;
  179. ; Repack_Pevmode_32_16_Proc
  180. ;
  181. ; Entry:
  182. ; DS:ESI --> 32-bit source (ESI might be flat offset)
  183. ; ES:EDI --> 16-bit destination (EDI is zero-extended from DI)
  184. ; direction flag cleared
  185. ;-----------------------------------------------------------------------;
  186. Repack_Devmode_32_16_Proc proc near public
  187. ; local done
  188. ;Move the common part as a single block move.
  189. MoveBytes <(size DEVMODECOMMON)>
  190. ;Update the dmSize field
  191. ;;;; mov es:[di].(dmSize - (size DEVMODECOMMON)),size DEVMODE16
  192. ;!!!Clear out any win32-only flags
  193. ;and es:[di].(dmFields - (size DEVMODECOMMON)),0FFFFh
  194. ;Insert win16-only fields. EDI points to the byte after
  195. ;DEVMODECOMMON. Afterwards, will point to byte after DEVMODE16.
  196. ;ZeroBytes <((size DEVMODE16) - (size DEVMODECOMMON))>
  197. ;Skip over the extra win32 fields. ESI still points to the byte
  198. ;after DEVMODECOMMON.
  199. add esi,(size DEVMODE32) - (size DEVMODECOMMON)
  200. ;Move the driver-dependent part. EDI points to the byte after
  201. ;DEVMODE16.
  202. mov cx,es:[di].(dmDriverExtra - (size DEVMODE16))
  203. jcxz done
  204. movzx ecx,cx
  205. mov edx,ecx
  206. shr cx,2
  207. and dx,3
  208. rep movs dword ptr es:[edi],dword ptr ds:[esi]
  209. mov cx,dx
  210. rep movs byte ptr es:[edi],byte ptr ds:[esi]
  211. done:
  212. ret
  213. Repack_Devmode_32_16_Proc endp
  214. ENDIF
  215. DIB_BITS_SIZE macro
  216. externDef Dib_Bits_Size_Proc:near16
  217. call Dib_Bits_Size_Proc
  218. endm
  219. ;-----------------------------------------------------------------------;
  220. ; Dib_Bits_Size_Proc
  221. ;
  222. ; Inputs:
  223. ; eax: linear address of 32-bit BITMAPINFOHEADER (or BITMAPCOREHEADER)
  224. ; struct.
  225. ;
  226. ; Output:
  227. ; ecx: inferred size of bitmap data, or 0 for failure.
  228. ;
  229. ; Formula is:
  230. ; if bi32_Compression != (BI_RGB | BI_BITFIELDS)
  231. ; size = bi32_SizeImage
  232. ; else
  233. ; size = ((Width * BitCount + 31) / 32) * 4 * Height * Planes
  234. ;-----------------------------------------------------------------------;
  235. Dib_Bits_Size_Proc proc near public
  236. ; local exit,fail_exit,use_formula
  237. ; local bitmapcoreheader,bitmapinfoheader
  238. push ds
  239. mov ds,FlatData
  240. mov esi,eax
  241. ; DPRINT "DIB_BIT_SIZE: Computing bitmap data size."
  242. ; int 3
  243. mov eax, dword ptr [esi]
  244. cmp eax, SIZEOF BMIH32
  245. je bitmapinfoheader
  246. cmp eax, SIZEOF BMV4H32
  247. je bitmapinfoheader
  248. cmp eax, SIZEOF BMV5H32
  249. je bitmapinfoheader
  250. cmp eax, SIZEOF BMCH32
  251. je bitmapcoreheader
  252. ; int 3
  253. jmp fail_exit
  254. bitmapcoreheader:
  255. movzx eax, [esi].bc32_Width
  256. movzx ebx,[esi].bc32_BitCount
  257. mul ebx
  258. jc fail_exit
  259. add eax, 31
  260. jc fail_exit
  261. shr eax, 5 ;Divide by 32 (and exorcise remainder!)
  262. shl eax, 2 ;Multiply by 4
  263. movzx ecx, [esi].bc32_Height
  264. mul ecx
  265. jc fail_exit
  266. movzx ebx,[esi].bc32_Planes
  267. mul ebx
  268. mov ecx,eax
  269. jnc exit
  270. jmp fail_exit
  271. bitmapinfoheader:
  272. cmp dword ptr [esi].bi32_Compression, BI_RGB
  273. je use_formula
  274. cmp dword ptr [esi].bi32_Compression, BI_BITFIELDS
  275. je use_formula
  276. mov ecx, [esi].bi32_SizeImage
  277. jmp exit
  278. use_formula:
  279. ; DPRINT "DIB_BIT_SIZE: Using formula."
  280. mov eax, [esi].bi32_Width
  281. xor ebx,ebx
  282. mov bx,[esi].bi32_BitCount
  283. mul ebx
  284. jc fail_exit
  285. add eax, 31
  286. jc fail_exit
  287. shr eax, 5 ;Divide by 32 (and exorcise remainder!)
  288. shl eax, 2 ;Multiply by 4
  289. mov ecx,[esi].bi32_Height
  290. test ecx,ecx ;top down dibs ?
  291. jns got_height
  292. neg ecx ;make it positive.
  293. got_height:
  294. mul ecx
  295. jc fail_exit
  296. xor ebx,ebx
  297. mov bx,[esi].bi32_Planes
  298. mul ebx
  299. mov ecx,eax
  300. jnc exit
  301. fail_exit:
  302. xor ecx,ecx
  303. exit:
  304. ; int 3
  305. pop ds
  306. ret
  307. Dib_Bits_Size_Proc endp
  308. THUNK16B ENDS
  309. ;-----------------------------------------------------------------------;
  310. ; UNPACK__GETTEXTMETRICSA_lpMetrics
  311. ;-----------------------------------------------------------------------;
  312. UNPACK__GETTEXTMETRICSA_lpMetrics macro x, y
  313. PACK_TEXTMETRIC_16_32
  314. endm
  315. ;-----------------------------------------------------------------------;
  316. ; PUSH__SETABORTPROC_pfnAbort
  317. ;-----------------------------------------------------------------------;
  318. PUSH__SETABORTPROC_pfnAbort macro iOffset, iTempOffset
  319. push dword ptr [bp+iOffset]
  320. push dword ptr CBID_ABORTPROC
  321. call AllocCallback
  322. push dx
  323. push ax
  324. endm
  325. ;-----------------------------------------------------------------------;
  326. ; PACK__STARTDOCA_lpdi
  327. ;-----------------------------------------------------------------------;
  328. OLD_DOCINFO_SIZE equ 12
  329. NEW_DOCINFO_SIZE equ 20
  330. PACK__STARTDOCA_lpdi macro iOffset, iTempOffset
  331. lods dword ptr ds:[esi]
  332. ; ax == lpdi->cbSize
  333. ; if cbSize is not the new sizeof(DOCINFO),
  334. ; assume lpdi is a 3.x style DOCINFO
  335. cmp ax,NEW_DOCINFO_SIZE
  336. je @F
  337. mov ax,OLD_DOCINFO_SIZE
  338. @@:
  339. push ax
  340. sub ax,2
  341. stosw ;;cbSize (int)
  342. MAP_POINTER LOCAL__STARTDOCA_lpszDocNameTemp ;;PLUGGED lpszDocName
  343. MAP_POINTER LOCAL__STARTDOCA_lpszOutputTemp ;;PLUGGED lpszOutput
  344. pop ax
  345. cmp ax,OLD_DOCINFO_SIZE
  346. je @F
  347. MAP_POINTER LOCAL__STARTDOCA_lpszDatatypeTemp
  348. lods dword ptr ds:[esi]
  349. stosd ;;fwType
  350. @@:
  351. endm
  352. ;-----------------------------------------------------------------------;
  353. ; UNPACK__STARTDOCA_lpdi
  354. ;-----------------------------------------------------------------------;
  355. UNPACK__STARTDOCA_lpdi macro iOffset, iTempOffset
  356. pushd LOCAL__STARTDOCA_lpszDocNameTemp
  357. call UnmapLS
  358. pushd LOCAL__STARTDOCA_lpszOutputTemp
  359. call UnmapLS
  360. pushd LOCAL__STARTDOCA_lpszDatatypeTemp
  361. call UnmapLS
  362. endm
  363. ;-----------------------------------------------------------------------;
  364. ; body_THKESCAPE
  365. ;-----------------------------------------------------------------------;
  366. body_THKESCAPE macro
  367. bp_hdc equ <bp_top>
  368. bp_nEscape equ <bp_top+ 4>
  369. bp_cbInput equ <bp_top+ 8>
  370. bp_lpInData equ <bp_top+12>
  371. bp_lpOutData equ <bp_top+16>
  372. push word ptr bp_hdc
  373. push word ptr bp_nEscape
  374. push word ptr bp_cbInput
  375. push dword ptr bp_lpInData
  376. push dword ptr bp_lpOutData
  377. call PrivateEscape
  378. endm
  379. ;-----------------------------------------------------------------------;
  380. ; body_SETMETAFILEBITSEX
  381. ;-----------------------------------------------------------------------;
  382. body_SETMETAFILEBITSEX macro
  383. local exit
  384. bp_nSize equ <bp_top>
  385. bp_lpvData equ <bp_top+4>
  386. bp_hmem equ <[bp-2]>
  387. sub sp,2 ;make space for bp_hmem
  388. ; Protect ourselves -- no pointer or no bytes to copy mean no reason to
  389. ; call Win3.1.
  390. mov eax,bp_lpvData
  391. or eax,eax
  392. jz exit
  393. mov eax,bp_nSize
  394. or eax,eax
  395. jz exit
  396. ; Allocate a global handle to pass to Win3.1. If can't get handle return
  397. ; error.
  398. ;
  399. ;!!! This memory should be deleted in DeleteMetaFile. If the app never
  400. ; calls DeletMetaFile, it will be deleted when the process dies because
  401. ; GlobalAlloc tags the memory with the process that allocated it.
  402. pushw GMEM_MOVEABLE
  403. push eax
  404. call GlobalAlloc
  405. movzx eax,ax ;prepare for error return code
  406. or ax,ax
  407. jz exit
  408. ; Copy the data from the input buffer to the global memory we allocated.
  409. mov bp_hmem,ax
  410. push ds
  411. mov ds,FlatData ;DS:ESI --> source
  412. mov esi,bp_lpvData ;
  413. mov es,ax ;ES:EDI --> destination
  414. xor edi,edi ;
  415. ; Compute dword (ECX) and byte (DX) counts. We can use DX because it will
  416. ; contain 0, 1, or 2. When we copy bytes, the high word of ECX will already
  417. ; be zero from the dword-copy, so we only have to update CX for the
  418. ; byte-copy.
  419. mov ecx,dword ptr bp_nSize
  420. mov dx,cx
  421. shr ecx,2
  422. and dx,3
  423. cld
  424. rep movs dword ptr es:[edi], dword ptr ds:[esi]
  425. mov cx,dx
  426. rep movs byte ptr es:[edi], byte ptr ds:[esi]
  427. pop ds
  428. ; Since Win32 GetMetaFileBitsEx actually returns the bits for a disk
  429. ; metafile, we must patch the metafile header now. (This is compatible
  430. ; with NT.)
  431. xor edi,edi
  432. mov word ptr es:[edi], 1 ; METAHEADER.mtType = MEMORYMETAFILE
  433. ; !!! SetMetaFileBitsBetter just returns the handle passed in. With
  434. ; this assumption, we will be passing back the handle allocated above
  435. ; with GlobalAlloc.
  436. push word ptr bp_hmem
  437. call SetMetaFileBitsBetter
  438. movzx eax,ax ;prepare return code
  439. ; EAX = return code (global memory handle)
  440. exit:
  441. endm
  442. ;-----------------------------------------------------------------------;
  443. ; CREATEBITMAP_COMMON:
  444. ;
  445. ; Common thunk code for CreateBitmap() and CreateBitmapIndirect().
  446. ; Tiles the bit buffer (if any), creates equivalent Win16 BITMAP
  447. ; structure on stack and calls Win16 CreateBitmapIndirect().
  448. ;
  449. ; Note: All device-dependent bitmap scan lines are word-padded (not
  450. ; dword-padded) even in Win32 (decided this with DavidW: 2/93)
  451. ;
  452. ; Entry points:
  453. ; eax = 0:32 pointer to Win32 BITMAP structure.
  454. ;
  455. ; Exit:
  456. ; eax = result of Win16 CreateBitmapIndirect() if successfully
  457. ; thunked arguments. 0 if unsuccessful.
  458. ;
  459. ;-----------------------------------------------------------------------;
  460. CREATEBITMAP_COMMON macro
  461. local exit,fail_exit,dwFreeInfo,wOldDS
  462. ; DPRINT "Just entered CREATEBITMAP_COMMON. eax -> Win32 BITMAP"
  463. ; int 3
  464. push bp
  465. mov bp,sp
  466. push ds ;Save ds
  467. xor edx,edx ;New local (to store result of TILE_BUFFER)
  468. push edx
  469. wOldDS equ word ptr [bp - 2]
  470. dwFreeInfo equ dword ptr [bp - 6]
  471. mov ds,FlatData
  472. mov esi,eax
  473. ;Infer the size of the bit buffer:
  474. ;
  475. ; size = ((width * bitspixel + 15) / 16) * 2 * height * planes
  476. ;
  477. mov ax,[esi].bm32_BitsPixel
  478. movzx eax,ax
  479. mul [esi].bm32_Width
  480. jc fail_exit
  481. add eax,15
  482. jc fail_exit
  483. shr eax,4
  484. shl eax,1
  485. mov ebx,eax ;Tuck WidthBytes in safe register
  486. mul [esi].bm32_Height
  487. jc fail_exit
  488. xor ecx,ecx
  489. mov cx,[esi].bm32_Planes
  490. mul ecx
  491. jc fail_exit
  492. mov ecx,eax
  493. ; assert(ecx == size of bm32_Bits buffer)
  494. sub sp,14 ;make room for a Win16 BITMAP structure
  495. mov ax,ss
  496. mov es,ax
  497. mov di,sp
  498. ; repack Win32 BITMAP (ds:esi) into Win16 BITMAP (es:di)
  499. lodsd ds:[esi] ;Type (DWORD->WORD)
  500. stosw es:[di]
  501. lodsd ds:[esi] ;Width (DWORD->WORD)
  502. stosw es:[di]
  503. lodsd ds:[esi] ;Height (DWORD->WORD)
  504. stosw es:[di]
  505. add esi,4 ;WidthBytes (DWORD->WORD)
  506. mov ax,bx ; Replace with our own computed value
  507. stosw es:[di]
  508. lodsw ds:[esi] ;Planes (WORD->BYTE)
  509. stosb es:[di]
  510. lodsw ds:[esi] ;BitsPixel (WORD->BYTE)
  511. stosb es:[di]
  512. lodsd ds:[esi] ;lpBits (0:32 -> tiled 0:16)
  513. ; DPRINT "CREATEBITMAP_COMMON: About to tile buffer"
  514. ; int 3
  515. push es ;Save registers that TILE_BUFFER
  516. push di ; trashes
  517. ; assert (eax == 0:32 ptr to bit data, ecx == inferred size of bit buffer)
  518. TILE_BUFFER
  519. pop di
  520. pop es
  521. jc fail_exit
  522. mov dwFreeInfo,ecx
  523. stosd es:[di]
  524. mov bx,sp
  525. push ss ;Arg: CreateBitmapIndirect(lpbm)
  526. push bx ;^^^
  527. ; DPRINT "CREATEBITMAP_COMMON: About to call Win16 API."
  528. ; int 3
  529. call CreateBitmapIndirect
  530. movzx eax,ax
  531. push eax ;save API result
  532. mov ecx,dwFreeInfo
  533. UNTILE_BUFFER
  534. pop eax ;restore API result
  535. jmp exit
  536. fail_exit:
  537. xor eax,eax
  538. exit:
  539. mov ds,wOldDS ;do this before restoring sp!
  540. mov sp,bp
  541. pop bp
  542. endm; CREATEBITMAP_COMMON
  543. ;-----------------------------------------------------------------------;
  544. ; body_CREATEBITMAPINDIRECT
  545. ;-----------------------------------------------------------------------;
  546. body_CREATEBITMAPINDIRECT macro
  547. mov eax,[bp_top] ;eax == 0:32 pointer to Win32 BITMAP
  548. CREATEBITMAP_COMMON
  549. endm
  550. ;-----------------------------------------------------------------------;
  551. ; body_CREATEBITMAP
  552. ;
  553. ; Create equivalent Win32 BITMAP structure on stack and call
  554. ; same code that CreateBitmapIndirect() does.
  555. ;-----------------------------------------------------------------------;
  556. body_CREATEBITMAP macro
  557. local bp_nWidth, bp_nHeight, bp_nPlanes, bp_nBitCount, bp_lpBits
  558. bp_nWidth equ [bp_top]
  559. bp_nHeight equ [bp_top+4]
  560. bp_nPlanes equ [bp_top+8]
  561. bp_nBitCount equ [bp_top+12]
  562. bp_lpBits equ [bp_top+16]
  563. ; Create an equivalent Win32 BITMAP structure on stack and pass it
  564. ; to CreateBitmapIndirect
  565. pushd bp_lpBits
  566. pushw bp_nBitCount
  567. pushw bp_nPlanes
  568. pushd 0 ;Dummy WidthBytes (CREATEBITMAPCOMMON ignores it)
  569. pushd bp_nHeight
  570. pushd bp_nWidth
  571. pushd 0 ;Type
  572. mov ax,sp
  573. push ss ;Arg: MapSL(sel:off)
  574. push ax ;^^^
  575. call MapSL ;OK: ss is never a movable handle here.
  576. CREATEBITMAP_COMMON
  577. mov sp,bp
  578. endm ;body_CREATEBITMAP
  579. ;-------------------------------------------------------------------------
  580. ; RAWPACK_GETBITMAPBITS
  581. ;-------------------------------------------------------------------------
  582. RAWPACK__GETBITMAPBITS_lpBits macro lpBits,lp1616
  583. local exit,fail_exit
  584. mov eax,[bp + &lpBits]
  585. or eax,eax
  586. jz fail_exit
  587. mov ecx,[bp_top + 4] ;dwCount (size of buffer)
  588. or ecx,ecx
  589. jz fail_exit ;is this the right action??
  590. TILE_BUFFER
  591. mov [bp - &lp1616&],eax
  592. mov LOCAL__GETBITMAPBITS_dwFreeInfo,ecx
  593. jmp exit
  594. fail_exit:
  595. mov sp,bp
  596. xor eax,eax
  597. ERRCHK_EXIT 0,87,Exit_12
  598. exit:
  599. endm ;RAWPACK_GETBITMAPBITS_lpBits
  600. ;-------------------------------------------------------------------------
  601. ; RAWUNPACK_GETBITMAPBITS
  602. ;-------------------------------------------------------------------------
  603. RAWUNPACK__GETBITMAPBITS_lpBits macro lpBits,lp1616
  604. mov ecx,LOCAL__GETBITMAPBITS_dwFreeInfo
  605. UNTILE_BUFFER
  606. endm ;RAWUNPACK_GETBITMAPBITS
  607. ;-------------------------------------------------------------------------
  608. ; RAWPACK_SETBITMAPBITS
  609. ;-------------------------------------------------------------------------
  610. RAWPACK__SETBITMAPBITS_lpBits macro lpBits,lp1616
  611. local exit,fail_exit
  612. mov eax,[bp + &lpBits]
  613. or eax,eax
  614. jz fail_exit
  615. mov ecx,[bp_top + 4] ;dwCount (size of buffer)
  616. or ecx,ecx
  617. jz fail_exit ;(fail return or 0 bytes copied: it's the same)
  618. TILE_BUFFER
  619. mov [bp - &lp1616&],eax
  620. mov LOCAL__SETBITMAPBITS_dwFreeInfo,ecx
  621. jmp exit
  622. fail_exit:
  623. mov sp,bp
  624. xor eax,eax
  625. ERRCHK_EXIT 0,87,Exit_12
  626. exit:
  627. endm ;RAWPACK_SETBITMAPBITS
  628. ;-------------------------------------------------------------------------
  629. ; RAWUNPACK_SETBITMAPBITS
  630. ;-------------------------------------------------------------------------
  631. RAWUNPACK__SETBITMAPBITS_lpBits macro lpBits,lp1616
  632. mov ecx,LOCAL__SETBITMAPBITS_dwFreeInfo
  633. UNTILE_BUFFER
  634. endm ;RAWUNPACK_SETBITMAPBITS
  635. ;-----------------------------------------------------------------------;
  636. ; body_DELETEMETAFILE
  637. ;-----------------------------------------------------------------------;
  638. body_DELETEMETAFILE macro
  639. local exit
  640. bp_hmf equ <bp_top>
  641. ; !!! Determine whether or not to delete directly!
  642. push bp_hmf
  643. call DeleteMetaFile
  644. cwde
  645. exit:
  646. endm
  647. IF 0
  648. ;-----------------------------------------------------------------------;
  649. ; body_CREATEICA
  650. ;-----------------------------------------------------------------------;
  651. body_CREATEICA macro
  652. local exit
  653. local repack_devmode
  654. local push_callframe
  655. bp_lpszDriver equ <bp_top>
  656. bp_lpszDevice equ <bp_top+4>
  657. bp_lpszOutput equ <bp_top+8>
  658. bp_lpdm equ <bp_top+12>
  659. bp_lpdmTmp equ <dword ptr [bp-4]>
  660. bp_hdm equ < word ptr [bp-6]>
  661. bp_lpszDriverTmp equ <dword ptr [bp-10]>
  662. bp_lpszDeviceTmp equ <dword ptr [bp-14]>
  663. bp_lpszOutputTmp equ <dword ptr [bp-18]>
  664. sub eax,eax
  665. push eax ;bp_lpdmTmp
  666. push ax ;bp_hdm
  667. push eax ;bp_lpszDriverTmp
  668. push eax ;bp_lpszDeviceTmp
  669. push eax ;bp_lpszOutputTmp
  670. mov ecx,bp_lpdm
  671. or ecx,ecx
  672. jnz repack_devmode
  673. jmp push_callframe
  674. ; We have to repack the DEVMODE structure. Compute the size needed,
  675. ; allocate it, setup pointers and invoke the macro to do the copying.
  676. repack_devmode:
  677. push word ptr GMEM_MOVEABLE
  678. mov es,FlatData
  679. movzx eax,es:[ecx].dmSize
  680. movzx ecx,es:[ecx].dmDriverExtra
  681. add eax,ecx
  682. push eax
  683. call GlobalAlloc
  684. movzx eax,ax ;prepare for error
  685. or ax,ax
  686. jz exit
  687. mov word ptr bp_hdm,ax
  688. ; Set up DS:ESI
  689. ; ES:EDI
  690. push ds
  691. mov ds,FlatData
  692. mov esi,bp_lpdm
  693. mov es,ax
  694. sub edi,edi
  695. mov word ptr bp_lpdmTmp[0],di
  696. mov word ptr bp_lpdmTmp[2],ax
  697. cld
  698. REPACK_DEVMODE_32_16
  699. pop ds
  700. push_callframe:
  701. push dword ptr bp_lpszDriver
  702. call MapLS ;PLUGGED
  703. mov bp_lpszDriverTmp,eax
  704. push eax
  705. push dword ptr bp_lpszDevice
  706. call MapLS ;PLUGGED
  707. mov bp_lpszDeviceTmp,eax
  708. push eax
  709. push dword ptr bp_lpszOutput
  710. call MapLS ;PLUGGED
  711. mov bp_lpszOutputTmp,eax
  712. push eax
  713. push bp_lpdmTmp
  714. call CreateIC
  715. movzx eax,ax
  716. push eax
  717. mov cx,bp_hdm
  718. or cx,cx
  719. jz @F
  720. push cx
  721. call GlobalFree
  722. @@:
  723. pushd bp_lpszOutputTmp
  724. call UnmapLS
  725. pushd bp_lpszDeviceTmp
  726. call UnmapLS
  727. pushd bp_lpszDriverTmp
  728. call UnmapLS
  729. pop eax
  730. exit:
  731. endm
  732. ENDIF
  733. ;-----------------------------------------------------------------------;
  734. ; body_GETOUTLINETEXTMETRICSA
  735. ;-----------------------------------------------------------------------;
  736. OUTLINETEXTMETRIC16_SIZEX equ 114+3*32+64
  737. OUTLINETEXTMETRIC32_SIZEX equ 212+3*32+64
  738. body_GETOUTLINETEXTMETRICSA macro
  739. local push_callframe
  740. local exit
  741. bp_hdc equ <bp_top>
  742. bp_cbData equ <bp_top+4>
  743. bp_lpotm equ <bp_top+8>
  744. bp_lpotm16 equ <dword ptr [bp-4]>
  745. bp_lpotm32 equ <dword ptr [bp-8]>
  746. sub eax,eax
  747. push eax ; Make room for lpotm16
  748. push eax ; Make room for lpotm32
  749. cmp dword ptr bp_lpotm, 0 ; Size call?
  750. je push_callframe ; Yes, drop thru
  751. ; Make 16bit return buffer
  752. sub sp, OUTLINETEXTMETRIC16_SIZEX
  753. mov word ptr bp_lpotm16[0],sp
  754. mov word ptr bp_lpotm16[2],ss
  755. ; Make 32bit temp buffer
  756. sub sp, OUTLINETEXTMETRIC32_SIZEX
  757. mov word ptr bp_lpotm32[0],sp
  758. mov word ptr bp_lpotm32[2],ss
  759. push_callframe:
  760. push word ptr bp_hdc
  761. pushw OUTLINETEXTMETRIC16_SIZEX
  762. push dword ptr bp_lpotm16
  763. call GetOutlineTextMetrics
  764. movzx eax,ax
  765. test eax, eax ; Win16 return success?
  766. jz exit ; No, return NULL
  767. cmp dword ptr bp_lpotm, 0 ; Caller really wants data?
  768. jne unpackotm ; Yes, unpack and copy it to him
  769. add eax, (OUTLINETEXTMETRIC32_SIZE - OUTLINETEXTMETRIC16_SIZE)
  770. jmp exit ; No, add delta and return
  771. unpackotm:
  772. ; Unpack the OUTLINETEXTMETRICS structure.
  773. push eax ; Save rc
  774. push ds ; Save ds
  775. xor esi, esi ;
  776. lds si, bp_lpotm16 ; ds:[esi] -> otm16 temp
  777. xor edi, edi ;
  778. les di, bp_lpotm32 ; es:[edi] -> otm32 temp
  779. cld
  780. PACK_OUTLINETEXTMETRIC_16_32
  781. pop ds ; Restore ds (FlatLand)
  782. xor esi, esi ; fs:[esi] -> otm32 temp
  783. lfs si, bp_lpotm32 ;
  784. mov es, FlatData ; es:[edi] -> caller's buffer
  785. mov edi, bp_lpotm ;
  786. mov ecx, bp_cbData ; Copy amount caller requested
  787. rep movsb es:[edi], fs:[esi] ;
  788. pop eax ; Restore rc
  789. exit:
  790. mov sp,bp
  791. endm
  792. ;-----------------------------------------------------------------------;
  793. ; body_GETOBJECTA
  794. ;-----------------------------------------------------------------------;
  795. body_GETOBJECTA macro
  796. local exit
  797. local type_palette
  798. local type_brush
  799. local type_pen
  800. local type_font
  801. local copy_bitmap
  802. local copy_palette
  803. local copy_brush
  804. local copy_pen
  805. local copy_font
  806. local copy_data
  807. local reload_dst
  808. local GO_BUF_SIZE
  809. bp_hObject equ <bp_top>
  810. bp_nCount equ <bp_top+4>
  811. bp_lpObject equ <bp_top+8>
  812. bp_lpObjectTmp equ <dword ptr [bp-4]>
  813. ;Make the temporary buffer big enough for 32-bit DIBSECTION, the biggest
  814. ;structure returned by GetObjectA32. We will allocate two temporary
  815. ;buffers. The first will receive the bits from Win3.1. The second
  816. ;will receive the repacked bits, and will then be copied to the output
  817. ;buffer.
  818. ;
  819. GO_BUF_SIZE equ DIBSECTION32_SIZE
  820. xor eax,eax
  821. push eax ; ptr param #1 bp_lpObjectTmp
  822. sub sp,GO_BUF_SIZE*2 ; alloc two temp buffers
  823. mov word ptr bp_lpObjectTmp[0],sp ; save buffer offset
  824. mov word ptr bp_lpObjectTmp[2],ss ; save buffer selector
  825. ; create new call frame and make the call
  826. push word ptr bp_hObject
  827. push word ptr GO_BUF_SIZE ; temp buffer size
  828. push dword ptr bp_lpObjectTmp
  829. call GetObject ; call 16-bit version
  830. cwde
  831. or ax,ax
  832. jz exit ; nothing to unpack
  833. mov si,bp_hObject ; dereference the object & find out
  834. mov cx,INT_OBJ_FONT ; assume it's a font
  835. test si,2 ; is it a moveable handle
  836. jz GO_Branch ; if not it must be a font
  837. mov si,[si] ; what type it is (LMHtoP)
  838. mov cx,[si].ilObjType ;
  839. and ch,HIGH (NOT INT_OBJ_FLAGS) ;
  840. GO_Branch:
  841. mov si,word ptr bp_lpObjectTmp
  842. mov edi,dword ptr bp_lpObject
  843. cld
  844. cmp cx,INT_OBJ_PALETTE
  845. je type_palette
  846. cmp cx,INT_OBJ_BRUSH
  847. je type_brush
  848. cmp cx,INT_OBJ_PEN
  849. je type_pen
  850. cmp cx,INT_OBJ_FONT
  851. je type_font
  852. ; Structure conversion code
  853. ; Each of these code fragments must leave with
  854. ; eax = computed number of bytes for return structure.
  855. ; bitmap
  856. or edi,edi
  857. jnz copy_bitmap
  858. mov eax,DIBSECTION32_SIZE ; sizeof DIBSECTION
  859. jmp exit
  860. copy_bitmap:
  861. mov di,ss
  862. mov ds,di
  863. mov es,di
  864. lea di,[si+GO_BUF_SIZE]
  865. lodsw ; bmType
  866. cwde
  867. stosd
  868. lodsw ; bmWidth
  869. mov cx,ax
  870. cwde
  871. stosd
  872. lodsw ; bmHeight
  873. cwde
  874. stosd
  875. lodsw ; bmWidthBytes
  876. cwde
  877. stosd ;store it
  878. lodsb ; bmPlanes
  879. cbw
  880. stosw
  881. lodsb ; bmBitsPixel
  882. cbw
  883. stosw
  884. ; the bmBits field will be non NULL for CreateDIBSection bitmaps and we need
  885. ; to convert that to a flat pointer.
  886. lodsd ; get bmBits
  887. or eax,eax ; is it null ?
  888. jz short @f ; yes, no translation needed.
  889. push eax ; 16:16 pointer
  890. call MapSL ; convert to flat.
  891. @@:
  892. stosd ; save.
  893. ; what follows now is the DIBSECTION structure minus the BITMAP structure.
  894. ; however, all the fields here are properly aligned and can be moved in one shot.
  895. mov cx,(DIBSECTION32_SIZE - BITMAP32_SIZE)/4
  896. .errnz (DIBSECTION32_SIZE - BITMAP32_SIZE) and 3
  897. rep movsd
  898. mov eax,DIBSECTION32_SIZE ; bytes generated thus far.
  899. jmp copy_data
  900. type_font:
  901. or edi,edi
  902. jnz copy_font
  903. mov eax,LOGFONT32_SIZE
  904. jmp exit
  905. copy_font:
  906. mov di,ss
  907. mov ds,di
  908. mov es,di
  909. lea di,[si+GO_BUF_SIZE]
  910. PACK_LOGFONT_16_32
  911. mov eax,LOGFONT32_SIZE
  912. jmp copy_data
  913. type_pen:
  914. or edi,edi
  915. jnz copy_pen
  916. mov eax,LOGPEN32_SIZE
  917. jmp exit
  918. copy_pen:
  919. mov di,ss
  920. mov ds,di
  921. mov es,di
  922. lea di,[si+GO_BUF_SIZE]
  923. lodsw ; lopnStyle
  924. cwde
  925. stosd
  926. lodsw ; lopnWidth.x
  927. cwde
  928. stosd
  929. lodsw ; lopnWidth.y
  930. cwde
  931. stosd
  932. movsd ; lopnColor
  933. mov eax,LOGPEN32_SIZE
  934. jmp copy_data
  935. type_brush:
  936. or edi,edi
  937. jnz copy_brush
  938. mov eax,LOGBRUSH32_SIZE
  939. jmp exit
  940. copy_brush:
  941. mov di,ss
  942. mov ds,di
  943. mov es,di
  944. lea di,[si+GO_BUF_SIZE]
  945. lodsw ; lbStyle
  946. cwde
  947. stosd
  948. movsd ; lbColor
  949. lodsw ; lbHatch
  950. cwde
  951. stosd
  952. mov eax,LOGBRUSH32_SIZE
  953. jmp copy_data
  954. type_palette:
  955. or edi,edi
  956. jnz copy_palette
  957. mov eax,4 ; only 4 bytes returned
  958. jmp exit
  959. copy_palette:
  960. mov di,ss
  961. mov ds,di
  962. mov es,di
  963. lea di,[si+GO_BUF_SIZE]
  964. lodsw
  965. movzx eax,ax
  966. stosd
  967. mov eax,4 ; only 4 bytes returned
  968. ; Copy converted data to caller's buffer.
  969. ; eax = computed byte count
  970. copy_data:
  971. mov ecx,dword ptr bp_nCount
  972. cmp ecx,eax
  973. jb reload_dst
  974. mov ecx,eax
  975. reload_dst:
  976. push ecx ; save return code
  977. mov edx,ecx
  978. shr ecx,2
  979. and edx,3
  980. movzx esi,word ptr bp_lpObjectTmp
  981. add esi,GO_BUF_SIZE
  982. mov es,cs:THUNK16BCodeData
  983. mov es,es:FlatData
  984. mov edi,dword ptr bp_lpObject
  985. rep movs dword ptr es:[edi],dword ptr ds:[esi]
  986. mov ecx,edx
  987. rep movs byte ptr es:[edi],byte ptr ds:[esi]
  988. pop eax ; restore return code directly to eax
  989. exit:
  990. endm
  991. ;------------------------------------------------------------------------
  992. ; RAWPACK__GETFONTDATA_lpvBuffer
  993. ;------------------------------------------------------------------------
  994. ; Special cases:
  995. ; lpvBuffer == NULL return size of required buffer
  996. ; cbData == 0 return size of required buffer
  997. RAWPACK__GETFONTDATA_lpvBuffer macro lpvBufferOff, lp16Off
  998. local fail_exit,exit,cbData
  999. cbData equ <[bp_top + 16]> ;size of lpvBuffer
  1000. mov eax,[bp + &lpvBufferOff&]
  1001. mov ecx,cbData
  1002. TILE_BUFFER
  1003. jc fail_exit
  1004. mov dword ptr [bp - &lp16Off&], eax
  1005. mov dword ptr LOCAL__GETFONTDATA_dwFreeInfo, ecx
  1006. jmp exit
  1007. fail_exit:
  1008. mov sp,bp
  1009. xor eax,eax ;GetFontData() returns -1 to indicate
  1010. dec eax ; failure.
  1011. ERRCHK_EXIT -1,87,Exit_20
  1012. exit:
  1013. endm ;RAWPACK__GETFONTDATA_lpvBuffer
  1014. ;------------------------------------------------------------------------
  1015. ; RAWUNPACK__GETFONTDATA_lpvBuffer
  1016. ;------------------------------------------------------------------------
  1017. RAWUNPACK__GETFONTDATA_lpvBuffer macro lpvBufferOff, lp16Off
  1018. mov ecx, dword ptr LOCAL__GETFONTDATA_dwFreeInfo
  1019. UNTILE_BUFFER
  1020. endm ;RAWUNPACK__GETFONTDATA_lpvBuffer
  1021. ;------------------------------------------------------------------------
  1022. ; RAWPACK__GETGLYPHOUTLINEA_lpvBuffer
  1023. ;------------------------------------------------------------------------
  1024. ;
  1025. ; Special cases:
  1026. ; lpvBuffer == NULL return size of required buffer
  1027. ; cbData == 0 return size of required buffer
  1028. RAWPACK__GETGLYPHOUTLINEA_lpvBuffer macro lpvBufferOff, lp16Off
  1029. local fail_exit,exit,cbData
  1030. cbData equ <[bp_top + 16]> ;size of user's buffer
  1031. mov eax,[bp+&lpvBufferOff&]
  1032. mov ecx,cbData
  1033. TILE_BUFFER
  1034. jc fail_exit
  1035. mov dword ptr [bp - &lp16Off&], eax
  1036. mov dword ptr LOCAL__GETGLYPHOUTLINEA_dwFreeInfo, ecx
  1037. jmp exit
  1038. fail_exit:
  1039. mov sp,bp
  1040. xor eax,eax
  1041. dec eax
  1042. ERRCHK_EXIT -1,87,Exit_28
  1043. exit:
  1044. endm ;RAWPACK__GETGLYPHOUTLINEA_lpvBuffer
  1045. ;------------------------------------------------------------------------
  1046. ; RAWUNPACK__GETGLYPHOUTLINEA_lpvBuffer
  1047. ;------------------------------------------------------------------------
  1048. RAWUNPACK__GETGLYPHOUTLINEA_lpvBuffer macro lpvBufferOff, lp16Off
  1049. mov ecx, LOCAL__GETGLYPHOUTLINEA_dwFreeInfo
  1050. UNTILE_BUFFER
  1051. endm ;RAWUNPACK__GETGLYPHOUTLINEA_lpvBuffer
  1052. ;------------------------------------------------------------------------
  1053. ; RAWPACK__GETKERNINGPAIRSA_lpkp
  1054. ;------------------------------------------------------------------------
  1055. RAWPACK__GETKERNINGPAIRSA_lpkp macro lpkpOff, lp16Off
  1056. local fail_exit,exit,cPairs,tile_it
  1057. cPairs equ <[bp_top + 4]>
  1058. mov eax,[bp+&lpkpOff&]
  1059. or eax,eax
  1060. jz tile_it
  1061. mov ecx,cPairs
  1062. or ecx,ecx ;if the buffer size is 0, function
  1063. jz fail_exit ; should return 0.
  1064. cmp ecx,10000h ;make sure buffer size will fit in
  1065. jae fail_exit ; a Win16 INT.
  1066. shl ecx,1
  1067. mov edx,ecx
  1068. shl ecx,1
  1069. add ecx,edx
  1070. ; assert(ecx == cPairs * 6)
  1071. tile_it:
  1072. ; int 3
  1073. TILE_BUFFER
  1074. ; int 3
  1075. jc fail_exit
  1076. mov dword ptr [bp - &lp16Off&], eax
  1077. mov dword ptr LOCAL__GETKERNINGPAIRSA_dwFreeInfo,ecx
  1078. jmp exit
  1079. fail_exit:
  1080. mov sp,bp
  1081. xor eax,eax
  1082. ERRCHK_EXIT 0,87,Exit_12
  1083. exit:
  1084. endm ;RAWPACK__GETKERNINGPAIRSA_lpkp
  1085. ;------------------------------------------------------------------------
  1086. ; RAWUNPACK__GETKERNINGPAIRSA_lpkp
  1087. ;------------------------------------------------------------------------
  1088. RAWUNPACK__GETKERNINGPAIRSA_lpkp macro lpkpOff, lp16Off
  1089. local exit,cPairs,unpack_loop
  1090. cPairs equ <[bp_top + 4]>
  1091. ; int 3
  1092. test ax, ax ; Any pairs returned?
  1093. jz exit ; No, skip out
  1094. mov esi,[bp + &lpkpOff&]
  1095. or esi,esi
  1096. jz exit
  1097. push ds
  1098. push es
  1099. movzx ecx,ax ; Get # pairs in ecx
  1100. mov ds,FlatData
  1101. mov ax,ds
  1102. mov es,ax
  1103. shl ecx,1
  1104. mov edx,ecx
  1105. shl ecx,1
  1106. ; assert(edx == 2*cPairs)
  1107. ; assert(ecx == 4*cPairs)
  1108. add esi,edx
  1109. add esi,ecx
  1110. dec esi
  1111. dec esi
  1112. ; assert(esi == lpkp + 6*cPairs - 2)
  1113. mov edi,esi
  1114. add edi,edx
  1115. ; assert(edi == lpkp + 8*cPairs - 2)
  1116. shr ecx,2 ;Restore ecx to cPairs
  1117. std
  1118. unpack_loop:
  1119. lodsw ds:[esi]
  1120. cwde
  1121. dec edi
  1122. dec edi
  1123. stosd es:[edi]
  1124. inc edi
  1125. inc edi
  1126. movsw es:[edi],ds:[esi]
  1127. movsw es:[edi],ds:[esi]
  1128. loopd unpack_loop
  1129. cld
  1130. pop es
  1131. pop ds
  1132. exit:
  1133. mov ecx,dword ptr LOCAL__GETKERNINGPAIRSA_dwFreeInfo
  1134. UNTILE_BUFFER
  1135. ; int 3
  1136. endm ;RAWUNPACK__GETKERNINGPAIRSA_lpkp
  1137. IF 0
  1138. ;-----------------------------------------------------------------------;
  1139. ; body_RESETDCA
  1140. ;-----------------------------------------------------------------------;
  1141. body_RESETDCA macro
  1142. local exit
  1143. local repack_devmode
  1144. local push_callframe
  1145. bp_hdc equ <bp_top>
  1146. bp_lpdm equ <bp_top+4>
  1147. bp_lpdmTmp equ <dword ptr [bp-4]>
  1148. bp_hdm equ < word ptr [bp-6]>
  1149. sub eax,eax
  1150. push eax ;bp_lpdmTmp
  1151. push ax ;bp_hdm
  1152. mov ecx,bp_lpdm
  1153. or ecx,ecx
  1154. jnz repack_devmode
  1155. jmp push_callframe
  1156. ; We have to repack the DEVMODE structure. Compute the size needed,
  1157. ; allocate it, setup pointers and invoke the macro to do the copying.
  1158. repack_devmode:
  1159. push word ptr GMEM_MOVEABLE
  1160. mov es,FlatData
  1161. movzx eax,es:[ecx].dmSize
  1162. movzx ecx,es:[ecx].dmDriverExtra
  1163. add eax,ecx
  1164. push eax
  1165. call GlobalAlloc
  1166. movzx eax,ax ;prepare for error
  1167. or ax,ax
  1168. jz exit
  1169. mov word ptr bp_hdm,ax
  1170. ; Set up DS:ESI
  1171. ; ES:EDI
  1172. push ds
  1173. mov ds,FlatData
  1174. mov esi,bp_lpdm
  1175. mov es,ax
  1176. sub edi,edi
  1177. mov word ptr bp_lpdmTmp[0],di
  1178. mov word ptr bp_lpdmTmp[2],ax
  1179. cld
  1180. REPACK_DEVMODE_32_16
  1181. pop ds
  1182. push_callframe:
  1183. push word ptr bp_hdc
  1184. push bp_lpdmTmp
  1185. call ResetDC
  1186. movzx eax,ax
  1187. mov cx,bp_hdm
  1188. or cx,cx
  1189. jz exit
  1190. push eax
  1191. push cx
  1192. call GlobalFree
  1193. pop eax
  1194. exit:
  1195. endm
  1196. ENDIF
  1197. ;---------------------------------------------------------------------------;
  1198. ; RAWPACK__THKCREATEDIBITMAP_lpInitBits
  1199. ;---------------------------------------------------------------------------;
  1200. RAWPACK__THKCREATEDIBITMAP_lpInitBits macro lpBits, lp1616
  1201. local exit,fail_exit
  1202. cmp dword ptr [bp_top+8], CBM_INIT
  1203. jne exit ;lp1616 already contains 0:0 pointer
  1204. mov eax,[bp_top + 16] ;Get pointer to BITMAPINFOHEADER
  1205. DIB_BITS_SIZE
  1206. or ecx,ecx
  1207. jz fail_exit
  1208. mov eax,[bp + &lpBits&]
  1209. or eax,eax
  1210. jz fail_exit
  1211. TILE_BUFFER
  1212. jc fail_exit
  1213. mov dword ptr [bp - &lp1616&], eax
  1214. mov dword ptr LOCAL__THKCREATEDIBITMAP_dwFreeInfo, ecx
  1215. jmp exit
  1216. fail_exit:
  1217. mov sp,bp
  1218. xor eax,eax
  1219. ERRCHK_EXIT 0,87,Exit_24
  1220. exit:
  1221. endm ;RAWPACK__THKCREATEDIBITMAP_lpInitBits
  1222. ;---------------------------------------------------------------------------;
  1223. ; RAWUNPACK__THKCREATEDIBITMAP_lpInitBits
  1224. ;---------------------------------------------------------------------------;
  1225. RAWUNPACK__THKCREATEDIBITMAP_lpInitBits macro lpBits, lp1616
  1226. mov ecx,dword ptr LOCAL__THKCREATEDIBITMAP_dwFreeInfo
  1227. UNTILE_BUFFER
  1228. endm ;RAWUNPACK__THKCREATEDIBITMAP_lpInitBits
  1229. ;---------------------------------------------------------------------------;
  1230. ; RAWPACK__STRETCHDIBITS_lpBits
  1231. ;---------------------------------------------------------------------------;
  1232. RAWPACK__STRETCHDIBITS_lpBits macro lpBits, lp1616
  1233. local exit,fail_exit
  1234. mov eax,[bp_top + 40] ;Get pointer to BITMAPINFOHEADER
  1235. DIB_BITS_SIZE
  1236. or ecx,ecx
  1237. jz fail_exit
  1238. mov eax,[bp + &lpBits&]
  1239. or eax,eax
  1240. jz fail_exit
  1241. TILE_BUFFER
  1242. jc fail_exit
  1243. mov dword ptr [bp - &lp1616&], eax
  1244. mov dword ptr LOCAL__STRETCHDIBITS_dwFreeInfo, ecx
  1245. jmp exit
  1246. fail_exit:
  1247. mov sp,bp
  1248. xor eax,eax
  1249. dec eax
  1250. ERRCHK_EXIT -1,87,Exit_52
  1251. exit:
  1252. endm ;RAWPACK__STRETCHDIBITS_lpBits
  1253. ;---------------------------------------------------------------------------;
  1254. ; RAWUNPACK__STRETCHDIBITS_lpBits
  1255. ;---------------------------------------------------------------------------;
  1256. RAWUNPACK__STRETCHDIBITS_lpBits macro lpBits, lp1616
  1257. mov ecx,dword ptr LOCAL__STRETCHDIBITS_dwFreeInfo
  1258. UNTILE_BUFFER
  1259. endm ;RAWUNPACK__STRETCHDIBITS_lpBits
  1260. ;---------------------------------------------------------------------------;
  1261. ; RAWPACK__SETDIBITS_lpBits
  1262. ;---------------------------------------------------------------------------;
  1263. RAWPACK__SETDIBITS_lpBits macro lpBits, lp1616
  1264. local exit,fail_exit
  1265. mov eax,[bp_top + 20] ;Get pointer to BITMAPINFOHEADER
  1266. DIB_BITS_SIZE
  1267. or ecx,ecx
  1268. jz fail_exit
  1269. mov eax,[bp + &lpBits&]
  1270. or eax,eax
  1271. jz fail_exit
  1272. TILE_BUFFER
  1273. jc fail_exit
  1274. mov dword ptr [bp - &lp1616&], eax
  1275. mov dword ptr LOCAL__SETDIBITS_dwFreeInfo, ecx
  1276. jmp exit
  1277. fail_exit:
  1278. mov sp,bp
  1279. xor eax,eax
  1280. ERRCHK_EXIT 0,87,Exit_28
  1281. exit:
  1282. endm ;RAWPACK__SETDIBITS_lpBits
  1283. ;---------------------------------------------------------------------------;
  1284. ; RAWUNPACK__SETDIBITS_lpBits
  1285. ;---------------------------------------------------------------------------;
  1286. RAWUNPACK__SETDIBITS_lpBits macro lpBits, lp1616
  1287. mov ecx,dword ptr LOCAL__SETDIBITS_dwFreeInfo
  1288. UNTILE_BUFFER
  1289. endm ;RAWUNPACK__SETDIBITS_lpBits
  1290. ;---------------------------------------------------------------------------;
  1291. ; RAWPACK__GETDIBITS_lpBits
  1292. ;---------------------------------------------------------------------------;
  1293. RAWPACK__GETDIBITS_lpBits macro lpBits, lp1616
  1294. local exit,null_exit,fail_exit
  1295. mov eax,[bp + &lpBits&]
  1296. or eax,eax
  1297. jz null_exit
  1298. mov eax,[bp_top + 20] ;Get pointer to BITMAPINFOHEADER
  1299. DIB_BITS_SIZE
  1300. or ecx,ecx
  1301. jz fail_exit
  1302. mov eax,[bp + &lpBits&]
  1303. TILE_BUFFER
  1304. jc fail_exit
  1305. mov dword ptr [bp - &lp1616&], eax
  1306. mov dword ptr LOCAL__GETDIBITS_dwFreeInfo, ecx
  1307. jmp exit
  1308. fail_exit:
  1309. mov sp,bp
  1310. xor eax,eax
  1311. ERRCHK_EXIT 0,87,Exit_28
  1312. null_exit:
  1313. xor eax,eax
  1314. mov dword ptr LOCAL__GETDIBITS_dwFreeInfo,eax
  1315. exit:
  1316. endm ;RAWPACK__GETDIBITS_lpBits
  1317. ;---------------------------------------------------------------------------;
  1318. ; RAWUNPACK__GETDIBITS_lpBits
  1319. ;---------------------------------------------------------------------------;
  1320. RAWUNPACK__GETDIBITS_lpBits macro lpBits, lp1616
  1321. mov ecx,dword ptr LOCAL__GETDIBITS_dwFreeInfo
  1322. UNTILE_BUFFER
  1323. endm ;RAWUNPACK__GETDIBITS_lpBits
  1324. ;---------------------------------------------------------------------------;
  1325. ; RAWPACK__SETDIBITSTODEVICE_lpBits
  1326. ;---------------------------------------------------------------------------;
  1327. RAWPACK__SETDIBITSTODEVICE_lpBits macro lpBits, lp1616
  1328. local exit,fail_exit
  1329. mov eax,[bp_top + 40] ;Get pointer to BITMAPINFOHEADER
  1330. DIB_BITS_SIZE
  1331. or ecx,ecx
  1332. jz fail_exit
  1333. mov eax,[bp + &lpBits&]
  1334. or eax,eax
  1335. jz fail_exit
  1336. TILE_BUFFER
  1337. jc fail_exit
  1338. mov dword ptr [bp - &lp1616&], eax
  1339. mov dword ptr LOCAL__SETDIBITSTODEVICE_dwFreeInfo, ecx
  1340. jmp exit
  1341. fail_exit:
  1342. mov sp,bp
  1343. xor eax,eax
  1344. ERRCHK_EXIT 0,87,Exit_48
  1345. exit:
  1346. endm ;RAWPACK__SETDIBITSTODEVICE_lpBits
  1347. ;---------------------------------------------------------------------------;
  1348. ; RAWUNPACK__SETDIBITSTODEVICE_lpBits
  1349. ;---------------------------------------------------------------------------;
  1350. RAWUNPACK__SETDIBITSTODEVICE_lpBits macro lpBits, lp1616
  1351. mov ecx,dword ptr LOCAL__SETDIBITSTODEVICE_dwFreeInfo
  1352. UNTILE_BUFFER
  1353. endm ;RAWUNPACK__SETDIBITSTODEVICE_lpBits
  1354. ;---------------------------------------------------------------------------;
  1355. ; RAWPACK__PLAYMETAFILERECORD_lpMetaRecord
  1356. ;---------------------------------------------------------------------------;
  1357. RAWPACK__PLAYMETAFILERECORD_lpMetaRecord macro lpMFR, lp1616
  1358. local exit,fail_exit
  1359. mov eax,[bp + &lpMFR&]
  1360. or eax,eax
  1361. jz fail_exit
  1362. mov es,FlatData
  1363. mov ecx,es:[eax]
  1364. shl ecx,1
  1365. jc fail_exit
  1366. add ecx,4 ; add some slop in case drivers touch
  1367. jo fail_exit ; a little too much... #9978,win95c
  1368. TILE_BUFFER
  1369. jc fail_exit
  1370. mov dword ptr [bp - &lp1616&], eax
  1371. mov dword ptr LOCAL__PLAYMETAFILERECORD_dwFreeInfo, ecx
  1372. jmp exit
  1373. fail_exit:
  1374. mov sp,bp
  1375. xor eax,eax ;PlayMetaFileRecord doesn't return a
  1376. ERRCHK_EXIT 0,87,Exit_16 ;a value, so fake it.
  1377. exit:
  1378. endm ;RAWPACK__PLAYMETAFILERECORD_lpMetaRecord
  1379. ;---------------------------------------------------------------------------;
  1380. ; RAWUNPACK__PLAYMETAFILERECORD_lpMetaRecord
  1381. ;---------------------------------------------------------------------------;
  1382. RAWUNPACK__PLAYMETAFILERECORD_lpMetaRecord macro lpMFR, lp1616
  1383. mov ecx,dword ptr LOCAL__PLAYMETAFILERECORD_dwFreeInfo
  1384. UNTILE_BUFFER
  1385. endm ;RAWUNPACK__PLAYMETAFILERECORD_lpMetaRecord
  1386. ;---------------------------------------------------------------------------;
  1387. ; Return value for PlayMetaFileRecord
  1388. ;---------------------------------------------------------------------------;
  1389. RET__PLAYMETAFILERECORD macro
  1390. ; The 16-bit PlayMetaFileRecord API has a void return but the Win32 version
  1391. ; has a BOOL return so always return success.
  1392. mov eax,1
  1393. endm
  1394. ;---------------------------------------------------------------------------
  1395. ; Handling error code of STARTDOC api.
  1396. ;---------------------------------------------------------------------------
  1397. err_STARTDOCA macro
  1398. local exit,l1,l2,l3,l4
  1399. cmp eax,0 ;Avoid overhead when successful
  1400. jge exit
  1401. cmp eax,-1 ;SP_ERROR, generic error, check GetLastError()
  1402. jne l1
  1403. call GetLastError
  1404. cmp eax,0
  1405. jne l4 ;if GetLastError() != 0, exit
  1406. pushd 87 ;if GetLastError() == 0, SetLastError(INVALID_PARAM)
  1407. call SetLastError
  1408. jmp l4
  1409. ; This expands to a pretty embarrassing control structure (checks
  1410. ; against all four values even after a match is found). Looking forward
  1411. ; to throwing this out when we optimize the thunk layer.
  1412. ; ERRCHK_EXIT -1,87,l1 ;SP_ERROR -> BAD_PARAM
  1413. l1: ERRCHK_EXIT -4,112,l2 ;SP_OUTOFDISK -> DISK_FULL
  1414. l2: ERRCHK_EXIT -5,8,l3 ;SP_OUTOFMEMORY -> NOT_ENOUGH_MEM
  1415. l3: ERRCHK_EXIT -3,63,l4 ;SP_USERABORT -> PRINT_CANCELLED
  1416. l4: mov eax,-1 ;return SP_ERROR for failure
  1417. exit:
  1418. endm ;err_STARTDOCA
  1419. ;---------------------------------------------------------------------------
  1420. ; Handling error code of ESCAPE api.
  1421. ;---------------------------------------------------------------------------
  1422. err_THKESCAPE macro
  1423. local exit,l1,l2,l3
  1424. cmp eax,0 ;Avoid overhead when successful
  1425. jge exit
  1426. ; This expands to a pretty embarrassing control structure (checks
  1427. ; against all four values even after a match is found). Looking forward
  1428. ; to throwing this out when we optimize the thunk layer.
  1429. ERRCHK_EXIT -1,87,l1 ;SP_ERROR -> BAD_PARAM
  1430. l1: ERRCHK_EXIT -4,112,l2 ;SP_OUTOFDISK -> DISK_FULL
  1431. l2: ERRCHK_EXIT -5,8,l3 ;SP_OUTOFMEMORY -> NOT_ENOUGH_MEM
  1432. l3: ERRCHK_EXIT -3,63,exit ;SP_USERABORT -> PRINT_CANCELLED
  1433. exit:
  1434. endm ;err_ESCAPE
  1435. ;--------------------------------------------------------------------------
  1436. ; body_GETTEXTEXTENTEXPOINTA
  1437. ;--------------------------------------------------------------------------
  1438. body_GETTEXTEXTENTEXPOINTA macro
  1439. local exit,fail_exit
  1440. local bp_hdc, bp_lpszStr, bp_cchString, bp_nMaxExtent
  1441. local bp_lpnFit, bp_alpDx, bp_lpSize
  1442. local bp_lpszStr16,bp_lpSize16
  1443. local p1,loop,loop_exit,loop_exit2,unpack_size,no_alpDx
  1444. bp_hdc equ <[bp_top]>
  1445. bp_lpszStr equ <[bp_top+4]>
  1446. bp_cchString equ <[bp_top+8]>
  1447. bp_nMaxExtent equ <[bp_top+12]>
  1448. bp_lpnFit equ <[bp_top+16]>
  1449. bp_alpDx equ <[bp_top+20]>
  1450. bp_lpSize equ <[bp_top+24]>
  1451. bp_lpszStr16 equ <[bp-4]> ;16:16 lpszStr pointer
  1452. bp_lpSize16 equ <[bp-8]> ;16:16 lpSize pointer
  1453. xor eax,eax ;Allocate 0-initialized locals
  1454. push eax ; bp_lpszStr16
  1455. push eax ; bp_lpSize16
  1456. ; Convert lpszStr arg to 16:16 pointer and stuff away.
  1457. mov eax,dword ptr bp_lpszStr
  1458. push eax
  1459. call MapLS ;PLUGGED
  1460. mov dword ptr bp_lpszStr16,eax
  1461. ; Convert lpSize arg to 16:16 pointer and stuff away.
  1462. mov eax,dword ptr bp_lpSize
  1463. push eax
  1464. call MapLS ;PLUGGED
  1465. mov dword ptr bp_lpSize16,eax
  1466. ; Optimization: if lpfnFit and alpDx both NULL, degenerate to
  1467. ; GetTextExtentPoint().
  1468. mov eax,dword ptr bp_lpnFit
  1469. or eax,dword ptr bp_alpDx
  1470. jz measure_whole
  1471. ; If lpfnFit == 0, we're supposed to ignore nMaxExtent. To avoid dealing
  1472. ; with this special case, set nMaxExtent to max.
  1473. mov eax,dword ptr bp_lpnFit
  1474. or eax,eax
  1475. jnz p1
  1476. dec eax ;eax <-- 0xffffffff
  1477. mov dword ptr bp_nMaxExtent, eax
  1478. ; Assert: nMaxExtent now set to valid value.
  1479. p1:
  1480. mov ecx,1
  1481. loop:
  1482. ; Measure increasingly long prefixes until we reach the end of the
  1483. ; string or exceed nMaxExtent. ecx == prefix length (ranges from 1
  1484. ; to cchString inclusive).
  1485. cmp ecx,dword ptr bp_cchString
  1486. ja loop_exit
  1487. push ecx ;Save prefix length
  1488. ; Note: Using caller's SIZE as temporary for GetTextExtentPoint().
  1489. ; If this is the last call before hitting the end of the string,
  1490. ; this'll put the right return value in SIZE. If not, we'll
  1491. ; do a final measure to set SIZE right.
  1492. push word ptr bp_hdc ;Arg: GetTextExtentPoint
  1493. push dword ptr bp_lpszStr16 ;Arg: GetTextExtentPoint
  1494. push cx ;Arg: GetTextExtentPoint
  1495. push dword ptr bp_lpSize16 ;Arg: GetTextExtentPoint
  1496. call GetTextExtentPoint
  1497. pop ecx ;Restore prefix length
  1498. or ax,ax
  1499. jz fail_exit
  1500. mov es,FlatData
  1501. mov esi,bp_lpSize
  1502. mov ax,es:[esi + 0] ;Retrieve size.cx
  1503. cwde
  1504. cmp eax,bp_nMaxExtent ;If exceeded nMaxExtent, end of
  1505. ja loop_exit ; story.
  1506. ; Store partial width in alpDx (if not NULL).
  1507. mov edi,dword ptr bp_alpDx
  1508. or edi,edi
  1509. jz no_alpDx
  1510. mov es,FlatData
  1511. mov es:[edi + ecx*4 - 4], eax
  1512. no_alpDx:
  1513. inc ecx
  1514. jmp loop
  1515. ; Assert: ecx - 1 == length of longest prefix not violating nMaxExtent
  1516. loop_exit:
  1517. dec ecx
  1518. mov edi,bp_lpnFit
  1519. or edi,edi
  1520. jz loop_exit2
  1521. mov es,FlatData
  1522. mov es:[edi],ecx
  1523. loop_exit2:
  1524. ; Optimization: if we ran off the end of the string, SIZE already contains
  1525. ; right (16-bit) values so bypass final call to GetTextExtentPoint().
  1526. cmp ecx,dword ptr bp_cchString
  1527. je unpack_size
  1528. ; Deliberate fall-through to measure_whole
  1529. measure_whole:
  1530. push word ptr bp_hdc
  1531. push dword ptr bp_lpszStr16
  1532. push word ptr bp_cchString
  1533. push dword ptr bp_lpSize16
  1534. call GetTextExtentPoint
  1535. or ax,ax
  1536. jz fail_exit
  1537. unpack_size:
  1538. ; Unpack LPSIZE object
  1539. mov es,FlatData
  1540. mov esi,bp_lpSize
  1541. mov ax,es:[esi + 2] ;Unpack Y
  1542. cwde
  1543. mov es:[esi + 4],eax
  1544. mov ax,es:[esi + 0] ;Unpack X
  1545. cwde
  1546. mov es:[esi + 0],eax
  1547. xor eax,eax ;Set success return value.
  1548. inc eax
  1549. jmp exit
  1550. fail_exit:
  1551. xor eax,eax
  1552. exit:
  1553. push eax
  1554. pushd bp_lpszStr16
  1555. call UnmapLS
  1556. pushd bp_lpSize16
  1557. call UnmapLS
  1558. pop eax
  1559. endm ;body_GETTEXTEXTENTEXPOINTA
  1560. ;--------------------------------------------------------------------------
  1561. ; body_THKPLAYENHMETAFILERECORD
  1562. ;--------------------------------------------------------------------------
  1563. body_THKPLAYENHMETAFILERECORD macro
  1564. local pop_exit
  1565. bp_hdc equ <[bp_top]>
  1566. bp_lpht equ <[bp_top+4]>
  1567. bp_lpby equ <[bp_top+8]>
  1568. bp_che equ <[bp_top+12]>
  1569. bp_cby equ <[bp_top+16]>
  1570. bp_return equ <[bp-4]> ;return value
  1571. bp_tile_lpht equ <[bp-8]> ;ecx from TILE_BUFFER
  1572. bp_tile_lpby equ <[bp-12]> ;ecx from TILE_BUFFER
  1573. ; Create zero-inited stack space for the return value.
  1574. xor eax, eax
  1575. push eax ;bp_return = 0
  1576. ; Convert lpht arg into a selector array and create stack space.
  1577. mov eax, dword ptr bp_lpht
  1578. mov ecx, dword ptr bp_che
  1579. test ecx, 0C0000000h ;so we can shift left safely
  1580. jnz pop_exit
  1581. shl ecx, 2 ;HANDLE is 4 bytes in 16-bit and 32-bit
  1582. TILE_BUFFER
  1583. push ecx
  1584. push eax ;save 16:16 ptr temporarily
  1585. ; Convert lpby arg into a selector array and create stack space.
  1586. mov eax, dword ptr bp_lpby
  1587. mov ecx, dword ptr bp_cby
  1588. TILE_BUFFER
  1589. pop edx ;get 16:16 pointer to handles
  1590. push ecx
  1591. ; Re-pack the stack and make the 16-bit call.
  1592. push word ptr bp_hdc
  1593. push edx ;16:16 pointer to handles
  1594. push eax ;16:16 pointer to bytes
  1595. push dword ptr bp_che
  1596. call PlayEnhMetaFileRecord
  1597. ; Save the return value on the stack. (The high word is already zero.)
  1598. mov word ptr bp_return, ax
  1599. ; Free the tiled selector arrays and stack space.
  1600. pop ecx
  1601. UNTILE_BUFFER
  1602. pop ecx
  1603. UNTILE_BUFFER
  1604. ; Clean the stack and set the return value.
  1605. pop_exit:
  1606. pop eax
  1607. endm ;body_THKPLAYENHMETAFILERECORD
  1608. ;-------------------------------------------------------------------------
  1609. ; RAWPACK_GETPATH_lpptl
  1610. ;-------------------------------------------------------------------------
  1611. RAWPACK__GETPATH_lpptl macro lpptl,lp1616
  1612. local exit,fail_exit,no_check
  1613. mov ecx,[bp_top+12] ;cptl (count of points)
  1614. test ecx, 0E0000000h ;so we can shift left safely
  1615. jnz fail_exit
  1616. shl ecx, 3 ;# bytes = cptl * 8
  1617. mov LOCAL__GETPATH_dwFreeInfo1,ecx ;assume ecx is zero
  1618. or ecx,ecx
  1619. jz exit
  1620. mov eax,[bp + &lpptl]
  1621. or eax,eax
  1622. jz fail_exit
  1623. ; Make sure it's writeable. If not, thunk fault handler will catch it.
  1624. mov es, FlatData
  1625. or byte ptr es:[eax],0
  1626. mov edx, [bp + &lpptl& + 4]
  1627. or edx,edx
  1628. jz no_check
  1629. or byte ptr es:[edx],0
  1630. no_check:
  1631. TILE_BUFFER
  1632. mov [bp - &lp1616&],eax
  1633. mov LOCAL__GETPATH_dwFreeInfo1,ecx
  1634. jmp exit
  1635. fail_exit:
  1636. mov sp,bp
  1637. xor eax,eax
  1638. dec eax
  1639. ERRCHK_EXIT -1,87,Exit_16
  1640. exit:
  1641. endm ;RAWPACK_GETPATH_lpBits
  1642. ;-------------------------------------------------------------------------
  1643. ; RAWUNPACK_GETPATH_lpptl
  1644. ;-------------------------------------------------------------------------
  1645. RAWUNPACK__GETPATH_lpptl macro lpptl,lp1616
  1646. mov ecx,LOCAL__GETPATH_dwFreeInfo1
  1647. UNTILE_BUFFER
  1648. endm ;RAWUNPACK_GETPATH
  1649. ;-------------------------------------------------------------------------
  1650. ; RAWPACK_GETPATH_lpby
  1651. ;-------------------------------------------------------------------------
  1652. RAWPACK__GETPATH_lpby macro lpby,lp1616
  1653. local exit,fail_exit
  1654. mov ecx,[bp_top+12] ;cptl (count of points)
  1655. mov LOCAL__GETPATH_dwFreeInfo2,ecx ;assume ecx is zero
  1656. or ecx,ecx
  1657. jz exit
  1658. mov eax,[bp + &lpby]
  1659. or eax,eax
  1660. jz fail_exit
  1661. TILE_BUFFER
  1662. mov [bp - &lp1616&],eax
  1663. mov LOCAL__GETPATH_dwFreeInfo2,ecx
  1664. jmp exit
  1665. fail_exit:
  1666. mov sp,bp
  1667. xor eax,eax
  1668. dec eax
  1669. ERRCHK_EXIT -1,87,Exit_16
  1670. exit:
  1671. endm ;RAWPACK_GETPATH_lpBits
  1672. ;-------------------------------------------------------------------------
  1673. ; RAWUNPACK_GETPATH_lpby
  1674. ;-------------------------------------------------------------------------
  1675. RAWUNPACK__GETPATH_lpby macro lpby,lp1616
  1676. mov ecx,LOCAL__GETPATH_dwFreeInfo2
  1677. UNTILE_BUFFER
  1678. endm ;RAWUNPACK_GETPATH
  1679. ;-------------------------------------------------------------------------
  1680. ; RAWPACK_GDICOMMENT
  1681. ;-------------------------------------------------------------------------
  1682. RAWPACK__GDICOMMENT_lpby macro lpby,lp1616
  1683. local exit,fail_exit
  1684. mov eax,[bp + &lpby]
  1685. or eax,eax
  1686. jz fail_exit
  1687. mov ecx,[bp_top+4] ;cby (size of buffer)
  1688. or ecx,ecx
  1689. jz fail_exit
  1690. TILE_BUFFER
  1691. mov [bp - &lp1616&],eax
  1692. mov LOCAL__GDICOMMENT_dwFreeInfo,ecx
  1693. jmp exit
  1694. fail_exit:
  1695. mov sp,bp
  1696. xor eax,eax
  1697. ERRCHK_EXIT 0,87,Exit_12
  1698. exit:
  1699. endm ;RAWPACK_GDICOMMENT_lpBits
  1700. ;-------------------------------------------------------------------------
  1701. ; RAWUNPACK_GDICOMMENT
  1702. ;-------------------------------------------------------------------------
  1703. RAWUNPACK__GDICOMMENT_lpby macro lpby,lp1616
  1704. mov ecx,LOCAL__GDICOMMENT_dwFreeInfo
  1705. UNTILE_BUFFER
  1706. endm ;RAWUNPACK_GDICOMMENT
  1707. ;-------------------------------------------------------------------------
  1708. ; RAWPACK_GETENHMETAFILEBITS
  1709. ;-------------------------------------------------------------------------
  1710. RAWPACK__GETENHMETAFILEBITS_lpby macro lpby,lp1616
  1711. local exit
  1712. mov eax,[bp + &lpby]
  1713. mov ecx,[bp_top+4] ;cby (size of buffer)
  1714. TILE_BUFFER
  1715. mov [bp - &lp1616&],eax
  1716. mov LOCAL__GETENHMETAFILEBITS_dwFreeInfo,ecx
  1717. exit:
  1718. endm ;RAWPACK_GETENHMETAFILEBITS_lpBits
  1719. ;-------------------------------------------------------------------------
  1720. ; RAWUNPACK_GETENHMETAFILEBITS
  1721. ;-------------------------------------------------------------------------
  1722. RAWUNPACK__GETENHMETAFILEBITS_lpby macro lpby,lp1616
  1723. mov ecx,LOCAL__GETENHMETAFILEBITS_dwFreeInfo
  1724. UNTILE_BUFFER
  1725. endm ;RAWUNPACK_GETENHMETAFILEBITS
  1726. ;-------------------------------------------------------------------------
  1727. ; RAWPACK_GETENHMETAFILEDESCRIPTIONA
  1728. ;-------------------------------------------------------------------------
  1729. RAWPACK__GETENHMETAFILEDESCRIPTIONA_lpby macro lpby,lp1616
  1730. local exit
  1731. mov eax,[bp + &lpby]
  1732. mov ecx,[bp_top+4] ;cby (size of buffer)
  1733. TILE_BUFFER
  1734. mov [bp - &lp1616&],eax
  1735. mov LOCAL__GETENHMETAFILEDESCRIPTIONA_dwFreeInfo,ecx
  1736. exit:
  1737. endm ;RAWPACK_GETENHMETAFILEDESCRIPTIONA_lpBits
  1738. ;-------------------------------------------------------------------------
  1739. ; RAWUNPACK_GETENHMETAFILEDESCRIPTIONA
  1740. ;-------------------------------------------------------------------------
  1741. RAWUNPACK__GETENHMETAFILEDESCRIPTIONA_lpby macro lpby,lp1616
  1742. mov ecx,LOCAL__GETENHMETAFILEDESCRIPTIONA_dwFreeInfo
  1743. UNTILE_BUFFER
  1744. endm ;RAWUNPACK_GETENHMETAFILEDESCRIPTIONA
  1745. ;-------------------------------------------------------------------------
  1746. ; RAWPACK_GETENHMETAFILEPALETTEENTRIES
  1747. ;-------------------------------------------------------------------------
  1748. RAWPACK__GETENHMETAFILEPALETTEENTRIES_lpby macro lpby,lp1616
  1749. local exit,fail_exit
  1750. mov eax,[bp + &lpby]
  1751. mov ecx,[bp_top+4] ;cpe (count of PALETTEENTRYs)
  1752. test ecx, 0C0000000h ;so we can shift left safely
  1753. jnz fail_exit
  1754. shl ecx,2
  1755. TILE_BUFFER
  1756. mov [bp - &lp1616&],eax
  1757. mov LOCAL__GETENHMETAFILEPALETTEENTRIES_dwFreeInfo,ecx
  1758. jmp exit
  1759. fail_exit:
  1760. mov sp,bp
  1761. xor eax,eax
  1762. dec eax
  1763. ERRCHK_EXIT -1,87,Exit_12
  1764. exit:
  1765. endm ;RAWPACK_GETENHMETAFILEPALETTEENTRIES_lpPALETTEENTRIES
  1766. ;-------------------------------------------------------------------------
  1767. ; RAWUNPACK_GETENHMETAFILEPALETTEENTRIES
  1768. ;-------------------------------------------------------------------------
  1769. RAWUNPACK__GETENHMETAFILEPALETTEENTRIES_lpby macro lpby,lp1616
  1770. mov ecx,LOCAL__GETENHMETAFILEPALETTEENTRIES_dwFreeInfo
  1771. UNTILE_BUFFER
  1772. endm ;RAWUNPACK_GETENHMETAFILEPALETTEENTRIES
  1773. ;-------------------------------------------------------------------------
  1774. ; RAWPACK_SETENHMETAFILEBITS
  1775. ;-------------------------------------------------------------------------
  1776. RAWPACK__SETENHMETAFILEBITS_lpby macro lpby,lp1616
  1777. local exit,fail_exit
  1778. mov eax,[bp + &lpby]
  1779. or eax,eax
  1780. jz fail_exit
  1781. mov ecx,[bp_top] ;cby (size of buffer)
  1782. or ecx,ecx
  1783. jz fail_exit
  1784. TILE_BUFFER
  1785. mov [bp - &lp1616&],eax
  1786. mov LOCAL__SETENHMETAFILEBITS_dwFreeInfo,ecx
  1787. jmp exit
  1788. fail_exit:
  1789. mov sp,bp
  1790. xor eax,eax
  1791. ERRCHK_EXIT 0,87,Exit_8
  1792. exit:
  1793. endm ;RAWPACK_SETENHMETAFILEBITS_lpBits
  1794. ;-------------------------------------------------------------------------
  1795. ; RAWUNPACK_SETENHMETAFILEBITS
  1796. ;-------------------------------------------------------------------------
  1797. RAWUNPACK__SETENHMETAFILEBITS_lpby macro lpby,lp1616
  1798. mov ecx,LOCAL__SETENHMETAFILEBITS_dwFreeInfo
  1799. UNTILE_BUFFER
  1800. endm ;RAWUNPACK_SETENHMETAFILEBITS
  1801. ;-------------------------------------------------------------------------
  1802. ; RAWPACK_ENUMOBJECTS
  1803. ;-------------------------------------------------------------------------
  1804. RAWPACK__ENUMOBJECTS_lpObjectFunc macro iOffset,iTempOffset
  1805. local pen, exit
  1806. cmp word ptr [bp_top+4],1 ;OBJ_PEN?
  1807. je pen
  1808. PACK_CALLBACK iOffset,iTempOffset,CBID_ENUMBRUSH
  1809. jmp exit
  1810. pen:
  1811. PACK_CALLBACK iOffset,iTempOffset,CBID_ENUMPEN
  1812. exit:
  1813. endm ;RAWPACK__ENUMOBJECTS_lpObjectFunc
  1814. ;-------------------------------------------------------------------------
  1815. ; RAWUNPACK_ENUMOBJECTS
  1816. ;-------------------------------------------------------------------------
  1817. RAWUNPACK__ENUMOBJECTS_lpObjectFunc macro iOffset,iTempOffset
  1818. local pen, exit
  1819. ;unpack don't care about CBID
  1820. ;just make it readable
  1821. cmp word ptr [bp_top+4],1 ;OBJ_PEN?
  1822. je pen
  1823. UNPACK_CALLBACK iOffset,iTempOffset,CBID_ENUMBRUSH
  1824. jmp exit
  1825. pen:
  1826. UNPACK_CALLBACK iOffset,iTempOffset,CBID_ENUMPEN
  1827. exit:
  1828. endm ;RAWUNPACK__ENUMOBJECTS_lpObjectFunc