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.

1565 lines
43 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: ddsup.cxx *
  3. * *
  4. * Copyright (c) 1990-2000 Microsoft Corporation *
  5. * *
  6. * DirectDraw support routines *
  7. * *
  8. \**************************************************************************/
  9. #include "precomp.hxx"
  10. DRVFN gaEngFuncs[] =
  11. {
  12. { INDEX_DxEngUnused, (PFN) NULL },
  13. { INDEX_DxEngIsTermSrv, (PFN) DxEngIsTermSrv },
  14. { INDEX_DxEngScreenAccessCheck, (PFN) DxEngScreenAccessCheck },
  15. { INDEX_DxEngRedrawDesktop, (PFN) DxEngRedrawDesktop },
  16. { INDEX_DxEngDispUniq, (PFN) DxEngDispUniq },
  17. { INDEX_DxEngIncDispUniq, (PFN) DxEngIncDispUniq },
  18. { INDEX_DxEngVisRgnUniq, (PFN) DxEngVisRgnUniq },
  19. { INDEX_DxEngLockShareSem, (PFN) DxEngLockShareSem },
  20. { INDEX_DxEngUnlockShareSem, (PFN) DxEngUnlockShareSem },
  21. { INDEX_DxEngEnumerateHdev, (PFN) DxEngEnumerateHdev },
  22. { INDEX_DxEngLockHdev, (PFN) DxEngLockHdev },
  23. { INDEX_DxEngUnlockHdev, (PFN) DxEngUnlockHdev },
  24. { INDEX_DxEngIsHdevLockedByCurrentThread, (PFN) DxEngIsHdevLockedByCurrentThread },
  25. { INDEX_DxEngReferenceHdev, (PFN) DxEngReferenceHdev },
  26. { INDEX_DxEngUnreferenceHdev, (PFN) DxEngUnreferenceHdev },
  27. { INDEX_DxEngGetDeviceGammaRamp, (PFN) DxEngGetDeviceGammaRamp },
  28. { INDEX_DxEngSetDeviceGammaRamp, (PFN) DxEngSetDeviceGammaRamp },
  29. { INDEX_DxEngSpTearDownSprites, (PFN) DxEngSpTearDownSprites },
  30. { INDEX_DxEngSpUnTearDownSprites, (PFN) DxEngSpUnTearDownSprites },
  31. { INDEX_DxEngSpSpritesVisible, (PFN) DxEngSpSpritesVisible },
  32. { INDEX_DxEngGetHdevData, (PFN) DxEngGetHdevData },
  33. { INDEX_DxEngSetHdevData, (PFN) DxEngSetHdevData },
  34. { INDEX_DxEngCreateMemoryDC, (PFN) DxEngCreateMemoryDC },
  35. { INDEX_DxEngGetDesktopDC, (PFN) DxEngGetDesktopDC },
  36. { INDEX_DxEngDeleteDC, (PFN) DxEngDeleteDC },
  37. { INDEX_DxEngCleanDC, (PFN) DxEngCleanDC },
  38. { INDEX_DxEngSetDCOwner, (PFN) DxEngSetDCOwner },
  39. { INDEX_DxEngLockDC, (PFN) DxEngLockDC },
  40. { INDEX_DxEngUnlockDC, (PFN) DxEngUnlockDC },
  41. { INDEX_DxEngSetDCState, (PFN) DxEngSetDCState },
  42. { INDEX_DxEngGetDCState, (PFN) DxEngGetDCState },
  43. { INDEX_DxEngSelectBitmap, (PFN) DxEngSelectBitmap },
  44. { INDEX_DxEngSetBitmapOwner, (PFN) DxEngSetBitmapOwner },
  45. { INDEX_DxEngDeleteSurface, (PFN) DxEngDeleteSurface },
  46. { INDEX_DxEngGetSurfaceData, (PFN) DxEngGetSurfaceData },
  47. { INDEX_DxEngAltLockSurface, (PFN) DxEngAltLockSurface },
  48. { INDEX_DxEngUploadPaletteEntryToSurface, (PFN) DxEngUploadPaletteEntryToSurface },
  49. { INDEX_DxEngMarkSurfaceAsDirectDraw, (PFN) DxEngMarkSurfaceAsDirectDraw },
  50. { INDEX_DxEngSelectPaletteToSurface, (PFN) DxEngSelectPaletteToSurface },
  51. { INDEX_DxEngSyncPaletteTableWithDevice, (PFN) DxEngSyncPaletteTableWithDevice },
  52. { INDEX_DxEngSetPaletteState, (PFN) DxEngSetPaletteState },
  53. { INDEX_DxEngGetRedirectionBitmap, (PFN) DxEngGetRedirectionBitmap },
  54. { INDEX_DxEngLoadImage, (PFN) DxEngLoadImage }
  55. };
  56. ULONG gcEngFuncs = sizeof(gaEngFuncs) / sizeof(DRVFN);
  57. DRVFN *gpDxFuncs = NULL;
  58. HANDLE ghDxGraphics = NULL;
  59. PFN_StartupDxGraphics gpfnStartupDxGraphics = NULL;
  60. PFN_CleanupDxGraphics gpfnCleanupDxGraphics = NULL;
  61. DWORD gdwDirectDrawContext = 0;
  62. extern ULONG giVisRgnUniqueness;
  63. extern "C" ULONG APIENTRY DxApiGetVersion(VOID);
  64. /******************************Public*Routine******************************\
  65. * DxDdStartupDxGraphics()
  66. *
  67. * History:
  68. *
  69. * Write it:
  70. * 31-Aug-2000 -by- Hideyuki Nagase [hideyukn]
  71. \**************************************************************************/
  72. NTSTATUS DxDdStartupDxGraphics(
  73. ULONG dummy1,
  74. DRVENABLEDATA *dummy2,
  75. ULONG dummy3,
  76. DRVENABLEDATA *dummy4,
  77. DWORD *dummy5,
  78. PEPROCESS pepSession)
  79. {
  80. NTSTATUS NtStatus;
  81. UNREFERENCED_PARAMETER(dummy1);
  82. UNREFERENCED_PARAMETER(dummy2);
  83. UNREFERENCED_PARAMETER(dummy3);
  84. UNREFERENCED_PARAMETER(dummy4);
  85. // Note: this is a dummy call to bring in dxapi.sys which we link to
  86. DxApiGetVersion();
  87. //
  88. // Load directx driver.
  89. //
  90. ghDxGraphics = EngLoadImage(L"drivers\\dxg.sys");
  91. if (ghDxGraphics)
  92. {
  93. //
  94. // Get initialization entry point.
  95. //
  96. gpfnStartupDxGraphics = (PFN_StartupDxGraphics)
  97. EngFindImageProcAddress(ghDxGraphics,"DxDdStartupDxGraphics");
  98. //
  99. // Get Un-initialization entry point.
  100. //
  101. gpfnCleanupDxGraphics = (PFN_CleanupDxGraphics)
  102. EngFindImageProcAddress(ghDxGraphics,"DxDdCleanupDxGraphics");
  103. if ((gpfnStartupDxGraphics == NULL) ||
  104. (gpfnCleanupDxGraphics == NULL))
  105. {
  106. WARNING("Can't find initalization export from dxg.sys");
  107. NtStatus = STATUS_PROCEDURE_NOT_FOUND;
  108. goto DxDd_InitError;
  109. }
  110. //
  111. // Initialize directx driver.
  112. //
  113. DRVENABLEDATA dedEng;
  114. DRVENABLEDATA dedDxg;
  115. // iDriverVersion for win32k.sys version
  116. //
  117. // - 0x00050001 for Whistler
  118. dedEng.iDriverVersion = 0x00050001;
  119. dedEng.c = gcEngFuncs;
  120. dedEng.pdrvfn = gaEngFuncs;
  121. NtStatus = (*gpfnStartupDxGraphics)(sizeof(DRVENABLEDATA),
  122. &dedEng,
  123. sizeof(DRVENABLEDATA),
  124. &dedDxg,
  125. &gdwDirectDrawContext,
  126. pepSession);
  127. if (NT_SUCCESS(NtStatus))
  128. {
  129. //
  130. // Keep the pointer to array of dxg calls
  131. //
  132. gpDxFuncs = dedDxg.pdrvfn;
  133. //
  134. // Now everything initialized correctly.
  135. //
  136. return (STATUS_SUCCESS);
  137. }
  138. else
  139. {
  140. WARNING("Failed on initialization for dxg.sys");
  141. //
  142. // fall through to error handling code.
  143. //
  144. }
  145. }
  146. else
  147. {
  148. WARNING("Failed on loading dxg.sys");
  149. //
  150. // fall through to error handling code.
  151. //
  152. NtStatus = STATUS_DLL_NOT_FOUND;
  153. }
  154. DxDd_InitError:
  155. if (ghDxGraphics)
  156. {
  157. EngUnloadImage(ghDxGraphics);
  158. }
  159. //
  160. // Put eveything back to NULL.
  161. //
  162. ghDxGraphics = NULL;
  163. gpfnStartupDxGraphics = NULL;
  164. gpfnCleanupDxGraphics = NULL;
  165. gpDxFuncs = NULL;
  166. return (NtStatus);
  167. }
  168. /******************************Public*Routine******************************\
  169. * DxDdCleanupDxGraphics()
  170. *
  171. * History:
  172. *
  173. * Write it:
  174. * 31-Aug-2000 -by- Hideyuki Nagase [hideyukn]
  175. \**************************************************************************/
  176. NTSTATUS DxDdCleanupDxGraphics(VOID)
  177. {
  178. if (ghDxGraphics)
  179. {
  180. //
  181. // call directx driver to let them clean up.
  182. //
  183. if (gpfnCleanupDxGraphics)
  184. {
  185. (*gpfnCleanupDxGraphics)();
  186. }
  187. //
  188. // Unload modules.
  189. //
  190. EngUnloadImage(ghDxGraphics);
  191. }
  192. //
  193. // Put eveything back to NULL.
  194. //
  195. ghDxGraphics = NULL;
  196. gpfnStartupDxGraphics = NULL;
  197. gpfnCleanupDxGraphics = NULL;
  198. gpDxFuncs = NULL;
  199. return (STATUS_SUCCESS);
  200. }
  201. /***************************************************************************\
  202. *
  203. * Internal functions called by dxg.sys
  204. *
  205. \***************************************************************************/
  206. BOOL DxEngIsTermSrv(VOID)
  207. {
  208. return(!!(SharedUserData->SuiteMask & (1 << TerminalServer)));
  209. }
  210. BOOL DxEngScreenAccessCheck(VOID)
  211. {
  212. return(UserScreenAccessCheck());
  213. }
  214. BOOL DxEngRedrawDesktop(VOID)
  215. {
  216. UserRedrawDesktop();
  217. return (TRUE);
  218. }
  219. ULONG DxEngDispUniq(VOID)
  220. {
  221. return (gpGdiSharedMemory->iDisplaySettingsUniqueness);
  222. }
  223. BOOL DxEngIncDispUniq(VOID)
  224. {
  225. LONG* pl = (PLONG) &gpGdiSharedMemory->iDisplaySettingsUniqueness;
  226. InterlockedIncrement(pl);
  227. return (TRUE);
  228. }
  229. ULONG DxEngVisRgnUniq(VOID)
  230. {
  231. return (giVisRgnUniqueness);
  232. }
  233. BOOL DxEngLockShareSem(VOID)
  234. {
  235. GDIFunctionID(DxEngLockShareSem);
  236. GreAcquireSemaphoreEx(ghsemShareDevLock, SEMORDER_SHAREDEVLOCK, NULL);
  237. return (TRUE);
  238. }
  239. BOOL DxEngUnlockShareSem(VOID)
  240. {
  241. GDIFunctionID(DxEngUnlockShareSem);
  242. GreReleaseSemaphoreEx(ghsemShareDevLock);
  243. return (TRUE);
  244. }
  245. HDEV DxEngEnumerateHdev(HDEV hdev)
  246. {
  247. return (hdevEnumerate(hdev));
  248. }
  249. BOOL DxEngLockHdev(HDEV hdev)
  250. {
  251. GDIFunctionID(DxEngLockHdev);
  252. PDEVOBJ poLock(hdev);
  253. GreAcquireSemaphoreEx(poLock.hsemDevLock(), SEMORDER_DEVLOCK, NULL);
  254. GreEnterMonitoredSection(poLock.ppdev, WD_DEVLOCK);
  255. return (TRUE);
  256. }
  257. BOOL DxEngUnlockHdev(HDEV hdev)
  258. {
  259. GDIFunctionID(DxEngUnlockHdev);
  260. PDEVOBJ poLock(hdev);
  261. GreExitMonitoredSection(poLock.ppdev, WD_DEVLOCK);
  262. GreReleaseSemaphoreEx(poLock.hsemDevLock());
  263. return (TRUE);
  264. }
  265. BOOL DxEngIsHdevLockedByCurrentThread(HDEV hdev)
  266. {
  267. PDEVOBJ poLock(hdev);
  268. return (GreIsSemaphoreOwnedByCurrentThread(poLock.hsemDevLock()));
  269. }
  270. BOOL DxEngReferenceHdev(HDEV hdev)
  271. {
  272. PDEVOBJ po(hdev);
  273. po.vReferencePdev();
  274. return (TRUE);
  275. }
  276. BOOL DxEngUnreferenceHdev(HDEV hdev)
  277. {
  278. PDEVOBJ po(hdev);
  279. po.vUnreferencePdev();
  280. return (TRUE);
  281. }
  282. BOOL DxEngGetDeviceGammaRamp(HDEV hdev,PVOID pv)
  283. {
  284. return (GreGetDeviceGammaRampInternal(hdev,pv));
  285. }
  286. BOOL DxEngSetDeviceGammaRamp(
  287. HDEV hdev,
  288. PVOID pv,
  289. BOOL b)
  290. {
  291. return (GreSetDeviceGammaRampInternal(hdev,pv,b));
  292. }
  293. BOOL DxEngSpTearDownSprites(
  294. HDEV hdev,
  295. RECTL* prcl,
  296. BOOL b)
  297. {
  298. return (bSpTearDownSprites(hdev,prcl,b));
  299. }
  300. BOOL DxEngSpUnTearDownSprites(
  301. HDEV hdev,
  302. RECTL* prcl,
  303. BOOL b)
  304. {
  305. vSpUnTearDownSprites(hdev,prcl,b);
  306. return (TRUE);
  307. }
  308. BOOL DxEngSpSpritesVisible(HDEV hdev)
  309. {
  310. return (bSpSpritesVisible(hdev));
  311. }
  312. ULONG_PTR DxEngGetHdevData(
  313. HDEV hdev,
  314. DWORD dwIndex)
  315. {
  316. ULONG_PTR ulRet = 0;
  317. PDEVOBJ po(hdev);
  318. switch (dwIndex)
  319. {
  320. case HDEV_SURFACEHANDLE:
  321. ulRet = (ULONG_PTR)(po.pSurface()->hGet());
  322. break;
  323. case HDEV_MINIPORTHANDLE:
  324. ulRet = (ULONG_PTR)(po.hScreen());
  325. break;
  326. case HDEV_DITHERFORMAT:
  327. ulRet = (ULONG_PTR)(po.iDitherFormat());
  328. break;
  329. case HDEV_GCAPS:
  330. ulRet = (ULONG_PTR)(po.flGraphicsCapsNotDynamic());
  331. break;
  332. case HDEV_GCAPS2:
  333. ulRet = (ULONG_PTR)(po.flGraphicsCaps2NotDynamic());
  334. break;
  335. case HDEV_FUNCTIONTABLE:
  336. ulRet = (ULONG_PTR)(po.apfn());
  337. break;
  338. case HDEV_DHPDEV:
  339. ulRet = (ULONG_PTR)(po.dhpdev());
  340. break;
  341. case HDEV_DXDATA:
  342. ulRet = (ULONG_PTR)(po.pDirectDrawContext());
  343. break;
  344. case HDEV_DXLOCKS:
  345. ulRet = (ULONG_PTR)(po.cDirectDrawDisableLocks());
  346. break;
  347. case HDEV_CAPSOVERRIDE:
  348. ulRet = (ULONG_PTR)(po.dwDriverCapableOverride());
  349. break;
  350. case HDEV_DISABLED:
  351. ulRet = (ULONG_PTR)(po.bDisabled());
  352. break;
  353. case HDEV_DDML:
  354. ulRet = (ULONG_PTR)(po.bMetaDriver());
  355. break;
  356. case HDEV_CLONE:
  357. ulRet = (ULONG_PTR)(po.bCloneDriver());
  358. break;
  359. case HDEV_DISPLAY:
  360. ulRet = (ULONG_PTR)(po.bDisplayPDEV());
  361. break;
  362. case HDEV_PARENTHDEV:
  363. ulRet = (ULONG_PTR)(po.hdevParent());
  364. break;
  365. case HDEV_DELETED:
  366. ulRet = (ULONG_PTR)(po.bDeleted());
  367. break;
  368. case HDEV_PALMANAGED:
  369. ulRet = (ULONG_PTR)(po.bIsPalManaged());
  370. break;
  371. case HDEV_LDEV:
  372. ulRet = (ULONG_PTR)(po.pldev());
  373. break;
  374. case HDEV_GRAPHICSDEVICE:
  375. ulRet = (ULONG_PTR)(((PDEV *)po.hdev())->pGraphicsDevice);
  376. break;
  377. }
  378. return (ulRet);
  379. }
  380. BOOL DxEngSetHdevData(
  381. HDEV hdev,
  382. DWORD dwIndex,
  383. ULONG_PTR ulData)
  384. {
  385. BOOL bRet = FALSE;
  386. PDEVOBJ po(hdev);
  387. switch (dwIndex)
  388. {
  389. case HDEV_DXLOCKS:
  390. po.cDirectDrawDisableLocks((ULONG)ulData);
  391. bRet = TRUE;
  392. break;
  393. }
  394. return (bRet);
  395. }
  396. // Functions for control DC
  397. HDC DxEngCreateMemoryDC(
  398. HDEV hdev)
  399. {
  400. return (GreCreateDisplayDC(hdev,DCTYPE_MEMORY,FALSE));
  401. }
  402. HDC DxEngGetDesktopDC(
  403. ULONG ulType,
  404. BOOL bAltType,
  405. BOOL bValidate)
  406. {
  407. return (UserGetDesktopDC(ulType, bAltType, bValidate));
  408. }
  409. BOOL DxEngDeleteDC(
  410. HDC hdc,
  411. BOOL bForce)
  412. {
  413. return (bDeleteDCInternal(hdc, bForce, FALSE));
  414. }
  415. BOOL DxEngCleanDC(
  416. HDC hdc)
  417. {
  418. return (GreCleanDC(hdc));
  419. }
  420. BOOL DxEngSetDCOwner(
  421. HDC hdc,
  422. W32PID pidOwner)
  423. {
  424. return (GreSetDCOwner(hdc, pidOwner));
  425. }
  426. PVOID DxEngLockDC(
  427. HDC hdc)
  428. {
  429. PVOID pvLockedDC = NULL;
  430. XDCOBJ dco(hdc);
  431. if (dco.bValid())
  432. {
  433. pvLockedDC = (PVOID)(dco.pdc);
  434. dco.vDontUnlockDC();
  435. }
  436. return (pvLockedDC);
  437. }
  438. BOOL DxEngUnlockDC(
  439. PVOID pvLockedDC)
  440. {
  441. XDCOBJ dco;
  442. dco.pdc = (PDC)pvLockedDC;
  443. dco.vUnlock();
  444. return (TRUE);
  445. }
  446. BOOL DxEngSetDCState(
  447. HDC hdc,
  448. DWORD dwState,
  449. ULONG_PTR ulData)
  450. {
  451. BOOL bRet = FALSE;
  452. MDCOBJA dco(hdc); // Multiple Alt Lock.
  453. if (dco.bValid())
  454. {
  455. switch (dwState)
  456. {
  457. case DCSTATE_FULLSCREEN:
  458. dco.bInFullScreen((BOOL)ulData);
  459. bRet = TRUE;
  460. break;
  461. }
  462. }
  463. return (bRet);
  464. }
  465. ULONG_PTR DxEngGetDCState(
  466. HDC hdc,
  467. DWORD dwState)
  468. {
  469. ULONG_PTR ulRet = 0;
  470. XDCOBJ dco(hdc);
  471. if (dco.bValid())
  472. {
  473. switch (dwState)
  474. {
  475. case DCSTATE_FULLSCREEN:
  476. ulRet = (ULONG_PTR)(dco.bInFullScreen());
  477. break;
  478. case DCSTATE_VISRGNCOMPLEX:
  479. {
  480. RGNOBJ ro(dco.pdc->prgnVis());
  481. ulRet = (ULONG_PTR)(ro.iComplexity());
  482. break;
  483. }
  484. case DCSTATE_HDEV:
  485. ulRet = (ULONG_PTR)(dco.hdev());
  486. break;
  487. }
  488. dco.vUnlockFast();
  489. }
  490. return (ulRet);
  491. }
  492. // Functions for control Bitmap/Surface
  493. HBITMAP DxEngSelectBitmap(
  494. HDC hdc,
  495. HBITMAP hbm)
  496. {
  497. return (hbmSelectBitmap(hdc, hbm, TRUE));
  498. }
  499. BOOL DxEngSetBitmapOwner(
  500. HBITMAP hbm,
  501. W32PID pidOwner)
  502. {
  503. return (GreSetBitmapOwner(hbm, pidOwner));
  504. }
  505. BOOL DxEngDeleteSurface(
  506. HSURF hsurf)
  507. {
  508. return (bDeleteSurface(hsurf));
  509. }
  510. ULONG_PTR DxEngGetSurfaceData(
  511. SURFOBJ* pso,
  512. DWORD dwIndex)
  513. {
  514. ULONG_PTR ulRet = 0;
  515. SURFACE *pSurface = SURFOBJ_TO_SURFACE_NOT_NULL(pso);
  516. switch (dwIndex)
  517. {
  518. case SURF_HOOKFLAGS:
  519. ulRet = (ULONG_PTR) pSurface->flags();
  520. break;
  521. case SURF_IS_DIRECTDRAW_SURFACE:
  522. ulRet = (ULONG_PTR) pSurface->bDirectDraw();
  523. break;
  524. case SURF_DD_SURFACE_HANDLE:
  525. ulRet = (ULONG_PTR) pSurface->hDDSurface;
  526. break;
  527. }
  528. return (ulRet);
  529. }
  530. SURFOBJ* DxEngAltLockSurface(
  531. HBITMAP hsurf)
  532. {
  533. SURFREF so;
  534. so.vAltLock((HSURF) hsurf);
  535. if (so.bValid())
  536. {
  537. so.vKeepIt();
  538. return(so.pSurfobj());
  539. }
  540. else
  541. {
  542. WARNING("DxEngAltLockSurface failed to lock handle\n");
  543. return((SURFOBJ *) NULL);
  544. }
  545. }
  546. BOOL DxEngUploadPaletteEntryToSurface(
  547. HDEV hdev,
  548. SURFOBJ* pso,
  549. PALETTEENTRY* puColorTable,
  550. ULONG cColors)
  551. {
  552. BOOL bRet = FALSE;
  553. PDEVOBJ po(hdev);
  554. if (po.bValid() && pso && puColorTable)
  555. {
  556. // Update the color table.
  557. SURFACE *pSurface = SURFOBJ_TO_SURFACE_NOT_NULL(pso);
  558. // Note that the scumy application might have delete the cached
  559. // bitmap, so we have to check for bValid() here. (It's been a
  560. // bad app, so we just protect against crashing, and don't bother
  561. // to re-create a good bitmap for him.)
  562. if (pSurface->bValid())
  563. {
  564. XEPALOBJ pal(pSurface->ppal());
  565. ASSERTGDI(pal.bValid(), "Unexpected invalid palette");
  566. // Since we'll be mucking with the palette table:
  567. pal.vUpdateTime();
  568. if (puColorTable == NULL)
  569. {
  570. ASSERTGDI(po.bIsPalManaged(), "Expected palettized display");
  571. // Make this palette share the same colour table as the
  572. // screen, so that we always get identity blts:
  573. pal.apalColorSet(po.ppalSurf());
  574. bRet = TRUE;
  575. }
  576. else
  577. {
  578. // Previously, there might not have been a color table, but
  579. // now there is. So reset the shared-palette pointer:
  580. pal.apalResetColorTable();
  581. PAL_ULONG* ppalstruc = pal.apalColorGet();
  582. __try
  583. {
  584. for (ULONG i = 0; i < cColors; i++)
  585. {
  586. ppalstruc->pal = *puColorTable;
  587. puColorTable++;
  588. ppalstruc++;
  589. }
  590. bRet = TRUE;
  591. }
  592. __except(EXCEPTION_EXECUTE_HANDLER)
  593. {
  594. WARNING("hbmDdCreateAndLockSurface: Bad color table");
  595. }
  596. }
  597. }
  598. }
  599. return (FALSE);
  600. }
  601. BOOL DxEngMarkSurfaceAsDirectDraw(
  602. SURFOBJ* pso,
  603. HANDLE hDdSurf)
  604. {
  605. if (pso)
  606. {
  607. SURFACE *pSurface = SURFOBJ_TO_SURFACE_NOT_NULL(pso);
  608. // Make sure that the USE_DEVLOCK flag is set so
  609. // that the devlock is always acquired before drawing
  610. // to the surface -- needed so that we can switch to
  611. // a different mode and 'turn-off' access to the
  612. // surface by changing the clipping:
  613. pSurface->vSetUseDevlock();
  614. pSurface->vSetDirectDraw();
  615. pSurface->hDDSurface = hDdSurf;
  616. return (TRUE);
  617. }
  618. return (FALSE);
  619. }
  620. HPALETTE DxEngSelectPaletteToSurface(
  621. SURFOBJ* pso,
  622. HPALETTE hpal)
  623. {
  624. HPALETTE hpalRet = NULL;
  625. EPALOBJ pal(hpal);
  626. if (pso && pal.bValid())
  627. {
  628. SURFACE *pSurface = SURFOBJ_TO_SURFACE_NOT_NULL(pso);
  629. // Get palette currently selected.
  630. PPALETTE ppalOld = pSurface->ppal();
  631. // Select palette into surface and increment ref count.
  632. pSurface->ppal(pal.ppalGet());
  633. pal.vRefPalette();
  634. #if 0 // TODO:
  635. if ((ppalOld != ppalDefaut) && (ppalOld != NULL))
  636. {
  637. hpalRet = ppalOld->hGet();
  638. ppalOld->vUnrefPalette();
  639. }
  640. #endif
  641. }
  642. return (hpalRet);
  643. }
  644. // Functions for control palette
  645. BOOL DxEngSyncPaletteTableWithDevice(
  646. HPALETTE hpal,
  647. HDEV hdev)
  648. {
  649. BOOL bRet = FALSE;
  650. PDEVOBJ po(hdev);
  651. EPALOBJ pal(hpal);
  652. if (po.bValid() && pal.bValid())
  653. {
  654. pal.apalColorSet(po.ppalSurf());
  655. bRet = TRUE;
  656. }
  657. return (bRet);
  658. }
  659. BOOL DxEngSetPaletteState(
  660. HPALETTE hpal,
  661. DWORD dwIndex,
  662. ULONG_PTR ulData)
  663. {
  664. BOOL bRet = FALSE;
  665. EPALOBJ pal(hpal);
  666. if (pal.bValid())
  667. {
  668. switch (dwIndex)
  669. {
  670. case PALSTATE_DIBSECTION:
  671. if (ulData)
  672. {
  673. pal.flPal(PAL_DIBSECTION);
  674. }
  675. else
  676. {
  677. pal.flPalSet(pal.flPal() & ~PAL_DIBSECTION);
  678. }
  679. bRet = TRUE;
  680. }
  681. }
  682. return (bRet);
  683. }
  684. // Functions for window handle
  685. HBITMAP DxEngGetRedirectionBitmap(
  686. HWND hWnd
  687. )
  688. {
  689. #ifdef DX_REDIRECTION
  690. return (UserGetRedirectionBitmap(hWnd));
  691. #else
  692. return (NULL);
  693. #endif // DX_REDIRECTION
  694. }
  695. // Functions to load image file
  696. HANDLE DxEngLoadImage(
  697. LPWSTR pwszDriver,
  698. BOOL bLoadInSessionSpace
  699. )
  700. {
  701. BOOL bLoaded;
  702. HANDLE h;
  703. GreAcquireSemaphoreEx(ghsemDriverMgmt, SEMORDER_DRIVERMGMT, NULL);
  704. h = ldevLoadImage(pwszDriver, TRUE, &bLoaded, bLoadInSessionSpace);
  705. GreReleaseSemaphoreEx(ghsemDriverMgmt);
  706. return h;
  707. }
  708. /***************************************************************************\
  709. *
  710. * Stub routines to call dxg.sys
  711. *
  712. \***************************************************************************/
  713. #define PPFNGET_DXFUNC(name) ((PFN_Dx##name)((gpDxFuncs[INDEX_Dx##name]).pfn))
  714. #define CALL_DXFUNC(name) (*(PPFNGET_DXFUNC(name)))
  715. extern "C"
  716. DWORD APIENTRY NtGdiDxgGenericThunk(
  717. IN ULONG_PTR ulIndex,
  718. IN ULONG_PTR ulHandle,
  719. IN OUT SIZE_T *pdwSizeOfPtr1,
  720. IN OUT PVOID pvPtr1,
  721. IN OUT SIZE_T *pdwSizeOfPtr2,
  722. IN OUT PVOID pvPtr2)
  723. {
  724. return (CALL_DXFUNC(DxgGenericThunk)(ulIndex,ulHandle,
  725. pdwSizeOfPtr1,pvPtr1,
  726. pdwSizeOfPtr2,pvPtr2));
  727. }
  728. DWORD APIENTRY NtGdiDdAddAttachedSurface(
  729. IN HANDLE hSurface,
  730. IN HANDLE hSurfaceAttached,
  731. IN OUT PDD_ADDATTACHEDSURFACEDATA puAddAttachedSurfaceData)
  732. {
  733. return (CALL_DXFUNC(DdAddAttachedSurface)(hSurface,hSurfaceAttached,puAddAttachedSurfaceData));
  734. }
  735. BOOL APIENTRY NtGdiDdAttachSurface(
  736. IN HANDLE hSurfaceFrom,
  737. IN HANDLE hSurfaceTo)
  738. {
  739. return (CALL_DXFUNC(DdAttachSurface)(hSurfaceFrom,hSurfaceTo));
  740. }
  741. DWORD APIENTRY NtGdiDdBlt(
  742. IN HANDLE hSurfaceDest,
  743. IN HANDLE hSurfaceSrc,
  744. IN OUT PDD_BLTDATA puBltData)
  745. {
  746. return (CALL_DXFUNC(DdBlt)(hSurfaceDest,hSurfaceSrc,puBltData));
  747. }
  748. DWORD APIENTRY NtGdiDdCanCreateSurface(
  749. IN HANDLE hDirectDraw,
  750. IN OUT PDD_CANCREATESURFACEDATA puCanCreateSurfaceData)
  751. {
  752. return (CALL_DXFUNC(DdCanCreateSurface)(hDirectDraw,puCanCreateSurfaceData));
  753. }
  754. DWORD APIENTRY NtGdiDdColorControl(
  755. IN HANDLE hSurface,
  756. IN OUT PDD_COLORCONTROLDATA puColorControlData)
  757. {
  758. return (CALL_DXFUNC(DdColorControl)(hSurface,puColorControlData));
  759. }
  760. HANDLE APIENTRY NtGdiDdCreateDirectDrawObject(
  761. IN HDC hdc)
  762. {
  763. return (CALL_DXFUNC(DdCreateDirectDrawObject)(hdc));
  764. }
  765. DWORD APIENTRY NtGdiDdCreateSurface(
  766. IN HANDLE hDirectDraw,
  767. IN HANDLE* hSurface,
  768. IN OUT DDSURFACEDESC* puSurfaceDescription,
  769. IN OUT DD_SURFACE_GLOBAL* puSurfaceGlobalData,
  770. IN OUT DD_SURFACE_LOCAL* puSurfaceLocalData,
  771. IN OUT DD_SURFACE_MORE* puSurfaceMoreData,
  772. IN OUT DD_CREATESURFACEDATA* puCreateSurfaceData,
  773. OUT HANDLE* puhSurface)
  774. {
  775. return (CALL_DXFUNC(DdCreateSurface)(hDirectDraw,hSurface,puSurfaceDescription,
  776. puSurfaceGlobalData,puSurfaceLocalData,
  777. puSurfaceMoreData,puCreateSurfaceData,
  778. puhSurface));
  779. }
  780. HANDLE APIENTRY NtGdiDdCreateSurfaceObject(
  781. IN HANDLE hDirectDrawLocal,
  782. IN HANDLE hSurface,
  783. IN PDD_SURFACE_LOCAL puSurfaceLocal,
  784. IN PDD_SURFACE_MORE puSurfaceMore,
  785. IN PDD_SURFACE_GLOBAL puSurfaceGlobal,
  786. IN BOOL bComplete)
  787. {
  788. return (CALL_DXFUNC(DdCreateSurfaceObject)(
  789. hDirectDrawLocal,hSurface,
  790. puSurfaceLocal,puSurfaceMore,puSurfaceGlobal,
  791. bComplete));
  792. }
  793. BOOL APIENTRY NtGdiDdDeleteSurfaceObject(
  794. IN HANDLE hSurface)
  795. {
  796. return (CALL_DXFUNC(DdDeleteSurfaceObject)(hSurface));
  797. }
  798. BOOL APIENTRY NtGdiDdDeleteDirectDrawObject(
  799. IN HANDLE hDirectDrawLocal)
  800. {
  801. return (CALL_DXFUNC(DdDeleteDirectDrawObject)(hDirectDrawLocal));
  802. }
  803. DWORD APIENTRY NtGdiDdDestroySurface(
  804. IN HANDLE hSurface,
  805. IN BOOL bRealDestroy)
  806. {
  807. return (CALL_DXFUNC(DdDestroySurface)(hSurface,bRealDestroy));
  808. }
  809. DWORD APIENTRY NtGdiDdFlip(
  810. IN HANDLE hSurfaceCurrent,
  811. IN HANDLE hSurfaceTarget,
  812. IN HANDLE hSurfaceCurrentLeft,
  813. IN HANDLE hSurfaceTargetLeft,
  814. IN OUT PDD_FLIPDATA puFlipData)
  815. {
  816. return (CALL_DXFUNC(DdFlip)(hSurfaceCurrent,hSurfaceTarget,
  817. hSurfaceCurrentLeft,hSurfaceTargetLeft,puFlipData));
  818. }
  819. DWORD APIENTRY NtGdiDdGetAvailDriverMemory(
  820. IN HANDLE hDirectDraw,
  821. IN OUT PDD_GETAVAILDRIVERMEMORYDATA puGetAvailDriverMemoryData)
  822. {
  823. return (CALL_DXFUNC(DdGetAvailDriverMemory)(hDirectDraw,puGetAvailDriverMemoryData));
  824. }
  825. DWORD APIENTRY NtGdiDdGetBltStatus(
  826. IN HANDLE hSurface,
  827. IN OUT PDD_GETBLTSTATUSDATA puGetBltStatusData)
  828. {
  829. return (CALL_DXFUNC(DdGetBltStatus)(hSurface,puGetBltStatusData));
  830. }
  831. HDC APIENTRY NtGdiDdGetDC(
  832. IN HANDLE hSurface,
  833. IN PALETTEENTRY* puColorTable)
  834. {
  835. return (CALL_DXFUNC(DdGetDC)(hSurface,puColorTable));
  836. }
  837. DWORD APIENTRY NtGdiDdGetDriverInfo(
  838. IN HANDLE hDirectDraw,
  839. IN OUT PDD_GETDRIVERINFODATA puGetDriverInfoData)
  840. {
  841. return (CALL_DXFUNC(DdGetDriverInfo)(hDirectDraw,puGetDriverInfoData));
  842. }
  843. DWORD APIENTRY NtGdiDdGetFlipStatus(
  844. IN HANDLE hSurface,
  845. IN OUT PDD_GETFLIPSTATUSDATA puGetFlipStatusData)
  846. {
  847. return (CALL_DXFUNC(DdGetFlipStatus)(hSurface,puGetFlipStatusData));
  848. }
  849. DWORD APIENTRY NtGdiDdGetScanLine(
  850. IN HANDLE hDirectDraw,
  851. IN OUT PDD_GETSCANLINEDATA puGetScanLineData)
  852. {
  853. return (CALL_DXFUNC(DdGetScanLine)(hDirectDraw,puGetScanLineData));
  854. }
  855. DWORD APIENTRY NtGdiDdSetExclusiveMode(
  856. IN HANDLE hDirectDraw,
  857. IN OUT PDD_SETEXCLUSIVEMODEDATA puSetExclusiveModeData)
  858. {
  859. return (CALL_DXFUNC(DdSetExclusiveMode)(hDirectDraw,puSetExclusiveModeData));
  860. }
  861. DWORD APIENTRY NtGdiDdFlipToGDISurface(
  862. IN HANDLE hDirectDraw,
  863. IN OUT PDD_FLIPTOGDISURFACEDATA puFlipToGDISurfaceData)
  864. {
  865. return (CALL_DXFUNC(DdFlipToGDISurface)(hDirectDraw,puFlipToGDISurfaceData));
  866. }
  867. DWORD APIENTRY NtGdiDdLock(
  868. IN HANDLE hSurface,
  869. IN OUT PDD_LOCKDATA puLockData,
  870. IN HDC hdcClip)
  871. {
  872. return (CALL_DXFUNC(DdLock)(hSurface,puLockData,hdcClip));
  873. }
  874. BOOL APIENTRY NtGdiDdQueryDirectDrawObject(
  875. HANDLE hDirectDrawLocal,
  876. DD_HALINFO* pHalInfo,
  877. DWORD* pCallBackFlags,
  878. LPD3DNTHAL_CALLBACKS puD3dCallbacks,
  879. LPD3DNTHAL_GLOBALDRIVERDATA puD3dDriverData,
  880. PDD_D3DBUFCALLBACKS puD3dBufferCallbacks,
  881. LPDDSURFACEDESC puD3dTextureFormats,
  882. DWORD* puNumHeaps,
  883. VIDEOMEMORY* puvmList,
  884. DWORD* puNumFourCC,
  885. DWORD* puFourCC)
  886. {
  887. return (CALL_DXFUNC(DdQueryDirectDrawObject)(hDirectDrawLocal,pHalInfo,pCallBackFlags,
  888. puD3dCallbacks,puD3dDriverData,puD3dBufferCallbacks,
  889. puD3dTextureFormats,puNumHeaps,puvmList,
  890. puNumFourCC,puFourCC));
  891. }
  892. BOOL APIENTRY NtGdiDdReenableDirectDrawObject(
  893. IN HANDLE hDirectDrawLocal,
  894. IN OUT BOOL* pubNewMode)
  895. {
  896. return (CALL_DXFUNC(DdReenableDirectDrawObject)(hDirectDrawLocal,pubNewMode));
  897. }
  898. BOOL APIENTRY NtGdiDdReleaseDC(
  899. IN HANDLE hSurface)
  900. {
  901. return (CALL_DXFUNC(DdReleaseDC)(hSurface));
  902. }
  903. BOOL APIENTRY NtGdiDdResetVisrgn(
  904. IN HANDLE hSurface,
  905. IN HWND hwnd)
  906. {
  907. return (CALL_DXFUNC(DdResetVisrgn)(hSurface,hwnd));
  908. }
  909. DWORD APIENTRY NtGdiDdSetColorKey(
  910. IN HANDLE hSurface,
  911. IN OUT PDD_SETCOLORKEYDATA puSetColorKeyData)
  912. {
  913. return (CALL_DXFUNC(DdSetColorKey)(hSurface,puSetColorKeyData));
  914. }
  915. DWORD APIENTRY NtGdiDdSetOverlayPosition(
  916. IN HANDLE hSurfaceSource,
  917. IN HANDLE hSurfaceDestination,
  918. IN OUT PDD_SETOVERLAYPOSITIONDATA puSetOverlayPositionData)
  919. {
  920. return (CALL_DXFUNC(DdSetOverlayPosition)(hSurfaceSource,hSurfaceDestination,puSetOverlayPositionData));
  921. }
  922. VOID APIENTRY NtGdiDdUnattachSurface(
  923. IN HANDLE hSurface,
  924. IN HANDLE hSurfaceAttached)
  925. {
  926. CALL_DXFUNC(DdUnattachSurface)(hSurface,hSurfaceAttached);
  927. }
  928. DWORD APIENTRY NtGdiDdUnlock(
  929. IN HANDLE hSurface,
  930. IN OUT PDD_UNLOCKDATA puUnlockData)
  931. {
  932. return (CALL_DXFUNC(DdUnlock)(hSurface,puUnlockData));
  933. }
  934. DWORD APIENTRY NtGdiDdUpdateOverlay(
  935. IN HANDLE hSurfaceDestination,
  936. IN HANDLE hSurfaceSource,
  937. IN OUT PDD_UPDATEOVERLAYDATA puUpdateOverlayData)
  938. {
  939. return (CALL_DXFUNC(DdUpdateOverlay)(hSurfaceDestination,hSurfaceSource,puUpdateOverlayData));
  940. }
  941. DWORD APIENTRY NtGdiDdWaitForVerticalBlank(
  942. IN HANDLE hDirectDraw,
  943. IN OUT PDD_WAITFORVERTICALBLANKDATA puWaitForVerticalBlankData)
  944. {
  945. return (CALL_DXFUNC(DdWaitForVerticalBlank)(hDirectDraw,puWaitForVerticalBlankData));
  946. }
  947. HANDLE APIENTRY NtGdiDdGetDxHandle(
  948. IN HANDLE hDirectDraw,
  949. IN HANDLE hSurface,
  950. IN BOOL bRelease)
  951. {
  952. return (CALL_DXFUNC(DdGetDxHandle)(hDirectDraw,hSurface,bRelease));
  953. }
  954. BOOL APIENTRY NtGdiDdSetGammaRamp(
  955. IN HANDLE hDirectDraw,
  956. IN HDC hdc,
  957. IN LPVOID lpGammaRamp)
  958. {
  959. return (CALL_DXFUNC(DdSetGammaRamp)(hDirectDraw,hdc,lpGammaRamp));
  960. }
  961. DWORD APIENTRY NtGdiDdLockD3D(
  962. IN HANDLE hSurface,
  963. IN OUT PDD_LOCKDATA puLockData)
  964. {
  965. return (CALL_DXFUNC(DdLockD3D)(hSurface,puLockData));
  966. }
  967. DWORD APIENTRY NtGdiDdUnlockD3D(
  968. IN HANDLE hSurface,
  969. IN OUT PDD_UNLOCKDATA puUnlockData)
  970. {
  971. return (CALL_DXFUNC(DdUnlockD3D)(hSurface,puUnlockData));
  972. }
  973. DWORD APIENTRY NtGdiDdCreateD3DBuffer(
  974. IN HANDLE hDirectDraw,
  975. IN OUT HANDLE* hSurface,
  976. IN OUT DDSURFACEDESC* puSurfaceDescription,
  977. IN OUT DD_SURFACE_GLOBAL* puSurfaceGlobalData,
  978. IN OUT DD_SURFACE_LOCAL* puSurfaceLocalData,
  979. IN OUT DD_SURFACE_MORE* puSurfaceMoreData,
  980. IN OUT DD_CREATESURFACEDATA* puCreateSurfaceData,
  981. IN OUT HANDLE* puhSurface)
  982. {
  983. return (CALL_DXFUNC(DdCreateD3DBuffer)(hDirectDraw,hSurface,puSurfaceDescription,
  984. puSurfaceGlobalData,puSurfaceLocalData,puSurfaceMoreData,
  985. puCreateSurfaceData,puhSurface));
  986. }
  987. DWORD APIENTRY NtGdiDdCanCreateD3DBuffer(
  988. IN HANDLE hDirectDraw,
  989. IN OUT PDD_CANCREATESURFACEDATA puCanCreateSurfaceData)
  990. {
  991. return (CALL_DXFUNC(DdCanCreateD3DBuffer)(hDirectDraw,puCanCreateSurfaceData));
  992. }
  993. DWORD APIENTRY NtGdiDdDestroyD3DBuffer(
  994. IN HANDLE hSurface)
  995. {
  996. return (CALL_DXFUNC(DdDestroyD3DBuffer)(hSurface));
  997. }
  998. DWORD APIENTRY NtGdiD3dContextCreate(
  999. IN HANDLE hDirectDrawLocal,
  1000. IN HANDLE hSurfColor,
  1001. IN HANDLE hSurfZ,
  1002. IN OUT D3DNTHAL_CONTEXTCREATEI *pdcci)
  1003. {
  1004. return (CALL_DXFUNC(D3dContextCreate)(hDirectDrawLocal,hSurfColor,hSurfZ,pdcci));
  1005. }
  1006. DWORD APIENTRY NtGdiD3dContextDestroy(
  1007. IN LPD3DNTHAL_CONTEXTDESTROYDATA pdcdad)
  1008. {
  1009. return (CALL_DXFUNC(D3dContextDestroy)(pdcdad));
  1010. }
  1011. DWORD APIENTRY NtGdiD3dContextDestroyAll(
  1012. OUT LPD3DNTHAL_CONTEXTDESTROYALLDATA pdcdad)
  1013. {
  1014. return (CALL_DXFUNC(D3dContextDestroyAll)(pdcdad));
  1015. }
  1016. DWORD APIENTRY NtGdiD3dValidateTextureStageState(
  1017. IN OUT LPD3DNTHAL_VALIDATETEXTURESTAGESTATEDATA pData)
  1018. {
  1019. return (CALL_DXFUNC(D3dValidateTextureStageState)(pData));
  1020. }
  1021. DWORD APIENTRY NtGdiD3dDrawPrimitives2(
  1022. IN HANDLE hCmdBuf,
  1023. IN HANDLE hVBuf,
  1024. IN OUT LPD3DNTHAL_DRAWPRIMITIVES2DATA pded,
  1025. IN OUT FLATPTR* pfpVidMemCmd,
  1026. IN OUT DWORD* pdwSizeCmd,
  1027. IN OUT FLATPTR* pfpVidMemVtx,
  1028. IN OUT DWORD* pdwSizeVtx)
  1029. {
  1030. return (CALL_DXFUNC(D3dDrawPrimitives2)(hCmdBuf,hVBuf,pded,pfpVidMemCmd,
  1031. pdwSizeCmd,pfpVidMemVtx,pdwSizeVtx));
  1032. }
  1033. DWORD APIENTRY NtGdiDdGetDriverState(
  1034. IN OUT PDD_GETDRIVERSTATEDATA pdata)
  1035. {
  1036. return(CALL_DXFUNC(DdGetDriverState)(pdata));
  1037. }
  1038. DWORD APIENTRY NtGdiDdCreateSurfaceEx(
  1039. IN HANDLE hDirectDraw,
  1040. IN HANDLE hSurface,
  1041. IN DWORD dwSurfaceHandle)
  1042. {
  1043. return (CALL_DXFUNC(DdCreateSurfaceEx)(hDirectDraw,hSurface,dwSurfaceHandle));
  1044. }
  1045. DWORD APIENTRY NtGdiDdGetMoCompGuids(
  1046. IN HANDLE hDirectDraw,
  1047. IN OUT PDD_GETMOCOMPGUIDSDATA puGetMoCompGuidsData)
  1048. {
  1049. return (CALL_DXFUNC(DdGetMoCompGuids)(hDirectDraw,puGetMoCompGuidsData));
  1050. }
  1051. DWORD APIENTRY NtGdiDdGetMoCompFormats(
  1052. IN HANDLE hDirectDraw,
  1053. IN OUT PDD_GETMOCOMPFORMATSDATA puGetMoCompFormatsData)
  1054. {
  1055. return (CALL_DXFUNC(DdGetMoCompFormats)(hDirectDraw,puGetMoCompFormatsData));
  1056. }
  1057. DWORD APIENTRY NtGdiDdGetMoCompBuffInfo(
  1058. IN HANDLE hDirectDraw,
  1059. IN OUT PDD_GETMOCOMPCOMPBUFFDATA puGetBuffData)
  1060. {
  1061. return (CALL_DXFUNC(DdGetMoCompBuffInfo)(hDirectDraw,puGetBuffData));
  1062. }
  1063. DWORD APIENTRY NtGdiDdGetInternalMoCompInfo(
  1064. IN HANDLE hDirectDraw,
  1065. IN OUT PDD_GETINTERNALMOCOMPDATA puGetInternalData)
  1066. {
  1067. return (CALL_DXFUNC(DdGetInternalMoCompInfo)(hDirectDraw,puGetInternalData));
  1068. }
  1069. HANDLE APIENTRY NtGdiDdCreateMoComp(
  1070. IN HANDLE hDirectDraw,
  1071. IN OUT PDD_CREATEMOCOMPDATA puCreateMoCompData)
  1072. {
  1073. return (CALL_DXFUNC(DdCreateMoComp)(hDirectDraw,puCreateMoCompData));
  1074. }
  1075. DWORD APIENTRY NtGdiDdDestroyMoComp(
  1076. IN HANDLE hMoComp,
  1077. IN OUT PDD_DESTROYMOCOMPDATA puDestroyMoCompData)
  1078. {
  1079. return (CALL_DXFUNC(DdDestroyMoComp)(hMoComp,puDestroyMoCompData));
  1080. }
  1081. DWORD APIENTRY NtGdiDdBeginMoCompFrame(
  1082. IN HANDLE hMoComp,
  1083. IN OUT PDD_BEGINMOCOMPFRAMEDATA puBeginFrameData)
  1084. {
  1085. return (CALL_DXFUNC(DdBeginMoCompFrame)(hMoComp,puBeginFrameData));
  1086. }
  1087. DWORD APIENTRY NtGdiDdEndMoCompFrame(
  1088. IN HANDLE hMoComp,
  1089. IN OUT PDD_ENDMOCOMPFRAMEDATA puEndFrameData)
  1090. {
  1091. return (CALL_DXFUNC(DdEndMoCompFrame)(hMoComp,puEndFrameData));
  1092. }
  1093. DWORD APIENTRY NtGdiDdRenderMoComp(
  1094. IN HANDLE hMoComp,
  1095. IN OUT PDD_RENDERMOCOMPDATA puRenderMoCompData)
  1096. {
  1097. return (CALL_DXFUNC(DdRenderMoComp)(hMoComp,puRenderMoCompData));
  1098. }
  1099. DWORD APIENTRY NtGdiDdQueryMoCompStatus(
  1100. IN OUT HANDLE hMoComp,
  1101. IN OUT PDD_QUERYMOCOMPSTATUSDATA puQueryMoCompStatusData)
  1102. {
  1103. return (CALL_DXFUNC(DdQueryMoCompStatus)(hMoComp,puQueryMoCompStatusData));
  1104. }
  1105. DWORD APIENTRY NtGdiDdAlphaBlt(
  1106. IN HANDLE hSurfaceDest,
  1107. IN HANDLE hSurfaceSrc,
  1108. IN OUT PDD_BLTDATA puBltData)
  1109. {
  1110. return (CALL_DXFUNC(DdAlphaBlt)(hSurfaceDest,hSurfaceSrc,puBltData));
  1111. }
  1112. DWORD APIENTRY NtGdiDvpCanCreateVideoPort(
  1113. IN HANDLE hDirectDraw,
  1114. IN OUT PDD_CANCREATEVPORTDATA puCanCreateVPortData)
  1115. {
  1116. return (CALL_DXFUNC(DvpCanCreateVideoPort)(hDirectDraw,puCanCreateVPortData));
  1117. }
  1118. DWORD APIENTRY NtGdiDvpColorControl(
  1119. IN HANDLE hVideoPort,
  1120. IN OUT PDD_VPORTCOLORDATA puVPortColorData)
  1121. {
  1122. return (CALL_DXFUNC(DvpColorControl)(hVideoPort,puVPortColorData));
  1123. }
  1124. HANDLE APIENTRY NtGdiDvpCreateVideoPort(
  1125. IN HANDLE hDirectDraw,
  1126. IN OUT PDD_CREATEVPORTDATA puCreateVPortData)
  1127. {
  1128. return (CALL_DXFUNC(DvpCreateVideoPort)(hDirectDraw,puCreateVPortData));
  1129. }
  1130. DWORD APIENTRY NtGdiDvpDestroyVideoPort(
  1131. IN HANDLE hVideoPort,
  1132. IN OUT PDD_DESTROYVPORTDATA puDestroyVPortData)
  1133. {
  1134. return (CALL_DXFUNC(DvpDestroyVideoPort)(hVideoPort,puDestroyVPortData));
  1135. }
  1136. DWORD APIENTRY NtGdiDvpFlipVideoPort(
  1137. IN HANDLE hVideoPort,
  1138. IN HANDLE hDDSurfaceCurrent,
  1139. IN HANDLE hDDSurfaceTarget,
  1140. IN OUT PDD_FLIPVPORTDATA puFlipVPortData)
  1141. {
  1142. return (CALL_DXFUNC(DvpFlipVideoPort)(hVideoPort,hDDSurfaceCurrent,
  1143. hDDSurfaceTarget,puFlipVPortData));
  1144. }
  1145. DWORD APIENTRY NtGdiDvpGetVideoPortBandwidth(
  1146. IN HANDLE hVideoPort,
  1147. IN OUT PDD_GETVPORTBANDWIDTHDATA puGetVPortBandwidthData)
  1148. {
  1149. return (CALL_DXFUNC(DvpGetVideoPortBandwidth)(hVideoPort,puGetVPortBandwidthData));
  1150. }
  1151. DWORD APIENTRY NtGdiDvpGetVideoPortField(
  1152. IN HANDLE hVideoPort,
  1153. IN OUT PDD_GETVPORTFIELDDATA puGetVPortFieldData)
  1154. {
  1155. return (CALL_DXFUNC(DvpGetVideoPortField)(hVideoPort,puGetVPortFieldData));
  1156. }
  1157. DWORD APIENTRY NtGdiDvpGetVideoPortFlipStatus(
  1158. IN HANDLE hDirectDraw,
  1159. IN OUT PDD_GETVPORTFLIPSTATUSDATA puGetVPortFlipStatusData)
  1160. {
  1161. return (CALL_DXFUNC(DvpGetVideoPortFlipStatus)(hDirectDraw,puGetVPortFlipStatusData));
  1162. }
  1163. DWORD APIENTRY NtGdiDvpGetVideoPortInputFormats(
  1164. IN HANDLE hVideoPort,
  1165. IN OUT PDD_GETVPORTINPUTFORMATDATA puGetVPortInputFormatData)
  1166. {
  1167. return (CALL_DXFUNC(DvpGetVideoPortInputFormats)(hVideoPort,puGetVPortInputFormatData));
  1168. }
  1169. DWORD APIENTRY NtGdiDvpGetVideoPortLine(
  1170. IN HANDLE hVideoPort,
  1171. IN OUT PDD_GETVPORTLINEDATA puGetVPortLineData)
  1172. {
  1173. return (CALL_DXFUNC(DvpGetVideoPortLine)(hVideoPort,puGetVPortLineData));
  1174. }
  1175. DWORD APIENTRY NtGdiDvpGetVideoPortOutputFormats(
  1176. IN HANDLE hVideoPort,
  1177. IN OUT PDD_GETVPORTOUTPUTFORMATDATA puGetVPortOutputFormatData)
  1178. {
  1179. return (CALL_DXFUNC(DvpGetVideoPortOutputFormats)(hVideoPort,puGetVPortOutputFormatData));
  1180. }
  1181. DWORD APIENTRY NtGdiDvpGetVideoPortConnectInfo(
  1182. IN HANDLE hDirectDraw,
  1183. IN OUT PDD_GETVPORTCONNECTDATA puGetVPortConnectData)
  1184. {
  1185. return (CALL_DXFUNC(DvpGetVideoPortConnectInfo)(hDirectDraw,puGetVPortConnectData));
  1186. }
  1187. DWORD APIENTRY NtGdiDvpGetVideoSignalStatus(
  1188. IN HANDLE hVideoPort,
  1189. IN OUT PDD_GETVPORTSIGNALDATA puGetVPortSignalData)
  1190. {
  1191. return (CALL_DXFUNC(DvpGetVideoSignalStatus)(hVideoPort,puGetVPortSignalData));
  1192. }
  1193. DWORD APIENTRY NtGdiDvpUpdateVideoPort(
  1194. IN HANDLE hVideoPort,
  1195. IN HANDLE* phSurfaceVideo,
  1196. IN HANDLE* phSurfaceVbi,
  1197. IN OUT PDD_UPDATEVPORTDATA puUpdateVPortData)
  1198. {
  1199. return (CALL_DXFUNC(DvpUpdateVideoPort)(hVideoPort,phSurfaceVideo,phSurfaceVbi,puUpdateVPortData));
  1200. }
  1201. DWORD APIENTRY NtGdiDvpWaitForVideoPortSync(
  1202. IN HANDLE hVideoPort,
  1203. IN OUT PDD_WAITFORVPORTSYNCDATA puWaitForVPortSyncData)
  1204. {
  1205. return (CALL_DXFUNC(DvpWaitForVideoPortSync)(hVideoPort,puWaitForVPortSyncData));
  1206. }
  1207. DWORD APIENTRY NtGdiDvpAcquireNotification(
  1208. IN HANDLE hVideoPort,
  1209. IN OUT HANDLE* phEvent,
  1210. IN LPDDVIDEOPORTNOTIFY pNotify)
  1211. {
  1212. return (CALL_DXFUNC(DvpAcquireNotification)(hVideoPort,phEvent,pNotify));
  1213. }
  1214. DWORD APIENTRY NtGdiDvpReleaseNotification(
  1215. IN HANDLE hVideoPort,
  1216. IN HANDLE hEvent)
  1217. {
  1218. return (CALL_DXFUNC(DvpReleaseNotification)(hVideoPort,hEvent));
  1219. }
  1220. FLATPTR WINAPI HeapVidMemAllocAligned(
  1221. LPVIDMEM lpVidMem,
  1222. DWORD dwWidth,
  1223. DWORD dwHeight,
  1224. LPSURFACEALIGNMENT lpAlignment ,
  1225. LPLONG lpNewPitch )
  1226. {
  1227. return (CALL_DXFUNC(DdHeapVidMemAllocAligned)(lpVidMem,dwWidth,dwHeight,lpAlignment,lpNewPitch));
  1228. }
  1229. VOID WINAPI VidMemFree( LPVMEMHEAP pvmh, FLATPTR ptr )
  1230. {
  1231. CALL_DXFUNC(DdHeapVidMemFree)(pvmh,ptr);
  1232. }
  1233. PVOID APIENTRY EngAllocPrivateUserMem(
  1234. PDD_SURFACE_LOCAL pSurfaceLocal,
  1235. SIZE_T cj,
  1236. ULONG tag
  1237. )
  1238. {
  1239. return (CALL_DXFUNC(DdAllocPrivateUserMem)(pSurfaceLocal,cj,tag));
  1240. }
  1241. VOID APIENTRY EngFreePrivateUserMem(
  1242. PDD_SURFACE_LOCAL pSurfaceLocal,
  1243. PVOID pv
  1244. )
  1245. {
  1246. CALL_DXFUNC(DdFreePrivateUserMem)(pSurfaceLocal,pv);
  1247. }
  1248. HRESULT APIENTRY EngDxIoctl(
  1249. ULONG ulIoctl,
  1250. PVOID pBuffer,
  1251. ULONG ulBufferSize
  1252. )
  1253. {
  1254. return (CALL_DXFUNC(DdIoctl)(ulIoctl,pBuffer,ulBufferSize));
  1255. }
  1256. PDD_SURFACE_LOCAL APIENTRY EngLockDirectDrawSurface(HANDLE hSurface)
  1257. {
  1258. return (CALL_DXFUNC(DdLockDirectDrawSurface)(hSurface));
  1259. }
  1260. BOOL APIENTRY EngUnlockDirectDrawSurface(PDD_SURFACE_LOCAL pSurface)
  1261. {
  1262. return (CALL_DXFUNC(DdUnlockDirectDrawSurface)(pSurface));
  1263. }
  1264. VOID APIENTRY GreSuspendDirectDraw(
  1265. HDEV hdev,
  1266. BOOL bChildren
  1267. )
  1268. {
  1269. CALL_DXFUNC(DdSuspendDirectDraw)(hdev,(bChildren ? DXG_SR_DDRAW_CHILDREN : 0));
  1270. }
  1271. VOID APIENTRY GreSuspendDirectDrawEx(
  1272. HDEV hdev,
  1273. ULONG fl
  1274. )
  1275. {
  1276. CALL_DXFUNC(DdSuspendDirectDraw)(hdev,fl);
  1277. }
  1278. VOID APIENTRY GreResumeDirectDraw(
  1279. HDEV hdev,
  1280. BOOL bChildren
  1281. )
  1282. {
  1283. CALL_DXFUNC(DdResumeDirectDraw)(hdev,(bChildren ? DXG_SR_DDRAW_CHILDREN : 0));
  1284. }
  1285. VOID APIENTRY GreResumeDirectDrawEx(
  1286. HDEV hdev,
  1287. ULONG fl
  1288. )
  1289. {
  1290. CALL_DXFUNC(DdResumeDirectDraw)(hdev,fl);
  1291. }
  1292. BOOL APIENTRY GreGetDirectDrawBounds(
  1293. HDEV hdev,
  1294. RECT* prcBounds
  1295. )
  1296. {
  1297. return (CALL_DXFUNC(DdGetDirectDrawBounds)(hdev,prcBounds));
  1298. }
  1299. BOOL APIENTRY GreEnableDirectDrawRedirection(
  1300. HDEV hdev,
  1301. BOOL bEnable
  1302. )
  1303. {
  1304. return (CALL_DXFUNC(DdEnableDirectDrawRedirection)(hdev,bEnable));
  1305. }
  1306. BOOL DxDdEnableDirectDraw(
  1307. HDEV hdev,
  1308. BOOL bEnableDriver
  1309. )
  1310. {
  1311. return (CALL_DXFUNC(DdEnableDirectDraw)(hdev,bEnableDriver));
  1312. }
  1313. VOID DxDdDisableDirectDraw(
  1314. HDEV hdev,
  1315. BOOL bDisableDriver
  1316. )
  1317. {
  1318. CALL_DXFUNC(DdDisableDirectDraw)(hdev,bDisableDriver);
  1319. }
  1320. VOID DxDdDynamicModeChange(
  1321. HDEV hdevOld,
  1322. HDEV hdevNew,
  1323. ULONG fl
  1324. )
  1325. {
  1326. CALL_DXFUNC(DdDynamicModeChange)(hdevOld,hdevNew,fl);
  1327. }
  1328. VOID DxDdCloseProcess(W32PID W32Pid)
  1329. {
  1330. //
  1331. // This function can be called at clean up even
  1332. // if dxg.sys hasn't been initialized. so before
  1333. // call dxg.sys, make sure it has been initialized
  1334. // or not.
  1335. //
  1336. if (ghDxGraphics && gpDxFuncs)
  1337. {
  1338. CALL_DXFUNC(DdCloseProcess)(W32Pid);
  1339. }
  1340. }
  1341. VOID DxDdSetAccelLevel(HDEV hdev, DWORD dwAccelLevel, DWORD dwOverride)
  1342. {
  1343. CALL_DXFUNC(DdSetAccelLevel)(hdev,dwAccelLevel,dwOverride);
  1344. }
  1345. DWORD DxDdGetSurfaceLock(HDEV hdev)
  1346. {
  1347. return (CALL_DXFUNC(DdGetSurfaceLock)(hdev));
  1348. }
  1349. PVOID DxDdEnumLockedSurfaceRect(HDEV hdev, PVOID pvSurf, RECTL *prcl)
  1350. {
  1351. return (CALL_DXFUNC(DdEnumLockedSurfaceRect)(hdev,pvSurf,prcl));
  1352. }