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