Leaked source code of windows server 2003
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.

4111 lines
118 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. umpddrv.cxx
  5. Abstract:
  6. User-mode printer driver support for Drv callback functions
  7. Environment:
  8. Windows NT 5.0
  9. Revision History:
  10. 07/8/97 -lingyunw-
  11. Created it.
  12. 09/17/97 -davidx-
  13. Clean up km-um thunking.
  14. --*/
  15. #include "precomp.hxx"
  16. #if !defined(_GDIPLUS_)
  17. extern BOOL GreCopyFD_GLYPHSET(FD_GLYPHSET *dst, FD_GLYPHSET *src, ULONG cjSize, BOOL bFromKernel);
  18. extern HSEMAPHORE ghsemEUDC2;
  19. DWORD
  20. UMPDOBJ::Thunk(PVOID pvIn, ULONG cjIn, PVOID pvOut, ULONG cjOut)
  21. {
  22. ASSERTGDI(!GreIsSemaphoreOwnedByCurrentThread(ghsemPalette),
  23. "ghsemPalette is held calling back to user mode driver\n");
  24. ASSERTGDI(!GreIsSemaphoreOwnedByCurrentThread(ghsemHmgr),
  25. "ghsemHmgr is held calling back to user mode driver\n");
  26. ASSERTGDI(!GreIsSemaphoreOwnedByCurrentThread(ghsemDriverMgmt),
  27. "ghsemDriverMgmt is held calling back to user mode driver\n");
  28. ASSERTGDI(!GreIsSemaphoreOwnedByCurrentThread(ghsemRFONTList),
  29. "ghsemRFONTList is held calling back to user mode driver\n");
  30. ASSERTGDI(!GreIsSemaphoreOwnedByCurrentThread(ghsemPublicPFT),
  31. "ghsemPublicPFT is held calling back to user mode driver\n");
  32. ASSERTGDI(!GreIsSemaphoreOwnedByCurrentThread(ghsemGdiSpool),
  33. "ghsemGdiSpool is held calling back to user mode driver\n");
  34. ASSERTGDI(!GreIsSemaphoreOwnedByCurrentThread(ghsemWndobj),
  35. "ghsemWndobj is held calling back to user mode driver\n");
  36. ASSERTGDI(!GreIsSemaphoreOwnedByCurrentThread(ghsemGlyphSet),
  37. "ghsemGlyphSet is held calling back to user mode driver\n");
  38. ASSERTGDI(!GreIsSemaphoreOwnedByCurrentThread(ghsemWndobj),
  39. "ghsemWndobj is held calling back to user mode driver\n");
  40. ASSERTGDI(!GreIsSemaphoreOwnedByCurrentThread(ghsemPrintKView),
  41. "ghsemPrintKView is held calling back to user mode driver\n");
  42. ASSERTGDI(!GreIsSemaphoreOwnedByCurrentThread(ghsemShareDevLock),
  43. "ghsemShareDevLock is held calling back to user mode driver\n");
  44. ASSERTGDI(!GreIsSemaphoreOwnedByCurrentThread(ghsemEUDC1),
  45. "ghsemEUDC1 is held calling back to user mode driver\n");
  46. // WINBUG #214225 we should enable these assertion when 214225 is fixed.
  47. //ASSERTGDI(!GreIsSemaphoreOwnedByCurrentThread(ghsemEUDC2),
  48. // "ghsemEUDC2 is held calling back to user mode driver\n");
  49. //ASSERTGDI(KeAreApcsDisabled() == 0,
  50. // "UMPDOBJ::Thunk(): holding some semaphore(s) while calling back to user mode\n");
  51. if (KeAreApcsDisabled())
  52. {
  53. WARNING("UMPDOBJ:Thunk(): holding kernel semaphore(s) while calling into user mode\n");
  54. }
  55. #if defined(_WIN64)
  56. if(bWOW64())
  57. {
  58. // pvIn and pvOut are pointers to stack ... fix this
  59. UM64_PVOID umIn = AllocUserMem(cjIn);
  60. UM64_PVOID umOut = AllocUserMem(cjOut);
  61. KERNEL_PVOID kmIn = GetKernelPtr(umIn);
  62. KERNEL_PVOID kmOut = GetKernelPtr(umOut);
  63. NTSTATUS status;
  64. ULONG ulType = ((UMPDTHDR*)pvIn)->umthdr.ulType;
  65. if(umIn == NULL || umOut == NULL) return -1;
  66. RtlCopyMemory(kmIn, pvIn, cjIn);
  67. if ((ulType == INDEX_DrvQueryFont && ((QUERYFONTINPUT*)pvIn)->iFace) ||
  68. (ulType == INDEX_DrvQueryFontTree && (((QUERYFONTINPUT*)pvIn)->iMode & (QFT_GLYPHSET | QFT_KERNPAIRS))))
  69. {
  70. ((QUERYFONTINPUT*)pvIn)->cjMaxData = ((QUERYFONTINPUT*)kmIn)->cjMaxData = ulGetMaxSize();
  71. ((QUERYFONTINPUT*)pvIn)->pv = ((QUERYFONTINPUT*)kmIn)->pv = (PVOID)((PBYTE)umOut + cjOut);
  72. }
  73. PROXYPORT proxyport(m_proxyPort);
  74. status = proxyport.SendRequest(umIn, cjIn, umOut, cjOut);
  75. RtlCopyMemory(pvOut, kmOut, cjOut);
  76. if(!status)
  77. return 0;
  78. else
  79. return -1;
  80. }
  81. else
  82. #endif
  83. {
  84. return ClientPrinterThunk(pvIn, cjIn, pvOut, cjOut);
  85. }
  86. }
  87. BOOL bIsFreeHooked(DHPDEV dhpdev, PUMPDOBJ pumpdobj)
  88. {
  89. BOOL bRet = TRUE;
  90. PUMDHPDEV pUMdhpdev = (PUMDHPDEV) dhpdev;
  91. if (!pumpdobj->bWOW64())
  92. {
  93. __try
  94. {
  95. PUMPD pUMPD;
  96. ProbeForRead (pUMdhpdev, sizeof(UMDHPDEV), sizeof(BYTE));
  97. pUMPD = pUMdhpdev->pUMPD;
  98. ProbeForRead (pUMPD, sizeof(UMPD), sizeof(BYTE));
  99. if (pUMPD->apfn[INDEX_DrvFree] == NULL)
  100. {
  101. bRet = FALSE;
  102. }
  103. }
  104. __except(EXCEPTION_EXECUTE_HANDLER)
  105. {
  106. WARNING ("fail to read dhpdev\n");
  107. bRet = FALSE;;
  108. }
  109. }
  110. return bRet;
  111. }
  112. //
  113. // BOOL UMPDDrvEnableDriver
  114. // UMPD DrvEnableDriver thunk.
  115. //
  116. // Returns
  117. // BOOLEAN
  118. //
  119. // Arguments:
  120. // pswzDriver Driver Path Name
  121. // ppUMPD Pointer to a buffer receiving a PUMPD pointer
  122. // which should be filled by the client UMPD thunk
  123. //
  124. // History:
  125. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  126. BOOL UMPDDrvDriverFn(
  127. PVOID cookie,
  128. BOOL * pbDrvFn
  129. )
  130. {
  131. DRVDRIVERFNINPUT Input;
  132. XUMPDOBJ XUMObjs;
  133. if(XUMObjs.bValid())
  134. {
  135. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  136. Input.umpdthdr.umthdr.ulType = INDEX_UMDriverFN;
  137. Input.umpdthdr.humpd = XUMObjs.hUMPD();
  138. Input.cookie = cookie;
  139. return XUMObjs.pumpdobj()->Thunk(&Input, sizeof(Input), (BOOL *) pbDrvFn, (sizeof(BOOL) * INDEX_LAST)) != 0xffffffff;
  140. }
  141. else
  142. {
  143. return FALSE;
  144. }
  145. }
  146. //
  147. // BOOL UMPDDrvEnableDriver
  148. // UMPD DrvEnableDriver thunk.
  149. //
  150. // Returns
  151. // BOOLEAN
  152. //
  153. // Arguments:
  154. // pswzDriver Driver Path Name
  155. // ppUMPD Pointer to a buffer receiving a PUMPD pointer
  156. // which should be filled by the client UMPD thunk
  157. //
  158. // History:
  159. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  160. BOOL UMPDDrvEnableDriver(
  161. LPWSTR pwszDriver,
  162. PVOID *pCookie
  163. )
  164. {
  165. DRVENABLEDRIVERINPUT Input;
  166. XUMPDOBJ XUMObjs;
  167. if(XUMObjs.bValid())
  168. {
  169. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  170. if (pwszDriver == NULL)
  171. {
  172. WARNING ("null pwszDriver passed in UMPDDrvEnableDriver\n");
  173. return FALSE;
  174. }
  175. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  176. Input.umpdthdr.umthdr.ulType = INDEX_UMPDDrvEnableDriver; //index for DrvEnableDriver
  177. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  178. Input.pwszDriver = pwszDriver;
  179. return pumpdobj->ThunkStringW(&Input.pwszDriver) &&
  180. pumpdobj->Thunk(&Input, sizeof(Input), pCookie, sizeof(PVOID)) != 0xffffffff;
  181. }
  182. else
  183. {
  184. return FALSE;
  185. }
  186. }
  187. //
  188. //
  189. // BOOL UMPDDrvDisablePDEV
  190. // UMPD DrvDisablePDEV thunk. This routine packs up the parameters
  191. // and send across to the client side, and copy the output parameters back
  192. // after returning from client side.
  193. //
  194. // Returns
  195. // VOID
  196. //
  197. // Arguments:
  198. // refer to DrvDisablePDEV
  199. //
  200. // History:
  201. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  202. //
  203. VOID
  204. UMPDDrvDisablePDEV(
  205. DHPDEV dhpdev
  206. )
  207. {
  208. XUMPDOBJ XUMObjs;
  209. if(XUMObjs.bValid())
  210. {
  211. DHPDEVINPUT Input;
  212. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  213. Input.umpdthdr.umthdr.ulType = INDEX_DrvDisablePDEV;
  214. Input.umpdthdr.humpd = XUMObjs.hUMPD();
  215. Input.dhpdev = dhpdev;
  216. XUMObjs.pumpdobj()->Thunk(&Input, sizeof(Input), NULL, 0);
  217. PW32THREAD pThread = W32GetCurrentThread();
  218. if (pThread->pUMPDObjs == NULL)
  219. {
  220. DestroyUMPDHeap((PUMPDHEAP) pThread->pUMPDHeap);
  221. pThread->pUMPDHeap = NULL;
  222. }
  223. }
  224. }
  225. //
  226. // BOOL UMPDDrvEnablePDEV
  227. // UMPD DrvEnablePDEV thunk. This routine pack up the input parameters
  228. // and send across to the client side, and copy the output parameters back
  229. // after returning from client side.
  230. //
  231. // Returns
  232. // BOOLEAN
  233. //
  234. // Arguments:
  235. // refer to DrvEnablePDEV
  236. //
  237. // History:
  238. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  239. //
  240. DHPDEV
  241. UMPDDrvEnablePDEV(
  242. PDEVMODEW pdm,
  243. PWSTR pLogAddress,
  244. ULONG cPatterns,
  245. HSURF *phsurfPatterns,
  246. ULONG cjCaps,
  247. ULONG *pdevcaps,
  248. ULONG cjDevInfo,
  249. DEVINFO *pDevInfo,
  250. HDEV hdev, // passed in as ppdev
  251. PWSTR pDeviceName,
  252. HANDLE hPrinter
  253. )
  254. {
  255. DRVENABLEPDEVINPUT Input;
  256. ULONG dmSize;
  257. DHPDEV dhpdev;
  258. XUMPDOBJ XUMObjs;
  259. if(XUMObjs.bValid())
  260. {
  261. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  262. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  263. Input.umpdthdr.umthdr.ulType = INDEX_DrvEnablePDEV;
  264. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  265. Input.umpdCookie = (PVOID) (((PPDEV) hdev)->dhpdev);
  266. Input.pdm = pdm;
  267. Input.pLogAddress = pLogAddress;
  268. Input.cPatterns = cPatterns;
  269. Input.phsurfPatterns = phsurfPatterns;
  270. Input.cjCaps = cjCaps;
  271. Input.cjDevInfo = cjDevInfo;
  272. Input.hdev = hdev;
  273. Input.pDeviceName = pDeviceName;
  274. Input.hPrinter = hPrinter;
  275. Input.bWOW64 = pumpdobj->bWOW64();
  276. Input.clientPid = Input.bWOW64 ? W32GetCurrentPID() : 0;
  277. dmSize = pdm ? pdm->dmSize + pdm->dmDriverExtra : 0;
  278. //
  279. // Allocate temporary output buffers
  280. //
  281. if (phsurfPatterns &&
  282. !(Input.phsurfPatterns = (HSURF *) pumpdobj->AllocUserMemZ(sizeof(HSURF)*cPatterns)) ||
  283. pdevcaps && !(Input.pdevcaps = (ULONG *) pumpdobj->AllocUserMemZ(cjCaps)) ||
  284. pDevInfo && !(Input.pDevInfo = (DEVINFO *) pumpdobj->AllocUserMemZ(cjDevInfo)))
  285. {
  286. return NULL;
  287. }
  288. #if defined (_WIN64)
  289. if (Input.bWOW64)
  290. {
  291. PBYTE pHtPat = (PBYTE)pumpdobj->AllocUserMemZ(HT_USERPAT_CX_MAX*HT_USERPAT_CY_MAX*3);
  292. if (pHtPat)
  293. {
  294. Input.pHTPatA = &pHtPat[HT_USERPAT_CX_MAX*HT_USERPAT_CY_MAX*0];
  295. Input.pHTPatB = &pHtPat[HT_USERPAT_CX_MAX*HT_USERPAT_CY_MAX*1];
  296. Input.pHTPatC = &pHtPat[HT_USERPAT_CX_MAX*HT_USERPAT_CY_MAX*2];
  297. }
  298. else
  299. {
  300. return NULL;
  301. }
  302. }
  303. #endif
  304. //
  305. // Thunk to user mode
  306. //
  307. if (!pumpdobj->ThunkMemBlock((PVOID *) &Input.pdm, dmSize) ||
  308. !pumpdobj->ThunkStringW(&Input.pLogAddress) ||
  309. !pumpdobj->ThunkStringW(&Input.pDeviceName) ||
  310. pumpdobj->Thunk(&Input, sizeof(Input), &dhpdev, sizeof(dhpdev)) == 0xffffffff)
  311. {
  312. return NULL;
  313. }
  314. if (phsurfPatterns)
  315. RtlCopyMemory(phsurfPatterns, pumpdobj->GetKernelPtr(Input.phsurfPatterns), cPatterns*sizeof(HSURF));
  316. if (pdevcaps)
  317. RtlCopyMemory(pdevcaps, pumpdobj->GetKernelPtr(Input.pdevcaps), cjCaps);
  318. #if defined(_WIN64)
  319. if (Input.bWOW64 && pdevcaps)
  320. {
  321. GDIINFO *pGdiInfo = (GDIINFO*)pdevcaps;
  322. if (pGdiInfo->ulHTPatternSize == HT_PATSIZE_USER &&
  323. pGdiInfo->cxHTPat <= HT_USERPAT_CX_MAX &&
  324. pGdiInfo->cyHTPat <= HT_USERPAT_CY_MAX)
  325. {
  326. // Mark the PDEV so we can cleanup the allocations in
  327. // case of a failure in pdevobj.cxx
  328. PDEVOBJ pdo(hdev);
  329. pdo.setfl(TRUE, PDEV_WOW64_HTPATSIZE_USER);
  330. pGdiInfo->pHTPatA = 0;
  331. pGdiInfo->pHTPatB = 0;
  332. pGdiInfo->pHTPatC = 0;
  333. LPBYTE pHTPatA = (LPBYTE)pumpdobj->GetKernelPtr(Input.pHTPatA);
  334. LPBYTE pHTPatB = (LPBYTE)pumpdobj->GetKernelPtr(Input.pHTPatB);
  335. LPBYTE pHTPatC = (LPBYTE)pumpdobj->GetKernelPtr(Input.pHTPatC);
  336. LPBYTE pHTPatACopy = NULL;
  337. LPBYTE pHTPatBCopy = NULL;
  338. LPBYTE pHTPatCCopy = NULL;
  339. if (Input.bHTPatA)
  340. pHTPatACopy = (LPBYTE)EngAllocUserMem(pGdiInfo->cxHTPat*pGdiInfo->cyHTPat, UMPD_MEMORY_TAG);
  341. if (Input.bHTPatB)
  342. pHTPatBCopy = (LPBYTE)EngAllocUserMem(pGdiInfo->cxHTPat*pGdiInfo->cyHTPat, UMPD_MEMORY_TAG);
  343. if (Input.bHTPatC)
  344. pHTPatCCopy = (LPBYTE)EngAllocUserMem(pGdiInfo->cxHTPat*pGdiInfo->cyHTPat, UMPD_MEMORY_TAG);
  345. // The DDI requires at least pHTPatA to be set. PatB and PatC
  346. // are optional.
  347. if (pHTPatACopy)
  348. {
  349. __try
  350. {
  351. ProbeAndReadBuffer(pHTPatACopy,
  352. pHTPatA,
  353. pGdiInfo->cxHTPat*
  354. pGdiInfo->cyHTPat);
  355. if (pHTPatBCopy)
  356. {
  357. ProbeAndReadBuffer(pHTPatBCopy,
  358. pHTPatB,
  359. pGdiInfo->cxHTPat*
  360. pGdiInfo->cyHTPat);
  361. }
  362. if (pHTPatCCopy)
  363. {
  364. ProbeAndReadBuffer(pHTPatCCopy,
  365. pHTPatC,
  366. pGdiInfo->cxHTPat*
  367. pGdiInfo->cyHTPat);
  368. }
  369. }
  370. __except (EXCEPTION_EXECUTE_HANDLER)
  371. {
  372. EngFreeUserMem(pHTPatACopy);
  373. EngFreeUserMem(pHTPatBCopy);
  374. EngFreeUserMem(pHTPatCCopy);
  375. pHTPatACopy = NULL;
  376. pHTPatBCopy = NULL;
  377. pHTPatCCopy = NULL;
  378. // Do not set the ulHTPatternSize to HTPAT_SIZE_USER.
  379. // Use the default which is super cell.
  380. pGdiInfo->ulHTPatternSize = HTPAT_SIZE_DEFAULT;
  381. }
  382. pGdiInfo->pHTPatA = pHTPatACopy;
  383. pGdiInfo->pHTPatB = pHTPatBCopy;
  384. pGdiInfo->pHTPatC = pHTPatCCopy;
  385. }
  386. else
  387. {
  388. pGdiInfo->ulHTPatternSize = HTPAT_SIZE_DEFAULT;
  389. }
  390. }
  391. }
  392. #endif
  393. if (pDevInfo)
  394. {
  395. //
  396. // fail the call if driver gives us back a NULL hpalDefault
  397. //
  398. DEVINFO * kmDevInfo = (DEVINFO *) pumpdobj->GetKernelPtr(Input.pDevInfo);
  399. if (kmDevInfo->hpalDefault == NULL)
  400. {
  401. if (dhpdev)
  402. UMPDDrvDisablePDEV(dhpdev);
  403. return NULL;
  404. }
  405. RtlCopyMemory(pDevInfo, kmDevInfo, cjDevInfo);
  406. }
  407. return (dhpdev);
  408. }
  409. else
  410. {
  411. return NULL;
  412. }
  413. }
  414. //
  415. // BOOL UMPDDrvCompletePDEV
  416. // UMPD DrvCompletePDEV thunk. This routine packs up the parameters
  417. // and send across to the client side, and copy the output parameters back
  418. // after returning from client side.
  419. //
  420. // Returns
  421. // VOID
  422. //
  423. // Arguments:
  424. // refer to DrvCompletePDEV
  425. //
  426. // History:
  427. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  428. //
  429. VOID
  430. UMPDDrvCompletePDEV(
  431. DHPDEV dhpdev,
  432. HDEV hdev
  433. )
  434. {
  435. DRVCOMPLETEPDEVINPUT Input;
  436. XUMPDOBJ XUMObjs;
  437. if(XUMObjs.bValid())
  438. {
  439. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  440. Input.umpdthdr.umthdr.ulType = INDEX_DrvCompletePDEV;
  441. Input.umpdthdr.humpd = XUMObjs.hUMPD();
  442. Input.dhpdev = dhpdev;
  443. Input.hdev = hdev;
  444. XUMObjs.pumpdobj()->Thunk(&Input, sizeof(Input), NULL, 0);
  445. }
  446. }
  447. //
  448. //
  449. // BOOL UMPDDrvResetPDEV
  450. // UMPD DrvResetPDEV thunk. This routine packs up the parameters
  451. // and send across to the client side, and copy the output parameters back
  452. // after returning from client side.
  453. //
  454. // Returns
  455. // BOOL
  456. //
  457. // Arguments:
  458. // refer to DrvResetPDEV
  459. //
  460. // History:
  461. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  462. //
  463. BOOL
  464. UMPDDrvResetPDEV(
  465. DHPDEV dhpdevOld,
  466. DHPDEV dhpdevNew
  467. )
  468. {
  469. DRVRESETPDEVINPUT Input;
  470. BOOL bRet;
  471. XUMPDOBJ XUMObjs;
  472. if(XUMObjs.bValid())
  473. {
  474. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  475. Input.umpdthdr.umthdr.ulType = INDEX_DrvResetPDEV;
  476. Input.umpdthdr.humpd = XUMObjs.hUMPD();
  477. Input.dhpdevOld = dhpdevOld;
  478. Input.dhpdevNew = dhpdevNew;
  479. return XUMObjs.pumpdobj()->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff &&
  480. bRet;
  481. }
  482. else
  483. {
  484. return FALSE;
  485. }
  486. }
  487. //
  488. //
  489. // BOOL UMPDDrvEnableSurface
  490. // UMPD DrvEnableSurface thunk. This routine packs up the parameters
  491. // and send across to the client side, and copy the output parameters back
  492. // after returning from client side.
  493. //
  494. // Returns
  495. // HSURF
  496. //
  497. // Arguments:
  498. // refer to DrvEnableSurface
  499. //
  500. // History:
  501. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  502. //
  503. HSURF
  504. UMPDDrvEnableSurface(
  505. DHPDEV dhpdev
  506. )
  507. {
  508. DHPDEVINPUT Input;
  509. HSURF hSurf;
  510. XUMPDOBJ XUMObjs;
  511. if(XUMObjs.bValid())
  512. {
  513. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  514. Input.umpdthdr.umthdr.ulType = INDEX_DrvEnableSurface;
  515. Input.umpdthdr.humpd = XUMObjs.hUMPD();
  516. Input.dhpdev = dhpdev;
  517. if (XUMObjs.pumpdobj()->Thunk(&Input, sizeof(Input), &hSurf, sizeof(HSURF)) == 0xffffffff)
  518. hSurf = NULL;
  519. if (hSurf)
  520. {
  521. SURFREF sr(hSurf);
  522. if (sr.bValid())
  523. {
  524. // According to the DDK:
  525. // If the surface is device-managed, at a minimum,
  526. // the driver must handle DrvTextOut, DrvStrokePath, and DrvCopyBits
  527. //
  528. if (sr.ps->iType() == STYPE_DEVICE)
  529. {
  530. if (!(sr.ps->SurfFlags & HOOK_BITBLT) ||
  531. !(sr.ps->SurfFlags & HOOK_STROKEPATH) ||
  532. !(sr.ps->SurfFlags & HOOK_TEXTOUT))
  533. {
  534. hSurf = 0;
  535. }
  536. }
  537. }
  538. else
  539. {
  540. hSurf = 0;
  541. }
  542. }
  543. return (hSurf);
  544. }
  545. else
  546. {
  547. return NULL;
  548. }
  549. }
  550. //
  551. //
  552. // BOOL UMPDDrvDisableSurface
  553. // UMPD DrvEnableSurface thunk. This routine packs up the parameters
  554. // and send across to the client side, and copy the output parameters back
  555. // after returning from client side.
  556. //
  557. // Returns
  558. // VOID
  559. //
  560. // Arguments:
  561. // refer to DrvDisableSurface
  562. //
  563. // History:
  564. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  565. //
  566. VOID
  567. UMPDDrvDisableSurface(
  568. DHPDEV dhpdev
  569. )
  570. {
  571. DHPDEVINPUT Input;
  572. XUMPDOBJ XUMObjs;
  573. if(XUMObjs.bValid())
  574. {
  575. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  576. Input.umpdthdr.umthdr.ulType = INDEX_DrvDisableSurface;
  577. Input.umpdthdr.humpd = XUMObjs.hUMPD();
  578. Input.dhpdev = dhpdev;
  579. XUMObjs.pumpdobj()->Thunk(&Input, sizeof(Input), NULL, 0);
  580. }
  581. }
  582. //
  583. //
  584. // BOOL UMPDDrvDisableDriver
  585. // UMPD DrvDisableDriver thunk. This routine packs up the parameters
  586. // and send across to the client side, and copy the output parameters back
  587. // after returning from client side.
  588. //
  589. // Returns
  590. // VOID
  591. //
  592. // Arguments:
  593. // refer to DrvDisableDriver
  594. //
  595. // History:
  596. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  597. //
  598. VOID
  599. UMPDDrvDisableDriver(
  600. )
  601. {
  602. #if 0
  603. UMPDTHDR umpdthdr;
  604. XUMPDOBJ XUMObjs;
  605. if(XUMObjs.bValid())
  606. {
  607. umpdthdr.umthdr.cjSize = sizeof(umpdthdr);
  608. umpdthdr.umthdr.ulType = INDEX_DrvDisableDriver;
  609. umpdthdr.humpd = XUMObjs.hUMPD();
  610. XUMObjs.pumpdobjs()->Thunk(&umpdthdr, sizeof(umpdthdr), NULL, 0);
  611. }
  612. #else
  613. WARNING("Unsupported UMPD entry point being called\n");
  614. DbgBreakPoint();
  615. #endif
  616. }
  617. #define UMPD_SIZEINOUTPUT(Input, Output) \
  618. ALIGN_UMPD_BUFFER(sizeof(Input)) + ALIGN_UMPD_BUFFER(sizeof(Output))
  619. #define UMPD_SIZESURFOBJ \
  620. ALIGN_UMPD_BUFFER(sizeof(SURFOBJ))
  621. #define UMPD_SIZEBITMAP(pso) \
  622. ALIGN_UMPD_BUFFER(pso->cjBits)
  623. #define UMPD_SIZEXLATEOBJ(pxlo) \
  624. (pxlo ? (ALIGN_UMPD_BUFFER(pxlo->cEntries * sizeof(ULONG)) + ALIGN_UMPD_BUFFER(sizeof(XLATEOBJ))) : 0)
  625. #define UMPD_SIZESTROBJ(pstro) \
  626. pstro ? ALIGN_UMPD_BUFFER(sizeof(WCHAR) * pstro->cGlyphs) + \
  627. ALIGN_UMPD_BUFFER(sizeof(GLYPHPOS) * pstro->cGlyphs) + \
  628. ALIGN_UMPD_BUFFER(sizeof(STROBJ)) \
  629. : 0
  630. #define UMPD_SIZELINEATTRS(plineattrs) \
  631. plineattrs ? ALIGN_UMPD_BUFFER(plineattrs->cstyle * sizeof(FLOAT_LONG)) + \
  632. ALIGN_UMPD_BUFFER(sizeof(LINEATTRS)) \
  633. : 0
  634. #define UMPD_SIZEXFORMOBJ ALIGN_UMPD_BUFFER(sizeof(XFORMOBJ))
  635. #define UMPD_SIZERECTL ALIGN_UMPD_BUFFER(sizeof(RECTL))
  636. #define UMPD_SIZECLIPOBJ ALIGN_UMPD_BUFFER(sizeof(CLIPOBJ))
  637. #define UMPD_SIZEPOINTL ALIGN_UMPD_BUFFER(sizeof(POINTL))
  638. #define UMPD_SIZEPERBANDI ALIGN_UMPD_BUFFER(sizeof(PERBANDINFO))
  639. #define UMPD_SIZECOLORADJ ALIGN_UMPD_BUFFER(sizeof(COLORADJUSTMENT))
  640. #define UMPD_SIZEBRUSHOBJ ALIGN_UMPD_BUFFER(sizeof(BRUSHOBJ))
  641. #define UMPD_SIZEFONTOBJ ALIGN_UMPD_BUFFER(sizeof(FONTOBJ))
  642. #define UMPD_SIZEBLENDOBJ ALIGN_UMPD_BUFFER(sizeof(BLENDOBJ))
  643. #define UMPD_SIZEPATHOBJ ALIGN_UMPD_BUFFER(sizeof(PATHOBJ))
  644. /*
  645. BOOL UMPDOBJ::bDeleteLargeBitmaps
  646. Delete the duplicated bitmaps for WOW64 printing only
  647. */
  648. BOOL UMPDOBJ::bDeleteLargeBitmaps(SURFOBJ *psoTrg, SURFOBJ *psoSrc, SURFOBJ *psoMsk)
  649. {
  650. UMPDFREEMEMINPUT Input;
  651. BOOL bRet;
  652. if (!psoTrg && !psoSrc && !psoMsk)
  653. return TRUE;
  654. ASSERTGDI(ulAllocSize() == 0, "bDeleteLargeBitmap ulAllocSize is not 0\n");
  655. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  656. Input.umpdthdr.umthdr.ulType = INDEX_UMPDFreeMemory;
  657. Input.umpdthdr.humpd = (HUMPD) this->hGet();
  658. Input.pvTrg = psoTrg ? psoTrg->pvBits : NULL;
  659. Input.pvSrc = psoSrc ? psoSrc->pvBits : NULL;
  660. Input.pvMsk = psoMsk ? psoMsk->pvBits : NULL;
  661. bRet = (Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff) && bRet;
  662. ResetHeap();
  663. return bRet;
  664. }
  665. /*
  666. KERNEL_PVLID UMPDOBJ::UMPDAllocUserMem
  667. Used for WOW64 printing. Allocate user mode memory via LPC calls.
  668. */
  669. KERNEL_PVOID UMPDOBJ::UMPDAllocUserMem(ULONG cjSize)
  670. {
  671. UMPDALLOCUSERMEMINPUT Input;
  672. KERNEL_PVOID pvRet = NULL;
  673. ASSERTGDI(ulAllocSize() == 0, "UMPDAllocUserMem ulAllocSize is not 0\n");
  674. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  675. Input.umpdthdr.umthdr.ulType = INDEX_UMPDAllocUserMem;
  676. Input.umpdthdr.humpd = (HUMPD) this->hGet();
  677. Input.cjSize = cjSize;
  678. if (Thunk(&Input, sizeof(Input), &pvRet, sizeof(KERNEL_PVOID)) == 0xffffffff)
  679. {
  680. ASSERTGDI(pvRet == NULL, "not NULL pvRet returned\n");
  681. }
  682. ResetHeap();
  683. return pvRet;
  684. }
  685. /* BOOL UMPDOBJ::bSendLargeBitmap
  686. Used for WOW64 printing when the bitmap size is bigger than 8M.
  687. The bitmap will be copied into the user mode address returned by UMPDOBJ::UMPDAllocUserMem call.
  688. */
  689. BOOL UMPDOBJ::bSendLargeBitmap(
  690. SURFOBJ *pso,
  691. BOOL *pbLargeBitmap
  692. )
  693. {
  694. UMPDCOPYMEMINPUT Input;
  695. KERNEL_PVOID pvRet = NULL, pvDest;
  696. PVOID pvSrc, pvBits;
  697. ULONG cjBmpSize, cjBuffSize, offset = 0;
  698. BOOL bRet = FALSE;
  699. if (!(pvDest = UMPDAllocUserMem(pso->cjBits)))
  700. return FALSE;
  701. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  702. Input.umpdthdr.umthdr.ulType = INDEX_UMPDCopyMemory;
  703. Input.umpdthdr.humpd = (HUMPD) this->hGet();
  704. Input.pvDest = pvDest;
  705. ASSERTGDI(ulAllocSize() == 0, "bSendLargeBitmap ulAllocSize is not 0\n");
  706. cjBuffSize = ulGetMaxSize() - ALIGN_UMPD_BUFFER(sizeof(Input)) - ALIGN_UMPD_BUFFER(sizeof(KERNEL_PVOID));
  707. cjBmpSize = pso->cjBits;
  708. pvBits = pso->pvBits;
  709. while(cjBmpSize)
  710. {
  711. Input.cjSize = (cjBmpSize > cjBuffSize) ? cjBuffSize : cjBmpSize;
  712. if ((Input.pvSrc = AllocUserMem(Input.cjSize)) == NULL)
  713. break;
  714. pvSrc = GetKernelPtr(Input.pvSrc);
  715. RtlCopyMemory(pvSrc, pvBits, Input.cjSize);
  716. if ((Thunk(&Input, sizeof(Input), &pvRet, sizeof(pvRet)) == 0xffffffff) || pvRet == NULL)
  717. break;
  718. offset += Input.cjSize;
  719. cjBmpSize -= Input.cjSize;
  720. Input.pvDest = (PBYTE)pvDest + offset;
  721. pvBits = (PBYTE)pso->pvBits + offset;
  722. ResetHeap();
  723. }
  724. offset = (ULONG)(LONG_PTR)((PBYTE)pso->pvScan0 - (PBYTE)pso->pvBits);
  725. pso->pvBits = pvDest;
  726. pso->pvScan0 = (PBYTE)pso->pvBits + offset;
  727. if (cjBmpSize == 0)
  728. {
  729. *pbLargeBitmap = TRUE;
  730. bRet = TRUE;
  731. }
  732. else
  733. {
  734. ResetHeap();
  735. bDeleteLargeBitmaps(pso, NULL, NULL);
  736. }
  737. return bRet;
  738. }
  739. /*
  740. BOOL UMPDOBJ::bThunkLargeBitmap
  741. Unsed only for WOW64 printing.
  742. Save the orignal pvBits and pvScan0 pointers.
  743. Check to see whether this is a big bitmap that can't fit into the heap.
  744. If so, send the request to allocate user mode space in the print server
  745. and copy the bitmap into the new address.
  746. pcjSize
  747. At the entry point, it contains the size needed, excluding the SURFOBJ sturct and the bitmap, to thunk the current DDI call.
  748. When exist, it contains the size needed to thunk the current DDI call, including the SURFOBJ and the bitmap.
  749. */
  750. BOOL UMPDOBJ::bThunkLargeBitmap(
  751. SURFOBJ *pso,
  752. PVOID *ppvBits,
  753. PVOID *ppvScan0,
  754. BOOL *pbSavePtr,
  755. BOOL *pbLargeBitmap,
  756. ULONG *pcjSize
  757. )
  758. {
  759. BOOL bRet = TRUE;
  760. ASSERTGDI(bWOW64(), "bThunkLargeBitmap called during NONE wow64 printing\n");
  761. if (pso && pso->pvBits)
  762. {
  763. ULONG cjSizeNeed, cjMaxSize;
  764. ASSERTGDI(ulAllocSize() == 0, "bThunkLargeBitmap: ulAllocSize is not 0\n");
  765. *pbSavePtr = TRUE;
  766. *ppvBits = pso->pvBits;
  767. *ppvScan0 = pso->pvScan0;
  768. cjMaxSize = ulGetMaxSize();
  769. cjSizeNeed = *pcjSize + UMPD_SIZESURFOBJ;
  770. if (pso->pvBits)
  771. {
  772. if ((cjSizeNeed + UMPD_SIZEBITMAP(pso)) > cjMaxSize)
  773. {
  774. bRet = bSendLargeBitmap(pso, pbLargeBitmap);
  775. }
  776. else
  777. cjSizeNeed += UMPD_SIZEBITMAP(pso);
  778. }
  779. if (bRet)
  780. *pcjSize = cjSizeNeed;
  781. }
  782. return bRet;
  783. }
  784. /*
  785. BOOL UMPDOBJ::bThunkLargeBitmaps()
  786. Only used for WOW64 printing.
  787. Thunk the large bitmaps by calling UMPDOBJ::bThunkLargeBitmap().
  788. pbLargeTrg
  789. pbLargeSrc
  790. pbLargeMsk
  791. are all initialized as FALSE before calling this routine.
  792. cjSize
  793. Heap size needed, excluding the surfobj's, to thunk the DDI call.
  794. */
  795. BOOL UMPDOBJ::bThunkLargeBitmaps(
  796. SURFOBJ *psoTrg,
  797. SURFOBJ *psoSrc,
  798. SURFOBJ *psoMsk,
  799. PVOID *ppvBitTrg,
  800. PVOID *ppvScanTrg,
  801. PVOID *ppvBitSrc,
  802. PVOID *ppvScanSrc,
  803. PVOID *ppvBitMsk,
  804. PVOID *ppvScanMsk,
  805. BOOL *pbSaveTrg,
  806. BOOL *pbLargeTrg,
  807. BOOL *pbSaveSrc,
  808. BOOL *pbLargeSrc,
  809. BOOL *pbSaveMsk,
  810. BOOL *pbLargeMsk,
  811. ULONG *pcjSize
  812. )
  813. {
  814. ULONG cjSizeNeed, cjMaxSize;
  815. BOOL bRet = TRUE;
  816. ASSERTGDI(bWOW64(), "bThunkLargeBitmaps called during NONE wow64 printing\n");
  817. if (!psoTrg && !psoSrc && !psoMsk)
  818. return TRUE;
  819. if (bRet = bThunkLargeBitmap(psoTrg, ppvBitTrg, ppvScanTrg, pbSaveTrg, pbLargeTrg, pcjSize))
  820. if (bRet = bThunkLargeBitmap(psoSrc, ppvBitSrc, ppvScanSrc, pbSaveSrc, pbLargeSrc, pcjSize))
  821. bRet = bThunkLargeBitmap(psoMsk, ppvBitMsk, ppvScanMsk, pbSaveMsk, pbLargeMsk, pcjSize);
  822. if (!bRet)
  823. {
  824. bDeleteLargeBitmaps((pbLargeTrg && *pbLargeTrg) ? psoTrg : NULL,
  825. (pbLargeSrc && *pbLargeSrc) ? psoSrc : NULL,
  826. (pbLargeMsk && *pbLargeMsk) ? psoMsk : NULL);
  827. }
  828. return bRet;
  829. }
  830. /* VOID UMPDOBJ::RestoreBitmap
  831. Used only for the WOW64 printing.
  832. Restore the orignal pvBits and pvScan0 pointers in SURFOBJ
  833. */
  834. VOID UMPDOBJ::RestoreBitmap(
  835. SURFOBJ *pso,
  836. PVOID pvBits,
  837. PVOID pvScan0,
  838. BOOL bSavePtr,
  839. BOOL bLargeBitmap
  840. )
  841. {
  842. ASSERTGDI(bWOW64(), "UMPDOBJ:RestoreBitmap bSavePtr is TRUE during NONE wow64 printing\n");
  843. if (bLargeBitmap)
  844. bDeleteLargeBitmaps(pso, NULL, NULL);
  845. pso->pvBits = pvBits;
  846. pso->pvScan0 = pvScan0;
  847. }
  848. /* VOID UMPDOBJ::RestoreBitmaps
  849. Used only for the WOW64 printing.
  850. Save as RestoreBitmap but takes three SURFOBJ instead of one.
  851. */
  852. VOID UMPDOBJ::RestoreBitmaps(
  853. SURFOBJ *psoTrg,
  854. SURFOBJ *psoSrc,
  855. SURFOBJ *psoMsk,
  856. PVOID pvBitTrg,
  857. PVOID pvScanTrg,
  858. PVOID pvBitSrc,
  859. PVOID pvScanSrc,
  860. PVOID pvBitMsk,
  861. PVOID pvScanMsk,
  862. BOOL bSaveTrg,
  863. BOOL bLargeTrg,
  864. BOOL bSaveSrc,
  865. BOOL bLargeSrc,
  866. BOOL bSaveMsk,
  867. BOOL bLargeMsk
  868. )
  869. {
  870. ASSERTGDI(bWOW64(), "RestoreBitmaps called during NONE wow64 printing\n");
  871. if (bSaveTrg || bSaveSrc || bSaveMsk)
  872. {
  873. bDeleteLargeBitmaps(bLargeTrg ? psoTrg : NULL, bLargeSrc ? psoSrc : NULL, bLargeMsk ? psoMsk : NULL);
  874. if (bSaveTrg)
  875. {
  876. psoTrg->pvBits = pvBitTrg;
  877. psoTrg->pvScan0 = pvScanTrg;
  878. }
  879. if (bSaveSrc)
  880. {
  881. psoSrc->pvBits = pvBitSrc;
  882. psoSrc->pvScan0 = pvScanSrc;
  883. }
  884. if (bSaveMsk)
  885. {
  886. psoMsk->pvBits = pvBitMsk;
  887. psoMsk->pvScan0 = pvScanMsk;
  888. }
  889. }
  890. }
  891. //
  892. //
  893. // BOOL UMPDDrvStartDoc
  894. // UMPD DrvStartDoc thunk. This routine packs up the parameters
  895. // and send across to the client side, and copy the output parameters back
  896. // after returning from client side.
  897. //
  898. // Returns
  899. // BOOL
  900. //
  901. // Arguments:
  902. // refer to DrvStartDoc
  903. //
  904. // History:
  905. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  906. //
  907. BOOL UMPDDrvStartDoc(
  908. SURFOBJ *pso,
  909. LPWSTR pwszDocName,
  910. DWORD dwJobId
  911. )
  912. {
  913. DRVSTARTDOCINPUT Input;
  914. BOOL bRet = TRUE;
  915. BOOL bSavePtr = FALSE, bLargeBitmap = FALSE;
  916. XUMPDOBJ XUMObjs;
  917. PVOID pvBits, pvScan0;
  918. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  919. if(!XUMObjs.bValid())
  920. return FALSE;
  921. if (pumpdobj->bWOW64())
  922. {
  923. ULONG cjSizeNeed = (ULONG)(UMPD_SIZEINOUTPUT(Input, bRet) +
  924. (pwszDocName ? ALIGN_UMPD_BUFFER((wcslen(pwszDocName) + 1) * sizeof(WCHAR)) : 0));
  925. bRet = pumpdobj->bThunkLargeBitmap(pso, &pvBits, &pvScan0, &bSavePtr, &bLargeBitmap, &cjSizeNeed);
  926. }
  927. if (bRet)
  928. {
  929. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  930. Input.umpdthdr.umthdr.ulType = INDEX_DrvStartDoc;
  931. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  932. Input.pso = pso;
  933. Input.pwszDocName = pwszDocName;
  934. Input.dwJobId = dwJobId;
  935. bRet = pumpdobj->psoDest(&Input.pso, bLargeBitmap) &&
  936. pumpdobj->ThunkStringW(&Input.pwszDocName) &&
  937. (pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff) &&
  938. bRet;
  939. }
  940. if (bSavePtr)
  941. pumpdobj->RestoreBitmap(pso, pvBits, pvScan0, bSavePtr, bLargeBitmap);
  942. return bRet;
  943. }
  944. //
  945. //
  946. // BOOL UMPDDrvEndDoc
  947. // UMPD DrvEndDoc thunk. This routine packs up the parameters
  948. // and send across to the client side, and copy the output parameters back
  949. // after returning from client side.
  950. //
  951. // Returns
  952. // BOOL
  953. //
  954. // Arguments:
  955. // refer to DrvEndDoc
  956. //
  957. // History:
  958. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  959. //
  960. BOOL UMPDDrvEndDoc(
  961. SURFOBJ *pso,
  962. FLONG fl
  963. )
  964. {
  965. DRVENDDOCINPUT Input;
  966. BOOL bRet = TRUE;
  967. BOOL bSavePtr = FALSE, bLargeBitmap = FALSE;
  968. XUMPDOBJ XUMObjs;
  969. PVOID pvBits, pvScan0;
  970. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  971. if (!XUMObjs.bValid())
  972. return FALSE;
  973. if (pumpdobj->bWOW64())
  974. {
  975. ULONG cjSizeNeed = UMPD_SIZEINOUTPUT(Input, bRet);
  976. bRet = pumpdobj->bThunkLargeBitmap(pso, &pvBits, &pvScan0, &bSavePtr, &bLargeBitmap, &cjSizeNeed);
  977. }
  978. if (bRet)
  979. {
  980. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  981. Input.umpdthdr.umthdr.ulType = INDEX_DrvEndDoc;
  982. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  983. Input.pso = pso;
  984. Input.fl = fl;
  985. bRet = pumpdobj->psoDest(&Input.pso, bLargeBitmap) &&
  986. pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff &&
  987. bRet;
  988. }
  989. if (bSavePtr)
  990. pumpdobj->RestoreBitmap(pso, pvBits, pvScan0, bSavePtr, bLargeBitmap);
  991. return bRet;
  992. }
  993. //
  994. //
  995. // BOOL UMPDDrvStartPage
  996. // UMPD DrvStartPage thunk. This routine packs up the parameters
  997. // and send across to the client side, and copy the output parameters back
  998. // after returning from client side.
  999. //
  1000. // Returns
  1001. // BOOL
  1002. //
  1003. // Arguments:
  1004. // refer to DrvStartPage
  1005. //
  1006. // History:
  1007. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  1008. //
  1009. BOOL UMPDDrvStartPage(
  1010. SURFOBJ *pso
  1011. )
  1012. {
  1013. SURFOBJINPUT Input;
  1014. BOOL bRet = TRUE;
  1015. BOOL bSavePtr = FALSE, bLargeBitmap = FALSE;
  1016. XUMPDOBJ XUMObjs;
  1017. PVOID pvBits, pvScan0;
  1018. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  1019. if (!XUMObjs.bValid())
  1020. return FALSE;
  1021. if (pumpdobj->bWOW64())
  1022. {
  1023. ULONG cjSizeNeed = UMPD_SIZEINOUTPUT(Input, bRet);
  1024. bRet = pumpdobj->bThunkLargeBitmap(pso, &pvBits, &pvScan0, &bSavePtr, &bLargeBitmap, &cjSizeNeed);
  1025. }
  1026. if (bRet)
  1027. {
  1028. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  1029. Input.umpdthdr.umthdr.ulType = INDEX_DrvStartPage;
  1030. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  1031. Input.pso = pso;
  1032. bRet = pumpdobj->psoDest(&Input.pso, bLargeBitmap) &&
  1033. pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff &&
  1034. bRet;
  1035. }
  1036. if (bSavePtr)
  1037. pumpdobj->RestoreBitmap(pso, pvBits, pvScan0, bSavePtr, bLargeBitmap);
  1038. return bRet;
  1039. }
  1040. //
  1041. //
  1042. // BOOL UMPDDrvSendPage
  1043. // UMPD DrvSendPage thunk. This routine packs up the parameters
  1044. // and send across to the client side, and copy the output parameters back
  1045. // after returning from client side.
  1046. //
  1047. // Returns
  1048. // BOOL
  1049. //
  1050. // Arguments:
  1051. // refer to DrvSendPage
  1052. //
  1053. // History:
  1054. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  1055. //
  1056. BOOL UMPDDrvSendPage(
  1057. SURFOBJ *pso
  1058. )
  1059. {
  1060. SURFOBJINPUT Input;
  1061. BOOL bRet = TRUE;
  1062. BOOL bSavePtr = FALSE, bLargeBitmap = FALSE;
  1063. XUMPDOBJ XUMObjs;
  1064. PVOID pvBits, pvScan0;
  1065. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  1066. if (!XUMObjs.bValid())
  1067. return FALSE;
  1068. if (pumpdobj->bWOW64())
  1069. {
  1070. ULONG cjSizeNeed = UMPD_SIZEINOUTPUT(Input, bRet);
  1071. bRet = pumpdobj->bThunkLargeBitmap(pso, &pvBits, &pvScan0, &bSavePtr, &bLargeBitmap, &cjSizeNeed);
  1072. }
  1073. if (bRet)
  1074. {
  1075. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  1076. Input.umpdthdr.umthdr.ulType = INDEX_DrvSendPage;
  1077. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  1078. Input.pso = pso;
  1079. bRet = pumpdobj->psoDest(&Input.pso, bLargeBitmap) &&
  1080. pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff &&
  1081. bRet;
  1082. }
  1083. if (bSavePtr)
  1084. pumpdobj->RestoreBitmap(pso, pvBits, pvScan0, bSavePtr, bLargeBitmap);
  1085. return bRet;
  1086. }
  1087. //
  1088. //
  1089. // BOOL UMPDDrvEscape
  1090. // UMPD DrvEscape thunk. This routine packs up the parameters
  1091. // and send across to the client side, and copy the output parameters back
  1092. // after returning from client side.
  1093. //
  1094. // Returns
  1095. // BOOL
  1096. //
  1097. // Arguments:
  1098. // refer to DrvEscape
  1099. //
  1100. // History:
  1101. // 8/14/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  1102. //
  1103. ULONG UMPDDrvEscape(
  1104. SURFOBJ *pso,
  1105. ULONG iEsc,
  1106. ULONG cjIn,
  1107. PVOID pvIn,
  1108. ULONG cjOut,
  1109. PVOID pvOut
  1110. )
  1111. {
  1112. DRVESCAPEINPUT Input;
  1113. ULONG ulRet = GDI_ERROR;
  1114. XUMPDOBJ XUMObjs;
  1115. BOOL bContinue = TRUE;
  1116. BOOL bSavePtr = FALSE, bLargeBitmap = FALSE;
  1117. PVOID pvBits, pvScan0;
  1118. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  1119. if (!XUMObjs.bValid())
  1120. return GDI_ERROR;
  1121. if (pumpdobj->bWOW64())
  1122. {
  1123. ULONG cjSizeNeed = UMPD_SIZEINOUTPUT(Input, ulRet) + UMPD_SIZEXFORMOBJ +
  1124. ALIGN_UMPD_BUFFER(cjIn) + ALIGN_UMPD_BUFFER(cjOut);
  1125. bContinue = pumpdobj->bThunkLargeBitmap(pso, &pvBits, &pvScan0,
  1126. &bSavePtr, &bLargeBitmap, &cjSizeNeed);
  1127. }
  1128. if (bContinue)
  1129. {
  1130. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  1131. Input.umpdthdr.umthdr.ulType = INDEX_DrvEscape;
  1132. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  1133. Input.pso = pso;
  1134. if (cjIn == 0)
  1135. pvIn = NULL;
  1136. if (cjOut == 0)
  1137. pvOut = NULL;
  1138. Input.iEsc = iEsc;
  1139. Input.cjIn = cjIn;
  1140. Input.pvIn = pvIn;
  1141. Input.cjOut = cjOut;
  1142. Input.pvOut = pvOut;
  1143. //
  1144. // If the input buffer is not empty and the address is in system
  1145. // address space, then we need to make a copy of the input
  1146. // buffer into temporary user mode buffer.
  1147. //
  1148. if (iEsc == DRAWPATTERNRECT)
  1149. {
  1150. PDEVOBJ pdo(pso->hdev);
  1151. if (pdo.flGraphicsCaps() & GCAPS_NUP)
  1152. {
  1153. XFORMOBJ *pxo = ((DRAWPATRECTP *)Input.pvIn)->pXformObj;
  1154. if (!pumpdobj->pxo(&pxo))
  1155. {
  1156. bContinue = FALSE;
  1157. }
  1158. else
  1159. {
  1160. ((DRAWPATRECTP *)Input.pvIn)->pXformObj = pxo;
  1161. }
  1162. }
  1163. }
  1164. if (bContinue)
  1165. {
  1166. if (cjIn && pumpdobj->bNeedThunk(pvIn) && !pumpdobj->ThunkMemBlock(&Input.pvIn, cjIn) ||
  1167. cjOut && !(Input.pvOut = pumpdobj->AllocUserMemZ(cjOut)) ||
  1168. !pumpdobj->psoDest(&Input.pso, bLargeBitmap) ||
  1169. pumpdobj->Thunk(&Input, sizeof(Input), &ulRet, sizeof(ulRet)) == 0xffffffff)
  1170. {
  1171. ulRet = GDI_ERROR;
  1172. }
  1173. else
  1174. {
  1175. if (cjOut)
  1176. RtlCopyMemory(pvOut, pumpdobj->GetKernelPtr(Input.pvOut), cjOut);
  1177. }
  1178. }
  1179. }
  1180. if (bSavePtr)
  1181. pumpdobj->RestoreBitmap(pso, pvBits, pvScan0, bSavePtr, bLargeBitmap);
  1182. return (ulRet);
  1183. }
  1184. //
  1185. //
  1186. // BOOL UMPDDrvDrawEscape
  1187. // UMPD DrvDrawEscape thunk. This routine packs up the parameters
  1188. // and send across to the client side, and copy the output parameters back
  1189. // after returning from client side.
  1190. //
  1191. // Returns
  1192. // BOOL
  1193. //
  1194. // Arguments:
  1195. // refer to DrvDrawEscape
  1196. //
  1197. // History:
  1198. // 10/3/98 -- Lingyun Wang [lingyunw] -- Wrote it.
  1199. //
  1200. ULONG UMPDDrvDrawEscape(
  1201. SURFOBJ *pso,
  1202. ULONG iEsc,
  1203. CLIPOBJ *pco,
  1204. RECTL *prcl,
  1205. ULONG cjIn,
  1206. PVOID pvIn
  1207. )
  1208. {
  1209. DRVDRAWESCAPEINPUT Input;
  1210. ULONG ulRet = GDI_ERROR;
  1211. XUMPDOBJ XUMObjs;
  1212. PVOID pvBits, pvScan0;
  1213. BOOL bContinue = TRUE;
  1214. BOOL bSavePtr = FALSE, bLargeBitmap = FALSE;
  1215. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  1216. if (!XUMObjs.bValid())
  1217. return GDI_ERROR;
  1218. if (pumpdobj->bWOW64())
  1219. {
  1220. ULONG cjSizeNeed = UMPD_SIZEINOUTPUT(Input, ulRet) + UMPD_SIZERECTL +
  1221. UMPD_SIZECLIPOBJ + ALIGN_UMPD_BUFFER(cjIn);
  1222. bContinue = pumpdobj->bThunkLargeBitmap(pso, &pvBits, &pvScan0, &bSavePtr,
  1223. &bLargeBitmap, &cjSizeNeed);
  1224. }
  1225. if (bContinue)
  1226. {
  1227. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  1228. Input.umpdthdr.umthdr.ulType = INDEX_DrvDrawEscape;
  1229. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  1230. Input.pso = pso;
  1231. if (cjIn == 0)
  1232. pvIn = NULL;
  1233. Input.iEsc = iEsc;
  1234. Input.pco = pco;
  1235. Input.prcl = prcl;
  1236. Input.cjIn = cjIn;
  1237. Input.pvIn = pvIn;
  1238. //
  1239. // If the input buffer is not empty and the address is in system
  1240. // address space, then we need to make a copy of the input
  1241. // buffer into temporary user mode buffer.
  1242. //
  1243. if (cjIn && pumpdobj->bNeedThunk(pvIn) && !pumpdobj->ThunkMemBlock(&Input.pvIn, cjIn) ||
  1244. !pumpdobj->psoDest(&Input.pso, bLargeBitmap) || !pumpdobj->pco(&Input.pco) ||
  1245. !pumpdobj->ThunkRECTL(&Input.prcl) ||
  1246. pumpdobj->Thunk(&Input, sizeof(Input), &ulRet, sizeof(ulRet)) == 0xffffffff)
  1247. {
  1248. ulRet = GDI_ERROR;
  1249. }
  1250. }
  1251. if (bSavePtr)
  1252. pumpdobj->RestoreBitmap(pso, pvBits, pvScan0, bSavePtr, bLargeBitmap);
  1253. return (ulRet);
  1254. }
  1255. //
  1256. //
  1257. // BOOL UMPDDrvStartBanding
  1258. // UMPD DrvStartBanding thunk. This routine packs up the parameters
  1259. // and send across to the client side, and copy the output parameters back
  1260. // after returning from client side.
  1261. //
  1262. // Returns
  1263. // BOOL
  1264. //
  1265. // Arguments:
  1266. // refer to DrvStartBanding
  1267. //
  1268. // History:
  1269. // 8/13/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  1270. //
  1271. BOOL UMPDDrvStartBanding(
  1272. SURFOBJ *pso,
  1273. POINTL *pptl
  1274. )
  1275. {
  1276. DRVBANDINGINPUT Input;
  1277. BOOL bRet = TRUE;
  1278. BOOL bSavePtr = FALSE, bLargeBitmap = FALSE;
  1279. XUMPDOBJ XUMObjs;
  1280. PVOID pvBits, pvScan0;
  1281. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  1282. if (!XUMObjs.bValid())
  1283. return FALSE;
  1284. if (pumpdobj->bWOW64())
  1285. {
  1286. ULONG cjSizeNeed = UMPD_SIZEINOUTPUT(Input, bRet) + UMPD_SIZEPOINTL;
  1287. bRet = pumpdobj->bThunkLargeBitmap(pso, &pvBits, &pvScan0, &bSavePtr, &bLargeBitmap, &cjSizeNeed);
  1288. }
  1289. if (bRet)
  1290. {
  1291. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  1292. Input.umpdthdr.umthdr.ulType = INDEX_DrvStartBanding;
  1293. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  1294. Input.pso = pso;
  1295. Input.pptl = pptl;
  1296. if (pumpdobj->psoDest(&Input.pso, bLargeBitmap) &&
  1297. pumpdobj->ThunkPOINTL(&Input.pptl) &&
  1298. pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff)
  1299. {
  1300. if (pptl != NULL)
  1301. RtlCopyMemory(pptl, pumpdobj->GetKernelPtr(Input.pptl), sizeof(POINTL));
  1302. }
  1303. }
  1304. if (bSavePtr)
  1305. pumpdobj->RestoreBitmap(pso, pvBits, pvScan0, bSavePtr, bLargeBitmap);
  1306. return bRet;
  1307. }
  1308. //
  1309. //
  1310. // BOOL UMPDDrvNextBand
  1311. // UMPD DrvNextBand thunk. This routine packs up the parameters
  1312. // and send across to the client side, and copy the output parameters back
  1313. // after returning from client side.
  1314. //
  1315. // Returns
  1316. // BOOL
  1317. //
  1318. // Arguments:
  1319. // refer to DrvNextBand
  1320. //
  1321. // History:
  1322. // 8/13/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  1323. //
  1324. BOOL UMPDDrvNextBand(
  1325. SURFOBJ *pso,
  1326. POINTL *pptl
  1327. )
  1328. {
  1329. DRVBANDINGINPUT Input;
  1330. BOOL bRet = TRUE;
  1331. BOOL bSavePtr = FALSE, bLargeBitmap = FALSE;
  1332. XUMPDOBJ XUMObjs;
  1333. PVOID pvBits, pvScan0;
  1334. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  1335. if (!XUMObjs.bValid())
  1336. return FALSE;
  1337. if (pumpdobj->bWOW64())
  1338. {
  1339. ULONG cjSizeNeed = UMPD_SIZEINOUTPUT(Input, bRet) + UMPD_SIZEPOINTL;
  1340. bRet = pumpdobj->bThunkLargeBitmap(pso, &pvBits, &pvScan0, &bSavePtr, &bLargeBitmap, &cjSizeNeed);
  1341. }
  1342. if (bRet)
  1343. {
  1344. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  1345. Input.umpdthdr.umthdr.ulType = INDEX_DrvNextBand;
  1346. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  1347. Input.pso = pso;
  1348. Input.pptl = pptl;
  1349. if (pumpdobj->psoDest(&Input.pso, bLargeBitmap) &&
  1350. pumpdobj->ThunkPOINTL(&Input.pptl) &&
  1351. pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff)
  1352. {
  1353. if (pptl != NULL)
  1354. RtlCopyMemory(pptl, pumpdobj->GetKernelPtr(Input.pptl), sizeof(POINTL));
  1355. }
  1356. }
  1357. if (bSavePtr)
  1358. pumpdobj->RestoreBitmap(pso, pvBits, pvScan0, bSavePtr, bLargeBitmap);
  1359. return bRet;
  1360. }
  1361. ULONG UMPDDrvQueryPerBandInfo(
  1362. SURFOBJ *pso,
  1363. PERBANDINFO *pbi
  1364. )
  1365. {
  1366. DRVPERBANDINPUT Input;
  1367. BOOL bRet = TRUE;
  1368. BOOL bSavePtr = FALSE, bLargeBitmap = FALSE;
  1369. XUMPDOBJ XUMObjs;
  1370. PVOID pvBits, pvScan0;
  1371. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  1372. if (!XUMObjs.bValid())
  1373. return FALSE;
  1374. if (pumpdobj->bWOW64())
  1375. {
  1376. ULONG cjSizeNeed = UMPD_SIZEINOUTPUT(Input, bRet) + UMPD_SIZEPERBANDI;
  1377. bRet = pumpdobj->bThunkLargeBitmap(pso, &pvBits, &pvScan0, &bSavePtr, &bLargeBitmap, &cjSizeNeed);
  1378. }
  1379. if (bRet)
  1380. {
  1381. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  1382. Input.umpdthdr.umthdr.ulType = INDEX_DrvQueryPerBandInfo;
  1383. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  1384. Input.pso = pso;
  1385. if (pumpdobj->psoDest(&Input.pso, bLargeBitmap) &&
  1386. (Input.pbi = (PERBANDINFO *) pumpdobj->AllocUserMem(sizeof(PERBANDINFO))) != NULL)
  1387. {
  1388. if (pbi != NULL)
  1389. RtlCopyMemory(pumpdobj->GetKernelPtr(Input.pbi), pbi, sizeof(PERBANDINFO));
  1390. if (pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff)
  1391. {
  1392. if (pbi != NULL)
  1393. RtlCopyMemory(pbi, pumpdobj->GetKernelPtr(Input.pbi), sizeof(PERBANDINFO));
  1394. }
  1395. }
  1396. }
  1397. if (bSavePtr)
  1398. pumpdobj->RestoreBitmap(pso, pvBits, pvScan0, bSavePtr, bLargeBitmap);
  1399. return bRet;
  1400. }
  1401. BOOL UMPDDrvQueryDeviceSupport(
  1402. SURFOBJ *pso,
  1403. XLATEOBJ *pxlo,
  1404. XFORMOBJ *pxo,
  1405. ULONG iType,
  1406. ULONG cjIn,
  1407. PVOID pvIn,
  1408. ULONG cjOut,
  1409. PVOID pvOut)
  1410. {
  1411. DRVQUERYDEVICEINPUT Input;
  1412. BOOL bRet = TRUE;
  1413. BOOL bSavePtr = FALSE, bLargeBitmap = FALSE;
  1414. XUMPDOBJ XUMObjs;
  1415. PVOID pvBits, pvScan0;
  1416. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  1417. if (!XUMObjs.bValid())
  1418. return FALSE;
  1419. if (pumpdobj->bWOW64())
  1420. {
  1421. ULONG cjSizeNeed = (ULONG)(UMPD_SIZEINOUTPUT(Input, bRet) + UMPD_SIZEXFORMOBJ + UMPD_SIZEXLATEOBJ(pxlo) +
  1422. ALIGN_UMPD_BUFFER(cjIn) + ALIGN_UMPD_BUFFER(cjOut));
  1423. bRet = pumpdobj->bThunkLargeBitmap(pso, &pvBits, &pvScan0, &bSavePtr, &bLargeBitmap, &cjSizeNeed);
  1424. }
  1425. if (bRet)
  1426. {
  1427. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  1428. Input.umpdthdr.umthdr.ulType = INDEX_DrvQueryDeviceSupport;
  1429. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  1430. Input.pso = pso;
  1431. Input.pxlo = pxlo;
  1432. Input.pxo = pxo;
  1433. if (cjIn == 0)
  1434. pvIn = NULL;
  1435. if (cjOut == 0)
  1436. pvOut = NULL;
  1437. Input.iType = iType;
  1438. Input.cjIn = cjIn;
  1439. Input.pvIn = pvIn;
  1440. Input.cjOut = cjOut;
  1441. Input.pvOut = pvOut;
  1442. //
  1443. // If the input buffer is not empty and the address is in system
  1444. // address space, then we need to make a copy of the input
  1445. // buffer into temporary user mode buffer for x86.
  1446. //
  1447. // For WOW64, we have to always copy the input buffer.
  1448. //
  1449. if (cjIn && !pumpdobj->ThunkMemBlock(&Input.pvIn, cjIn) ||
  1450. cjOut && !(Input.pvOut = pumpdobj->AllocUserMemZ(cjOut)) ||
  1451. !pumpdobj->psoDest(&Input.pso, bLargeBitmap) || !pumpdobj->pxlo(&Input.pxlo) || !pumpdobj->pxo(&Input.pxo) ||
  1452. pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(bRet)) == 0xffffffff)
  1453. {
  1454. bRet = FALSE;
  1455. }
  1456. else
  1457. {
  1458. if (cjOut)
  1459. RtlCopyMemory(pvOut, pumpdobj->GetKernelPtr(Input.pvOut), cjOut);
  1460. }
  1461. }
  1462. if (bSavePtr)
  1463. pumpdobj->RestoreBitmap(pso, pvBits, pvScan0, bSavePtr, bLargeBitmap);
  1464. return bRet;
  1465. }
  1466. //
  1467. //
  1468. // BOOL UMPDDrvPlgBlt
  1469. // UMPD DrvPlgBlt thunk. This routine packs up the parameters
  1470. // and send across to the client side, and copy the output parameters back
  1471. // after returning from client side.
  1472. //
  1473. // Returns
  1474. // BOOL
  1475. //
  1476. // Arguments:
  1477. // refer to DrvPlgBlt
  1478. //
  1479. // History:
  1480. // 8/13/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  1481. //
  1482. BOOL UMPDDrvPlgBlt(
  1483. SURFOBJ *psoTrg,
  1484. SURFOBJ *psoSrc,
  1485. SURFOBJ *psoMsk,
  1486. CLIPOBJ *pco,
  1487. XLATEOBJ *pxlo,
  1488. COLORADJUSTMENT *pca,
  1489. POINTL *pptlBrushOrg,
  1490. POINTFIX *pptfx,
  1491. RECTL *prcl,
  1492. POINTL *pptl,
  1493. ULONG iMode
  1494. )
  1495. {
  1496. DRVPLGBLTINPUT Input;
  1497. BOOL bRet = TRUE;
  1498. BOOL bSaveTrg = FALSE, bSaveSrc = FALSE ,bSaveMsk = FALSE;
  1499. BOOL bLargeTrg = FALSE, bLargeSrc = FALSE, bLargeMsk = FALSE;
  1500. XUMPDOBJ XUMObjs;
  1501. PVOID pvBitTrg, pvBitSrc, pvBitMsk;
  1502. PVOID pvScanTrg, pvScanSrc, pvScanMsk;
  1503. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  1504. if (!XUMObjs.bValid())
  1505. return FALSE;
  1506. if (pumpdobj->bWOW64())
  1507. {
  1508. ULONG cjSizeNeed = (ULONG)(UMPD_SIZEINOUTPUT(Input, bRet) + UMPD_SIZECLIPOBJ + UMPD_SIZEXLATEOBJ(pxlo) +
  1509. UMPD_SIZECOLORADJ + 2 * UMPD_SIZEPOINTL + ALIGN_UMPD_BUFFER(sizeof(POINTFIX)*3) + UMPD_SIZERECTL);
  1510. bRet = pumpdobj->bThunkLargeBitmaps(psoTrg, psoSrc, psoMsk,
  1511. &pvBitTrg, &pvScanTrg,
  1512. &pvBitSrc, &pvScanSrc,
  1513. &pvBitMsk, &pvScanMsk,
  1514. &bSaveTrg, &bLargeTrg,
  1515. &bSaveSrc, &bLargeSrc,
  1516. &bSaveMsk, &bLargeMsk,
  1517. &cjSizeNeed);
  1518. }
  1519. if (bRet)
  1520. {
  1521. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  1522. Input.umpdthdr.umthdr.ulType = INDEX_DrvPlgBlt;
  1523. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  1524. Input.psoTrg = psoTrg;
  1525. Input.psoSrc = psoSrc;
  1526. Input.psoMask = psoMsk;
  1527. Input.pco = pco;
  1528. Input.pxlo = pxlo;
  1529. Input.pca = pca;
  1530. Input.pptlBrushOrg = pptlBrushOrg;
  1531. Input.pptfx = pptfx;
  1532. Input.prcl = prcl;
  1533. Input.pptl = pptl;
  1534. Input.iMode = iMode;
  1535. bRet = pumpdobj->psoDest(&Input.psoTrg, bLargeTrg) &&
  1536. pumpdobj->psoSrc(&Input.psoSrc, bLargeSrc) &&
  1537. pumpdobj->psoMask(&Input.psoMask, bLargeMsk) &&
  1538. pumpdobj->pco(&Input.pco) &&
  1539. pumpdobj->pxlo(&Input.pxlo) &&
  1540. pumpdobj->ThunkCOLORADJUSTMENT(&Input.pca) &&
  1541. pumpdobj->ThunkPOINTL(&Input.pptlBrushOrg) &&
  1542. pumpdobj->ThunkMemBlock((PVOID*) &Input.pptfx, sizeof(POINTFIX)*3) &&
  1543. pumpdobj->ThunkRECTL(&Input.prcl) &&
  1544. pumpdobj->ThunkPOINTL(&Input.pptl) &&
  1545. pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff &&
  1546. bRet;
  1547. }
  1548. if (pumpdobj->bWOW64())
  1549. {
  1550. pumpdobj->RestoreBitmaps(psoTrg, psoSrc, psoMsk,
  1551. pvBitTrg, pvScanTrg, pvBitSrc, pvScanSrc, pvBitMsk, pvScanMsk,
  1552. bSaveTrg, bLargeTrg, bSaveSrc, bLargeSrc, bSaveMsk, bLargeMsk);
  1553. }
  1554. return bRet;
  1555. }
  1556. HBITMAP UMPDDrvCreateDeviceBitmap(
  1557. DHPDEV dhpdev,
  1558. SIZEL sizl,
  1559. ULONG iFormat
  1560. )
  1561. {
  1562. return 0;
  1563. }
  1564. //
  1565. // need to pass in a dhpdev here from the calling routine
  1566. //
  1567. VOID UMPDDrvDeleteDeviceBitmap(
  1568. DHPDEV dhpdev,
  1569. DHSURF dhsurf
  1570. )
  1571. {
  1572. XUMPDOBJ XUMObjs;
  1573. if(XUMObjs.bValid())
  1574. {
  1575. DRVDELETEDEVBITMAP Input;
  1576. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  1577. Input.umpdthdr.umthdr.ulType = INDEX_DrvDeleteDeviceBitmap;
  1578. Input.umpdthdr.humpd = XUMObjs.hUMPD();
  1579. Input.dhpdev = dhpdev;
  1580. Input.dhsurf = dhsurf;
  1581. XUMObjs.pumpdobj()->Thunk(&Input, sizeof(Input), NULL, 0);
  1582. }
  1583. }
  1584. //
  1585. //
  1586. // BOOL UMPDDrvDitherColor
  1587. // UMPD DrvDitherColo thunk. This routine pack up the input parameters
  1588. // and send across to the client side, and copy the output parameters back
  1589. // after returning from client side.
  1590. //
  1591. // Returns
  1592. // ULONG
  1593. //
  1594. // Arguments:
  1595. // refer to DrvDitherColor
  1596. //
  1597. // History:
  1598. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  1599. //
  1600. INT
  1601. GetBitDepthFromBMF(
  1602. INT bmf
  1603. )
  1604. #define MIN_BMF_INDEX BMF_1BPP
  1605. #define MAX_BMF_INDEX BMF_8RLE
  1606. #define BMF_COUNT (MAX_BMF_INDEX - MIN_BMF_INDEX + 1)
  1607. {
  1608. static const INT bitdepths[BMF_COUNT] =
  1609. {
  1610. 1, // BMF_1BPP
  1611. 4, // BMF_4BPP
  1612. 8, // BMF_8BPP
  1613. 16, // BMF_16BPP
  1614. 24, // BMF_24BPP
  1615. 32, // BMF_32BPP
  1616. 4, // BMF_4RLE
  1617. 8 // BMF_8RLE
  1618. };
  1619. if (bmf < MIN_BMF_INDEX || bmf > MAX_BMF_INDEX)
  1620. return 0;
  1621. else
  1622. return bitdepths[bmf - MIN_BMF_INDEX];
  1623. }
  1624. ULONG UMPDDrvDitherColor(
  1625. DHPDEV dhpdevIn, // the first parameter is actually a ppdev
  1626. ULONG iMode,
  1627. ULONG rgb,
  1628. ULONG *pul
  1629. )
  1630. {
  1631. DRVDITHERCOLORINPUT Input;
  1632. ULONG ulRet;
  1633. XUMPDOBJ XUMObjs;
  1634. PDEV *ppdev;
  1635. DHPDEV dhpdev;
  1636. INT cj;
  1637. if(XUMObjs.bValid())
  1638. {
  1639. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  1640. ppdev = (PDEV *)dhpdevIn;
  1641. dhpdev = ppdev->dhpdev;
  1642. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  1643. Input.umpdthdr.umthdr.ulType = INDEX_DrvDitherColor;
  1644. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  1645. Input.dhpdev = dhpdev;
  1646. Input.iMode = iMode;
  1647. Input.rgb = rgb;
  1648. if ((cj = GetBitDepthFromBMF(ppdev->devinfo.iDitherFormat)) <= 0)
  1649. return DCR_SOLID;
  1650. cj = ((ppdev->devinfo.cxDither * cj + 7) / 8) * ppdev->devinfo.cyDither;
  1651. if ((Input.pul = (ULONG *) pumpdobj->AllocUserMem(cj)) == NULL ||
  1652. pumpdobj->Thunk(&Input, sizeof(Input), &ulRet, sizeof(ULONG)) == 0xffffffff)
  1653. {
  1654. return DCR_SOLID;
  1655. }
  1656. if (Input.pul != NULL)
  1657. RtlCopyMemory(pul, pumpdobj->GetKernelPtr(Input.pul), cj);
  1658. return ulRet;
  1659. }
  1660. else
  1661. {
  1662. return FALSE;
  1663. }
  1664. }
  1665. //
  1666. //
  1667. // BOOL UMPDDrvRealizeBrush
  1668. // UMPD DrvRealizeBrush thunk. This routine pack up the input parameters
  1669. // and send across to the client side, and copy the output parameters back
  1670. // after returning from client side.
  1671. //
  1672. // Returns
  1673. // ULONG
  1674. //
  1675. // Arguments:
  1676. // refer to DrvRealizeBrush
  1677. //
  1678. // History:
  1679. // 8/13/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  1680. //
  1681. BOOL UMPDDrvRealizeBrush(
  1682. BRUSHOBJ *pbo,
  1683. SURFOBJ *psoTarget,
  1684. SURFOBJ *psoPattern,
  1685. SURFOBJ *psoMask,
  1686. XLATEOBJ *pxlo,
  1687. ULONG iHatch
  1688. )
  1689. {
  1690. DRVREALIZEBRUSHINPUT Input;
  1691. BOOL bRet = TRUE;
  1692. BOOL bSaveTrg = FALSE, bSavePat = FALSE, bSaveMsk = FALSE;
  1693. BOOL bLargeTrg = FALSE, bLargePat = FALSE, bLargeMsk = FALSE;
  1694. XUMPDOBJ XUMObjs;
  1695. PVOID pvBitTrg, pvBitPat, pvBitMsk;
  1696. PVOID pvScanTrg, pvScanPat, pvScanMsk;
  1697. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  1698. if (!XUMObjs.bValid())
  1699. return FALSE;
  1700. if (pumpdobj->bWOW64())
  1701. {
  1702. ULONG cjSizeNeed = (ULONG)(UMPD_SIZEINOUTPUT(Input, bRet) + UMPD_SIZEBRUSHOBJ + UMPD_SIZEXLATEOBJ(pxlo));
  1703. bRet = pumpdobj->bThunkLargeBitmaps(psoTarget, psoPattern, psoMask,
  1704. &pvBitTrg, &pvScanTrg,
  1705. &pvBitPat, &pvScanPat,
  1706. &pvBitMsk, &pvScanMsk,
  1707. &bSaveTrg, &bLargeTrg,
  1708. &bSavePat, &bLargePat,
  1709. &bSaveMsk, &bLargeMsk,
  1710. &cjSizeNeed);
  1711. }
  1712. if (bRet)
  1713. {
  1714. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  1715. Input.umpdthdr.umthdr.ulType = INDEX_DrvRealizeBrush;
  1716. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  1717. Input.pbo = pbo;
  1718. Input.psoTrg = psoTarget;
  1719. Input.psoPat = psoPattern;
  1720. Input.psoMsk = psoMask;
  1721. Input.pxlo = pxlo;
  1722. Input.iHatch = iHatch;
  1723. bRet = pumpdobj->pbo(&Input.pbo) &&
  1724. pumpdobj->psoDest(&Input.psoTrg, bLargeTrg) &&
  1725. pumpdobj->psoSrc(&Input.psoPat, bLargePat) &&
  1726. pumpdobj->psoMask(&Input.psoMsk, bLargeMsk) &&
  1727. pumpdobj->pxlo(&Input.pxlo) &&
  1728. pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff &&
  1729. bRet;
  1730. }
  1731. if (pumpdobj->bWOW64())
  1732. {
  1733. pumpdobj->RestoreBitmaps(psoTarget, psoPattern, psoMask,
  1734. pvBitTrg, pvScanTrg, pvBitPat, pvScanPat, pvBitMsk, pvScanMsk,
  1735. bSaveTrg, bLargeTrg, bSavePat, bLargePat, bSaveMsk, bLargeMsk);
  1736. }
  1737. return bRet;
  1738. }
  1739. // private
  1740. VOID UMPDMyDrvFree(
  1741. PUMPDOBJ pumpdobj,
  1742. DHPDEV dhpdev,
  1743. PVOID pv,
  1744. ULONG id)
  1745. {
  1746. DRVFREEINPUT Input;
  1747. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  1748. Input.umpdthdr.umthdr.ulType = INDEX_DrvFree;
  1749. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  1750. Input.dhpdev = dhpdev;
  1751. Input.pv = pv;
  1752. Input.id = id;
  1753. pumpdobj->Thunk(&Input, sizeof(Input), NULL, NULL);
  1754. }
  1755. PIFIMETRICS UMPDDrvQueryFont(
  1756. DHPDEV dhpdev,
  1757. ULONG_PTR iFile,
  1758. ULONG iFace,
  1759. ULONG *pid
  1760. )
  1761. {
  1762. QUERYFONTINPUT Input;
  1763. PIFIMETRICS pifi, pifiKM = NULL;
  1764. XUMPDOBJ XUMObjs;
  1765. ULONG cj = 0;
  1766. if(XUMObjs.bValid())
  1767. {
  1768. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  1769. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  1770. Input.umpdthdr.umthdr.ulType = INDEX_DrvQueryFont;
  1771. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  1772. Input.dhpdev = dhpdev;
  1773. Input.iFile = iFile;
  1774. Input.iFace = iFace;
  1775. Input.pid = (ULONG *) pumpdobj->AllocUserMemZ(sizeof(ULONG));
  1776. Input.cjMaxData = 0;
  1777. Input.pv = NULL;
  1778. if (Input.pid == NULL ||
  1779. pumpdobj->Thunk(&Input, sizeof(Input), &pifi, sizeof(pifi)) == 0xffffffff)
  1780. {
  1781. return NULL;
  1782. }
  1783. *pid = *((ULONG *) pumpdobj->GetKernelPtr(Input.pid));
  1784. if (pifi)
  1785. {
  1786. if (iFace)
  1787. {
  1788. if (Input.pv)
  1789. {
  1790. if (Input.cjMaxData)
  1791. {
  1792. PIFIMETRICS kmpifi = (PIFIMETRICS) pumpdobj->GetKernelPtr(Input.pv);
  1793. cj = kmpifi->cjThis;
  1794. ASSERTGDI(Input.cjMaxData >= cj, "UMPDDrvQueryFont: not enough buffer\n");
  1795. if (pifiKM = (PIFIMETRICS)PALLOCMEM(cj, UMPD_MEMORY_TAG))
  1796. RtlCopyMemory(pifiKM, kmpifi, cj);
  1797. }
  1798. else
  1799. {
  1800. WARNING("UMPDDrvQueryFont: not enough buffer\n");
  1801. }
  1802. }
  1803. else
  1804. {
  1805. __try
  1806. {
  1807. ProbeForRead(pifi, sizeof(DWORD), sizeof(BYTE));
  1808. cj = pifi->cjThis;
  1809. //
  1810. // pifiKM is returned to the font code, it will call
  1811. // on DrvFree to free it later
  1812. //
  1813. if (pifiKM = (PIFIMETRICS)PALLOCMEM(cj, UMPD_MEMORY_TAG))
  1814. {
  1815. ProbeForRead(pifi, cj, sizeof(BYTE));
  1816. RtlCopyMemory(pifiKM, pifi, cj);
  1817. }
  1818. }
  1819. __except(EXCEPTION_EXECUTE_HANDLER)
  1820. {
  1821. WARNING ("fail to read pifi\n");
  1822. return NULL;
  1823. }
  1824. }
  1825. //
  1826. // call DrvFree to free the user mode copy
  1827. //
  1828. if (bIsFreeHooked(dhpdev, pumpdobj))
  1829. UMPDMyDrvFree(pumpdobj, dhpdev, pifi, *pid);
  1830. }
  1831. else
  1832. {
  1833. //
  1834. // if iFace == 0, it comes from PDEVOBJ__cFonts when cFonts==-1
  1835. // to query number of fonts supported.
  1836. //
  1837. // In this case, pifi will contain the number of fonts supported
  1838. //
  1839. return pifi;
  1840. }
  1841. }
  1842. //
  1843. // we use the lower part of pifiKM pointer as the id,
  1844. // to make sure no one is going to over-write any fields we returned
  1845. //
  1846. *pid = (ULONG)(ULONG_PTR)pifiKM;
  1847. return pifiKM;
  1848. }
  1849. else
  1850. {
  1851. return NULL;
  1852. }
  1853. }
  1854. BOOL GreFixAndCopyFD_GLYPHSET(
  1855. FD_GLYPHSET *dst,
  1856. FD_GLYPHSET *src,
  1857. ULONG cjSize,
  1858. PUMPDOBJ pumpdobj
  1859. )
  1860. {
  1861. ULONG index, offset;
  1862. RtlCopyMemory(dst, src, cjSize);
  1863. for (index=0; index < src->cRuns; index++)
  1864. {
  1865. if (src->awcrun[index].phg != NULL)
  1866. {
  1867. offset = (ULONG) ((PBYTE)(pumpdobj->GetKernelPtr(src->awcrun[index].phg)) - (PBYTE)src);
  1868. if (offset >= cjSize)
  1869. {
  1870. WARNING("GreFixAndCopyFD_GLYPHSET failed.\n");
  1871. return FALSE;
  1872. }
  1873. dst->awcrun[index].phg = (HGLYPH*) ((PBYTE) dst + offset);
  1874. }
  1875. }
  1876. return TRUE;
  1877. }
  1878. PVOID UMPDDrvQueryFontTree(
  1879. DHPDEV dhpdev,
  1880. ULONG_PTR iFile,
  1881. ULONG iFace,
  1882. ULONG iMode,
  1883. ULONG *pid
  1884. )
  1885. {
  1886. QUERYFONTINPUT Input;
  1887. PVOID pv = NULL, kmpv = NULL;
  1888. PVOID pvKM = NULL;
  1889. XUMPDOBJ XUMObjs;
  1890. ULONG cjSize;
  1891. BOOL bProxyBuffer = FALSE;
  1892. if(XUMObjs.bValid())
  1893. {
  1894. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  1895. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  1896. Input.umpdthdr.umthdr.ulType = INDEX_DrvQueryFontTree;
  1897. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  1898. Input.dhpdev = dhpdev;
  1899. Input.iFile = iFile;
  1900. Input.iFace = iFace;
  1901. Input.iMode = iMode;
  1902. Input.pid = (ULONG *) pumpdobj->AllocUserMemZ(sizeof(ULONG));
  1903. Input.cjMaxData = 0;
  1904. Input.pv = NULL;
  1905. if (Input.pid == NULL ||
  1906. pumpdobj->Thunk(&Input, sizeof(Input), &pv, sizeof(pv)) == 0xffffffff ||
  1907. pv == NULL)
  1908. {
  1909. return NULL;
  1910. }
  1911. *pid = *((ULONG *) pumpdobj->GetKernelPtr(Input.pid));
  1912. cjSize = 0;
  1913. bProxyBuffer = pumpdobj->bWOW64() && Input.pv && Input.cjMaxData;
  1914. kmpv = pumpdobj->GetKernelPtr(Input.pv);
  1915. if (iMode == QFT_GLYPHSET)
  1916. {
  1917. // using proxy
  1918. if (bProxyBuffer)
  1919. {
  1920. cjSize = ((PFD_GLYPHSET)kmpv)->cjThis;
  1921. }
  1922. else if (!pumpdobj->bWOW64())
  1923. {
  1924. __try
  1925. {
  1926. cjSize = offsetof(FD_GLYPHSET, awcrun) + ((PFD_GLYPHSET)pv)->cRuns * sizeof(WCRUN) + ((PFD_GLYPHSET)pv)->cGlyphsSupported * sizeof(HGLYPH);
  1927. }
  1928. __except (EXCEPTION_EXECUTE_HANDLER)
  1929. {
  1930. WARNING ("fail to read pv\n");
  1931. return NULL;
  1932. }
  1933. }
  1934. }
  1935. else if (iMode == QFT_KERNPAIRS)
  1936. {
  1937. // Find the end of the kerning pair array (indicated by a zeroed out
  1938. // FD_KERNINGPAIR structure).
  1939. FD_KERNINGPAIR *pkpEnd;
  1940. if (bProxyBuffer)
  1941. {
  1942. pkpEnd = (FD_KERNINGPAIR*)kmpv;
  1943. while ((pkpEnd->wcFirst) || (pkpEnd->wcSecond) || (pkpEnd->fwdKern))
  1944. {
  1945. pkpEnd += 1;
  1946. cjSize++;
  1947. }
  1948. }
  1949. else if (!pumpdobj->bWOW64())
  1950. {
  1951. pkpEnd = (FD_KERNINGPAIR *)pv;
  1952. __try
  1953. {
  1954. while ((pkpEnd->wcFirst) || (pkpEnd->wcSecond) || (pkpEnd->fwdKern))
  1955. {
  1956. pkpEnd += 1;
  1957. cjSize++;
  1958. }
  1959. }
  1960. __except (EXCEPTION_EXECUTE_HANDLER)
  1961. {
  1962. WARNING ("fail to read kerning pair\n");
  1963. return NULL;
  1964. }
  1965. }
  1966. cjSize = (cjSize + 1) * sizeof(FD_KERNINGPAIR);
  1967. }
  1968. if (cjSize && (pvKM = PALLOCMEM(cjSize, UMPD_MEMORY_TAG)))
  1969. {
  1970. if (iMode == QFT_GLYPHSET)
  1971. {
  1972. if (bProxyBuffer)
  1973. {
  1974. if (!GreFixAndCopyFD_GLYPHSET((FD_GLYPHSET*)pvKM, (FD_GLYPHSET*)kmpv, cjSize, pumpdobj))
  1975. {
  1976. VFREEMEM(pvKM);
  1977. pvKM = NULL;
  1978. }
  1979. }
  1980. else if (!pumpdobj->bWOW64())
  1981. {
  1982. __try
  1983. {
  1984. if (!GreCopyFD_GLYPHSET((FD_GLYPHSET*)pvKM, (FD_GLYPHSET*)pv, cjSize, FALSE))
  1985. {
  1986. VFREEMEM(pvKM);
  1987. pvKM = NULL;
  1988. }
  1989. }
  1990. __except (EXCEPTION_EXECUTE_HANDLER)
  1991. {
  1992. WARNING ("fail to copy pv\n");
  1993. if (pvKM)
  1994. VFREEMEM(pvKM);
  1995. return NULL;
  1996. }
  1997. }
  1998. }
  1999. else if (iMode == QFT_KERNPAIRS)
  2000. {
  2001. if (bProxyBuffer)
  2002. {
  2003. RtlCopyMemory(pvKM, kmpv, cjSize);
  2004. }
  2005. else if (!pumpdobj->bWOW64())
  2006. {
  2007. __try
  2008. {
  2009. ProbeForRead(pv, cjSize, sizeof(BYTE));
  2010. RtlCopyMemory(pvKM, pv, cjSize);
  2011. }
  2012. __except (EXCEPTION_EXECUTE_HANDLER)
  2013. {
  2014. WARNING ("fail to copy pv\n");
  2015. if (pvKM)
  2016. VFREEMEM(pvKM);
  2017. return NULL;
  2018. }
  2019. }
  2020. }
  2021. }
  2022. //
  2023. // free the user mode copy
  2024. //
  2025. if (bIsFreeHooked(dhpdev, pumpdobj))
  2026. UMPDMyDrvFree(pumpdobj, dhpdev, pv, *pid);
  2027. //
  2028. // we use the lower part of pifiKM pointer as the id,
  2029. // to make sure no one is going to over-write any fields we returned
  2030. //
  2031. *pid = (ULONG)(ULONG_PTR)pvKM;
  2032. }
  2033. return pvKM;
  2034. }
  2035. LONG UMPDDrvQueryFontData(
  2036. DHPDEV dhpdev,
  2037. FONTOBJ *pfo,
  2038. ULONG iMode,
  2039. HGLYPH hg,
  2040. GLYPHDATA *pgd,
  2041. PVOID pv,
  2042. ULONG cjSize
  2043. )
  2044. {
  2045. QUERYFONTDATAINPUT Input;
  2046. LONG lRet;
  2047. XUMPDOBJ XUMObjs;
  2048. if(XUMObjs.bValid())
  2049. {
  2050. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  2051. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  2052. Input.umpdthdr.umthdr.ulType = INDEX_DrvQueryFontData;
  2053. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  2054. if (cjSize == 0)
  2055. pv = NULL;
  2056. Input.dhpdev = dhpdev;
  2057. Input.pfo = pfo;
  2058. Input.iMode = iMode;
  2059. Input.hg = hg;
  2060. Input.pgd = pgd;
  2061. Input.pv = pv;
  2062. Input.cjSize = cjSize;
  2063. if (!pumpdobj->ThunkMemBlock((PVOID *) &Input.pgd, sizeof(GLYPHDATA)) ||
  2064. !pumpdobj->ThunkMemBlock((PVOID *) &Input.pv, cjSize) ||
  2065. !pumpdobj->pfo(&Input.pfo))
  2066. {
  2067. return FD_ERROR;
  2068. }
  2069. else
  2070. {
  2071. RFONTTMPOBJ rfto(PFO_TO_PRF(pfo));
  2072. UMPDReleaseRFONTSem(rfto, pumpdobj, NULL, NULL, NULL);
  2073. if (pumpdobj->Thunk(&Input, sizeof(Input), &lRet, sizeof(lRet)) == 0xffffffff)
  2074. lRet = FD_ERROR;
  2075. UMPDAcquireRFONTSem(rfto, pumpdobj, 0, 0, NULL);
  2076. }
  2077. if ((lRet != FD_ERROR) && (pv != NULL))
  2078. RtlCopyMemory(pv, pumpdobj->GetKernelPtr(Input.pv), cjSize);
  2079. if ((lRet != FD_ERROR) && pgd)
  2080. RtlCopyMemory(pgd, pumpdobj->GetKernelPtr(Input.pgd), sizeof(GLYPHDATA));
  2081. return lRet;
  2082. }
  2083. else
  2084. {
  2085. return FD_ERROR;
  2086. }
  2087. }
  2088. //
  2089. // DrvGetGlyphMode is only called from RFONTOBJ::bRealizeFont before the rfont semaphore is
  2090. // intialized, no need to release the rfont sem here
  2091. //
  2092. ULONG UMPDDrvGetGlyphMode(
  2093. DHPDEV dhpdev,
  2094. FONTOBJ *pfo
  2095. )
  2096. {
  2097. GETGLYPHMODEINPUT Input;
  2098. ULONG ulRet;
  2099. XUMPDOBJ XUMObjs;
  2100. if(XUMObjs.bValid())
  2101. {
  2102. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  2103. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  2104. Input.umpdthdr.umthdr.ulType = INDEX_DrvGetGlyphMode;
  2105. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  2106. Input.dhpdev = dhpdev;
  2107. Input.pfo = pfo;
  2108. if (!pumpdobj->pfo(&Input.pfo) ||
  2109. pumpdobj->Thunk(&Input, sizeof(Input), &ulRet, sizeof(ULONG)) == 0xffffffff)
  2110. {
  2111. ulRet = FO_GLYPHBITS;
  2112. }
  2113. return (ulRet);
  2114. }
  2115. else
  2116. {
  2117. return(FO_GLYPHBITS);
  2118. }
  2119. }
  2120. ULONG UMPDDrvFontManagement(
  2121. SURFOBJ *pso,
  2122. FONTOBJ *pfo,
  2123. ULONG iMode,
  2124. ULONG cjIn,
  2125. PVOID pvIn,
  2126. ULONG cjOut,
  2127. PVOID pvOut
  2128. )
  2129. {
  2130. FONTMANAGEMENTINPUT Input;
  2131. ULONG ulRet = 0xffffffff;
  2132. XUMPDOBJ XUMObjs;
  2133. PVOID pvBits, pvScan0;
  2134. BOOL bContinue = TRUE;
  2135. BOOL bSavePtr = FALSE, bLargeBitmap = FALSE;
  2136. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  2137. if(!XUMObjs.bValid())
  2138. return 0xffffffff;
  2139. if (pumpdobj->bWOW64() && iMode != QUERYESCSUPPORT && pso && pso->pvBits)
  2140. {
  2141. ULONG cjSizeNeed = UMPD_SIZEINOUTPUT(Input, ulRet) + UMPD_SIZEFONTOBJ +
  2142. ALIGN_UMPD_BUFFER(cjIn) + ALIGN_UMPD_BUFFER(cjOut);
  2143. bContinue = pumpdobj->bThunkLargeBitmap(pso, &pvBits, &pvScan0, &bSavePtr,
  2144. &bLargeBitmap, &cjSizeNeed);
  2145. }
  2146. if (bContinue)
  2147. {
  2148. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  2149. Input.umpdthdr.umthdr.ulType = INDEX_DrvFontManagement;
  2150. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  2151. if (cjIn == 0)
  2152. pvIn = NULL;
  2153. if (cjOut == 0)
  2154. pvOut = NULL;
  2155. if (iMode == QUERYESCSUPPORT)
  2156. {
  2157. Input.pso = NULL;
  2158. Input.dhpdev = (DHPDEV) pso;
  2159. }
  2160. else
  2161. Input.pso = pso;
  2162. Input.pfo = pfo;
  2163. Input.iMode = iMode;
  2164. Input.cjIn = cjIn;
  2165. Input.pvIn = pvIn;
  2166. Input.cjOut = cjOut;
  2167. Input.pvOut = pvOut;
  2168. if ((pvOut && !(Input.pvOut = pumpdobj->AllocUserMemZ(cjOut))) ||
  2169. !pumpdobj->psoDest(&Input.pso, bLargeBitmap) ||
  2170. !pumpdobj->pfo(&Input.pfo) ||
  2171. !pumpdobj->ThunkMemBlock(&Input.pvIn, cjIn))
  2172. {
  2173. ulRet = 0xffffffff;
  2174. }
  2175. else
  2176. {
  2177. RFONTTMPOBJ rfto(PFO_TO_PRF(pfo));
  2178. UMPDReleaseRFONTSem(rfto, pumpdobj, NULL, NULL, NULL);
  2179. if (pumpdobj->Thunk(&Input, sizeof(Input), &ulRet, sizeof(ulRet)) == 0xffffffff)
  2180. ulRet = 0xffffffff;
  2181. UMPDAcquireRFONTSem(rfto, pumpdobj, 0, 0, NULL);
  2182. if ((ulRet != 0xffffffff) && pvOut)
  2183. RtlCopyMemory(pvOut, pumpdobj->GetKernelPtr(Input.pvOut), cjOut);
  2184. }
  2185. }
  2186. if (bSavePtr)
  2187. pumpdobj->RestoreBitmap(pso, pvBits, pvScan0, bSavePtr, bLargeBitmap);
  2188. return (ulRet);
  2189. }
  2190. VOID UMPDDrvFree(
  2191. PVOID pv,
  2192. ULONG id)
  2193. {
  2194. if (pv)
  2195. {
  2196. //
  2197. // id field is used to keep pv value to make
  2198. // sure pv/pid are returned from umpd
  2199. //
  2200. if (IS_SYSTEM_ADDRESS(pv) && (id == (ULONG)(ULONG_PTR)pv))
  2201. {
  2202. VFREEMEM(pv);
  2203. }
  2204. else
  2205. {
  2206. ASSERTGDI (id == (ULONG)(ULONG_PTR)pv, "UMPDDrvFree -- bad address passed in\n");
  2207. }
  2208. }
  2209. }
  2210. BOOL UMPDDrvQueryAdvanceWidths(
  2211. DHPDEV dhpdev,
  2212. FONTOBJ *pfo,
  2213. ULONG iMode,
  2214. HGLYPH *phg,
  2215. PVOID pvWidths,
  2216. ULONG cGlyphs
  2217. )
  2218. {
  2219. QUERYADVWIDTHSINPUT Input;
  2220. BOOL bRet;
  2221. XUMPDOBJ XUMObjs;
  2222. if(XUMObjs.bValid())
  2223. {
  2224. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  2225. if (phg == NULL || pvWidths == NULL)
  2226. {
  2227. WARNING("invalid parameter in UMPDDrvQueryAdvanceWidths\n");
  2228. return FALSE;
  2229. }
  2230. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  2231. Input.umpdthdr.umthdr.ulType = INDEX_DrvQueryAdvanceWidths;
  2232. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  2233. Input.dhpdev = dhpdev;
  2234. Input.pfo = pfo;
  2235. Input.iMode = iMode;
  2236. Input.phg = phg;
  2237. Input.pvWidths = pvWidths;
  2238. Input.cGlyphs = cGlyphs;
  2239. if (!(Input.pvWidths = pumpdobj->AllocUserMemZ(sizeof(USHORT)*cGlyphs)) ||
  2240. !pumpdobj->pfo(&Input.pfo) ||
  2241. !pumpdobj->ThunkMemBlock((PVOID *) &Input.phg, sizeof(HGLYPH)*cGlyphs))
  2242. {
  2243. return FALSE;
  2244. }
  2245. else
  2246. {
  2247. // DrvQueryAdvancedWidth is called from NtGdiGetWidthTable with rfo lcok.
  2248. RFONTTMPOBJ rfto(PFO_TO_PRF(pfo));
  2249. UMPDReleaseRFONTSem(rfto, pumpdobj, NULL, NULL, NULL);
  2250. if (pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(bRet)) == 0xffffffff)
  2251. bRet = FALSE;
  2252. UMPDAcquireRFONTSem(rfto, pumpdobj, 0, 0, NULL);
  2253. }
  2254. RtlCopyMemory(pvWidths, pumpdobj->GetKernelPtr(Input.pvWidths), sizeof(USHORT)*cGlyphs);
  2255. return (bRet);
  2256. }
  2257. else
  2258. {
  2259. return FALSE;
  2260. }
  2261. }
  2262. //
  2263. //
  2264. // BOOL UMPDDrvBitBlt
  2265. // UMPD DrvBitBlt thunk. This routine packs up the parameters
  2266. // and send across to the client side, and copy the output parameters back
  2267. // after returning from client side.
  2268. //
  2269. // Returns
  2270. // BOOL
  2271. //
  2272. // Arguments:
  2273. // refer to DrvBitBlt
  2274. //
  2275. // History:
  2276. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  2277. //
  2278. BOOL UMPDDrvBitBlt(
  2279. SURFOBJ *psoTrg,
  2280. SURFOBJ *psoSrc,
  2281. SURFOBJ *psoMask,
  2282. CLIPOBJ *pco,
  2283. XLATEOBJ *pxlo,
  2284. RECTL *prclTrg,
  2285. POINTL *pptlSrc,
  2286. POINTL *pptlMask,
  2287. BRUSHOBJ *pbo,
  2288. POINTL *pptlBrush,
  2289. ROP4 rop4
  2290. )
  2291. {
  2292. DRVBITBLTINPUT Input;
  2293. BOOL bRet = TRUE;
  2294. BOOL bSaveTrg = FALSE, bSaveSrc = FALSE, bSaveMsk = FALSE;
  2295. BOOL bLargeTrg = FALSE, bLargeSrc = FALSE, bLargeMsk = FALSE;
  2296. XUMPDOBJ XUMObjs;
  2297. PVOID pvBitTrg, pvBitSrc, pvBitMsk;
  2298. PVOID pvScanTrg, pvScanSrc, pvScanMsk;
  2299. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  2300. if (!XUMObjs.bValid())
  2301. return FALSE;
  2302. if (pumpdobj->bWOW64())
  2303. {
  2304. ULONG cjSizeNeed = (ULONG)(UMPD_SIZEINOUTPUT(Input, bRet) + UMPD_SIZECLIPOBJ + UMPD_SIZEXLATEOBJ(pxlo) +
  2305. UMPD_SIZERECTL + 3 * UMPD_SIZEPOINTL + UMPD_SIZEBRUSHOBJ);
  2306. bRet = pumpdobj->bThunkLargeBitmaps(psoTrg, psoSrc, psoMask,
  2307. &pvBitTrg, &pvScanTrg,
  2308. &pvBitSrc, &pvScanSrc,
  2309. &pvBitMsk, &pvScanMsk,
  2310. &bSaveTrg, &bLargeTrg,
  2311. &bSaveSrc, &bLargeSrc,
  2312. &bSaveMsk, &bLargeMsk,
  2313. &cjSizeNeed);
  2314. }
  2315. if (bRet)
  2316. {
  2317. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  2318. Input.umpdthdr.umthdr.ulType = INDEX_DrvBitBlt;
  2319. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  2320. Input.psoTrg = psoTrg;
  2321. Input.psoSrc = psoSrc;
  2322. Input.psoMask = psoMask;
  2323. Input.pco = pco;
  2324. Input.pxlo = pxlo;
  2325. Input.prclTrg = prclTrg;
  2326. Input.pptlSrc = pptlSrc;
  2327. Input.pptlMask = pptlMask;
  2328. Input.pbo = pbo;
  2329. Input.pptlBrush = pptlBrush;
  2330. Input.rop4 = rop4;
  2331. bRet = pumpdobj->psoDest(&Input.psoTrg, bLargeTrg) &&
  2332. pumpdobj->psoSrc(&Input.psoSrc, bLargeSrc) &&
  2333. pumpdobj->psoMask(&Input.psoMask, bLargeMsk) &&
  2334. pumpdobj->pco(&Input.pco) &&
  2335. pumpdobj->pxlo(&Input.pxlo) &&
  2336. pumpdobj->ThunkRECTL(&Input.prclTrg) &&
  2337. pumpdobj->ThunkPOINTL(&Input.pptlSrc) &&
  2338. pumpdobj->ThunkPOINTL(&Input.pptlMask) &&
  2339. pumpdobj->pbo(&Input.pbo) &&
  2340. pumpdobj->ThunkPOINTL(&Input.pptlBrush) &&
  2341. pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff &&
  2342. bRet;
  2343. }
  2344. if (pumpdobj->bWOW64())
  2345. {
  2346. pumpdobj->RestoreBitmaps(psoTrg, psoSrc, psoMask,
  2347. pvBitTrg, pvScanTrg, pvBitSrc, pvScanSrc, pvBitMsk, pvScanMsk,
  2348. bSaveTrg, bLargeTrg, bSaveSrc, bLargeSrc, bSaveMsk, bLargeMsk);
  2349. }
  2350. return bRet;
  2351. }
  2352. //
  2353. //
  2354. // BOOL UMPDDrvStretchBlt
  2355. // UMPD DrvStretchBlt thunk. This routine packs up the parameters
  2356. // and send across to the client side, and copy the output parameters back
  2357. // after returning from client side.
  2358. //
  2359. // Returns
  2360. // BOOL
  2361. //
  2362. // Arguments:
  2363. // refer to DrvStretchBlt
  2364. //
  2365. // History:
  2366. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  2367. //
  2368. BOOL UMPDDrvStretchBlt(
  2369. SURFOBJ *psoDest,
  2370. SURFOBJ *psoSrc,
  2371. SURFOBJ *psoMask,
  2372. CLIPOBJ *pco,
  2373. XLATEOBJ *pxlo,
  2374. COLORADJUSTMENT *pca,
  2375. POINTL *pptlHTOrg,
  2376. RECTL *prclDest,
  2377. RECTL *prclSrc,
  2378. POINTL *pptlMask,
  2379. ULONG iMode
  2380. )
  2381. {
  2382. DRVSTRETCHBLTINPUT Input;
  2383. BOOL bRet = TRUE;
  2384. BOOL bSaveDst = FALSE, bSaveSrc = FALSE, bSaveMsk = FALSE;
  2385. BOOL bLargeDst = FALSE, bLargeSrc = FALSE, bLargeMsk = FALSE;
  2386. XUMPDOBJ XUMObjs;
  2387. PVOID pvBitDst, pvBitSrc, pvBitMsk;
  2388. PVOID pvScanDst, pvScanSrc, pvScanMsk;
  2389. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  2390. if (!XUMObjs.bValid())
  2391. return FALSE;
  2392. if (pumpdobj->bWOW64())
  2393. {
  2394. ULONG cjSizeNeed = (ULONG)(UMPD_SIZEINOUTPUT(Input, bRet) + UMPD_SIZECLIPOBJ + UMPD_SIZEXLATEOBJ(pxlo) +
  2395. UMPD_SIZECOLORADJ + 2 * UMPD_SIZERECTL + 2 * UMPD_SIZEPOINTL);
  2396. bRet = pumpdobj->bThunkLargeBitmaps(psoDest, psoSrc, psoMask,
  2397. &pvBitDst, &pvScanDst,
  2398. &pvBitSrc, &pvScanSrc,
  2399. &pvBitMsk, &pvScanMsk,
  2400. &bSaveDst, &bLargeDst,
  2401. &bSaveSrc, &bLargeSrc,
  2402. &bSaveMsk, &bLargeMsk,
  2403. &cjSizeNeed);
  2404. }
  2405. if (bRet)
  2406. {
  2407. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  2408. Input.umpdthdr.umthdr.ulType = INDEX_DrvStretchBlt;
  2409. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  2410. Input.psoTrg = psoDest;
  2411. Input.psoSrc = psoSrc;
  2412. Input.psoMask = psoMask;
  2413. Input.pco = pco;
  2414. Input.pxlo = pxlo;
  2415. Input.pca = pca;
  2416. Input.pptlHTOrg = pptlHTOrg;
  2417. Input.prclTrg = prclDest;
  2418. Input.prclSrc = prclSrc;
  2419. Input.pptlMask = pptlMask;
  2420. Input.iMode = iMode;
  2421. bRet = pumpdobj->psoDest(&Input.psoTrg, bLargeDst) &&
  2422. pumpdobj->psoSrc(&Input.psoSrc, bLargeSrc) &&
  2423. pumpdobj->psoMask(&Input.psoMask, bLargeMsk) &&
  2424. pumpdobj->pco(&Input.pco) &&
  2425. pumpdobj->pxlo(&Input.pxlo) &&
  2426. pumpdobj->ThunkCOLORADJUSTMENT(&Input.pca) &&
  2427. pumpdobj->ThunkPOINTL(&Input.pptlHTOrg) &&
  2428. pumpdobj->ThunkRECTL(&Input.prclTrg) &&
  2429. pumpdobj->ThunkRECTL(&Input.prclSrc) &&
  2430. pumpdobj->ThunkPOINTL(&Input.pptlMask) &&
  2431. pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff &&
  2432. bRet;
  2433. }
  2434. if (pumpdobj->bWOW64())
  2435. {
  2436. pumpdobj->RestoreBitmaps(psoDest, psoSrc, psoMask,
  2437. pvBitDst, pvScanDst, pvBitSrc, pvScanSrc, pvBitMsk, pvScanMsk,
  2438. bSaveDst, bLargeDst, bSaveSrc, bLargeSrc, bSaveMsk, bLargeMsk);
  2439. }
  2440. return bRet;
  2441. }
  2442. //
  2443. //
  2444. // BOOL UMPDDrvStretchBltROP
  2445. // UMPD DrvStretchBltROP thunk. This routine packs up the parameters
  2446. // and send across to the client side, and copy the output parameters back
  2447. // after returning from client side.
  2448. //
  2449. // Returns
  2450. // BOOL
  2451. //
  2452. // Arguments:
  2453. // refer to DrvStretchBltROP
  2454. //
  2455. // History:
  2456. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  2457. //
  2458. BOOL UMPDDrvStretchBltROP(
  2459. SURFOBJ *psoDest,
  2460. SURFOBJ *psoSrc,
  2461. SURFOBJ *psoMask,
  2462. CLIPOBJ *pco,
  2463. XLATEOBJ *pxlo,
  2464. COLORADJUSTMENT *pca,
  2465. POINTL *pptlHTOrg,
  2466. RECTL *prclDest,
  2467. RECTL *prclSrc,
  2468. POINTL *pptlMask,
  2469. ULONG iMode,
  2470. BRUSHOBJ *pbo,
  2471. DWORD rop4
  2472. )
  2473. {
  2474. DRVSTRETCHBLTINPUT Input;
  2475. BOOL bRet = TRUE;
  2476. BOOL bSaveDst = FALSE, bSaveSrc = FALSE, bSaveMsk = FALSE;
  2477. BOOL bLargeDst = FALSE, bLargeSrc = FALSE, bLargeMsk = FALSE;
  2478. XUMPDOBJ XUMObjs;
  2479. PVOID pvBitDst, pvBitSrc, pvBitMsk;
  2480. PVOID pvScanDst, pvScanSrc, pvScanMsk;
  2481. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  2482. if(!XUMObjs.bValid())
  2483. return FALSE;
  2484. if (pumpdobj->bWOW64())
  2485. {
  2486. ULONG cjSizeNeed = (ULONG)(UMPD_SIZEINOUTPUT(Input, bRet) + UMPD_SIZECLIPOBJ + UMPD_SIZEXLATEOBJ(pxlo) +
  2487. UMPD_SIZECOLORADJ + 2 * UMPD_SIZEPOINTL + 2 * UMPD_SIZERECTL + UMPD_SIZEBRUSHOBJ);
  2488. bRet = pumpdobj->bThunkLargeBitmaps(psoDest, psoSrc, psoMask,
  2489. &pvBitDst, &pvScanDst,
  2490. &pvBitSrc, &pvScanSrc,
  2491. &pvBitMsk, &pvScanMsk,
  2492. &bSaveDst, &bLargeDst,
  2493. &bSaveSrc, &bLargeSrc,
  2494. &bSaveMsk, &bLargeMsk,
  2495. &cjSizeNeed);
  2496. }
  2497. if (bRet)
  2498. {
  2499. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  2500. Input.umpdthdr.umthdr.ulType = INDEX_DrvStretchBltROP;
  2501. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  2502. Input.psoTrg = psoDest;
  2503. Input.psoSrc = psoSrc;
  2504. Input.psoMask = psoMask;
  2505. Input.pco = pco;
  2506. Input.pxlo = pxlo;
  2507. Input.pca = pca;
  2508. Input.pptlHTOrg = pptlHTOrg;
  2509. Input.prclTrg = prclDest;
  2510. Input.prclSrc = prclSrc;
  2511. Input.pptlMask = pptlMask;
  2512. Input.iMode = iMode;
  2513. Input.pbo = pbo;
  2514. Input.rop4 = rop4;
  2515. bRet = pumpdobj->psoDest(&Input.psoTrg, bLargeDst) &&
  2516. pumpdobj->psoSrc(&Input.psoSrc, bLargeSrc) &&
  2517. pumpdobj->psoMask(&Input.psoMask, bLargeMsk) &&
  2518. pumpdobj->pco(&Input.pco) &&
  2519. pumpdobj->pxlo(&Input.pxlo) &&
  2520. pumpdobj->ThunkCOLORADJUSTMENT(&Input.pca) &&
  2521. pumpdobj->ThunkPOINTL(&Input.pptlHTOrg) &&
  2522. pumpdobj->ThunkRECTL(&Input.prclTrg) &&
  2523. pumpdobj->ThunkRECTL(&Input.prclSrc) &&
  2524. pumpdobj->ThunkPOINTL(&Input.pptlMask) &&
  2525. pumpdobj->pbo(&Input.pbo) &&
  2526. pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff &&
  2527. bRet;
  2528. }
  2529. if (pumpdobj->bWOW64())
  2530. {
  2531. pumpdobj->RestoreBitmaps(psoDest, psoSrc, psoMask,
  2532. pvBitDst, pvScanDst, pvBitSrc, pvScanSrc, pvBitMsk, pvScanMsk,
  2533. bSaveDst, bLargeDst, bSaveSrc, bLargeSrc, bSaveMsk, bLargeMsk);
  2534. }
  2535. return bRet;
  2536. }
  2537. BOOL UMPDDrvAlphaBlend(
  2538. SURFOBJ *psoDest,
  2539. SURFOBJ *psoSrc,
  2540. CLIPOBJ *pco,
  2541. XLATEOBJ *pxlo,
  2542. RECTL *prclDest,
  2543. RECTL *prclSrc,
  2544. BLENDOBJ *pBlendObj
  2545. )
  2546. {
  2547. ALPHAINPUT Input;
  2548. BOOL bRet = TRUE;
  2549. BOOL bSaveDst = FALSE, bSaveSrc = FALSE;
  2550. BOOL bLargeDst = FALSE, bLargeSrc = FALSE;
  2551. XUMPDOBJ XUMObjs;
  2552. PVOID pvBitDst, pvBitSrc;
  2553. PVOID pvScanDst, pvScanSrc;
  2554. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  2555. if(!XUMObjs.bValid())
  2556. return FALSE;
  2557. if (pumpdobj->bWOW64())
  2558. {
  2559. ULONG cjSizeNeed = (ULONG)(UMPD_SIZEINOUTPUT(Input, bRet) + UMPD_SIZECLIPOBJ + UMPD_SIZEXLATEOBJ(pxlo) +
  2560. 2 * UMPD_SIZERECTL + UMPD_SIZEBLENDOBJ);
  2561. bRet = pumpdobj->bThunkLargeBitmaps(psoDest, psoSrc, NULL,
  2562. &pvBitDst, &pvScanDst,
  2563. &pvBitSrc, &pvScanSrc,
  2564. NULL, NULL,
  2565. &bSaveDst, &bLargeDst,
  2566. &bSaveSrc, &bLargeSrc,
  2567. NULL, NULL,
  2568. &cjSizeNeed);
  2569. }
  2570. if (bRet)
  2571. {
  2572. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  2573. Input.umpdthdr.umthdr.ulType = INDEX_DrvAlphaBlend;
  2574. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  2575. Input.psoTrg = psoDest;
  2576. Input.psoSrc = psoSrc;
  2577. Input.pco = pco;
  2578. Input.pxlo = pxlo;
  2579. Input.prclDest = prclDest;
  2580. Input.prclSrc = prclSrc;
  2581. Input.pBlendObj = pBlendObj;
  2582. bRet = pumpdobj->psoDest(&Input.psoTrg, bLargeDst) &&
  2583. pumpdobj->psoSrc(&Input.psoSrc, bLargeSrc) &&
  2584. pumpdobj->pco(&Input.pco) &&
  2585. pumpdobj->pxlo(&Input.pxlo) &&
  2586. pumpdobj->ThunkRECTL(&Input.prclDest) &&
  2587. pumpdobj->ThunkRECTL(&Input.prclSrc) &&
  2588. pumpdobj->ThunkBLENDOBJ(&Input.pBlendObj) &&
  2589. pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff &&
  2590. bRet;
  2591. }
  2592. if (pumpdobj->bWOW64())
  2593. {
  2594. pumpdobj->RestoreBitmaps(psoDest, psoSrc, NULL,
  2595. pvBitDst, pvScanDst, pvBitSrc, pvScanSrc, NULL, NULL,
  2596. bSaveDst, bLargeDst, bSaveSrc, bLargeSrc, FALSE, FALSE);
  2597. }
  2598. return bRet;
  2599. }
  2600. BOOL UMPDDrvGradientFill(
  2601. SURFOBJ *psoDest,
  2602. CLIPOBJ *pco,
  2603. XLATEOBJ *pxlo,
  2604. TRIVERTEX *pVertex,
  2605. ULONG nVertex,
  2606. PVOID pMesh,
  2607. ULONG nMesh,
  2608. RECTL *prclExtents,
  2609. POINTL *pptlDitherOrg,
  2610. ULONG ulMode
  2611. )
  2612. {
  2613. GRADIENTINPUT Input;
  2614. BOOL bRet = TRUE;
  2615. BOOL bSavePtr = FALSE, bLargeBitmap = FALSE;
  2616. ULONG cjMesh;
  2617. XUMPDOBJ XUMObjs;
  2618. PVOID pvBits, pvScan0;
  2619. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  2620. if(!XUMObjs.bValid())
  2621. return FALSE;
  2622. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  2623. Input.umpdthdr.umthdr.ulType = INDEX_DrvGradientFill;
  2624. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  2625. Input.psoTrg = psoDest;
  2626. Input.pco = pco;
  2627. Input.pxlo = pxlo;
  2628. Input.pVertex = pVertex;
  2629. Input.nVertex = nVertex;
  2630. Input.pMesh = pMesh;
  2631. Input.nMesh = nMesh;
  2632. Input.prclExtents = prclExtents;
  2633. Input.pptlDitherOrg = pptlDitherOrg;
  2634. Input.ulMode = ulMode;
  2635. //
  2636. // Figure out the size of pMesh input buffer
  2637. //
  2638. switch (ulMode)
  2639. {
  2640. case GRADIENT_FILL_RECT_H:
  2641. case GRADIENT_FILL_RECT_V:
  2642. cjMesh = sizeof(GRADIENT_RECT);
  2643. break;
  2644. case GRADIENT_FILL_TRIANGLE:
  2645. cjMesh = sizeof(GRADIENT_TRIANGLE);
  2646. break;
  2647. default:
  2648. RIP("Invalid ulMode in DrvGradientFill\n");
  2649. return FALSE;
  2650. }
  2651. cjMesh *= nMesh;
  2652. if (pumpdobj->bWOW64())
  2653. {
  2654. ULONG cjSizeNeed = (ULONG)(UMPD_SIZEINOUTPUT(Input, bRet) + UMPD_SIZECLIPOBJ + UMPD_SIZEXLATEOBJ(pxlo) +
  2655. ALIGN_UMPD_BUFFER(sizeof(TRIVERTEX)*nVertex) + ALIGN_UMPD_BUFFER(cjMesh) +
  2656. UMPD_SIZERECTL + UMPD_SIZEPOINTL);
  2657. bRet = pumpdobj->bThunkLargeBitmap(psoDest, &pvBits, &pvScan0, &bSavePtr, &bLargeBitmap, &cjSizeNeed);
  2658. }
  2659. if (bRet)
  2660. {
  2661. bRet = pumpdobj->psoDest(&Input.psoTrg, bLargeBitmap) &&
  2662. pumpdobj->pco(&Input.pco) &&
  2663. pumpdobj->pxlo(&Input.pxlo) &&
  2664. pumpdobj->ThunkMemBlock((PVOID *)&Input.pVertex, sizeof(TRIVERTEX)*nVertex) &&
  2665. pumpdobj->ThunkMemBlock(&Input.pMesh, cjMesh) &&
  2666. pumpdobj->ThunkRECTL(&Input.prclExtents) &&
  2667. pumpdobj->ThunkPOINTL(&Input.pptlDitherOrg) &&
  2668. pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff &&
  2669. bRet;
  2670. }
  2671. if (bSavePtr)
  2672. pumpdobj->RestoreBitmap(psoDest, pvBits, pvScan0, bSavePtr, bLargeBitmap);
  2673. return bRet;
  2674. }
  2675. BOOL UMPDDrvTransparentBlt(
  2676. SURFOBJ *psoDst,
  2677. SURFOBJ *psoSrc,
  2678. CLIPOBJ *pco,
  2679. XLATEOBJ *pxlo,
  2680. RECTL *prclDst,
  2681. RECTL *prclSrc,
  2682. ULONG TransColor,
  2683. UINT ulReserved
  2684. )
  2685. {
  2686. TRANSPARENTINPUT Input;
  2687. BOOL bRet = TRUE;
  2688. BOOL bSaveDst = FALSE, bSaveSrc = FALSE;
  2689. BOOL bLargeDst = FALSE, bLargeSrc = FALSE;
  2690. XUMPDOBJ XUMObjs;
  2691. PVOID pvBitDst, pvBitSrc, pvScanDst, pvScanSrc;
  2692. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  2693. if(!XUMObjs.bValid())
  2694. return FALSE;
  2695. if (pumpdobj->bWOW64())
  2696. {
  2697. ULONG cjSizeNeed = (ULONG)(UMPD_SIZEINOUTPUT(Input, bRet) + UMPD_SIZECLIPOBJ +
  2698. UMPD_SIZEXLATEOBJ(pxlo) + 2 * UMPD_SIZERECTL);
  2699. bRet = pumpdobj->bThunkLargeBitmaps(psoDst, psoSrc, NULL,
  2700. &pvBitDst, &pvScanDst,
  2701. &pvBitSrc, &pvScanSrc,
  2702. NULL, NULL,
  2703. &bSaveDst, &bLargeDst,
  2704. &bSaveSrc, &bLargeSrc,
  2705. NULL, NULL,
  2706. &cjSizeNeed);
  2707. }
  2708. if (bRet)
  2709. {
  2710. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  2711. Input.umpdthdr.umthdr.ulType = INDEX_DrvTransparentBlt;
  2712. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  2713. Input.psoTrg = psoDst;
  2714. Input.psoSrc = psoSrc;
  2715. Input.pco = pco;
  2716. Input.pxlo = pxlo;
  2717. Input.prclDst = prclDst;
  2718. Input.prclSrc = prclSrc;
  2719. Input.TransColor = TransColor;
  2720. Input.ulReserved = ulReserved;
  2721. bRet = pumpdobj->psoDest(&Input.psoTrg, bLargeDst) &&
  2722. pumpdobj->psoSrc(&Input.psoSrc, bLargeSrc) &&
  2723. pumpdobj->pco(&Input.pco) &&
  2724. pumpdobj->pxlo(&Input.pxlo) &&
  2725. pumpdobj->ThunkRECTL(&Input.prclDst) &&
  2726. pumpdobj->ThunkRECTL(&Input.prclSrc) &&
  2727. pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff &&
  2728. bRet;
  2729. }
  2730. if (pumpdobj->bWOW64())
  2731. {
  2732. pumpdobj->RestoreBitmaps(psoDst, psoSrc, NULL,
  2733. pvBitDst, pvScanDst, pvBitSrc, pvScanSrc, NULL, NULL,
  2734. bSaveDst, bLargeDst, bSaveSrc, bLargeSrc, FALSE, FALSE);
  2735. }
  2736. return bRet;
  2737. }
  2738. //
  2739. //
  2740. // BOOL UMPDDrvCopyBits
  2741. // UMPD DrvCopyBits thunk. This routine packs up the parameters
  2742. // and send across to the client side, and copy the output parameters back
  2743. // after returning from client side.
  2744. //
  2745. // Returns
  2746. // BOOL
  2747. //
  2748. // Arguments:
  2749. // refer to DrvCopyBits
  2750. //
  2751. // History:
  2752. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  2753. //
  2754. BOOL UMPDDrvCopyBits(
  2755. SURFOBJ *psoDest,
  2756. SURFOBJ *psoSrc,
  2757. CLIPOBJ *pco,
  2758. XLATEOBJ *pxlo,
  2759. RECTL *prclDest,
  2760. POINTL *pptlSrc
  2761. )
  2762. {
  2763. DRVCOPYBITSINPUT Input;
  2764. BOOL bRet = TRUE;
  2765. BOOL bSaveDst = FALSE, bSaveSrc = FALSE;
  2766. BOOL bLargeDst = FALSE, bLargeSrc = FALSE;
  2767. XUMPDOBJ XUMObjs;
  2768. PVOID pvBitDst, pvBitSrc, pvScanDst, pvScanSrc;
  2769. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  2770. if(!XUMObjs.bValid())
  2771. return FALSE;
  2772. if (pumpdobj->bWOW64())
  2773. {
  2774. ULONG cjSizeNeed = (ULONG)(UMPD_SIZEINOUTPUT(Input, bRet) + UMPD_SIZECLIPOBJ +
  2775. UMPD_SIZEXLATEOBJ(pxlo) + UMPD_SIZERECTL + UMPD_SIZEPOINTL);
  2776. bRet = pumpdobj->bThunkLargeBitmaps(psoDest, psoSrc, NULL,
  2777. &pvBitDst, &pvScanDst,
  2778. &pvBitSrc, &pvScanSrc,
  2779. NULL, NULL,
  2780. &bSaveDst, &bLargeDst,
  2781. &bSaveSrc, &bLargeSrc,
  2782. NULL, NULL,
  2783. &cjSizeNeed);
  2784. }
  2785. if (bRet)
  2786. {
  2787. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  2788. Input.umpdthdr.umthdr.ulType = INDEX_DrvCopyBits;
  2789. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  2790. Input.psoTrg = psoDest;
  2791. Input.psoSrc = psoSrc;
  2792. Input.pco = pco;
  2793. Input.pxlo = pxlo;
  2794. Input.prclTrg = prclDest;
  2795. Input.pptlSrc = pptlSrc;
  2796. bRet = pumpdobj->psoDest(&Input.psoTrg, bLargeDst) &&
  2797. pumpdobj->psoSrc(&Input.psoSrc, bLargeSrc) &&
  2798. pumpdobj->pco(&Input.pco) &&
  2799. pumpdobj->pxlo(&Input.pxlo) &&
  2800. pumpdobj->ThunkRECTL(&Input.prclTrg) &&
  2801. pumpdobj->ThunkPOINTL(&Input.pptlSrc) &&
  2802. pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff &&
  2803. bRet;
  2804. }
  2805. if (pumpdobj->bWOW64())
  2806. {
  2807. pumpdobj->RestoreBitmaps(psoDest, psoSrc, NULL,
  2808. pvBitDst, pvScanDst, pvBitSrc, pvScanSrc, NULL, NULL,
  2809. bSaveDst, bLargeDst, bSaveSrc, bLargeSrc, FALSE, FALSE);
  2810. }
  2811. return bRet;
  2812. }
  2813. //
  2814. //
  2815. // BOOL UMPDDrvTextOut
  2816. // UMPD DrvTextOut thunk. This routine packs up the parameters
  2817. // and send across to the client side, and copy the output parameters back
  2818. // after returning from client side.
  2819. //
  2820. // Returns
  2821. // BOOL
  2822. //
  2823. // Arguments:
  2824. // refer to DrvTextOut
  2825. //
  2826. // History:
  2827. // 8/14/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  2828. //
  2829. BOOL UMPDDrvTextOut(
  2830. SURFOBJ *pso,
  2831. STROBJ *pstro,
  2832. FONTOBJ *pfo,
  2833. CLIPOBJ *pco,
  2834. RECTL *prclExtra,
  2835. RECTL *prclOpaque,
  2836. BRUSHOBJ *pboFore,
  2837. BRUSHOBJ *pboOpaque,
  2838. POINTL *pptlOrg,
  2839. MIX mix
  2840. )
  2841. {
  2842. TEXTOUTINPUT Input;
  2843. ULONG cjprclExtra;
  2844. BOOL bRet = TRUE;
  2845. BOOL bSavePtr = FALSE, bLargeBitmap = FALSE;
  2846. XUMPDOBJ XUMObjs;
  2847. PVOID pvBits, pvScan0;
  2848. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  2849. if(!XUMObjs.bValid())
  2850. return FALSE;
  2851. //
  2852. // find out the number of rclextra rectangles
  2853. //
  2854. if (prclExtra != (PRECTL) NULL)
  2855. {
  2856. RECTL *prcl;
  2857. cjprclExtra = 1;
  2858. prcl = prclExtra;
  2859. while (prcl->left != prcl->right)
  2860. cjprclExtra++, prcl++;
  2861. cjprclExtra *= sizeof(RECTL);
  2862. }
  2863. else
  2864. cjprclExtra = 0;
  2865. if (pumpdobj->bWOW64())
  2866. {
  2867. ULONG cjSizeNeed = UMPD_SIZEINOUTPUT(Input, bRet) + UMPD_SIZECLIPOBJ + UMPD_SIZEFONTOBJ +
  2868. UMPD_SIZESTROBJ(pstro) + ALIGN_UMPD_BUFFER(cjprclExtra) +
  2869. UMPD_SIZERECTL + UMPD_SIZEPOINTL + 2 * UMPD_SIZEBRUSHOBJ;
  2870. bRet = pumpdobj->bThunkLargeBitmap(pso, &pvBits, &pvScan0, &bSavePtr, &bLargeBitmap, &cjSizeNeed);
  2871. }
  2872. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  2873. Input.umpdthdr.umthdr.ulType = INDEX_DrvTextOut;
  2874. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  2875. Input.pso = pso;
  2876. Input.pstro = pstro;
  2877. Input.pfo = pfo;
  2878. Input.pco = pco;
  2879. Input.prclExtra = prclExtra;
  2880. Input.prclOpaque = prclOpaque;
  2881. Input.pboFore = pboFore;
  2882. Input.pboOpaque = pboOpaque;
  2883. Input.pptlOrg = pptlOrg;
  2884. Input.mix = mix;
  2885. if (bRet)
  2886. {
  2887. if (pumpdobj->psoDest(&Input.pso, bLargeBitmap) &&
  2888. pumpdobj->pstro(&Input.pstro) &&
  2889. pumpdobj->pfo(&Input.pfo) &&
  2890. pumpdobj->pco(&Input.pco) &&
  2891. pumpdobj->ThunkMemBlock((PVOID *) &Input.prclExtra, cjprclExtra) &&
  2892. pumpdobj->ThunkRECTL(&Input.prclOpaque) &&
  2893. pumpdobj->pbo(&Input.pboFore) &&
  2894. pumpdobj->pboFill(&Input.pboOpaque) &&
  2895. pumpdobj->ThunkPOINTL(&Input.pptlOrg))
  2896. {
  2897. RFONTTMPOBJ rfto(PFO_TO_PRF(pfo));
  2898. UMPDReleaseRFONTSem(rfto, pumpdobj, NULL, NULL, NULL);
  2899. if (pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) == 0xffffffff)
  2900. bRet = FALSE;
  2901. UMPDAcquireRFONTSem(rfto, pumpdobj, 0, 0, NULL);
  2902. }
  2903. }
  2904. if (bSavePtr)
  2905. pumpdobj->RestoreBitmap(pso, pvBits, pvScan0, bSavePtr, bLargeBitmap);
  2906. return bRet;
  2907. }
  2908. //
  2909. //
  2910. // BOOL UMPDDrvLineTo
  2911. // UMPD DrvLineTo thunk. This routine packs up the parameters
  2912. // and send across to the client side, and copy the output parameters back
  2913. // after returning from client side.
  2914. //
  2915. // Returns
  2916. // BOOL
  2917. //
  2918. // Arguments:
  2919. // refer to DrvLineTo
  2920. //
  2921. // History:
  2922. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  2923. //
  2924. BOOL UMPDDrvLineTo(
  2925. SURFOBJ *pso,
  2926. CLIPOBJ *pco,
  2927. BRUSHOBJ *pbo,
  2928. LONG x1,
  2929. LONG y1,
  2930. LONG x2,
  2931. LONG y2,
  2932. RECTL *prclBounds,
  2933. MIX mix
  2934. )
  2935. {
  2936. DRVLINETOINPUT Input;
  2937. BOOL bRet = TRUE;
  2938. BOOL bSavePtr = FALSE, bLargeBitmap = FALSE;
  2939. XUMPDOBJ XUMObjs;
  2940. PVOID pvBits, pvScan0;
  2941. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  2942. if(!XUMObjs.bValid())
  2943. return FALSE;
  2944. if (pumpdobj->bWOW64())
  2945. {
  2946. ULONG cjSizeNeed = UMPD_SIZEINOUTPUT(Input, bRet) + UMPD_SIZERECTL + UMPD_SIZECLIPOBJ + UMPD_SIZEBRUSHOBJ;
  2947. bRet = pumpdobj->bThunkLargeBitmap(pso, &pvBits, &pvScan0, &bSavePtr, &bLargeBitmap, &cjSizeNeed);
  2948. }
  2949. if (bRet)
  2950. {
  2951. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  2952. Input.umpdthdr.umthdr.ulType = INDEX_DrvLineTo;
  2953. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  2954. Input.pso = pso;
  2955. Input.pco = pco;
  2956. Input.pbo = pbo;
  2957. Input.x1 = x1;
  2958. Input.y1 = y1;
  2959. Input.x2 = x2;
  2960. Input.y2 = y2;
  2961. Input.prclBounds = prclBounds;
  2962. Input.mix = mix;
  2963. bRet = pumpdobj->psoDest(&Input.pso, bLargeBitmap) &&
  2964. pumpdobj->pco(&Input.pco) &&
  2965. pumpdobj->pbo(&Input.pbo) &&
  2966. pumpdobj->ThunkRECTL(&Input.prclBounds) &&
  2967. pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff &&
  2968. bRet;
  2969. }
  2970. if (bSavePtr)
  2971. pumpdobj->RestoreBitmap(pso, pvBits, pvScan0, bSavePtr, bLargeBitmap);
  2972. return bRet;
  2973. }
  2974. //
  2975. //
  2976. // BOOL UMPDDrvStrokePath
  2977. // UMPD DrvStrokePath thunk. This routine packs up the parameters
  2978. // and send across to the client side, and copy the output parameters back
  2979. // after returning from client side.
  2980. //
  2981. // Returns
  2982. // BOOL
  2983. //
  2984. // Arguments:
  2985. // refer to DrvStrokePath
  2986. //
  2987. // History:
  2988. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  2989. //
  2990. BOOL UMPDDrvStrokePath(
  2991. SURFOBJ *pso,
  2992. PATHOBJ *ppo,
  2993. CLIPOBJ *pco,
  2994. XFORMOBJ *pxo,
  2995. BRUSHOBJ *pbo,
  2996. POINTL *pptlBrushOrg,
  2997. LINEATTRS *plineattrs,
  2998. MIX mix
  2999. )
  3000. {
  3001. STORKEANDFILLINPUT Input;
  3002. BOOL bRet = TRUE;
  3003. BOOL bSavePtr = FALSE, bLargeBitmap = FALSE;
  3004. XUMPDOBJ XUMObjs;
  3005. PVOID pvBits, pvScan0;
  3006. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  3007. if(!XUMObjs.bValid())
  3008. return FALSE;
  3009. if (pumpdobj->bWOW64())
  3010. {
  3011. ULONG cjSizeNeed = UMPD_SIZEINOUTPUT(Input, bRet) + UMPD_SIZECLIPOBJ + UMPD_SIZEPATHOBJ +
  3012. UMPD_SIZEXFORMOBJ + UMPD_SIZEBRUSHOBJ + UMPD_SIZEPOINTL + UMPD_SIZELINEATTRS(plineattrs);
  3013. bRet = pumpdobj->bThunkLargeBitmap(pso, &pvBits, &pvScan0, &bSavePtr, &bLargeBitmap, &cjSizeNeed);
  3014. }
  3015. if (bRet)
  3016. {
  3017. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  3018. Input.umpdthdr.umthdr.ulType = INDEX_DrvStrokePath;
  3019. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  3020. Input.pso = pso;
  3021. Input.ppo = ppo;
  3022. Input.pco = pco;
  3023. Input.pxo = pxo;
  3024. Input.pbo = pbo;
  3025. Input.pptlBrushOrg = pptlBrushOrg;
  3026. Input.plineattrs = plineattrs;
  3027. Input.mix = mix;
  3028. bRet = pumpdobj->psoDest(&Input.pso, bLargeBitmap) &&
  3029. pumpdobj->ppo(&Input.ppo) &&
  3030. pumpdobj->pco(&Input.pco) &&
  3031. pumpdobj->pxo(&Input.pxo) &&
  3032. pumpdobj->pbo(&Input.pbo) &&
  3033. pumpdobj->ThunkPOINTL(&Input.pptlBrushOrg) &&
  3034. pumpdobj->ThunkLINEATTRS(&Input.plineattrs) &&
  3035. pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff &&
  3036. bRet;
  3037. }
  3038. if (bSavePtr)
  3039. pumpdobj->RestoreBitmap(pso, pvBits, pvScan0, bSavePtr, bLargeBitmap);
  3040. return bRet;
  3041. }
  3042. //
  3043. //
  3044. // BOOL UMPDDrvFillPath
  3045. // UMPD DrvFillPath thunk. This routine packs up the parameters
  3046. // and send across to the client side, and copy the output parameters back
  3047. // after returning from client side.
  3048. //
  3049. // Returns
  3050. // BOOL
  3051. //
  3052. // Arguments:
  3053. // refer to DrvFillPath
  3054. //
  3055. // History:
  3056. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  3057. //
  3058. BOOL UMPDDrvFillPath(
  3059. SURFOBJ *pso,
  3060. PATHOBJ *ppo,
  3061. CLIPOBJ *pco,
  3062. BRUSHOBJ *pbo,
  3063. POINTL *pptlBrushOrg,
  3064. MIX mix,
  3065. FLONG flOptions
  3066. )
  3067. {
  3068. STORKEANDFILLINPUT Input;
  3069. BOOL bRet = TRUE;
  3070. BOOL bSavePtr = FALSE, bLargeBitmap = FALSE;
  3071. XUMPDOBJ XUMObjs;
  3072. PVOID pvBits, pvScan0;
  3073. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  3074. if(!XUMObjs.bValid())
  3075. return FALSE;
  3076. if (pumpdobj->bWOW64())
  3077. {
  3078. ULONG cjSizeNeed = UMPD_SIZEINOUTPUT(Input, bRet) + UMPD_SIZEPATHOBJ + UMPD_SIZECLIPOBJ +
  3079. UMPD_SIZEBRUSHOBJ + UMPD_SIZEPOINTL;
  3080. bRet = pumpdobj->bThunkLargeBitmap(pso, &pvBits, &pvScan0, &bSavePtr, &bLargeBitmap, &cjSizeNeed);
  3081. }
  3082. if (bRet)
  3083. {
  3084. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  3085. Input.umpdthdr.umthdr.ulType = INDEX_DrvFillPath;
  3086. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  3087. Input.pso = pso;
  3088. Input.ppo = ppo;
  3089. Input.pco = pco;
  3090. Input.pbo = pbo;
  3091. Input.pptlBrushOrg = pptlBrushOrg;
  3092. Input.mix = mix;
  3093. Input.flOptions = flOptions;
  3094. bRet = pumpdobj->psoDest(&Input.pso, bLargeBitmap) &&
  3095. pumpdobj->ppo(&Input.ppo) &&
  3096. pumpdobj->pco(&Input.pco) &&
  3097. pumpdobj->pbo(&Input.pbo) &&
  3098. pumpdobj->ThunkPOINTL(&Input.pptlBrushOrg) &&
  3099. pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff &&
  3100. bRet;
  3101. }
  3102. if (bSavePtr)
  3103. pumpdobj->RestoreBitmap(pso, pvBits, pvScan0, bSavePtr, bLargeBitmap);
  3104. return bRet;
  3105. }
  3106. //
  3107. // BOOL UMPDStrokeAndFillPath
  3108. // UMPD DrvStrokeAndFillPath thunk. This routine packs up the parameters
  3109. // and send across to the client side, and copy the output parameters back
  3110. // after returning from client side.
  3111. //
  3112. // Returns
  3113. // BOOL
  3114. //
  3115. // Arguments:
  3116. // refer to DrvStrokeAndFillPath
  3117. //
  3118. // History:
  3119. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  3120. //
  3121. BOOL UMPDDrvStrokeAndFillPath(
  3122. SURFOBJ *pso,
  3123. PATHOBJ *ppo,
  3124. CLIPOBJ *pco,
  3125. XFORMOBJ *pxo,
  3126. BRUSHOBJ *pboStroke,
  3127. LINEATTRS *plineattrs,
  3128. BRUSHOBJ *pboFill,
  3129. POINTL *pptlBrushOrg,
  3130. MIX mix,
  3131. FLONG flOptions
  3132. )
  3133. {
  3134. STORKEANDFILLINPUT Input;
  3135. BOOL bRet = TRUE;
  3136. BOOL bSavePtr = FALSE, bLargeBitmap = FALSE;
  3137. XUMPDOBJ XUMObjs;
  3138. PVOID pvBits, pvScan0;
  3139. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  3140. if(!XUMObjs.bValid())
  3141. return FALSE;
  3142. if (pumpdobj->bWOW64())
  3143. {
  3144. ULONG cjSizeNeed = UMPD_SIZEINOUTPUT(Input, bRet) + UMPD_SIZEPATHOBJ + UMPD_SIZECLIPOBJ +
  3145. UMPD_SIZEXFORMOBJ + UMPD_SIZELINEATTRS(plineattrs) + 2 * UMPD_SIZEBRUSHOBJ + UMPD_SIZEPOINTL;
  3146. bRet = pumpdobj->bThunkLargeBitmap(pso, &pvBits, &pvScan0, &bSavePtr, &bLargeBitmap, &cjSizeNeed);
  3147. }
  3148. if (bRet)
  3149. {
  3150. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  3151. Input.umpdthdr.umthdr.ulType = INDEX_DrvStrokeAndFillPath;
  3152. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  3153. Input.pso = pso;
  3154. Input.ppo = ppo;
  3155. Input.pco = pco;
  3156. Input.pxo = pxo;
  3157. Input.pbo = pboStroke;
  3158. Input.plineattrs = plineattrs;
  3159. Input.pboFill = pboFill;
  3160. Input.pptlBrushOrg = pptlBrushOrg;
  3161. Input.mix = mix;
  3162. Input.flOptions = flOptions;
  3163. bRet = pumpdobj->psoDest(&Input.pso, bLargeBitmap) &&
  3164. pumpdobj->ppo(&Input.ppo) &&
  3165. pumpdobj->pco(&Input.pco) &&
  3166. pumpdobj->pxo(&Input.pxo) &&
  3167. pumpdobj->pbo(&Input.pbo) &&
  3168. pumpdobj->ThunkLINEATTRS(&Input.plineattrs) &&
  3169. pumpdobj->pboFill(&Input.pboFill) &&
  3170. pumpdobj->ThunkPOINTL(&Input.pptlBrushOrg) &&
  3171. pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff &&
  3172. bRet;
  3173. }
  3174. if (bSavePtr)
  3175. pumpdobj->RestoreBitmap(pso, pvBits, pvScan0, bSavePtr, bLargeBitmap);
  3176. return bRet;
  3177. }
  3178. BOOL APIENTRY
  3179. UMPDDrvPaint(
  3180. SURFOBJ *pso,
  3181. CLIPOBJ *pco,
  3182. BRUSHOBJ *pbo,
  3183. POINTL *pptlBrushOrg,
  3184. MIX mix
  3185. )
  3186. {
  3187. STORKEANDFILLINPUT Input;
  3188. BOOL bRet = TRUE;
  3189. BOOL bSavePtr = FALSE, bLargeBitmap = FALSE;
  3190. XUMPDOBJ XUMObjs;
  3191. PVOID pvBits, pvScan0;
  3192. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  3193. if(!XUMObjs.bValid())
  3194. return FALSE;
  3195. if (pumpdobj->bWOW64())
  3196. {
  3197. ULONG cjSizeNeed = UMPD_SIZEINOUTPUT(Input, bRet) + UMPD_SIZECLIPOBJ + UMPD_SIZEPOINTL + UMPD_SIZEBRUSHOBJ;
  3198. bRet = pumpdobj->bThunkLargeBitmap(pso, &pvBits, &pvScan0, &bSavePtr, &bLargeBitmap, &cjSizeNeed);
  3199. }
  3200. if (bRet)
  3201. {
  3202. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  3203. Input.umpdthdr.umthdr.ulType = INDEX_DrvPaint;
  3204. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  3205. Input.pso = pso;
  3206. Input.pco = pco;
  3207. Input.pbo = pbo;
  3208. Input.pptlBrushOrg = pptlBrushOrg;
  3209. Input.mix = mix;
  3210. bRet = pumpdobj->psoDest(&Input.pso, bLargeBitmap) &&
  3211. pumpdobj->pco(&Input.pco) &&
  3212. pumpdobj->pbo(&Input.pbo) &&
  3213. pumpdobj->ThunkPOINTL(&Input.pptlBrushOrg) &&
  3214. pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff &&
  3215. bRet;
  3216. }
  3217. if (bSavePtr)
  3218. pumpdobj->RestoreBitmap(pso, pvBits, pvScan0, bSavePtr, bLargeBitmap);
  3219. return bRet;
  3220. }
  3221. BOOL UMPDDrvQuerySpoolType(
  3222. DHPDEV dhpdev,
  3223. LPWSTR pwszDataType
  3224. )
  3225. {
  3226. WARNING("UMPDDrvQuerySpoolType not needed\n");
  3227. return 0;
  3228. }
  3229. HANDLE UMPDDrvIcmCreateColorTransform(
  3230. DHPDEV dhpdev,
  3231. LPLOGCOLORSPACEW pLogColorSpace,
  3232. PVOID pvSourceProfile,
  3233. ULONG cjSourceProfile,
  3234. PVOID pvDestProfile,
  3235. ULONG cjDestProfile,
  3236. PVOID pvTargetProfile,
  3237. ULONG cjTargetProfile,
  3238. DWORD dwReserved
  3239. )
  3240. {
  3241. DRVICMCREATECOLORINPUT Input;
  3242. HANDLE hRet;
  3243. XUMPDOBJ XUMObjs;
  3244. if(XUMObjs.bValid())
  3245. {
  3246. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  3247. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  3248. Input.umpdthdr.umthdr.ulType = INDEX_DrvIcmCreateColorTransform;
  3249. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  3250. Input.dhpdev = dhpdev;
  3251. Input.pLogColorSpace = pLogColorSpace;
  3252. Input.pvSourceProfile = pvSourceProfile;
  3253. Input.cjSourceProfile = cjSourceProfile;
  3254. Input.pvDestProfile = pvDestProfile;
  3255. Input.cjDestProfile = cjDestProfile;
  3256. Input.pvTargetProfile = pvTargetProfile;
  3257. Input.cjTargetProfile = cjTargetProfile;
  3258. Input.dwReserved = dwReserved;
  3259. if (!pumpdobj->ThunkMemBlock((PVOID *) &Input.pLogColorSpace, sizeof(LOGCOLORSPACE)) ||
  3260. !pumpdobj->ThunkMemBlock((PVOID *)&Input.pvSourceProfile, cjSourceProfile) ||
  3261. !pumpdobj->ThunkMemBlock((PVOID *)&Input.pvDestProfile, cjDestProfile) ||
  3262. !pumpdobj->ThunkMemBlock((PVOID *)&Input.pvTargetProfile, cjTargetProfile))
  3263. {
  3264. hRet = 0;
  3265. }
  3266. else
  3267. {
  3268. if (pumpdobj->Thunk(&Input, sizeof(Input), &hRet, sizeof(HANDLE)) == 0xffffffff)
  3269. hRet = 0;
  3270. }
  3271. return (hRet);
  3272. }
  3273. else
  3274. {
  3275. return FALSE;
  3276. }
  3277. }
  3278. BOOL UMPDDrvIcmDeleteColorTransform(
  3279. DHPDEV dhpdev,
  3280. HANDLE hcmXform
  3281. )
  3282. {
  3283. XUMPDOBJ XUMObjs;
  3284. DRVICMDELETECOLOR Input;
  3285. BOOL bRet;
  3286. if(XUMObjs.bValid())
  3287. {
  3288. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  3289. Input.umpdthdr.umthdr.ulType = INDEX_DrvIcmDeleteColorTransform;
  3290. Input.umpdthdr.humpd = XUMObjs.hUMPD();
  3291. Input.dhpdev = dhpdev;
  3292. Input.hcmXform = hcmXform;
  3293. return XUMObjs.pumpdobj()->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff &&
  3294. bRet;
  3295. }
  3296. else
  3297. {
  3298. return FALSE;
  3299. }
  3300. }
  3301. BOOL UMPDDrvIcmCheckBitmapBits(
  3302. DHPDEV dhpdev,
  3303. HANDLE hColorTransform,
  3304. SURFOBJ *pso,
  3305. PBYTE paResults
  3306. )
  3307. {
  3308. DRVICMCHECKBITMAPINPUT Input;
  3309. BOOL bRet = TRUE;
  3310. BOOL bSavePtr = FALSE, bLargeBitmap = FALSE;
  3311. XUMPDOBJ XUMObjs;
  3312. ULONG cjSize;
  3313. PVOID pvBits, pvScan0;
  3314. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  3315. if(!XUMObjs.bValid())
  3316. return FALSE;
  3317. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  3318. Input.umpdthdr.umthdr.ulType = INDEX_DrvIcmCheckBitmapBits;
  3319. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  3320. Input.dhpdev = dhpdev;
  3321. Input.hColorTransform = hColorTransform;
  3322. Input.pso = pso;
  3323. Input.paResults = paResults;
  3324. //
  3325. // Hideyuki says that paResults size is based on the number of pixels in pso,
  3326. // one byte for each pixel
  3327. //
  3328. cjSize = pso->sizlBitmap.cx * pso->sizlBitmap.cy;
  3329. if (pumpdobj->bWOW64())
  3330. {
  3331. ULONG cjSizeNeed = UMPD_SIZEINOUTPUT(Input, bRet) + ALIGN_UMPD_BUFFER(sizeof(BYTE) * cjSize);
  3332. bRet = pumpdobj->bThunkLargeBitmap(pso, &pvBits, &pvScan0, &bSavePtr, &bLargeBitmap, &cjSizeNeed);
  3333. }
  3334. if (bRet)
  3335. {
  3336. bRet = pumpdobj->psoDest(&Input.pso, bLargeBitmap) &&
  3337. (Input.paResults = (PBYTE)pumpdobj->AllocUserMemZ(sizeof(BYTE) * cjSize)) &&
  3338. (pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff) &&
  3339. bRet;
  3340. }
  3341. if (bSavePtr)
  3342. pumpdobj->RestoreBitmap(pso, pvBits, pvScan0, bSavePtr, bLargeBitmap);
  3343. return bRet;
  3344. }
  3345. BOOL UMPDEngFreeUserMem(KERNEL_PVOID pv)
  3346. {
  3347. UMPDFREEMEMINPUT Input;
  3348. BOOL bRet;
  3349. XUMPDOBJ XUMObjs;
  3350. PUMPDOBJ pumpdobj = XUMObjs.pumpdobj();
  3351. if(!XUMObjs.bValid() || !pumpdobj->bWOW64())
  3352. return FALSE;
  3353. Input.umpdthdr.umthdr.cjSize = sizeof(Input);
  3354. Input.umpdthdr.umthdr.ulType = INDEX_UMPDEngFreeUserMem;
  3355. Input.umpdthdr.humpd = (HUMPD) pumpdobj->hGet();
  3356. Input.pvTrg = pv;
  3357. Input.pvSrc = NULL;
  3358. Input.pvMsk = NULL;
  3359. bRet = (pumpdobj->Thunk(&Input, sizeof(Input), &bRet, sizeof(BOOL)) != 0xffffffff) && bRet;
  3360. return bRet;
  3361. }
  3362. //
  3363. //
  3364. // gpUMDriverFunc
  3365. // Our kernel mode thunk functions table.
  3366. //
  3367. // History:
  3368. // 7/17/97 -- Lingyun Wang [lingyunw] -- Wrote it.
  3369. //
  3370. PFN gpUMDriverFunc[INDEX_LAST] =
  3371. {
  3372. (PFN)UMPDDrvEnablePDEV,
  3373. (PFN)UMPDDrvCompletePDEV,
  3374. (PFN)UMPDDrvDisablePDEV,
  3375. (PFN)UMPDDrvEnableSurface,
  3376. (PFN)UMPDDrvDisableSurface,
  3377. (PFN)NULL,
  3378. (PFN)NULL,
  3379. (PFN)UMPDDrvResetPDEV,
  3380. (PFN)UMPDDrvDisableDriver,
  3381. (PFN)NULL,
  3382. (PFN)UMPDDrvCreateDeviceBitmap,
  3383. (PFN)UMPDDrvDeleteDeviceBitmap,
  3384. (PFN)UMPDDrvRealizeBrush,
  3385. (PFN)UMPDDrvDitherColor,
  3386. (PFN)UMPDDrvStrokePath,
  3387. (PFN)UMPDDrvFillPath,
  3388. (PFN)UMPDDrvStrokeAndFillPath,
  3389. (PFN)UMPDDrvPaint,
  3390. (PFN)UMPDDrvBitBlt,
  3391. (PFN)UMPDDrvCopyBits,
  3392. (PFN)UMPDDrvStretchBlt,
  3393. (PFN)NULL,
  3394. (PFN)NULL, //UMPDDrvSetPalette,
  3395. (PFN)UMPDDrvTextOut,
  3396. (PFN)UMPDDrvEscape,
  3397. (PFN)UMPDDrvDrawEscape,
  3398. (PFN)UMPDDrvQueryFont,
  3399. (PFN)UMPDDrvQueryFontTree,
  3400. (PFN)UMPDDrvQueryFontData,
  3401. (PFN)NULL, //UMPDDrvSetPointerShape,
  3402. (PFN)NULL, //UMPDDrvMovePointer,
  3403. (PFN)UMPDDrvLineTo,
  3404. (PFN)UMPDDrvSendPage,
  3405. (PFN)UMPDDrvStartPage,
  3406. (PFN)UMPDDrvEndDoc,
  3407. (PFN)UMPDDrvStartDoc,
  3408. (PFN)NULL,
  3409. (PFN)UMPDDrvGetGlyphMode,
  3410. (PFN)NULL, //DrvSync
  3411. (PFN)NULL,
  3412. (PFN)NULL, //UMPDDrvSaveScreenBits
  3413. (PFN)NULL,
  3414. (PFN)UMPDDrvFree,
  3415. (PFN)NULL, //UMPDDrvDestroyFont,
  3416. (PFN)NULL, //UMPDDrvQueryFontCaps,
  3417. (PFN)NULL, //UMPDDrvLoadFontFile,
  3418. (PFN)NULL, //UMPDDrvUnloadFontFile,
  3419. (PFN)UMPDDrvFontManagement,
  3420. (PFN)NULL, //UMPDDrvQueryTrueTypeTable,
  3421. (PFN)NULL, //UMPDDrvQueryTrueTypeOutline,
  3422. (PFN)NULL, //UMPDDrvGetTrueTypeFile,
  3423. (PFN)NULL, //UMPDDrvQueryFontFile,
  3424. (PFN)NULL, //UMPDDrvMovePanning
  3425. (PFN)UMPDDrvQueryAdvanceWidths,
  3426. (PFN)NULL, //UMPDDrvSetPixelFormat,
  3427. (PFN)NULL, //UMPDDrvDescribePixelFormat,
  3428. (PFN)NULL, //UMPDDrvSwapBuffers,
  3429. (PFN)UMPDDrvStartBanding,
  3430. (PFN)UMPDDrvNextBand,
  3431. (PFN)NULL, //UMPDDrvGetDirectDrawInfo,
  3432. (PFN)NULL, //UMPDDrvEnableDirectDraw,
  3433. (PFN)NULL, //UMPDDrvDisableDirectDraw,
  3434. (PFN)UMPDDrvQuerySpoolType,
  3435. (PFN)NULL, //UMPDDrvCreateLayerBitmap,
  3436. (PFN)UMPDDrvIcmCreateColorTransform,
  3437. (PFN)UMPDDrvIcmDeleteColorTransform,
  3438. (PFN)UMPDDrvIcmCheckBitmapBits,
  3439. (PFN)NULL, //UMPDDrvIcmSetDeviceGammaRamp,
  3440. (PFN)UMPDDrvGradientFill,
  3441. (PFN)UMPDDrvStretchBltROP,
  3442. (PFN)UMPDDrvPlgBlt,
  3443. (PFN)UMPDDrvAlphaBlend,
  3444. (PFN)NULL, //UMPDDrvSynthesizeFont,
  3445. (PFN)NULL, //UMPDDrvGetSynthesizedFontFiles,
  3446. (PFN)UMPDDrvTransparentBlt,
  3447. (PFN)UMPDDrvQueryPerBandInfo,
  3448. (PFN)UMPDDrvQueryDeviceSupport,
  3449. };
  3450. #endif // !_GDIPLUS_