ReactOS 0.4.15-dev-7712-gbbbcd8e
NtGdiDdQueryDirectDrawObject.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for NtGdiDdCreateDirectDrawObject
5 * PROGRAMMERS:
6 */
7
8#include "../win32nt.h"
9
10#include <ddrawi.h>
11
12/* Note : OsThunkDdQueryDirectDrawObject is the usermode name of NtGdiDdQueryDirectDrawObject
13 * it lives in d3d8thk.dll and in windows 2000 it doing syscall direcly to win32k.sus
14 * in windows xp and higher it call to gdi32.dll to DdEntry41 and it doing the syscall
15 */
17{
18 HANDLE hDirectDraw;
20 DWORD *pCallBackFlags = NULL;
21 LPD3DNTHAL_CALLBACKS puD3dCallbacks = NULL;
22 LPD3DNTHAL_GLOBALDRIVERDATA puD3dDriverData = NULL;
23 PDD_D3DBUFCALLBACKS puD3dBufferCallbacks = NULL;
24 LPDDSURFACEDESC puD3dTextureFormats = NULL;
25 DWORD *puNumHeaps = NULL;
26 VIDEOMEMORY *puvmList = NULL;
27 DWORD *puNumFourCC = NULL;
28 DWORD *puFourCC = NULL;
29
30 DD_HALINFO HalInfo;
31 DD_HALINFO oldHalInfo;
32 DWORD CallBackFlags[4];
33
34 D3DNTHAL_CALLBACKS D3dCallbacks;
35 D3DNTHAL_CALLBACKS oldD3dCallbacks;
36
37 D3DNTHAL_GLOBALDRIVERDATA D3dDriverData;
38 D3DNTHAL_GLOBALDRIVERDATA oldD3dDriverData;
39
40 DD_D3DBUFCALLBACKS D3dBufferCallbacks;
41 DD_D3DBUFCALLBACKS oldD3dBufferCallbacks;
42
43 DDSURFACEDESC2 D3dTextureFormats[100];
44 DWORD NumHeaps = 0;
45 VIDEOMEMORY vmList;
46 //DWORD NumFourCC = 0;
47 //DWORD FourCC = 0;
49 HDC hdc;
50
51 DWORD dwTextureCounter = 0;
52 DDSURFACEDESC *myDesc = NULL;
53
54 /* clear data */
55 memset(&vmList,0,sizeof(VIDEOMEMORY));
56 memset(&D3dTextureFormats,0,sizeof(DDSURFACEDESC));
57 memset(&D3dBufferCallbacks,0,sizeof(DD_D3DBUFCALLBACKS));
58 memset(&D3dDriverData,0,sizeof(D3DNTHAL_GLOBALDRIVERDATA));
59 memset(&D3dCallbacks,0,sizeof(D3DNTHAL_CALLBACKS));
60 memset(&HalInfo,0,sizeof(DD_HALINFO));
61 memset(CallBackFlags,0,sizeof(DWORD)*3);
62
63 /* Get current display mode */
65
66 /* Create hdc that we can use */
67 hdc = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
68 ASSERT(hdc != NULL);
69
70
72 RTEST(hDirectDraw != NULL);
73
74 /* testing OsThunkDdQueryDirectDrawObject( NULL, .... */
76 pCallBackFlags, puD3dCallbacks,
77 puD3dDriverData, puD3dBufferCallbacks,
78 puD3dTextureFormats, puNumHeaps,
79 puvmList, puNumFourCC,
80 puFourCC) == FALSE);
81
83 RTEST(pCallBackFlags == NULL);
84 RTEST(puD3dCallbacks == NULL);
85 RTEST(puD3dDriverData == NULL);
86 RTEST(puD3dBufferCallbacks == NULL);
87 RTEST(puD3dTextureFormats == NULL);
88 RTEST(puNumFourCC == NULL);
89 RTEST(puFourCC == NULL);
90 RTEST(puNumHeaps == NULL);
91 RTEST(puvmList == NULL);
92
93 if (hDirectDraw == NULL)
94 {
95 skip("No DirectDrawObject\n");
96 ok(DeleteDC(hdc) != 0, "DeleteDC() failed\n");
97 return;
98 }
99
100 /* testing NtGdiDdQueryDirectDrawObject( hDirectDrawLocal, NULL, .... */
102 pCallBackFlags, puD3dCallbacks,
103 puD3dDriverData, puD3dBufferCallbacks,
104 puD3dTextureFormats, puNumHeaps,
105 puvmList, puNumFourCC,
106 puFourCC) == FALSE);
107
108 RTEST(pHalInfo == NULL);
109 RTEST(pCallBackFlags == NULL);
110 RTEST(puD3dCallbacks == NULL);
111 RTEST(puD3dDriverData == NULL);
112 RTEST(puD3dBufferCallbacks == NULL);
113 RTEST(puD3dTextureFormats == NULL);
114 RTEST(puNumFourCC == NULL);
115 RTEST(puFourCC == NULL);
116 RTEST(puNumHeaps == NULL);
117 RTEST(puvmList == NULL);
118
119 /* testing NtGdiDdQueryDirectDrawObject( hDirectDrawLocal, pHalInfo, NULL, .... */
120 pHalInfo = &HalInfo;
122 pCallBackFlags, puD3dCallbacks,
123 puD3dDriverData, puD3dBufferCallbacks,
124 puD3dTextureFormats, puNumHeaps,
125 puvmList, puNumFourCC,
126 puFourCC)== FALSE);
127
128 RTEST(pHalInfo != NULL);
129 ASSERT(pHalInfo != NULL);
130
131 RTEST(pCallBackFlags == NULL);
132 RTEST(puD3dCallbacks == NULL);
133 RTEST(puD3dDriverData == NULL);
134 RTEST(puD3dBufferCallbacks == NULL);
135 RTEST(puD3dTextureFormats == NULL);
136 RTEST(puNumFourCC == NULL);
137 RTEST(puFourCC == NULL);
138 RTEST(puNumHeaps == NULL);
139 RTEST(puvmList == NULL);
140
141 if ((pHalInfo->dwSize != sizeof(DD_HALINFO)) &&
142 (pHalInfo->dwSize != sizeof(DD_HALINFO_V4)))
143 {
144 RTEST(pHalInfo->dwSize != sizeof(DD_HALINFO));
145 ASSERT(pHalInfo->dwSize != sizeof(DD_HALINFO));
146 }
147
148 if (pHalInfo->dwSize == sizeof(DD_HALINFO))
149 {
150 /*the offset, in bytes, to primary surface in the display memory */
151 /* some graphic card like sis 760 GX, Nvida GF7900GS does not set any offset at all */
152 // RTEST(pHalInfo->vmiData.fpPrimary != 0 );
153
154 /* unsuse always 0 */
155 RTEST(pHalInfo->vmiData.dwFlags == 0 );
156
157 /* Check the res */
158 RTEST(pHalInfo->vmiData.dwDisplayWidth == devmode.dmPelsWidth );
159 RTEST(pHalInfo->vmiData.dwDisplayHeight == devmode.dmPelsHeight );
160
161 /* This can never be test for it is who big the line is after it been align displayPitch */
162 RTEST(pHalInfo->vmiData.lDisplayPitch != 0);
163
164 RTEST(pHalInfo->vmiData.ddpfDisplay.dwSize == sizeof(DDPIXELFORMAT) );
165 ASSERT(pHalInfo->vmiData.ddpfDisplay.dwSize == sizeof(DDPIXELFORMAT));
166
167 /* We can not check if it DDPF_RGB flags been set for primary surface
168 * for it can be DDPF_PALETTEINDEXED1,DDPF_PALETTEINDEXED2,DDPF_PALETTEINDEXED4,DDPF_PALETTEINDEXED8, DDPF_PALETTEINDEXEDTO8, DDPF_RGB, DDPF_YUV
169 */
170 RTEST( (pHalInfo->vmiData.ddpfDisplay.dwFlags & (DDPF_PALETTEINDEXED1 | DDPF_PALETTEINDEXED2 | DDPF_PALETTEINDEXED4 |
172
173
174 /* No fourcc are use on primary screen */
175 RTEST(pHalInfo->vmiData.ddpfDisplay.dwFourCC == 0 );
176
177 /* Count RGB Bits 8/16/24/32 */
178 RTEST(pHalInfo->vmiData.ddpfDisplay.dwRGBBitCount == devmode.dmBitsPerPel );
179
180 /* The rgb mask can not be detected in user mode, for it can be 15Bpp convert to 16Bpp mode, so we have no way detect correct mask
181 * But the mask can never be Zero
182 */
183 RTEST(pHalInfo->vmiData.ddpfDisplay.dwRBitMask != 0 );
184 RTEST(pHalInfo->vmiData.ddpfDisplay.dwGBitMask != 0 );
185 RTEST(pHalInfo->vmiData.ddpfDisplay.dwBBitMask != 0 );
186
187 /* primary never set the alpha blend mask */
188 RTEST(pHalInfo->vmiData.ddpfDisplay.dwRGBAlphaBitMask == 0 );
189
190 /* This can not be test at usermode it is each hardware drv that fill in it,
191 * only way to found them is to use this call */
192 // pHalInfo->vmiData->dwOffscreenAlign
193 // pHalInfo->vmiData->dwOverlayAlign
194 // pHalInfo->vmiData->dwTextureAlign
195 // pHalInfo->vmiData->dwZBufferAlign
196 // pHalInfo->vmiData->dwAlphaAlign
197
198 /* the primary display address */
199 RTEST( ( (DWORD_PTR)pHalInfo->vmiData.pvPrimary & (~0x80000000)) != 0 );
200
201 /* test see if we got back the pvmList here
202 * acording msdn vmiData.dwNumHeaps and vmiData.pvmList
203 * exists for _VIDEOMEMORYINFO but they do not, it reviews
204 * in ddk and wdk and own testcase
205 */
206 // RTEST(pHalInfo->vmiData.dwNumHeaps != 0 );
207 // RTEST(pHalInfo->vmiData.pvmList != 0 );
208
209 /* Test see if we got any hardware acclartions for 2d or 3d, this always fill in
210 * that mean we found a bugi drv and dx does not work on this drv
211 */
212
213 /* the SIS 760 GX will never fill it in, it is a bugi drv */
214 RTEST(pHalInfo->ddCaps.dwSize == sizeof(DDCORECAPS));
215
216 /* Testing see if we got any hw support for
217 * This test can fail on video card that does not support 2d/overlay/3d
218 */
219 //RTEST( pHalInfo->ddCaps.dwCaps != 0);
220 RTEST( pHalInfo->ddCaps.ddsCaps.dwCaps != 0);
221
222 /* This flags is obsolete and should not be used by the driver */
223 RTEST( pHalInfo->ddCaps.dwFXAlphaCaps == 0);
224
225
226 /* basic dx 2 is found if this flags not set
227 * if this fail we do not have a dx driver install acodring ms, some version of windows it
228 * is okay this fail and drv does then only support basic dx
229 *
230 */
231 if (pHalInfo->dwFlags != 0)
232 {
234 RTEST( ( (DWORD_PTR)pHalInfo->GetDriverInfo & 0x80000000) != 0 );
235 ASSERT( ((DWORD_PTR)pHalInfo->GetDriverInfo & 0x80000000) != 0 );
236 }
237
238 /* point to kmode direcly to the graphic drv, the drv is kmode and it is kmode address we getting back*/
239
240
241 /* the pHalInfo->ddCaps.ddsCaps.dwCaps & DDSCAPS_3DDEVICE will be ignore, only way detect it proper follow code,
242 * this will be fill in of all drv, it is not only for 3d stuff, this always fill by win32k.sys or dxg.sys depns
243 * if it windows 2000 or windows xp/2003
244 *
245 * point to kmode direcly to the win32k.sys, win32k.sys is kmode and it is kmode address we getting back
246 */
247 //RTEST( ( (DWORD_PTR)pHalInfo->lpD3DGlobalDriverData & (~0x80000000)) != 0 );
248 //RTEST( ( (DWORD_PTR)pHalInfo->lpD3DHALCallbacks & (~0x80000000)) != 0 );
249 //RTEST( ( (DWORD_PTR)pHalInfo->lpD3DHALCallbacks & (~0x80000000)) != 0 );
250 }
251
252 /* Backup DD_HALINFO so we do not need resting it */
253 RtlCopyMemory(&oldHalInfo, &HalInfo, sizeof(DD_HALINFO));
254
255 /* testing NtGdiDdQueryDirectDrawObject( hDirectDrawLocal, pHalInfo, pCallBackFlags, NULL, .... */
256 pHalInfo = &HalInfo;
257 pCallBackFlags = CallBackFlags;
259
261 pCallBackFlags, puD3dCallbacks,
262 puD3dDriverData, puD3dBufferCallbacks,
263 puD3dTextureFormats, puNumHeaps,
264 puvmList, puNumFourCC,
265 puFourCC)== FALSE);
266 RTEST(pHalInfo != NULL);
267 ASSERT(pHalInfo != NULL);
268
269 RTEST(pCallBackFlags != NULL);
270 ASSERT(pCallBackFlags != NULL);
271
272 RTEST(puD3dCallbacks == NULL);
273 RTEST(puD3dDriverData == NULL);
274 RTEST(puD3dBufferCallbacks == NULL);
275 RTEST(puD3dTextureFormats == NULL);
276 RTEST(puNumFourCC == NULL);
277 RTEST(puFourCC == NULL);
278 RTEST(puNumHeaps == NULL);
279 RTEST(puvmList == NULL);
280
281 /* We do not retesting DD_HALINFO, instead we compare it */
282 RTEST(memcmp(&oldHalInfo, pHalInfo, sizeof(DD_HALINFO)) == 0);
283
284 /* Rember on some nivida drv the pCallBackFlags will not be set even they api exists in the drv
285 * known workaround is to check if the drv really return a kmode pointer for the drv functions
286 * we want to use.
287 */
288 //RTEST(pCallBackFlags[0] != 0);
289 //RTEST(pCallBackFlags[1] != 0);
290 RTEST(pCallBackFlags[2] == 0);
291
292 /* testing NtGdiDdQueryDirectDrawObject( hDirectDrawLocal, pHalInfo, pCallBackFlags, D3dCallbacks, NULL, .... */
293 pHalInfo = &HalInfo;
294 pCallBackFlags = CallBackFlags;
295 puD3dCallbacks = &D3dCallbacks;
296
298 RtlZeroMemory(pCallBackFlags,sizeof(DWORD)*3);
299
301 pCallBackFlags, puD3dCallbacks,
302 puD3dDriverData, puD3dBufferCallbacks,
303 puD3dTextureFormats, puNumHeaps,
304 puvmList, puNumFourCC,
305 puFourCC)== FALSE);
306 RTEST(pHalInfo != NULL);
307 ASSERT(pHalInfo != NULL);
308
309 RTEST(pCallBackFlags != NULL);
310 ASSERT(pCallBackFlags != NULL);
311
312 /* rember puD3dCallbacks shall never return NULL */
313 RTEST(puD3dCallbacks != NULL);
314 ASSERT(puD3dCallbacks != NULL);
315
316 /* the pHalInfo->ddCaps.ddsCaps.dwCaps & DDSCAPS_3DDEVICE will be ignore, only way detect it proper follow code,
317 * this will be fill in of all drv, it is not only for 3d stuff, this always fill by win32k.sys or dxg.sys depns
318 * if it windows 2000 or windows xp/2003
319 */
320 //RTEST(puD3dCallbacks->dwSize == sizeof(D3DNTHAL_CALLBACKS));
321
322 /* Nivda like GF7900GS will not follow ms design rule here,
323 * ContextDestroyAll must alwyas be NULL for it is not longer inuse in windows 2000 and higher
324 */
325 RTEST(puD3dCallbacks->ContextDestroyAll == NULL);
326
327 /* Nivda like GF7900GS will not follow ms design rule here,
328 * SceneCapture must alwyas be NULL for it is not longer inuse in windows 2000 and higher
329 */
330 RTEST(puD3dCallbacks->SceneCapture == NULL);
331 RTEST(puD3dCallbacks->dwReserved10 == 0);
332 RTEST(puD3dCallbacks->dwReserved11 == 0);
333 RTEST(puD3dCallbacks->dwReserved22 == 0);
334 RTEST(puD3dCallbacks->dwReserved23 == 0);
335 RTEST(puD3dCallbacks->dwReserved == 0);
336 RTEST(puD3dCallbacks->TextureCreate == NULL);
337 RTEST(puD3dCallbacks->TextureDestroy == NULL);
338 RTEST(puD3dCallbacks->TextureSwap == NULL);
339 RTEST(puD3dCallbacks->TextureGetSurf == NULL);
340 RTEST(puD3dCallbacks->dwReserved12 == 0);
341 RTEST(puD3dCallbacks->dwReserved13 == 0);
342 RTEST(puD3dCallbacks->dwReserved14 == 0);
343 RTEST(puD3dCallbacks->dwReserved15 == 0);
344 RTEST(puD3dCallbacks->dwReserved16 == 0);
345 RTEST(puD3dCallbacks->dwReserved17 == 0);
346 RTEST(puD3dCallbacks->dwReserved18 == 0);
347 RTEST(puD3dCallbacks->dwReserved19 == 0);
348 RTEST(puD3dCallbacks->dwReserved20 == 0);
349 RTEST(puD3dCallbacks->dwReserved21 == 0);
350 RTEST(puD3dCallbacks->dwReserved24 == 0);
351 RTEST(puD3dCallbacks->dwReserved0 == 0);
352 RTEST(puD3dCallbacks->dwReserved1 == 0);
353 RTEST(puD3dCallbacks->dwReserved2 == 0);
354 RTEST(puD3dCallbacks->dwReserved3 == 0);
355 RTEST(puD3dCallbacks->dwReserved4 == 0);
356 RTEST(puD3dCallbacks->dwReserved5 == 0);
357 RTEST(puD3dCallbacks->dwReserved6 == 0);
358 RTEST(puD3dCallbacks->dwReserved7 == 0);
359 RTEST(puD3dCallbacks->dwReserved8 == 0);
360 RTEST(puD3dCallbacks->dwReserved9 == 0);
361
362 /* how detect puD3dCallbacks->ContextCreate and puD3dCallbacks->ContextDestroy shall be set for bugi drv like nivda ? */
363 /* pointer direcly to the graphic drv, it is kmode pointer */
364 // RTEST( ( (DWORD)puD3dCallbacks->ContextCreate & (~0x80000000)) != 0 );
365 // RTEST( ( (DWORD)puD3dCallbacks->ContextDestroy & (~0x80000000)) != 0 );
366
367 RTEST(puD3dDriverData == NULL);
368 RTEST(puD3dBufferCallbacks == NULL);
369 RTEST(puD3dTextureFormats == NULL);
370 RTEST(puNumFourCC == NULL);
371 RTEST(puFourCC == NULL);
372 RTEST(puNumHeaps == NULL);
373 RTEST(puvmList == NULL);
374
375 /* We do not retesting DD_HALINFO, instead we compare it */
376 RTEST(memcmp(&oldHalInfo, pHalInfo, sizeof(DD_HALINFO)) == 0);
377 //RTEST(pCallBackFlags[0] != 0);
378 //RTEST(pCallBackFlags[1] != 0);
379 RTEST(pCallBackFlags[2] == 0);
380
381 /* Backup D3DNTHAL_CALLBACKS so we do not need resting it */
382 RtlCopyMemory(&oldD3dCallbacks, &D3dCallbacks, sizeof(D3DNTHAL_CALLBACKS));
383
384
385/* testing NtGdiDdQueryDirectDrawObject( hDD, pHalInfo, pCallBackFlags, puD3dCallbacks, puD3dDriverData, NULL, */
386 pHalInfo = &HalInfo;
387 pCallBackFlags = CallBackFlags;
388 puD3dCallbacks = &D3dCallbacks;
389 puD3dDriverData = &D3dDriverData;
390
392 RtlZeroMemory(pCallBackFlags,sizeof(DWORD)*3);
393 RtlZeroMemory(puD3dCallbacks,sizeof(D3DNTHAL_CALLBACKS));
394
396 pCallBackFlags, puD3dCallbacks,
397 puD3dDriverData, puD3dBufferCallbacks,
398 puD3dTextureFormats, puNumHeaps,
399 puvmList, puNumFourCC,
400 puFourCC)== FALSE);
401 RTEST(pHalInfo != NULL);
402 ASSERT(pHalInfo != NULL);
403
404 RTEST(pCallBackFlags != NULL);
405 ASSERT(pCallBackFlags != NULL);
406
407 RTEST(puD3dCallbacks != NULL);
408 ASSERT(puD3dCallbacks != NULL);
409
410 RTEST(puD3dDriverData != NULL);
411 ASSERT(puD3dDriverData != NULL);
412
413 RTEST(puD3dBufferCallbacks == NULL);
414 RTEST(puD3dTextureFormats == NULL);
415 RTEST(puNumFourCC == NULL);
416 RTEST(puFourCC == NULL);
417 RTEST(puNumHeaps == NULL);
418 RTEST(puvmList == NULL);
419
420 /* We retesting pCallBackFlags */
421 //RTEST(pCallBackFlags[0] != 0);
422 //RTEST(pCallBackFlags[1] != 0);
423 RTEST(pCallBackFlags[2] == 0);
424
425 /* We do not retesting instead we compare it */
426 RTEST(memcmp(&oldHalInfo, pHalInfo, sizeof(DD_HALINFO)) == 0);
427 RTEST(memcmp(&oldD3dCallbacks, puD3dCallbacks, sizeof(D3DNTHAL_CALLBACKS)) == 0);
428
429 /* start test of puD3dDriverData */
430
431 //RTEST(puD3dDriverData->dwSize == sizeof(D3DNTHAL_GLOBALDRIVERDATA));
432 //RTEST(puD3dDriverData->hwCaps.dwSize == sizeof(D3DNTHALDEVICEDESC_V1));
433 //RTEST(puD3dDriverData->hwCaps.dtcTransformCaps.dwSize == sizeof(D3DTRANSFORMCAPS));
434 //RTEST(puD3dDriverData->hwCaps.dlcLightingCaps.dwSize == sizeof(D3DLIGHTINGCAPS));
435 //RTEST(puD3dDriverData->hwCaps.dpcLineCaps.dwSize == sizeof(D3DPRIMCAPS));
436 //RTEST(puD3dDriverData->hwCaps.dpcTriCaps.dwSize == sizeof(D3DPRIMCAPS));
437 RTEST(puD3dDriverData->hwCaps.dwMaxBufferSize == 0);
438 RTEST(puD3dDriverData->hwCaps.dwMaxVertexCount == 0);
439
440 /* Backup D3DHAL_GLOBALDRIVERDATA so we do not need resting it */
441 RtlCopyMemory(&oldD3dDriverData, &D3dDriverData, sizeof(D3DNTHAL_GLOBALDRIVERDATA));
442
443/* testing NtGdiDdQueryDirectDrawObject( hDD, pHalInfo, pCallBackFlags, puD3dCallbacks, puD3dDriverData, puD3dBufferCallbacks, NULL, */
444 pHalInfo = &HalInfo;
445 pCallBackFlags = CallBackFlags;
446 puD3dCallbacks = &D3dCallbacks;
447 puD3dDriverData = &D3dDriverData;
448 puD3dBufferCallbacks = &D3dBufferCallbacks;
449
451 RtlZeroMemory(pCallBackFlags,sizeof(DWORD)*3);
452 RtlZeroMemory(puD3dCallbacks,sizeof(D3DNTHAL_CALLBACKS));
453 RtlZeroMemory(puD3dDriverData,sizeof(D3DNTHAL_GLOBALDRIVERDATA));
454
456 pCallBackFlags, puD3dCallbacks,
457 puD3dDriverData, puD3dBufferCallbacks,
458 puD3dTextureFormats, puNumHeaps,
459 puvmList, puNumFourCC,
460 puFourCC)== FALSE);
461 RTEST(pHalInfo != NULL);
462 RTEST(pCallBackFlags != NULL);
463
464 if (pHalInfo->ddCaps.ddsCaps.dwCaps & DDSCAPS_3DDEVICE )
465 {
466 RTEST(puD3dCallbacks != NULL);
467 RTEST(puD3dDriverData != NULL);
468 RTEST(puD3dBufferCallbacks != NULL);
469 }
470
471 RTEST(pHalInfo != NULL);
472 ASSERT(pHalInfo != NULL);
473
474 RTEST(pCallBackFlags != NULL);
475 ASSERT(pCallBackFlags != NULL);
476
477 RTEST(puD3dCallbacks != NULL);
478 ASSERT(puD3dCallbacks != NULL);
479
480 RTEST(puD3dDriverData != NULL);
481 ASSERT(puD3dDriverData != NULL);
482
483 RTEST(puD3dBufferCallbacks != NULL);
484 ASSERT(puD3dDriverData != NULL);
485
486 RTEST(puD3dTextureFormats == NULL);
487 RTEST(puNumFourCC == NULL);
488 RTEST(puFourCC == NULL);
489 RTEST(puNumHeaps == NULL);
490 RTEST(puvmList == NULL);
491
492 /* We retesting the flags */
493 //RTEST(pCallBackFlags[0] != 0);
494 //RTEST(pCallBackFlags[1] != 0);
495 RTEST(pCallBackFlags[2] == 0);
496
497 /* We do not retesting instead we compare it */
498 RTEST(memcmp(&oldHalInfo, pHalInfo, sizeof(DD_HALINFO)) == 0);
499 RTEST(memcmp(&oldD3dCallbacks, puD3dCallbacks, sizeof(D3DNTHAL_CALLBACKS)) == 0);
500 RTEST(memcmp(&oldD3dDriverData, puD3dDriverData, sizeof(D3DNTHAL_GLOBALDRIVERDATA)) == 0);
501
502 /* start test of puD3dBufferCallbacks */
503 //RTEST(puD3dBufferCallbacks->dwSize == sizeof(DD_D3DBUFCALLBACKS));
504 if (puD3dBufferCallbacks->dwFlags & DDHAL_D3DBUFCB32_CANCREATED3DBUF)
505 {
506 /* point to kmode direcly to the graphic drv, the drv is kmode and it is kmode address we getting back*/
507 RTEST( ( (DWORD_PTR)puD3dBufferCallbacks->CanCreateD3DBuffer & (~0x80000000)) != 0 );
508 }
509 else
510 {
511 RTEST( puD3dBufferCallbacks->CanCreateD3DBuffer == NULL);
512 }
513
514 if (puD3dBufferCallbacks->dwFlags & DDHAL_D3DBUFCB32_CREATED3DBUF)
515 {
516 /* point to kmode direcly to the graphic drv, the drv is kmode and it is kmode address we getting back*/
517 RTEST( ( (DWORD_PTR)puD3dBufferCallbacks->CreateD3DBuffer & (~0x80000000)) != 0 );
518 }
519 else
520 {
521 RTEST( puD3dBufferCallbacks->CreateD3DBuffer == NULL);
522 }
523
524 if (puD3dBufferCallbacks->dwFlags & DDHAL_D3DBUFCB32_DESTROYD3DBUF)
525 {
526 /* point to kmode direcly to the graphic drv, the drv is kmode and it is kmode address we getting back*/
527 RTEST( ( (DWORD_PTR)puD3dBufferCallbacks->DestroyD3DBuffer & (~0x80000000)) != 0 );
528 }
529 else
530 {
531 RTEST( puD3dBufferCallbacks->DestroyD3DBuffer == NULL);
532 }
533
534 if (puD3dBufferCallbacks->dwFlags & DDHAL_D3DBUFCB32_LOCKD3DBUF)
535 {
536 /* point to kmode direcly to the graphic drv, the drv is kmode and it is kmode address we getting back*/
537 RTEST( ( (DWORD_PTR)puD3dBufferCallbacks->LockD3DBuffer & (~0x80000000)) != 0 );
538 }
539 else
540 {
541 RTEST( puD3dBufferCallbacks->LockD3DBuffer == NULL);
542 }
543
544 if (puD3dBufferCallbacks->dwFlags & DDHAL_D3DBUFCB32_UNLOCKD3DBUF)
545 {
546 /* point to kmode direcly to the graphic drv, the drv is kmode and it is kmode address we getting back*/
547 RTEST( ( (DWORD_PTR)puD3dBufferCallbacks->UnlockD3DBuffer & (~0x80000000)) != 0 );
548 }
549 else
550 {
551 RTEST( puD3dBufferCallbacks->UnlockD3DBuffer == NULL);
552 }
553
554 /* Backup DD_D3DBUFCALLBACKS so we do not need resting it */
555 RtlCopyMemory(&oldD3dBufferCallbacks, &D3dBufferCallbacks, sizeof(DD_D3DBUFCALLBACKS));
556
557
558/* testing NtGdiDdQueryDirectDrawObject( hDD, pHalInfo, pCallBackFlags, puD3dCallbacks, puD3dDriverData, puD3dBufferCallbacks, puD3dTextureFormats, NULL, */
559 pHalInfo = &HalInfo;
560 pCallBackFlags = CallBackFlags;
561 puD3dCallbacks = &D3dCallbacks;
562 puD3dDriverData = &D3dDriverData;
563 puD3dBufferCallbacks = &D3dBufferCallbacks;
564
565 /* It is forbein to return a DDSURFACEDESC2 it should always be DDSURFACEDESC
566 This is only for detected bad drivers that does not follow the rules, if they
567 does not follow tthe rules, not everthing being copy then in gdi32.dll
568 gdi32.dll always assume it is DDSURFACEDESC size
569 */
570 if (puD3dDriverData->dwNumTextureFormats != 0)
571 {
572 puD3dTextureFormats = malloc (puD3dDriverData->dwNumTextureFormats * sizeof(DDSURFACEDESC2));
573 ASSERT(puD3dTextureFormats != NULL);
574 }
575
577 RtlZeroMemory(pCallBackFlags,sizeof(DWORD)*3);
578 RtlZeroMemory(puD3dCallbacks,sizeof(D3DNTHAL_CALLBACKS));
579 RtlZeroMemory(puD3dDriverData,sizeof(D3DNTHAL_GLOBALDRIVERDATA));
580 RtlZeroMemory(&D3dBufferCallbacks,sizeof(DD_D3DBUFCALLBACKS));
581
583 pCallBackFlags, puD3dCallbacks,
584 puD3dDriverData, puD3dBufferCallbacks,
585 puD3dTextureFormats, puNumHeaps,
586 puvmList, puNumFourCC,
587 puFourCC)== FALSE);
588
589 RTEST(pHalInfo != NULL);
590 ASSERT(pHalInfo != NULL);
591
592 RTEST(pCallBackFlags != NULL);
593 ASSERT(pCallBackFlags != NULL);
594
595 RTEST(puD3dCallbacks != NULL);
596 ASSERT(puD3dCallbacks != NULL);
597
598 RTEST(puD3dDriverData != NULL);
599 ASSERT(puD3dDriverData != NULL);
600
601 RTEST(puD3dBufferCallbacks != NULL);
602 ASSERT(puD3dDriverData != NULL);
603
604 RTEST(puNumFourCC == NULL);
605 RTEST(puFourCC == NULL);
606 RTEST(puNumHeaps == NULL);
607 RTEST(puvmList == NULL);
608
609 /* We retesting the flags */
610 //RTEST(pCallBackFlags[0] != 0);
611 //RTEST(pCallBackFlags[1] != 0);
612 RTEST(pCallBackFlags[2] == 0);
613
614 /* We do not retesting instead we compare it */
615 RTEST(memcmp(&oldHalInfo, pHalInfo, sizeof(DD_HALINFO)) == 0);
616 RTEST(memcmp(&oldD3dCallbacks, puD3dCallbacks, sizeof(D3DNTHAL_CALLBACKS)) == 0);
617 RTEST(memcmp(&oldD3dDriverData, puD3dDriverData, sizeof(D3DNTHAL_GLOBALDRIVERDATA)) == 0);
618 RTEST(memcmp(&oldD3dBufferCallbacks, puD3dBufferCallbacks, sizeof(DD_D3DBUFCALLBACKS)) == 0);
619
620 /* start test of dwNumTextureFormats */
621 if (puD3dDriverData->dwNumTextureFormats != 0)
622 {
623 myDesc = puD3dTextureFormats;
624 for (dwTextureCounter=0;dwTextureCounter<puD3dDriverData->dwNumTextureFormats;dwTextureCounter++)
625 {
626 RTEST(myDesc->dwSize == sizeof(DDSURFACEDESC));
627 ASSERT(myDesc->dwSize == sizeof(DDSURFACEDESC));
628
629 RTEST( (myDesc->dwFlags & (~(DDSD_CAPS|DDSD_PIXELFORMAT))) == 0);
630 RTEST(myDesc->dwHeight == 0);
631 RTEST(myDesc->dwWidth == 0);
632 RTEST(myDesc->dwLinearSize == 0);
633 RTEST(myDesc->dwBackBufferCount == 0);
634 RTEST(myDesc->dwZBufferBitDepth == 0);
635 RTEST(myDesc->dwAlphaBitDepth == 0);
636 RTEST(myDesc->dwReserved == 0);
637 RTEST(myDesc->lpSurface == 0);
638 RTEST(myDesc->ddckCKDestOverlay.dwColorSpaceLowValue == 0);
639 RTEST(myDesc->ddckCKDestOverlay.dwColorSpaceHighValue == 0);
640 RTEST(myDesc->ddckCKDestBlt.dwColorSpaceLowValue == 0);
641 RTEST(myDesc->ddckCKDestBlt.dwColorSpaceHighValue == 0);
642 RTEST(myDesc->ddckCKSrcOverlay.dwColorSpaceLowValue == 0);
643 RTEST(myDesc->ddckCKSrcOverlay.dwColorSpaceHighValue == 0);
644 RTEST(myDesc->ddckCKSrcBlt.dwColorSpaceLowValue == 0);
645 RTEST(myDesc->ddckCKSrcBlt.dwColorSpaceHighValue == 0);
646 RTEST(myDesc->ddpfPixelFormat.dwSize == sizeof(DDPIXELFORMAT));
647 RTEST(myDesc->ddpfPixelFormat.dwFlags != 0);
648 if (myDesc->ddpfPixelFormat.dwFlags & DDPF_FOURCC)
649 {
650 RTEST(myDesc->ddpfPixelFormat.dwFourCC != 0);
651 }
652 RTEST(myDesc->ddsCaps.dwCaps == DDSCAPS_TEXTURE);
653
654 myDesc = (DDSURFACEDESC *) (((DWORD_PTR) myDesc) + sizeof(DDSURFACEDESC));
655 }
656 }
657
658
659 /* testing NtGdiDdQueryDirectDrawObject( hDD, pHalInfo, pCallBackFlags, puD3dCallbacks, puD3dDriverData, puD3dBufferCallbacks, puD3dTextureFormats, puNumHeaps, NULL, */
660 pHalInfo = &HalInfo;
661 pCallBackFlags = CallBackFlags;
662 puD3dCallbacks = &D3dCallbacks;
663 puD3dDriverData = &D3dDriverData;
664 puD3dBufferCallbacks = &D3dBufferCallbacks;
665 puNumHeaps = &NumHeaps;
666
667 if (puD3dDriverData->dwNumTextureFormats != 0)
668 {
669 RtlZeroMemory(puD3dTextureFormats, puD3dDriverData->dwNumTextureFormats * sizeof(DDSURFACEDESC2));
670 }
672 RtlZeroMemory(pCallBackFlags,sizeof(DWORD)*3);
673 RtlZeroMemory(puD3dCallbacks,sizeof(D3DNTHAL_CALLBACKS));
674 RtlZeroMemory(puD3dDriverData,sizeof(D3DNTHAL_GLOBALDRIVERDATA));
675 RtlZeroMemory(&D3dBufferCallbacks,sizeof(DD_D3DBUFCALLBACKS));
676
678 pCallBackFlags, puD3dCallbacks,
679 puD3dDriverData, puD3dBufferCallbacks,
680 puD3dTextureFormats, puNumHeaps,
681 puvmList, puNumFourCC,
682 puFourCC)== FALSE);
683
684 RTEST(pHalInfo != NULL);
685 ASSERT(pHalInfo != NULL);
686
687 RTEST(pCallBackFlags != NULL);
688 ASSERT(pCallBackFlags != NULL);
689
690 RTEST(puD3dCallbacks != NULL);
691 ASSERT(puD3dCallbacks != NULL);
692
693 RTEST(puD3dDriverData != NULL);
694 ASSERT(puD3dDriverData != NULL);
695
696 RTEST(puD3dBufferCallbacks != NULL);
697 ASSERT(puD3dDriverData != NULL);
698
699 RTEST(puNumHeaps != NULL);
700 ASSERT(puNumHeaps != NULL);
701 RTEST(NumHeaps == 0);
702
703 RTEST(puNumFourCC == NULL);
704 RTEST(puFourCC == NULL);
705
706 RTEST(puvmList == NULL);
707
708 /* We retesting the flags */
709 //RTEST(pCallBackFlags[0] != 0);
710 //RTEST(pCallBackFlags[1] != 0);
711 RTEST(pCallBackFlags[2] == 0);
712
713 /* We do not retesting instead we compare it */
714 RTEST(memcmp(&oldHalInfo, pHalInfo, sizeof(DD_HALINFO)) == 0);
715 RTEST(memcmp(&oldD3dCallbacks, puD3dCallbacks, sizeof(D3DNTHAL_CALLBACKS)) == 0);
716 RTEST(memcmp(&oldD3dDriverData, puD3dDriverData, sizeof(D3DNTHAL_GLOBALDRIVERDATA)) == 0);
717 RTEST(memcmp(&oldD3dBufferCallbacks, puD3dBufferCallbacks, sizeof(DD_D3DBUFCALLBACKS)) == 0);
718 /* we skip resting texture */
719
720
721 /* testing NtGdiDdQueryDirectDrawObject( hDD, pHalInfo, pCallBackFlags, puD3dCallbacks, puD3dDriverData, puD3dBufferCallbacks, puD3dTextureFormats, puNumHeaps, puvmList, NULL, */
722 pHalInfo = &HalInfo;
723 pCallBackFlags = CallBackFlags;
724 puD3dCallbacks = &D3dCallbacks;
725 puD3dDriverData = &D3dDriverData;
726 puD3dBufferCallbacks = &D3dBufferCallbacks;
727 puNumHeaps = &NumHeaps;
728 puvmList = &vmList;
729
730 if (puD3dDriverData->dwNumTextureFormats != 0)
731 {
732 RtlZeroMemory(puD3dTextureFormats, puD3dDriverData->dwNumTextureFormats * sizeof(DDSURFACEDESC2));
733 }
735 RtlZeroMemory(pCallBackFlags,sizeof(DWORD)*3);
736 RtlZeroMemory(puD3dCallbacks,sizeof(D3DNTHAL_CALLBACKS));
737 RtlZeroMemory(puD3dDriverData,sizeof(D3DNTHAL_GLOBALDRIVERDATA));
738 RtlZeroMemory(&D3dBufferCallbacks,sizeof(DD_D3DBUFCALLBACKS));
739
741 pCallBackFlags, puD3dCallbacks,
742 puD3dDriverData, puD3dBufferCallbacks,
743 puD3dTextureFormats, puNumHeaps,
744 puvmList, puNumFourCC,
745 puFourCC)== FALSE);
746
747 RTEST(pHalInfo != NULL);
748 ASSERT(pHalInfo != NULL);
749
750 RTEST(pCallBackFlags != NULL);
751 ASSERT(pCallBackFlags != NULL);
752
753 RTEST(puD3dCallbacks != NULL);
754 ASSERT(puD3dCallbacks != NULL);
755
756 RTEST(puD3dDriverData != NULL);
757 ASSERT(puD3dDriverData != NULL);
758
759 RTEST(puD3dBufferCallbacks != NULL);
760 ASSERT(puD3dDriverData != NULL);
761
762 RTEST(puNumHeaps != NULL);
763 ASSERT(puNumHeaps != NULL);
764 RTEST(NumHeaps == 0);
765
766 RTEST(puvmList != NULL);
767
768 RTEST(puNumFourCC == NULL);
769 RTEST(puFourCC == NULL);
770
771
772
773 /* We retesting the flags */
774 //RTEST(pCallBackFlags[0] != 0);
775 //RTEST(pCallBackFlags[1] != 0);
776 RTEST(pCallBackFlags[2] == 0);
777
778 /* We do not retesting instead we compare it */
779 RTEST(memcmp(&oldHalInfo, pHalInfo, sizeof(DD_HALINFO)) == 0);
780 RTEST(memcmp(&oldD3dCallbacks, puD3dCallbacks, sizeof(D3DNTHAL_CALLBACKS)) == 0);
781 RTEST(memcmp(&oldD3dDriverData, puD3dDriverData, sizeof(D3DNTHAL_GLOBALDRIVERDATA)) == 0);
782 RTEST(memcmp(&oldD3dBufferCallbacks, puD3dBufferCallbacks, sizeof(DD_D3DBUFCALLBACKS)) == 0);
783 /* we skip resting texture */
784
785 /* Todo
786 * adding test for
787 * puNumFourCC
788 * puFourCC
789 */
790
791 ok(NtGdiDdDeleteDirectDrawObject(hDirectDraw) == TRUE,
792 "NtGdiDdDeleteDirectDrawObject() failed\n");
793
794 ok(DeleteDC(hdc) != 0, "DeleteDC() failed\n");
795}
DEVMODEW devmode
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
void DDSURFACEDESC
Definition: amvideo.idl:25
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define DDHALINFO_GETDRIVERINFOSET
Definition: ddrawi.h:667
#define DDHALINFO_GETDRIVERINFO2
Definition: ddrawi.h:668
#define DDHAL_D3DBUFCB32_LOCKD3DBUF
Definition: ddrawint.h:1308
#define DDHAL_D3DBUFCB32_CANCREATED3DBUF
Definition: ddrawint.h:1305
#define DDHAL_D3DBUFCB32_DESTROYD3DBUF
Definition: ddrawint.h:1307
#define DDHAL_D3DBUFCB32_UNLOCKD3DBUF
Definition: ddrawint.h:1309
#define DDHAL_D3DBUFCB32_CREATED3DBUF
Definition: ddrawint.h:1306
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ASSERT(a)
Definition: mode.c:44
#define RTEST(x)
Definition: precomp.h:21
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
__kernel_entry W32KAPI BOOL APIENTRY NtGdiDdQueryDirectDrawObject(_In_ HANDLE hDirectDrawLocal, _Out_ PDD_HALINFO pHalInfo, _Out_writes_(3) DWORD *pCallBackFlags, _Out_opt_ LPD3DNTHAL_CALLBACKS puD3dCallbacks, _Out_opt_ LPD3DNTHAL_GLOBALDRIVERDATA puD3dDriverData, _Out_opt_ PDD_D3DBUFCALLBACKS puD3dBufferCallbacks, _Out_opt_ LPDDSURFACEDESC puD3dTextureFormats, _Out_ DWORD *puNumHeaps, _Out_opt_ VIDEOMEMORY *puvmList, _Out_ DWORD *puNumFourCC, _Out_opt_ DWORD *puFourCC)
__kernel_entry W32KAPI BOOL APIENTRY NtGdiDdDeleteDirectDrawObject(_In_ HANDLE hDirectDrawLocal)
__kernel_entry W32KAPI HANDLE APIENTRY NtGdiDdCreateDirectDrawObject(_In_ HDC hdc)
#define L(x)
Definition: ntvdm.h:50
#define DDPF_PALETTEINDEXEDTO8
Definition: ddraw.h:505
#define DDPF_PALETTEINDEXED4
Definition: ddraw.h:504
#define DDSD_PIXELFORMAT
Definition: ddraw.h:216
#define DDPF_PALETTEINDEXED2
Definition: ddraw.h:513
#define DDPF_YUV
Definition: ddraw.h:510
#define DDPF_FOURCC
Definition: ddraw.h:503
#define DDPF_RGB
Definition: ddraw.h:507
#define DDPF_PALETTEINDEXED1
Definition: ddraw.h:512
#define DDPF_PALETTEINDEXED8
Definition: ddraw.h:506
#define DDSCAPS_3DDEVICE
Definition: ddraw.h:263
#define DDSCAPS_TEXTURE
Definition: ddraw.h:262
#define DDSD_CAPS
Definition: ddraw.h:208
#define memset(x, y, z)
Definition: compat.h:39
ULONG_PTR dwReserved5
Definition: d3dnthal.h:166
LPD3DNTHAL_SCENECAPTURECB SceneCapture
Definition: d3dnthal.h:140
LPD3DNTHAL_TEXTURESWAPCB TextureSwap
Definition: d3dnthal.h:148
ULONG_PTR dwReserved
Definition: d3dnthal.h:145
ULONG_PTR dwReserved7
Definition: d3dnthal.h:168
ULONG_PTR dwReserved8
Definition: d3dnthal.h:169
ULONG_PTR dwReserved2
Definition: d3dnthal.h:163
LPD3DNTHAL_TEXTURECREATECB TextureCreate
Definition: d3dnthal.h:146
LPD3DNTHAL_TEXTUREGETSURFCB TextureGetSurf
Definition: d3dnthal.h:149
ULONG_PTR dwReserved6
Definition: d3dnthal.h:167
ULONG_PTR dwReserved0
Definition: d3dnthal.h:161
ULONG_PTR dwReserved1
Definition: d3dnthal.h:162
ULONG_PTR dwReserved4
Definition: d3dnthal.h:165
ULONG_PTR dwReserved9
Definition: d3dnthal.h:170
LPD3DNTHAL_TEXTUREDESTROYCB TextureDestroy
Definition: d3dnthal.h:147
LPD3DNTHAL_CONTEXTDESTROYALLCB ContextDestroyAll
Definition: d3dnthal.h:139
ULONG_PTR dwReserved3
Definition: d3dnthal.h:164
D3DNTHALDEVICEDESC_V1 hwCaps
Definition: d3dnthal.h:128
PDD_CANCREATESURFACE CanCreateD3DBuffer
Definition: ddrawint.h:1032
PDD_CREATESURFACE CreateD3DBuffer
Definition: ddrawint.h:1033
PDD_SURFCB_DESTROYSURFACE DestroyD3DBuffer
Definition: ddrawint.h:1034
PDD_SURFCB_LOCK LockD3DBuffer
Definition: ddrawint.h:1035
PDD_SURFCB_UNLOCK UnlockD3DBuffer
Definition: ddrawint.h:1036
DWORD dmBitsPerPel
Definition: wingdi.h:1647
DWORD dmPelsWidth
Definition: wingdi.h:1648
DWORD dmPelsHeight
Definition: wingdi.h:1649
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
BOOL WINAPI EnumDisplaySettingsA(LPCSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEA lpDevMode)
Definition: display.c:312
_Out_ DD_HALINFO * pHalInfo
Definition: winddi.h:4226
BOOL WINAPI DeleteDC(_In_ HDC)
HDC WINAPI CreateDCW(_In_opt_ LPCWSTR pszDriver, _In_opt_ LPCWSTR pszDevice, _In_opt_ LPCWSTR psz, _In_opt_ const DEVMODEW *pdmInit)
#define ENUM_CURRENT_SETTINGS
Definition: winuser.h:179