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.

824 lines
24 KiB

  1. ;-------------------------------
  2. ; CVT.INC MUST BE INCLUDED FIRST
  3. ;-------------------------------
  4. include cvt.inc
  5. ;==============================================================================
  6. ; repack TEXTMETRIC from 32-bit to 16-bit
  7. ;
  8. ;==============================================================================
  9. PACK_TEXTMETRIC_32_16 macro fEmbedded
  10. lodsd ;tmHeight
  11. stosw
  12. lodsd ;tmAscent
  13. stosw
  14. lodsd ;tmDescent
  15. stosw
  16. lodsd ;tmInternalLeading
  17. stosw
  18. lodsd ;tmExternalLeading
  19. stosw
  20. lodsd ;tmAveCharWidth
  21. stosw
  22. lodsd ;tmMaxCharWidth
  23. stosw
  24. lodsd ;tmWeight
  25. stosw
  26. add esi,(4+4+4)
  27. ;32-bit order --> 16-bit order
  28. ;--------------------------------------
  29. ;tmFirstChar tmItalic
  30. ;tmLastChar tmUnderlined
  31. ;tmDefaultChar tmStruckOut
  32. ;tmBreakChar tmFirstChar
  33. ;tmItalic tmLastChar
  34. ;tmUnderlined tmDefaultChar
  35. ;tmStruckOut tmBreakChar
  36. ;tmPitchAndFamily tmPitchAndFamily
  37. ;tmCharSet tmCharSet
  38. mov eax,[esi+4]
  39. stosd ;;only three bytes valid
  40. dec edi
  41. mov eax,[esi+0]
  42. stosd
  43. mov ax,[esi+7]
  44. stosw
  45. sub esi,(4+4+4)
  46. lodsd ;tmOverhang
  47. stosw
  48. lodsd ;tmDigitizedAspectX
  49. stosw
  50. lodsd ;tmDigitizedAspectY
  51. stosw
  52. ifnb <fEmbedded>
  53. ;;Keep esi in sync since this macro is embedded in another.
  54. add esi,9
  55. endif
  56. endm
  57. ;==============================================================================
  58. ; repack TEXTMETRIC from 16-bit to 32-bit
  59. ;
  60. ;==============================================================================
  61. PACK_TEXTMETRIC_16_32 macro fEmbedded
  62. lodsw ;tmHeight
  63. cwde
  64. stos dword ptr es:[edi]
  65. lodsw ;tmAscent
  66. cwde
  67. stos dword ptr es:[edi]
  68. lodsw ;tmDescent
  69. cwde
  70. stos dword ptr es:[edi]
  71. lodsw ;tmInternalLeading
  72. cwde
  73. stos dword ptr es:[edi]
  74. lodsw ;tmExternalLeading
  75. cwde
  76. stos dword ptr es:[edi]
  77. lodsw ;tmAveCharWidth
  78. cwde
  79. stos dword ptr es:[edi]
  80. lodsw ;tmMaxCharWidth
  81. cwde
  82. stos dword ptr es:[edi]
  83. lodsw ;tmWeight
  84. cwde
  85. stos dword ptr es:[edi]
  86. add esi,9
  87. lodsw ;tmOverhang
  88. cwde
  89. stos dword ptr es:[edi]
  90. lodsw ;tmDigitizedAspectX
  91. cwde
  92. stos dword ptr es:[edi]
  93. lodsw ;tmDigitizedAspectY
  94. cwde
  95. stos dword ptr es:[edi]
  96. sub esi,(2+2+2+9)
  97. ;16-bit order --> 32-bit order
  98. ;--------------------------------------
  99. ;tmItalic tmFirstChar
  100. ;tmUnderlined tmLastChar
  101. ;tmStruckOut tmDefaultChar
  102. ;tmFirstChar tmBreakChar
  103. ;tmLastChar tmItalic
  104. ;tmDefaultChar tmUnderlined
  105. ;tmBreakChar tmStruckOut
  106. ;tmPitchAndFamily tmPitchAndFamily
  107. ;tmCharSet tmCharSet
  108. mov eax,[esi+3] ;First Last Default Break-char
  109. stos dword ptr es:[edi]
  110. mov eax,[esi+0] ;
  111. stos dword ptr es:[edi] ;Italic Underlined StruckOut
  112. dec edi ;
  113. mov ax,[esi+7]
  114. stos word ptr es:[edi] ;Pitch CharSet
  115. ifnb <fEmbedded>
  116. ;;Keep esi in sync since this macro is embedded in another.
  117. add esi,(2+2+2+9)
  118. endif
  119. endm
  120. ;==============================================================================
  121. ;==============================================================================
  122. PACK_POINT_16_32 macro
  123. ncopysx 2
  124. endm
  125. ;==============================================================================
  126. ;==============================================================================
  127. PACK_RECT_32_16 macro
  128. ncopyt 4
  129. endm
  130. PACK_RECT_16_32 macro
  131. ncopysx 4
  132. endm
  133. ;==============================================================================
  134. ;==============================================================================
  135. PACK_PANOSE_16_32 macro
  136. ;copy ten bytes
  137. ;;;; sub eax,eax
  138. ;;;; stos dword ptr es:[edi] ;!!! kirko says this will disappear
  139. lodsd
  140. stos dword ptr es:[edi]
  141. lodsd
  142. stos dword ptr es:[edi]
  143. lodsw
  144. stos word ptr es:[edi]
  145. endm
  146. ;==============================================================================
  147. ; repack OUTLINETEXTMETRIC from 16-bit to 32-bit
  148. ;
  149. ; Requirements:
  150. ; DS:ESI --> source (16-bit)
  151. ; ES:EDI --> dest (32-bit)
  152. ;==============================================================================
  153. OUTLINETEXTMETRIC16_SIZE equ 114
  154. OUTLINETEXTMETRIC32_SIZE equ 212
  155. PACK_OUTLINETEXTMETRIC_16_32 macro
  156. COPY_STRING macro
  157. local loop_top
  158. loop_top:
  159. lodsb
  160. stos byte ptr es:[edi]
  161. or al,al
  162. jnz loop_top
  163. endm
  164. COPY_OTM_STRING macro last
  165. mov cx,si ;;save source ptr into struct
  166. mov si,[si] ;;get offset to chars
  167. add si,bx ;;add in base
  168. COPY_STRING ;;copy characters
  169. mov si,cx ;;restore source ptr into struct
  170. ifb <last>
  171. add si,2 ;;next offset in struct
  172. endif
  173. endm
  174. COPY_ADJUSTED_OFFSET macro
  175. lodsw
  176. movzx eax,ax
  177. add eax,OUTLINETEXTMETRIC32_SIZE - OUTLINETEXTMETRIC16_SIZE
  178. stos dword ptr es:[edi]
  179. endm
  180. mov bx,si ;;save copy for strings at end
  181. COPY_ADJUSTED_OFFSET ;otmSize
  182. PACK_TEXTMETRIC_16_32 embedded ;otmTextMetrics
  183. lodsb ;otmFiller
  184. stosb es:[edi] ;
  185. add edi, 3 ;DWORD align otmPanoseNumber
  186. PACK_PANOSE_16_32 ;otmPanoseNumber
  187. add edi, 1 ;DWORD align otmfsSelection
  188. UMAP_WORDTODWORD ;otmfsSelection;
  189. UMAP_WORDTODWORD ;otmfsType;
  190. UMAP_WORDTODWORD ;otmsCharSlopeRise;
  191. UMAP_WORDTODWORD ;otmsCharSlopeRun;
  192. UMAP_INTTOLONG ;otmItalicAngle;
  193. UMAP_WORDTODWORD ;otmEMSquare;
  194. UMAP_WORDTODWORD ;otmAscent;
  195. UMAP_INTTOLONG ;otmDescent;
  196. UMAP_INTTOLONG ;otmLineGap;
  197. UMAP_WORDTODWORD ;otmXHeight;
  198. UMAP_WORDTODWORD ;otmCapEmHeight;
  199. PACK_RECT_16_32 ;otmrcFontBox;
  200. UMAP_INTTOLONG ;otmMacAscent;
  201. UMAP_INTTOLONG ;otmMacDescent;
  202. UMAP_WORDTODWORD ;otmMacLineGap;
  203. UMAP_WORDTODWORD ;otmusMinimumPPEM;
  204. PACK_POINT_16_32 ;otmptSubscriptSize;
  205. PACK_POINT_16_32 ;otmptSubscriptOffset;
  206. PACK_POINT_16_32 ;otmptSuperscriptSize;
  207. PACK_POINT_16_32 ;otmptSuperscriptOffset;
  208. UMAP_WORDTODWORD ;otmsStrikeoutSize;
  209. UMAP_INTTOLONG ;otmsStrikeoutPosition;
  210. ; Need to flip otmUnderscorePosition and otmUnderscoreSize
  211. movzx eax, word ptr [si+2] ; otmUnderscoreSize
  212. stosd es:[edi] ;
  213. movsx eax, word ptr [si] ; otmUnderscorePosition
  214. stosd es:[edi] ;
  215. add si, 4 ;
  216. COPY_ADJUSTED_OFFSET ;otmpFamilyName;
  217. COPY_ADJUSTED_OFFSET ;otmpFaceName;
  218. COPY_ADJUSTED_OFFSET ;otmpStyleName;
  219. COPY_ADJUSTED_OFFSET ;otmpFullName;
  220. ;;Rewind source to first of string offsets
  221. sub si,2*4
  222. COPY_OTM_STRING
  223. COPY_OTM_STRING
  224. COPY_OTM_STRING
  225. COPY_OTM_STRING last
  226. purge COPY_STRING
  227. purge COPY_OTM_STRING
  228. purge COPY_ADJUSTED_OFFSET
  229. endm
  230. ;==============================================================================
  231. ; repack NEWTEXTMETRIC from 16-bit to 32-bit
  232. ;
  233. ;==============================================================================
  234. PACK_NEWTEXTMETRIC_16_32 macro
  235. PACK_TEXTMETRIC_16_32 embedded
  236. add edi,3 ;padding bytes
  237. lodsd ;ntmFlags
  238. stos dword ptr es:[edi]
  239. sub eax,eax
  240. lodsw ;ntmSizeEM
  241. stos dword ptr es:[edi]
  242. lodsw ;ntmCellHeight
  243. stos dword ptr es:[edi]
  244. lodsw ;ntmAvgWidth
  245. stos dword ptr es:[edi]
  246. endm
  247. ;==============================================================================
  248. ; repack LOGFONT from 32-bit to 16-bit
  249. ;
  250. ;==============================================================================
  251. PACK_LOGFONT_32_16 macro
  252. lodsd ;lfHeight
  253. stosw
  254. lodsd ;lfWidth
  255. stosw
  256. lodsd ;lfEscapement
  257. stosw
  258. lodsd ;lfOrientation
  259. stosw
  260. lodsd ;lfWeight
  261. stosw
  262. ;These are all BYTE fields:
  263. ;lfItalic
  264. ;lfUnderline
  265. ;lfStrikeOut
  266. ;lfCharSet
  267. ;lfOutPrecision
  268. ;lfClipPrecision
  269. ;lfQuality
  270. ;lfPitchAndFamily
  271. ;lfFaceName[32]
  272. mov ecx,40/4
  273. rep movsd
  274. endm
  275. ;==============================================================================
  276. ; repack LOGFONT from 16-bit to 32-bit
  277. ;
  278. ;==============================================================================
  279. PACK_LOGFONT_16_32 macro
  280. lodsw ;lfHeight
  281. cwde
  282. stosd
  283. lodsw ;lfWidth
  284. cwde
  285. stosd
  286. lodsw ;lfEscapement
  287. cwde
  288. stosd
  289. lodsw ;lfOrientation
  290. cwde
  291. stosd
  292. lodsw ;lfWeight
  293. cwde
  294. stosd
  295. ;These are all BYTE fields:
  296. ;lfItalic
  297. ;lfUnderline
  298. ;lfStrikeOut
  299. ;lfCharSet
  300. ;lfOutPrecision
  301. ;lfClipPrecision
  302. ;lfQuality
  303. ;lfPitchAndFamily
  304. ;lfFaceName[32]
  305. mov ecx,40/4
  306. rep movsd
  307. endm
  308. ;==============================================================================
  309. ; Convert MLOGFONT 32->16
  310. ;
  311. ;==============================================================================
  312. PACK_MLOGFONT_32_16 macro
  313. ncopyt 5
  314. ncopyd 40/4
  315. endm
  316. ;==============================================================================
  317. ; Convert MLOGFONT 16->32
  318. ;
  319. ;==============================================================================
  320. PACK_MLOGFONT_16_32 macro
  321. ncopysx 5
  322. ncopyd 40/4
  323. endm
  324. ;==============================================================================
  325. ; repack ENUMLOGFONT from 16-bit to 32-bit
  326. ;
  327. ;==============================================================================
  328. PACK_ENUMLOGFONT_16_32 macro
  329. lodsw ;lfHeight
  330. cwde
  331. stos dword ptr es:[edi]
  332. lodsw ;lfWidth
  333. cwde
  334. stos dword ptr es:[edi]
  335. lodsw ;lfEscapement
  336. cwde
  337. stos dword ptr es:[edi]
  338. lodsw ;lfOrientation
  339. cwde
  340. stos dword ptr es:[edi]
  341. lodsw ;lfWeight
  342. cwde
  343. stos dword ptr es:[edi]
  344. ;These are all BYTE fields:
  345. ;lfItalic
  346. ;lfUnderline
  347. ;lfStrikeOut
  348. ;lfCharSet
  349. ;lfOutPrecision
  350. ;lfClipPrecision
  351. ;lfQuality
  352. ;lfPitchAndFamily
  353. ;lfFaceName[32]
  354. ;elfFullName[64]
  355. ;elfStyle[32]
  356. mov ecx,136/4
  357. rep movs dword ptr es:[edi],dword ptr ds:[esi]
  358. endm
  359. ;==============================================================================
  360. ; repack BITMAP from 32-bit to 16-bit
  361. ;
  362. ;==============================================================================
  363. PACK_BITMAP_32_16 macro
  364. lodsd ;bmType
  365. stosw
  366. lodsd ;bmWidth
  367. stosw
  368. lodsd ;bmHeight
  369. stosw
  370. lodsd ;bmWidthBytes
  371. stosw
  372. lodsw ;bmPlanes
  373. stosb
  374. lodsw ;bmBitsPixel
  375. stosb
  376. movsd ;bmBits
  377. endm
  378. ;-----------------------------------------------------------------------;
  379. ; Printer api thunk stuff
  380. ;-----------------------------------------------------------------------;
  381. DEVMODECOMMON struc
  382. dmDeviceName db 32 dup (?)
  383. dmSpecVersion dw ?
  384. dmDriverVersion dw ?
  385. dmSize dw ?
  386. dmDriverExtra dw ?
  387. dmFields dd ?
  388. dmOrientation dw ?
  389. dmPaperSize dw ?
  390. dmPaperLength dw ?
  391. dmPaperWidth dw ?
  392. dmScale dw ?
  393. dmCopies dw ?
  394. dmDefaultSource dw ?
  395. dmPrintQuality dw ?
  396. dmColor dw ?
  397. dmDuplex dw ?
  398. dmYResolution dw ?
  399. dmTTOption dw ?
  400. DEVMODECOMMON ends
  401. DEVMODE16 struc
  402. dmCommon db size DEVMODECOMMON dup (?)
  403. DEVMODE16 ends
  404. DEVMODE32 struc
  405. dmCommon db size DEVMODECOMMON dup (?)
  406. dmCollate dw ?
  407. dmFormName db 32 dup (?)
  408. dmUnusedPadding dw ?
  409. dmBitsPerPel dw ?
  410. dmPelsWidth dd ?
  411. dmPelsHeight dd ?
  412. dmDisplayMode dd ?
  413. DEVMODE32 ends
  414. ;-----------------------------------------------------------------------;
  415. ; REPACK_DEVMODE_32_16
  416. ;
  417. ; Entry:
  418. ; DS:ESI --> 32-bit source (ESI might be flat offset)
  419. ; ES:EDI --> 16-bit destination (EDI is zero-extended from DI)
  420. ; direction flag cleared
  421. ;-----------------------------------------------------------------------;
  422. REPACK_DEVMODE_32_16 macro
  423. local done
  424. ;Move the common part as a single block move.
  425. MoveBytes <(size DEVMODECOMMON)>
  426. ;Update the dmSize field
  427. mov es:[di].(dmSize - (size DEVMODECOMMON)),size DEVMODE16
  428. ;!!!Clear out any win32-only flags
  429. ;and es:[di].(dmFields - (size DEVMODECOMMON)),0FFFFh
  430. ;Insert win16-only fields. EDI points to the byte after
  431. ;DEVMODECOMMON. Afterwards, will point to byte after DEVMODE16.
  432. ;ZeroBytes <((size DEVMODE16) - (size DEVMODECOMMON))>
  433. ;Skip over the extra win32 fields. ESI still points to the byte
  434. ;after DEVMODECOMMON.
  435. add esi,(size DEVMODE32) - (size DEVMODECOMMON)
  436. ;Move the driver-dependent part. EDI points to the byte after
  437. ;DEVMODE16.
  438. mov cx,es:[di].(dmDriverExtra - (size DEVMODE16))
  439. jcxz done
  440. movzx ecx,cx
  441. mov edx,ecx
  442. shr cx,2
  443. and dx,3
  444. rep movs dword ptr es:[edi],dword ptr ds:[esi]
  445. mov cx,dx
  446. rep movs byte ptr es:[edi],byte ptr ds:[esi]
  447. done:
  448. endm
  449. ;-----------------------------------------------------------------------;
  450. ; REPACK_DEVMODE_16_32
  451. ;
  452. ; Entry:
  453. ; DS:ESI --> 16-bit destination (ESI is zero-extended from SI)
  454. ; ES:EDI --> 32-bit source (EDI might be flat offset)
  455. ; direction flag cleared
  456. ;-----------------------------------------------------------------------;
  457. REPACK_DEVMODE_16_32 macro
  458. local done
  459. ;Move the common part as a single block move.
  460. MoveBytes <(size DEVMODECOMMON)>
  461. ;Update the dmSize field
  462. mov es:[edi].(dmSize - (size DEVMODECOMMON)),size DEVMODE32
  463. ;Insert the win32-only fields (advances EDI to end of DEVMODE32)
  464. ZeroBytes <((size DEVMODE32) - (size DEVMODECOMMON))>
  465. ;Move the driver-dependent part. SI points to the byte after
  466. ;DEVMODECOMMON.
  467. movzx ecx,[si].(dmDriverExtra - (size DEVMODECOMMON))
  468. jcxz done
  469. mov edx,ecx
  470. shr cx,2
  471. and dx,3
  472. rep movs dword ptr es:[edi],dword ptr ds:[esi]
  473. mov cx,dx
  474. rep movs byte ptr es:[edi],byte ptr ds:[esi]
  475. done:
  476. endm
  477. OLETARGETDEVICE16 struc
  478. otd16DeviceNameOffset dw ?
  479. otd16DriverNameOffset dw ?
  480. otd16PortNameOffset dw ?
  481. otd16ExtDevmodeOffset dw ?
  482. otd16ExtDevmodeSize dw ?
  483. otd16EnvironmentOffset dw ?
  484. otd16EnvironmentSize dw ?
  485. ;otd16Data[1] db 1 dup (?)
  486. OLETARGETDEVICE16 ends
  487. OLETARGETDEVICE32 struc
  488. otd32DeviceNameOffset dd ?
  489. otd32DriverNameOffset dd ?
  490. otd32PortNameOffset dd ?
  491. otd32ExtDevmodeOffset dd ?
  492. otd32ExtDevmodeSize dd ?
  493. otd32EnvironmentOffset dd ?
  494. otd32EnvironmentSize dd ?
  495. ;otd32Data[1] db 1 dup (?)
  496. OLETARGETDEVICE32 ends
  497. ;-----------------------------------------------------------------------;
  498. ; REPACK_OLETARGETDEVICE_32_16
  499. ;
  500. ; Entry:
  501. ; DS:ESI --> 32-bit source (ESI might be flat offset)
  502. ; ES:EDI --> 16-bit destination (EDI is zero-extended from DI)
  503. ; direction flag cleared
  504. ;-----------------------------------------------------------------------;
  505. REPACK_OLETARGETDEVICE_32_16 macro
  506. ; Entry:
  507. ; DS:ESI --> 32-bit source (ESI might be flat offset)
  508. ; ES:EDI --> 16-bit destination (EDI is zero-extended from DI)
  509. ; ES:BX --> 16-bit structure base
  510. ; direction flag cleared
  511. ;
  512. ; Exit:
  513. ; DS:ESI preserved
  514. ; ES:EDI updated
  515. ; ES:BX preserved
  516. MOVE_STRING macro foo
  517. local loop_top
  518. push esi ;save original source
  519. add esi,[esi].otd32&foo&Offset
  520. add esi,size OLETARGETDEVICE32
  521. mov ax,di ;current offset
  522. sub ax,bx ;offset from base
  523. sub ax,size OLETARGETDEVICE16 ;offsets start from end
  524. mov es:[bx].otd16&foo&Offset,ax ;store new offset
  525. loop_top:
  526. mov al,[esi]
  527. mov es:[di],al
  528. inc esi
  529. inc di
  530. or al,al
  531. jnz loop_top
  532. pop esi
  533. endm
  534. ; Entry:
  535. ; DS:ESI --> 32-bit source (ESI might be flat offset)
  536. ; ES:EDI --> 16-bit destination (EDI is zero-extended from DI)
  537. ; ES:BX --> 16-bit structure base
  538. ; direction flag cleared
  539. ;
  540. ; Exit:
  541. ; DS:ESI preserved
  542. ; ES:EDI updated
  543. ; ES:BX preserved
  544. MOVE_DEVMODE macro foo
  545. local exit, empty_fields
  546. mov eax,[esi].otd32&foo&Size
  547. or eax,eax
  548. jz empty_fields
  549. push esi ;save original source
  550. push bx ;base pointer
  551. add esi,[esi].otd32&foo&Offset
  552. add esi,size OLETARGETDEVICE32
  553. mov ax,di ;current offset
  554. sub ax,bx ;offset from base
  555. sub ax,size OLETARGETDEVICE16 ;offsets start from end
  556. mov es:[bx].otd16&foo&Offset,ax ;store new offset
  557. REPACK_DEVMODE_32_16
  558. pop bx ;restore base pointer
  559. pop esi
  560. mov ax,di
  561. sub ax,es:[bx].otd16&foo&Offset
  562. mov es:[bx].otd16&foo&Size,ax ;store new size
  563. jmp short exit
  564. empty_fields:
  565. mov es:[bx].otd16&foo&Offset,ax ;store null offset
  566. mov es:[bx].otd16&foo&Size,ax ;store null size
  567. exit:
  568. endm
  569. mov bx,di
  570. add di,size OLETARGETDEVICE16 ;put first string here
  571. MOVE_STRING DeviceName
  572. MOVE_STRING DriverName
  573. MOVE_STRING PortName
  574. MOVE_DEVMODE ExtDevmode
  575. MOVE_DEVMODE Environment
  576. purge MOVE_STRING
  577. purge MOVE_DEVMODE
  578. endm
  579. ;-----------------------------------------------------------------------;
  580. ; REPACK_OLETARGETDEVICE_16_32
  581. ;
  582. ; Entry:
  583. ; DS:ESI --> 16-bit source (ESI is zero-extended from SI)
  584. ; ES:EDI --> 32-bit destination (EDI might be flat offset)
  585. ; direction flag cleared
  586. ;-----------------------------------------------------------------------;
  587. REPACK_OLETARGETDEVICE_16_32 macro
  588. ; Entry:
  589. ; DS:ESI --> 16-bit source (ESI is zero-extended from DI)
  590. ; ES:EDI --> 32-bit destination (EDI might be flat offset)
  591. ; ES:EBX --> 32-bit structure base
  592. ; direction flag cleared
  593. ;
  594. ; Exit:
  595. ; DS:ESI preserved
  596. ; ES:EDI updated
  597. ; ES:EBX preserved
  598. MOVE_STRING macro foo
  599. local loop_top
  600. push si ;save original source
  601. add si,[si].otd16&foo&Offset
  602. add si,size OLETARGETDEVICE16
  603. mov eax,edi ;current offset
  604. sub eax,ebx ;offset from base
  605. sub eax,size OLETARGETDEVICE32 ;offsets start from end
  606. mov es:[ebx].otd32&foo&Offset,eax ;store new offset
  607. loop_top:
  608. mov al,[si]
  609. mov es:[edi],al
  610. inc si
  611. inc edi
  612. or al,al
  613. jnz loop_top
  614. pop si
  615. endm
  616. ; Entry:
  617. ; DS:ESI --> 16-bit source (ESI is zero-extended from DI)
  618. ; ES:EDI --> 32-bit destination (EDI might be flat offset)
  619. ; ES:EBX --> 32-bit structure base
  620. ; direction flag cleared
  621. ;
  622. ; Exit:
  623. ; DS:ESI preserved
  624. ; ES:EDI updated
  625. ; ES:EBX preserved
  626. MOVE_DEVMODE macro foo
  627. local exit, empty_fields
  628. mov ax,[si].otd16&foo&Size
  629. or ax,ax
  630. jz empty_fields
  631. push si ;save original source
  632. push ebx ;base pointer
  633. add si,[si].otd16&foo&Offset
  634. add si,size OLETARGETDEVICE16
  635. mov eax,edi ;current offset
  636. sub eax,ebx ;offset from base
  637. sub eax,size OLETARGETDEVICE32 ;offsets start from end
  638. mov es:[ebx].otd32&foo&Offset,eax ;store new offset
  639. REPACK_DEVMODE_16_32
  640. pop ebx ;restore base pointer
  641. pop si
  642. mov eax,edi
  643. sub eax,es:[ebx].otd32&foo&Offset
  644. mov es:[ebx].otd32&foo&Size,eax ;store new size
  645. jmp short exit
  646. empty_fields:
  647. sub eax,eax
  648. mov es:[ebx].otd32&foo&Offset,eax ;store null offset
  649. mov es:[ebx].otd32&foo&Size,eax ;store null size
  650. exit:
  651. endm
  652. mov ebx,edi
  653. add edi,size OLETARGETDEVICE32 ;put first string here
  654. MOVE_STRING DeviceName
  655. MOVE_STRING DriverName
  656. MOVE_STRING PortName
  657. MOVE_DEVMODE ExtDevmode
  658. MOVE_DEVMODE Environment
  659. purge MOVE_STRING
  660. purge MOVE_DEVMODE
  661. endm