xref: /reactos/win32ss/reactx/ntddraw/ddraw.c (revision c2c66aff)
1 /*
2  * COPYRIGHT:        See COPYING in the top level directory
3  * PROJECT:          ReactOS kernel
4  * PURPOSE:          Native DirectDraw implementation
5  * FILE:             win32ss/reactx/ntddraw/ddraw.c
6  * PROGRAMER:        Magnus olsen (magnus@greatlord.com)
7  * REVISION HISTORY:
8  *       19/1-2006   Magnus Olsen
9  */
10 
11 #include <win32k.h>
12 #include <debug.h>
13 
14 PGD_DXDDSTARTUPDXGRAPHICS gpfnStartupDxGraphics = NULL;
15 PGD_DXDDCLEANUPDXGRAPHICS gpfnCleanupDxGraphics = NULL;
16 
17 /* export from dxeng.c */
18 extern DRVFN gaEngFuncs[];
19 extern ULONG gcEngFuncs;
20 extern EDD_DIRECTDRAW_GLOBAL edd_DdirectDraw_Global;
21 
22 
23 DRVFN gpDxFuncs[DXG_INDEX_DxDdIoctl + 1];
24 HANDLE ghDxGraphics = NULL;
25 ULONG gdwDirectDrawContext = 0;
26 
27 #define DXDBG 1
28 
29 /************************************************************************/
30 /* DirectX graphic/video driver enable start here                       */
31 /************************************************************************/
32 BOOL
33 intEnableReactXDriver(HDC hdc)
34 {
35     NTSTATUS Status;
36     PEPROCESS Proc = NULL;
37     PDC pDC = NULL;
38     PPDEVOBJ pDev = NULL;
39     PGD_DXDDENABLEDIRECTDRAW pfnDdEnableDirectDraw = NULL;
40     BOOL success = FALSE;
41 
42     /* FIXME: Get the process data */
43 
44     /* Do not try load dxg.sys when it have already been load once */
45     if (gpfnStartupDxGraphics == NULL)
46     {
47         Status = DxDdStartupDxGraphics(0,NULL,0,NULL,NULL, Proc);
48         if (!NT_SUCCESS(Status))
49         {
50             DPRINT1("Warning: Failed to create the directx interface\n");
51             return FALSE;
52         }
53     }
54 
55     pDC = DC_LockDc(hdc);
56     if (pDC == NULL)
57     {
58         DPRINT1("Warning: Failed to lock hdc\n");
59         return FALSE;
60     }
61 
62     pDev = pDC->ppdev;
63 
64     /* Test and see if drv got a DX interface or not */
65     if  ( ( pDev->DriverFunctions.DisableDirectDraw == NULL) ||
66           ( pDev->DriverFunctions.EnableDirectDraw == NULL))
67     {
68         DPRINT1("Warning : DisableDirectDraw and EnableDirectDraw are NULL, no dx driver \n");
69     }
70     else
71     {
72 
73         /* Check and see if DX has been enabled or not */
74         if ( pDev->pEDDgpl->pvmList == NULL)
75         {
76             pDev->pEDDgpl->ddCallbacks.dwSize = sizeof(DD_CALLBACKS);
77             pDev->pEDDgpl->ddSurfaceCallbacks.dwSize = sizeof(DD_SURFACECALLBACKS);
78             pDev->pEDDgpl->ddPaletteCallbacks.dwSize = sizeof(DD_PALETTECALLBACKS);
79 
80             pfnDdEnableDirectDraw = (PGD_DXDDENABLEDIRECTDRAW)gpDxFuncs[DXG_INDEX_DxDdEnableDirectDraw].pfn;
81             if (pfnDdEnableDirectDraw == NULL)
82             {
83                 DPRINT1("Warning: no pfnDdEnableDirectDraw\n");
84             }
85             else
86             {
87                 DPRINT1(" call to pfnDdEnableDirectDraw \n ");
88 
89                 /* Note: it is the hdev struct it wants, not the drv hPDev aka pdc->PDev */
90                 success = pfnDdEnableDirectDraw(pDC->ppdev, TRUE);
91             }
92         }
93         else
94         {
95             DPRINT1(" The dxg.sys and graphic card driver interface is enabled \n ");
96             success = TRUE;
97         }
98     }
99 
100 
101     DPRINT1("Return value : 0x%08x\n",success);
102     DC_UnlockDc(pDC);
103     DPRINT1(" end call to pfnDdEnableDirectDraw \n ");
104     return success;
105 }
106 
107 /************************************************************************/
108 /* DirectX graphic/video driver enable ends here                        */
109 /************************************************************************/
110 
111 /************************************************************************/
112 /* DirectX graphic/video driver loading and cleanup starts here         */
113 /************************************************************************/
114 NTSTATUS
115 APIENTRY
116 DxDdStartupDxGraphics(  ULONG ulc1,
117                         PDRVENABLEDATA DxEngDrvOld,
118                         ULONG ulc2,
119                         PDRVENABLEDATA DxgDrvOld,
120                         PULONG DirectDrawContext,
121                         PEPROCESS Proc)
122 {
123     DRVENABLEDATA DxEngDrv;
124     DRVENABLEDATA DxgDrv;
125 
126     NTSTATUS Status = STATUS_PROCEDURE_NOT_FOUND;
127 
128     /* FIXME: Setup of gaEngFuncs driver export list
129      * but not in this api, we can add it here tempary until we figout where
130      * no code have been writen for it yet
131      */
132 
133 
134     /* FIXME: ReactOS does not loading the dxapi.sys or import functions from it yet */
135     // DxApiGetVersion()
136 
137     /* Loading the kernel interface of DirectX for win32k */
138 
139     DPRINT1("Warning: trying loading xp/2003/windows7/reactos dxg.sys\n");
140     ghDxGraphics = EngLoadImage(L"\\SystemRoot\\System32\\drivers\\dxg.sys");
141     if ( ghDxGraphics == NULL)
142     {
143         Status = STATUS_DLL_NOT_FOUND;
144         DPRINT1("Warning: no ReactX or DirectX kernel driver found\n");
145     }
146     else
147     {
148         /* Import DxDdStartupDxGraphics and  DxDdCleanupDxGraphics */
149         gpfnStartupDxGraphics = EngFindImageProcAddress(ghDxGraphics,"DxDdStartupDxGraphics");
150         gpfnCleanupDxGraphics = EngFindImageProcAddress(ghDxGraphics,"DxDdCleanupDxGraphics");
151 
152         if ((gpfnStartupDxGraphics) &&
153             (gpfnCleanupDxGraphics))
154         {
155             /* Setup driver data for activate the dx interface */
156             DxEngDrv.iDriverVersion = DDI_DRIVER_VERSION_NT5_01;
157             DxEngDrv.pdrvfn = gaEngFuncs;
158             DxEngDrv.c = gcEngFuncs;
159 
160             Status = gpfnStartupDxGraphics ( sizeof(DRVENABLEDATA),
161                                              &DxEngDrv,
162                                              sizeof(DRVENABLEDATA),
163                                              &DxgDrv,
164                                              &gdwDirectDrawContext,
165                                              Proc );
166         }
167 
168         /* Check if we manage loading the data and execute the dxStartupDxGraphics if it is successful */
169         if (!NT_SUCCESS(Status))
170         {
171             gpfnStartupDxGraphics = NULL;
172             gpfnCleanupDxGraphics = NULL;
173             if (ghDxGraphics != NULL)
174             {
175                 EngUnloadImage( ghDxGraphics);
176                 ghDxGraphics = NULL;
177             }
178             DPRINT1("Warning: DirectX graphics interface can not be initialized\n");
179         }
180         else
181         {
182             /* Sort the drv functions list in index order, this allows us doing, smaller optimize
183              * in API that are redirect to dx.sys
184              */
185 
186             PDRVFN lstDrvFN = DxgDrv.pdrvfn;
187             INT t;
188             for (t=0;t<=DXG_INDEX_DxDdIoctl;t++)
189             {
190                 gpDxFuncs[lstDrvFN[t].iFunc].iFunc =lstDrvFN[t].iFunc;
191                 gpDxFuncs[lstDrvFN[t].iFunc].pfn =lstDrvFN[t].pfn;
192             }
193 
194             DPRINT1("DirectX interface is activated\n");
195 
196         }
197         /* Return the status */
198     }
199 
200     return Status;
201 }
202 
203 /************************************************************************/
204 /* DirectX graphic/video driver loading cleanup ends here               */
205 /************************************************************************/
206 
207 /************************************************************************/
208 /* NtGdiDdCreateDirectDrawObject                                        */
209 /************************************************************************/
210 HANDLE
211 APIENTRY
212 NtGdiDdCreateDirectDrawObject(HDC hdc)
213 {
214     PGD_DDCREATEDIRECTDRAWOBJECT pfnDdCreateDirectDrawObject;
215 
216     if (hdc == NULL)
217     {
218         DPRINT1("Warning: hdc is NULL\n");
219         return 0;
220     }
221 
222     /* FIXME: This should be alloc for each drv and use it from each drv, not global for whole win32k */
223     if (intEnableReactXDriver(hdc) == FALSE)
224     {
225         DPRINT1("Warning: Failed to start the DirectX interface from the graphic driver\n");
226         return DDHAL_DRIVER_NOTHANDLED;
227     }
228 
229     /* Get the pfnDdCreateDirectDrawObject after we load the drv */
230     pfnDdCreateDirectDrawObject = (PGD_DDCREATEDIRECTDRAWOBJECT)gpDxFuncs[DXG_INDEX_DxDdCreateDirectDrawObject].pfn;
231 
232     if (pfnDdCreateDirectDrawObject == NULL)
233     {
234         DPRINT1("Warning: no pfnDdCreateDirectDrawObject\n");
235         return DDHAL_DRIVER_NOTHANDLED;
236     }
237 
238     DPRINT1("Calling dxg.sys DdCreateDirectDrawObject\n");
239 
240     return pfnDdCreateDirectDrawObject(hdc);
241 }
242 
243 /*++
244 * @name NtGdiDxgGenericThunk
245 * @implemented
246 *
247 * The function NtGdiDxgGenericThunk redirects DirectX calls to another function.
248 * It redirects to dxg.sys in Windows XP/2003, dxkrnl.sys in Vista and is fully implemented in win32k.sys in Windows 2000 and below
249 *
250 * @param ULONG_PTR ulIndex
251 * The functions we want to redirect
252 *
253 * @param ULONG_PTR ulHandle
254 * Unknown
255 *
256 * @param SIZE_T *pdwSizeOfPtr1
257 * Unknown
258 *
259 * @param PVOID pvPtr1
260 * Unknown
261 *
262 * @param SIZE_T *pdwSizeOfPtr2
263 * Unknown
264 *
265 * @param PVOID pvPtr2
266 * Unknown
267 *
268 * @return
269 * Always returns DDHAL_DRIVER_NOTHANDLED
270 *
271 * @remarks.
272 * dxg.sys NtGdiDxgGenericThunk calls are redirected to dxg.sys
273 * This function is no longer used but is still present in Windows NT 2000/XP/2003.
274 *
275 *--*/
276 DWORD
277 APIENTRY
278 NtGdiDxgGenericThunk(ULONG_PTR ulIndex,
279                      ULONG_PTR ulHandle,
280                      SIZE_T *pdwSizeOfPtr1,
281                      PVOID pvPtr1,
282                      SIZE_T *pdwSizeOfPtr2,
283                      PVOID pvPtr2)
284 {
285     PGD_DXGENERICTRUNK pfnDxgGenericThunk = (PGD_DXGENERICTRUNK)gpDxFuncs[DXG_INDEX_DxDxgGenericThunk].pfn;
286 
287     if (pfnDxgGenericThunk == NULL)
288     {
289         DPRINT1("Warning: no pfnDxgGenericThunk\n");
290         return DDHAL_DRIVER_NOTHANDLED;
291     }
292 
293     DPRINT1("Calling dxg.sys pfnDxgGenericThunk\n");
294     return pfnDxgGenericThunk(ulIndex, ulHandle, pdwSizeOfPtr1, pvPtr1, pdwSizeOfPtr2, pvPtr2);
295 }
296 
297 /************************************************************************/
298 /* NtGdiDdGetDriverState                                                */
299 /************************************************************************/
300 DWORD
301 APIENTRY
302 NtGdiDdGetDriverState(PDD_GETDRIVERSTATEDATA pdata)
303 {
304     PGD_DDGETDRIVERSTATE pfnDdGetDriverState = (PGD_DDGETDRIVERSTATE)gpDxFuncs[DXG_INDEX_DxDdGetDriverState].pfn;
305 
306     if (pfnDdGetDriverState == NULL)
307     {
308         DPRINT1("Warning: no pfnDdGetDriverState\n");
309         return DDHAL_DRIVER_NOTHANDLED;
310     }
311 
312     DPRINT1("Calling dxg.sys DdGetDriverState\n");
313     return pfnDdGetDriverState(pdata);
314 }
315 
316 /************************************************************************/
317 /* NtGdiDdColorControl                                                  */
318 /************************************************************************/
319 DWORD
320 APIENTRY
321 NtGdiDdColorControl(HANDLE hSurface,
322                     PDD_COLORCONTROLDATA puColorControlData)
323 {
324     PGD_DDCOLORCONTROL pfnDdColorControl = (PGD_DDCOLORCONTROL)gpDxFuncs[DXG_INDEX_DxDdColorControl].pfn;
325 
326     if (pfnDdColorControl == NULL)
327     {
328         DPRINT1("Warning: no pfnDdColorControl\n");
329         return DDHAL_DRIVER_NOTHANDLED;
330     }
331 
332     DPRINT1("Calling dxg.sys DdColorControl\n");
333     return pfnDdColorControl(hSurface,puColorControlData);
334 }
335 
336 /************************************************************************/
337 /* NtGdiDdCreateSurfaceObject                                           */
338 /************************************************************************/
339 HANDLE
340 APIENTRY
341 NtGdiDdCreateSurfaceObject(HANDLE hDirectDrawLocal,
342                            HANDLE hSurface,
343                            PDD_SURFACE_LOCAL puSurfaceLocal,
344                            PDD_SURFACE_MORE puSurfaceMore,
345                            PDD_SURFACE_GLOBAL puSurfaceGlobal,
346                            BOOL bComplete
347 )
348 {
349     PGD_DXDDCREATESURFACEOBJECT pfnDdCreateSurfaceObject = (PGD_DXDDCREATESURFACEOBJECT)gpDxFuncs[DXG_INDEX_DxDdCreateSurfaceObject].pfn;
350 
351     if (pfnDdCreateSurfaceObject == NULL)
352     {
353         DPRINT1("Warning: no pfnDdCreateSurfaceObject\n");
354         return DDHAL_DRIVER_NOTHANDLED;
355     }
356 
357     DPRINT1("Calling dxg.sys pfnDdCreateSurfaceObject\n");
358     return pfnDdCreateSurfaceObject(hDirectDrawLocal, hSurface, puSurfaceLocal, puSurfaceMore, puSurfaceGlobal, bComplete);
359 }
360 
361 /************************************************************************/
362 /* NtGdiDdDeleteDirectDrawObject                                        */
363 /************************************************************************/
364 BOOL
365 APIENTRY
366 NtGdiDdDeleteDirectDrawObject(HANDLE hDirectDrawLocal)
367 {
368     PGD_DXDDDELETEDIRECTDRAWOBJECT pfnDdDeleteDirectDrawObject = (PGD_DXDDDELETEDIRECTDRAWOBJECT)gpDxFuncs[DXG_INDEX_DxDdDeleteDirectDrawObject].pfn;
369 
370     if (pfnDdDeleteDirectDrawObject == NULL)
371     {
372         DPRINT1("Warning: no pfnDdDeleteDirectDrawObject\n");
373         return FALSE;
374     }
375 
376     if (hDirectDrawLocal == NULL)
377     {
378          DPRINT1("Warning: hDirectDrawLocal is NULL\n");
379          return FALSE;
380     }
381 
382     DPRINT1("hDirectDrawLocal = %p \n", hDirectDrawLocal);
383     DPRINT1("Calling dxg.sys pfnDdDeleteDirectDrawObject\n");
384 
385     return pfnDdDeleteDirectDrawObject(hDirectDrawLocal);
386 }
387 
388 /************************************************************************/
389 /* NtGdiDdDeleteSurfaceObject                                           */
390 /************************************************************************/
391 BOOL
392 APIENTRY
393 NtGdiDdDeleteSurfaceObject(HANDLE hSurface)
394 {
395     PGD_DXDDDELETESURFACEOBJECT pfnDdDeleteSurfaceObject = (PGD_DXDDDELETESURFACEOBJECT)gpDxFuncs[DXG_INDEX_DxDdDeleteSurfaceObject].pfn;
396 
397     if (pfnDdDeleteSurfaceObject == NULL)
398     {
399         DPRINT1("Warning: no pfnDdDeleteSurfaceObject\n");
400         return DDHAL_DRIVER_NOTHANDLED;
401     }
402     /* Try and see if the handle is valid */
403 
404     DPRINT1("Calling dxg.sys DdDeleteSurfaceObject\n");
405     return pfnDdDeleteSurfaceObject(hSurface);
406 }
407 
408 /************************************************************************/
409 /* NtGdiDdQueryDirectDrawObject                                         */
410 /************************************************************************/
411 BOOL
412 APIENTRY
413 NtGdiDdQueryDirectDrawObject(HANDLE hDirectDrawLocal,
414                              DD_HALINFO  *pHalInfo,
415                              DWORD *pCallBackFlags,
416                              LPD3DNTHAL_CALLBACKS puD3dCallbacks,
417                              LPD3DNTHAL_GLOBALDRIVERDATA puD3dDriverData,
418                              PDD_D3DBUFCALLBACKS puD3dBufferCallbacks,
419                              LPDDSURFACEDESC puD3dTextureFormats,
420                              DWORD *puNumHeaps,
421                              VIDEOMEMORY *puvmList,
422                              DWORD *puNumFourCC,
423                              DWORD *puFourCC)
424 {
425     PGD_DXDDQUERYDIRECTDRAWOBJECT pfnDdQueryDirectDrawObject = (PGD_DXDDQUERYDIRECTDRAWOBJECT)gpDxFuncs[DXG_INDEX_DxDdQueryDirectDrawObject].pfn;
426 
427     if (pfnDdQueryDirectDrawObject == NULL)
428     {
429         DPRINT1("Warning: no pfnDdQueryDirectDrawObject\n");
430         return DDHAL_DRIVER_NOTHANDLED;
431     }
432 
433     DPRINT1("Calling dxg.sys pfnDdQueryDirectDrawObject\n");
434 
435 
436     return pfnDdQueryDirectDrawObject(hDirectDrawLocal, pHalInfo, pCallBackFlags, puD3dCallbacks, puD3dDriverData,
437                                       puD3dBufferCallbacks, puD3dTextureFormats, puNumHeaps, puvmList, puNumFourCC, puFourCC);
438 
439 }
440 
441 
442 /************************************************************************/
443 /* NtGdiDdReenableDirectDrawObject                                      */
444 /************************************************************************/
445 BOOL
446 APIENTRY
447 NtGdiDdReenableDirectDrawObject(HANDLE hDirectDrawLocal,
448                                 BOOL *pubNewMode)
449 {
450 #if DXDBG
451     BOOL status = FALSE;
452 #endif
453     PGD_DXDDREENABLEDIRECTDRAWOBJECT pfnDdReenableDirectDrawObject = (PGD_DXDDREENABLEDIRECTDRAWOBJECT)gpDxFuncs[DXG_INDEX_DxDdReenableDirectDrawObject].pfn;
454 
455     if (pfnDdReenableDirectDrawObject == NULL)
456     {
457         DPRINT1("Warning: no pfnDdReenableDirectDrawObject\n");
458         return DDHAL_DRIVER_NOTHANDLED;
459     }
460 
461     DPRINT1("Calling dxg.sys pfnDdReenableDirectDrawObject\n");
462 
463 #if DXDBG
464     status = pfnDdReenableDirectDrawObject(hDirectDrawLocal, pubNewMode);
465     DPRINT1("end Calling dxg.sys pfnDdReenableDirectDrawObject\n");
466     DPRINT1("return value : 0x%08x\n", status);
467     return status;
468 #else
469     return pfnDdReenableDirectDrawObject(hDirectDrawLocal, pubNewMode);
470 #endif
471 }
472 
473 
474 /************************************************************************/
475 /* NtGdiDdGetDriverInfo                                                 */
476 /************************************************************************/
477 DWORD
478 APIENTRY
479 NtGdiDdGetDriverInfo(HANDLE hDirectDrawLocal,
480                      PDD_GETDRIVERINFODATA puGetDriverInfoData)
481 
482 {
483     PGD_DXDDGETDRIVERINFO pfnDdGetDriverInfo = (PGD_DXDDGETDRIVERINFO)gpDxFuncs[DXG_INDEX_DxDdGetDriverInfo].pfn;
484 
485     if (pfnDdGetDriverInfo == NULL)
486     {
487         DPRINT1("Warning: no pfnDdGetDriverInfo\n");
488         return DDHAL_DRIVER_NOTHANDLED;
489     }
490 
491     DPRINT1("Calling dxg.sys pfnDdGetDriverInfo\n");
492     return pfnDdGetDriverInfo(hDirectDrawLocal, puGetDriverInfoData);
493 }
494 
495 
496 /************************************************************************/
497 /* NtGdiDdGetAvailDriverMemory                                          */
498 /************************************************************************/
499 DWORD
500 APIENTRY
501 NtGdiDdGetAvailDriverMemory(HANDLE hDirectDrawLocal,
502                             PDD_GETAVAILDRIVERMEMORYDATA puGetAvailDriverMemoryData)
503 {
504     PGD_DXDDGETAVAILDRIVERMEMORY pfnDdGetAvailDriverMemory = (PGD_DXDDGETAVAILDRIVERMEMORY)gpDxFuncs[DXG_INDEX_DxDdGetAvailDriverMemory].pfn;
505 
506     if (pfnDdGetAvailDriverMemory == NULL)
507     {
508         DPRINT1("Warning: no pfnDdGetAvailDriverMemory\n");
509         return DDHAL_DRIVER_NOTHANDLED;
510     }
511 
512     DPRINT1("Calling dxg.sys pfnDdGetAvailDriverMemory\n");
513     return pfnDdGetAvailDriverMemory(hDirectDrawLocal, puGetAvailDriverMemoryData);
514 }
515 
516 
517 /************************************************************************/
518 /* NtGdiDdSetExclusiveMode                                              */
519 /************************************************************************/
520 
521 DWORD
522 APIENTRY
523 NtGdiDdSetExclusiveMode(HANDLE hDirectDraw,
524                         PDD_SETEXCLUSIVEMODEDATA puSetExclusiveModeData)
525 {
526     PGD_DXDDSETEXCLUSIVEMODE pfnDdSetExclusiveMode = (PGD_DXDDSETEXCLUSIVEMODE)gpDxFuncs[DXG_INDEX_DxDdSetExclusiveMode].pfn;
527 
528     if (pfnDdSetExclusiveMode == NULL)
529     {
530         DPRINT1("Warning: no pfnDdSetExclusiveMode\n");
531         return DDHAL_DRIVER_NOTHANDLED;
532     }
533 
534     DPRINT1("Calling dxg.sys pfnDdSetExclusiveMode\n");
535     return pfnDdSetExclusiveMode(hDirectDraw, puSetExclusiveModeData);
536 
537 }
538 
539 
540 /************************************************************************/
541 /* NtGdiDdFlipToGDISurface                                              */
542 /************************************************************************/
543 DWORD
544 APIENTRY
545 NtGdiDdFlipToGDISurface(HANDLE hDirectDraw,
546                         PDD_FLIPTOGDISURFACEDATA puFlipToGDISurfaceData)
547 {
548     PGD_DXDDFLIPTOGDISURFACE pfnDdFlipToGDISurface = (PGD_DXDDFLIPTOGDISURFACE)gpDxFuncs[DXG_INDEX_DxDdFlipToGDISurface].pfn;
549 
550     if (pfnDdFlipToGDISurface == NULL)
551     {
552         DPRINT1("Warning: no pfnDdFlipToGDISurface\n");
553         return DDHAL_DRIVER_NOTHANDLED;
554     }
555 
556     DPRINT1("Calling dxg.sys pfnDdFlipToGDISurface\n");
557     return pfnDdFlipToGDISurface(hDirectDraw, puFlipToGDISurfaceData);
558 
559 }
560 
561 /************************************************************************/
562 /* NtGdiDdGetDC                                                         */
563 /************************************************************************/
564 HDC
565 APIENTRY
566 NtGdiDdGetDC(HANDLE hSurface,
567              PALETTEENTRY *puColorTable)
568 {
569     PGD_DDGETDC pfnDdGetDC = (PGD_DDGETDC)gpDxFuncs[DXG_INDEX_DxDdGetDC].pfn;
570 
571     if (pfnDdGetDC == NULL)
572     {
573         DPRINT1("Warning: no pfnDdGetDC\n");
574         return DDHAL_DRIVER_NOTHANDLED;
575     }
576 
577     DPRINT1("Calling dxg.sys pfnDdGetDC\n");
578     return pfnDdGetDC(hSurface, puColorTable);
579 }
580 
581 /************************************************************************/
582 /* NtGdiDdGetDxHandle                                                   */
583 /************************************************************************/
584 HANDLE
585 APIENTRY
586 NtGdiDdGetDxHandle(HANDLE hDirectDraw,
587                    HANDLE hSurface,
588                    BOOL bRelease)
589 {
590     PGD_DDGETDXHANDLE pfnDdGetDxHandle = (PGD_DDGETDXHANDLE)gpDxFuncs[DXG_INDEX_DxDdGetDxHandle].pfn;
591 
592     if (pfnDdGetDxHandle == NULL)
593     {
594         DPRINT1("Warning: no pfnDdGetDxHandle\n");
595         return DDHAL_DRIVER_NOTHANDLED;
596     }
597 
598     DPRINT1("Calling dxg.sys pfnDdGetDxHandle\n");
599     return pfnDdGetDxHandle(hDirectDraw, hSurface, bRelease);
600 }
601 
602 
603 /************************************************************************/
604 /* NtGdiDdReleaseDC                                                     */
605 /************************************************************************/
606 BOOL
607 APIENTRY
608 NtGdiDdReleaseDC(HANDLE hSurface)
609 {
610     PGD_DDRELEASEDC pfnDdReleaseDC = (PGD_DDRELEASEDC)gpDxFuncs[DXG_INDEX_DxDdReleaseDC].pfn;
611 
612     if (pfnDdReleaseDC == NULL)
613     {
614         DPRINT1("Warning: no pfnDdReleaseDC\n");
615         return DDHAL_DRIVER_NOTHANDLED;
616     }
617 
618     DPRINT1("Calling dxg.sys pfnDdReleaseDC\n");
619     return pfnDdReleaseDC(hSurface);
620 }
621 
622 /************************************************************************/
623 /* NtGdiDdResetVisrgn                                                   */
624 /************************************************************************/
625 BOOL
626 APIENTRY
627 NtGdiDdResetVisrgn(HANDLE hSurface,
628                    HWND hwnd)
629 {
630 
631     PGD_DDRESTVISRGN pfnDdResetVisrgn = (PGD_DDRESTVISRGN)gpDxFuncs[DXG_INDEX_DxDdResetVisrgn].pfn;
632 
633     if (pfnDdResetVisrgn == NULL)
634     {
635         DPRINT1("Warning: no pfnDdResetVisrgn\n");
636         return DDHAL_DRIVER_NOTHANDLED;
637     }
638 
639     DPRINT1("Calling dxg.sys pfnDdResetVisrgn\n");
640     return pfnDdResetVisrgn(hSurface, hwnd);
641 }
642 
643 /************************************************************************/
644 /* NtGdiDdSetGammaRamp                                                  */
645 /************************************************************************/
646 BOOL
647 APIENTRY
648 NtGdiDdSetGammaRamp(HANDLE hDirectDraw,
649                     HDC hdc,
650                     LPVOID lpGammaRamp)
651 {
652     PGD_DDSETGAMMARAMP pfnDdSetGammaRamp = (PGD_DDSETGAMMARAMP)gpDxFuncs[DXG_INDEX_DxDdSetGammaRamp].pfn;
653 
654     if (pfnDdSetGammaRamp == NULL)
655     {
656         DPRINT1("Warning: no pfnDdSetGammaRamp\n");
657         return DDHAL_DRIVER_NOTHANDLED;
658     }
659 
660     DPRINT1("Calling dxg.sys pfnDdSetGammaRamp\n");
661     return pfnDdSetGammaRamp(hDirectDraw, hdc, lpGammaRamp);
662 }
663