71a4e4a0c9e9c201a13354759d1fbbfc69a618ae
[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 /* if this fail we do not have a dx driver install acodring ms, some version of windows it
214 * is okay this fail and drv does then only support basic dx
215 */
216 RTEST( (pHalInfo->dwFlags & (DDHALINFO_GETDRIVERINFOSET | DDHALINFO_GETDRIVERINFO2)) != 0 );
217
218 /* point to kmode direcly to the graphic drv, the drv is kmode and it is kmode address we getting back*/
219 RTEST( ( (DWORD)pHalInfo->GetDriverInfo & (~0x80000000)) != 0 );
220 ASSERT( ((DWORD)pHalInfo->GetDriverInfo & (~0x80000000)) != 0 );
221
222 /* the pHalInfo->ddCaps.ddsCaps.dwCaps & DDSCAPS_3DDEVICE will be ignore, only way detect it proper follow code,
223 * 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
224 * if it windows 2000 or windows xp/2003
225 *
226 * point to kmode direcly to the win32k.sys, win32k.sys is kmode and it is kmode address we getting back
227 */
228 RTEST( ( (DWORD)pHalInfo->lpD3DGlobalDriverData & (~0x80000000)) != 0 );
229 RTEST( ( (DWORD)pHalInfo->lpD3DHALCallbacks & (~0x80000000)) != 0 );
230 RTEST( ( (DWORD)pHalInfo->lpD3DHALCallbacks & (~0x80000000)) != 0 );
231 }
232
233 /* Backup DD_HALINFO so we do not need resting it */
234 RtlCopyMemory(&oldHalInfo, &HalInfo, sizeof(DD_HALINFO));
235
236 /* testing NtGdiDdQueryDirectDrawObject( hDirectDrawLocal, pHalInfo, pCallBackFlags, NULL, .... */
237 pHalInfo = &HalInfo;
238 pCallBackFlags = CallBackFlags;
239 RtlZeroMemory(pHalInfo,sizeof(DD_HALINFO));
240
241 RTEST(NtGdiDdQueryDirectDrawObject( hDirectDraw, pHalInfo,
242 pCallBackFlags, puD3dCallbacks,
243 puD3dDriverData, puD3dBufferCallbacks,
244 puD3dTextureFormats, puNumHeaps,
245 puvmList, puNumFourCC,
246 puFourCC)== FALSE);
247 RTEST(pHalInfo != NULL);
248 ASSERT(pHalInfo != NULL);
249
250 RTEST(pCallBackFlags != NULL);
251 ASSERT(pCallBackFlags != NULL);
252
253 RTEST(puD3dCallbacks == NULL);
254 RTEST(puD3dDriverData == NULL);
255 RTEST(puD3dBufferCallbacks == NULL);
256 RTEST(puD3dTextureFormats == NULL);
257 RTEST(puNumFourCC == NULL);
258 RTEST(puFourCC == NULL);
259 RTEST(puNumHeaps == NULL);
260 RTEST(puvmList == NULL);
261
262 /* We do not retesting DD_HALINFO, instead we compare it */
263 RTEST(memcmp(&oldHalInfo, pHalInfo, sizeof(DD_HALINFO)) == 0);
264
265 /* Rember on some nivida drv the pCallBackFlags will not be set even they api exists in the drv
266 * known workaround is to check if the drv really return a kmode pointer for the drv functions
267 * we want to use.
268 */
269 RTEST(pCallBackFlags[0] != 0);
270 RTEST(pCallBackFlags[1] != 0);
271 RTEST(pCallBackFlags[2] == 0);
272
273 /* testing NtGdiDdQueryDirectDrawObject( hDirectDrawLocal, pHalInfo, pCallBackFlags, D3dCallbacks, NULL, .... */
274 pHalInfo = &HalInfo;
275 pCallBackFlags = CallBackFlags;
276 puD3dCallbacks = &D3dCallbacks;
277
278 RtlZeroMemory(pHalInfo,sizeof(DD_HALINFO));
279 RtlZeroMemory(pCallBackFlags,sizeof(DWORD)*3);
280
281 RTEST(NtGdiDdQueryDirectDrawObject( hDirectDraw, pHalInfo,
282 pCallBackFlags, puD3dCallbacks,
283 puD3dDriverData, puD3dBufferCallbacks,
284 puD3dTextureFormats, puNumHeaps,
285 puvmList, puNumFourCC,
286 puFourCC)== FALSE);
287 RTEST(pHalInfo != NULL);
288 ASSERT(pHalInfo != NULL);
289
290 RTEST(pCallBackFlags != NULL);
291 ASSERT(pCallBackFlags != NULL);
292
293 /* rember puD3dCallbacks shall never return NULL */
294 RTEST(puD3dCallbacks != NULL);
295 ASSERT(puD3dCallbacks != NULL);
296
297 /* the pHalInfo->ddCaps.ddsCaps.dwCaps & DDSCAPS_3DDEVICE will be ignore, only way detect it proper follow code,
298 * 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
299 * if it windows 2000 or windows xp/2003
300 */
301 RTEST(puD3dCallbacks->dwSize == sizeof(D3DNTHAL_CALLBACKS));
302
303 /* Nivda like GF7900GS will not follow ms design rule here,
304 * ContextDestroyAll must alwyas be NULL for it is not longer inuse in windows 2000 and higher
305 */
306 RTEST(puD3dCallbacks->ContextDestroyAll == NULL);
307
308 /* Nivda like GF7900GS will not follow ms design rule here,
309 * SceneCapture must alwyas be NULL for it is not longer inuse in windows 2000 and higher
310 */
311 RTEST(puD3dCallbacks->SceneCapture == NULL);
312 RTEST(puD3dCallbacks->dwReserved10 == 0);
313 RTEST(puD3dCallbacks->dwReserved11 == 0);
314 RTEST(puD3dCallbacks->dwReserved22 == 0);
315 RTEST(puD3dCallbacks->dwReserved23 == 0);
316 RTEST(puD3dCallbacks->dwReserved == 0);
317 RTEST(puD3dCallbacks->TextureCreate == NULL);
318 RTEST(puD3dCallbacks->TextureDestroy == NULL);
319 RTEST(puD3dCallbacks->TextureSwap == NULL);
320 RTEST(puD3dCallbacks->TextureGetSurf == NULL);
321 RTEST(puD3dCallbacks->dwReserved12 == 0);
322 RTEST(puD3dCallbacks->dwReserved13 == 0);
323 RTEST(puD3dCallbacks->dwReserved14 == 0);
324 RTEST(puD3dCallbacks->dwReserved15 == 0);
325 RTEST(puD3dCallbacks->dwReserved16 == 0);
326 RTEST(puD3dCallbacks->dwReserved17 == 0);
327 RTEST(puD3dCallbacks->dwReserved18 == 0);
328 RTEST(puD3dCallbacks->dwReserved19 == 0);
329 RTEST(puD3dCallbacks->dwReserved20 == 0);
330 RTEST(puD3dCallbacks->dwReserved21 == 0);
331 RTEST(puD3dCallbacks->dwReserved24 == 0);
332 RTEST(puD3dCallbacks->dwReserved0 == 0);
333 RTEST(puD3dCallbacks->dwReserved1 == 0);
334 RTEST(puD3dCallbacks->dwReserved2 == 0);
335 RTEST(puD3dCallbacks->dwReserved3 == 0);
336 RTEST(puD3dCallbacks->dwReserved4 == 0);
337 RTEST(puD3dCallbacks->dwReserved5 == 0);
338 RTEST(puD3dCallbacks->dwReserved6 == 0);
339 RTEST(puD3dCallbacks->dwReserved7 == 0);
340 RTEST(puD3dCallbacks->dwReserved8 == 0);
341 RTEST(puD3dCallbacks->dwReserved9 == 0);
342
343 /* how detect puD3dCallbacks->ContextCreate and puD3dCallbacks->ContextDestroy shall be set for bugi drv like nivda ? */
344 /* pointer direcly to the graphic drv, it is kmode pointer */
345 // RTEST( ( (DWORD)puD3dCallbacks->ContextCreate & (~0x80000000)) != 0 );
346 // RTEST( ( (DWORD)puD3dCallbacks->ContextDestroy & (~0x80000000)) != 0 );
347
348 RTEST(puD3dDriverData == NULL);
349 RTEST(puD3dBufferCallbacks == NULL);
350 RTEST(puD3dTextureFormats == NULL);
351 RTEST(puNumFourCC == NULL);
352 RTEST(puFourCC == NULL);
353 RTEST(puNumHeaps == NULL);
354 RTEST(puvmList == NULL);
355
356 /* We do not retesting DD_HALINFO, instead we compare it */
357 RTEST(memcmp(&oldHalInfo, pHalInfo, sizeof(DD_HALINFO)) == 0);
358 RTEST(pCallBackFlags[0] != 0);
359 RTEST(pCallBackFlags[1] != 0);
360 RTEST(pCallBackFlags[2] == 0);
361
362 /* Backup D3DNTHAL_CALLBACKS so we do not need resting it */
363 RtlCopyMemory(&oldD3dCallbacks, &D3dCallbacks, sizeof(D3DNTHAL_CALLBACKS));
364
365
366 /* testing NtGdiDdQueryDirectDrawObject( hDD, pHalInfo, pCallBackFlags, puD3dCallbacks, puD3dDriverData, NULL, */
367 pHalInfo = &HalInfo;
368 pCallBackFlags = CallBackFlags;
369 puD3dCallbacks = &D3dCallbacks;
370 puD3dDriverData = &D3dDriverData;
371
372 RtlZeroMemory(pHalInfo,sizeof(DD_HALINFO));
373 RtlZeroMemory(pCallBackFlags,sizeof(DWORD)*3);
374 RtlZeroMemory(puD3dCallbacks,sizeof(D3DNTHAL_CALLBACKS));
375
376 RTEST(NtGdiDdQueryDirectDrawObject( hDirectDraw, pHalInfo,
377 pCallBackFlags, puD3dCallbacks,
378 puD3dDriverData, puD3dBufferCallbacks,
379 puD3dTextureFormats, puNumHeaps,
380 puvmList, puNumFourCC,
381 puFourCC)== FALSE);
382 RTEST(pHalInfo != NULL);
383 ASSERT(pHalInfo != NULL);
384
385 RTEST(pCallBackFlags != NULL);
386 ASSERT(pCallBackFlags != NULL);
387
388 RTEST(puD3dCallbacks != NULL);
389 ASSERT(puD3dCallbacks != NULL);
390
391 RTEST(puD3dDriverData != NULL);
392 ASSERT(puD3dDriverData != NULL);
393
394 RTEST(puD3dBufferCallbacks == NULL);
395 RTEST(puD3dTextureFormats == NULL);
396 RTEST(puNumFourCC == NULL);
397 RTEST(puFourCC == NULL);
398 RTEST(puNumHeaps == NULL);
399 RTEST(puvmList == NULL);
400
401 /* We retesting pCallBackFlags */
402 RTEST(pCallBackFlags[0] != 0);
403 RTEST(pCallBackFlags[1] != 0);
404 RTEST(pCallBackFlags[2] == 0);
405
406 /* We do not retesting instead we compare it */
407 RTEST(memcmp(&oldHalInfo, pHalInfo, sizeof(DD_HALINFO)) == 0);
408 RTEST(memcmp(&oldD3dCallbacks, puD3dCallbacks, sizeof(D3DNTHAL_CALLBACKS)) == 0);
409
410 /* start test of puD3dDriverData */
411
412 RTEST(puD3dDriverData->dwSize == sizeof(D3DNTHAL_GLOBALDRIVERDATA));
413 RTEST(puD3dDriverData->hwCaps.dwSize == sizeof(D3DNTHALDEVICEDESC_V1));
414 RTEST(puD3dDriverData->hwCaps.dtcTransformCaps.dwSize == sizeof(D3DTRANSFORMCAPS));
415 RTEST(puD3dDriverData->hwCaps.dlcLightingCaps.dwSize == sizeof(D3DLIGHTINGCAPS));
416 RTEST(puD3dDriverData->hwCaps.dpcLineCaps.dwSize == sizeof(D3DPRIMCAPS));
417 RTEST(puD3dDriverData->hwCaps.dpcTriCaps.dwSize == sizeof(D3DPRIMCAPS));
418 RTEST(puD3dDriverData->hwCaps.dwMaxBufferSize == 0);
419 RTEST(puD3dDriverData->hwCaps.dwMaxVertexCount == 0);
420
421 /* Backup D3DHAL_GLOBALDRIVERDATA so we do not need resting it */
422 RtlCopyMemory(&oldD3dDriverData, &D3dDriverData, sizeof(D3DNTHAL_GLOBALDRIVERDATA));
423
424 /* testing NtGdiDdQueryDirectDrawObject( hDD, pHalInfo, pCallBackFlags, puD3dCallbacks, puD3dDriverData, puD3dBufferCallbacks, NULL, */
425 pHalInfo = &HalInfo;
426 pCallBackFlags = CallBackFlags;
427 puD3dCallbacks = &D3dCallbacks;
428 puD3dDriverData = &D3dDriverData;
429 puD3dBufferCallbacks = &D3dBufferCallbacks;
430
431 RtlZeroMemory(pHalInfo,sizeof(DD_HALINFO));
432 RtlZeroMemory(pCallBackFlags,sizeof(DWORD)*3);
433 RtlZeroMemory(puD3dCallbacks,sizeof(D3DNTHAL_CALLBACKS));
434 RtlZeroMemory(puD3dDriverData,sizeof(D3DNTHAL_CALLBACKS));
435
436 RTEST(NtGdiDdQueryDirectDrawObject( hDirectDraw, pHalInfo,
437 pCallBackFlags, puD3dCallbacks,
438 puD3dDriverData, puD3dBufferCallbacks,
439 puD3dTextureFormats, puNumHeaps,
440 puvmList, puNumFourCC,
441 puFourCC)== FALSE);
442 RTEST(pHalInfo != NULL);
443 RTEST(pCallBackFlags != NULL);
444
445 if (pHalInfo->ddCaps.ddsCaps.dwCaps & DDSCAPS_3DDEVICE )
446 {
447 RTEST(puD3dCallbacks != NULL);
448 RTEST(puD3dDriverData != NULL);
449 RTEST(puD3dBufferCallbacks != NULL);
450 }
451
452 RTEST(pHalInfo != NULL);
453 ASSERT(pHalInfo != NULL);
454
455 RTEST(pCallBackFlags != NULL);
456 ASSERT(pCallBackFlags != NULL);
457
458 RTEST(puD3dCallbacks != NULL);
459 ASSERT(puD3dCallbacks != NULL);
460
461 RTEST(puD3dDriverData != NULL);
462 ASSERT(puD3dDriverData != NULL);
463
464 RTEST(puD3dBufferCallbacks != NULL);
465 ASSERT(puD3dDriverData != NULL);
466
467 RTEST(puD3dTextureFormats == NULL);
468 RTEST(puNumFourCC == NULL);
469 RTEST(puFourCC == NULL);
470 RTEST(puNumHeaps == NULL);
471 RTEST(puvmList == NULL);
472
473 /* We retesting the flags */
474 RTEST(pCallBackFlags[0] != 0);
475 RTEST(pCallBackFlags[1] != 0);
476 RTEST(pCallBackFlags[2] == 0);
477
478 /* We do not retesting instead we compare it */
479 RTEST(memcmp(&oldHalInfo, pHalInfo, sizeof(DD_HALINFO)) == 0);
480 RTEST(memcmp(&oldD3dCallbacks, puD3dCallbacks, sizeof(D3DNTHAL_CALLBACKS)) == 0);
481 RTEST(memcmp(&oldD3dDriverData, puD3dDriverData, sizeof(D3DNTHAL_GLOBALDRIVERDATA)) == 0);
482
483 /* start test of puD3dBufferCallbacks */
484 RTEST(puD3dBufferCallbacks->dwSize == sizeof(DD_D3DBUFCALLBACKS));
485 if (puD3dBufferCallbacks->dwFlags & DDHAL_D3DBUFCB32_CANCREATED3DBUF)
486 {
487 /* point to kmode direcly to the graphic drv, the drv is kmode and it is kmode address we getting back*/
488 RTEST( ( (DWORD)puD3dBufferCallbacks->CanCreateD3DBuffer & (~0x80000000)) != 0 );
489 }
490 else
491 {
492 RTEST( puD3dBufferCallbacks->CanCreateD3DBuffer == NULL);
493 }
494
495 if (puD3dBufferCallbacks->dwFlags & DDHAL_D3DBUFCB32_CREATED3DBUF)
496 {
497 /* point to kmode direcly to the graphic drv, the drv is kmode and it is kmode address we getting back*/
498 RTEST( ( (DWORD)puD3dBufferCallbacks->CreateD3DBuffer & (~0x80000000)) != 0 );
499 }
500 else
501 {
502 RTEST( puD3dBufferCallbacks->CreateD3DBuffer == NULL);
503 }
504
505 if (puD3dBufferCallbacks->dwFlags & DDHAL_D3DBUFCB32_DESTROYD3DBUF)
506 {
507 /* point to kmode direcly to the graphic drv, the drv is kmode and it is kmode address we getting back*/
508 RTEST( ( (DWORD)puD3dBufferCallbacks->DestroyD3DBuffer & (~0x80000000)) != 0 );
509 }
510 else
511 {
512 RTEST( puD3dBufferCallbacks->DestroyD3DBuffer == NULL);
513 }
514
515 if (puD3dBufferCallbacks->dwFlags & DDHAL_D3DBUFCB32_LOCKD3DBUF)
516 {
517 /* point to kmode direcly to the graphic drv, the drv is kmode and it is kmode address we getting back*/
518 RTEST( ( (DWORD)puD3dBufferCallbacks->LockD3DBuffer & (~0x80000000)) != 0 );
519 }
520 else
521 {
522 RTEST( puD3dBufferCallbacks->LockD3DBuffer == NULL);
523 }
524
525 if (puD3dBufferCallbacks->dwFlags & DDHAL_D3DBUFCB32_UNLOCKD3DBUF)
526 {
527 /* point to kmode direcly to the graphic drv, the drv is kmode and it is kmode address we getting back*/
528 RTEST( ( (DWORD)puD3dBufferCallbacks->UnlockD3DBuffer & (~0x80000000)) != 0 );
529 }
530 else
531 {
532 RTEST( puD3dBufferCallbacks->UnlockD3DBuffer == NULL);
533 }
534
535 /* Backup DD_D3DBUFCALLBACKS so we do not need resting it */
536 RtlCopyMemory(&oldD3dBufferCallbacks, &D3dBufferCallbacks, sizeof(DD_D3DBUFCALLBACKS));
537
538
539 /* testing NtGdiDdQueryDirectDrawObject( hDD, pHalInfo, pCallBackFlags, puD3dCallbacks, puD3dDriverData, puD3dBufferCallbacks, puD3dTextureFormats, NULL, */
540 pHalInfo = &HalInfo;
541 pCallBackFlags = CallBackFlags;
542 puD3dCallbacks = &D3dCallbacks;
543 puD3dDriverData = &D3dDriverData;
544 puD3dBufferCallbacks = &D3dBufferCallbacks;
545
546 /* It is forbein to return a DDSURFACEDESC2 it should always be DDSURFACEDESC
547 This is only for detected bad drivers that does not follow the rules, if they
548 does not follow tthe rules, not everthing being copy then in gdi32.dll
549 gdi32.dll always assume it is DDSURFACEDESC size
550 */
551 if (puD3dDriverData->dwNumTextureFormats != 0)
552 {
553 puD3dTextureFormats = malloc (puD3dDriverData->dwNumTextureFormats * sizeof(DDSURFACEDESC2));
554 }
555
556 RtlZeroMemory(pHalInfo,sizeof(DD_HALINFO));
557 RtlZeroMemory(pCallBackFlags,sizeof(DWORD)*3);
558 RtlZeroMemory(puD3dCallbacks,sizeof(D3DNTHAL_CALLBACKS));
559 RtlZeroMemory(puD3dDriverData,sizeof(D3DNTHAL_GLOBALDRIVERDATA));
560 RtlZeroMemory(&D3dBufferCallbacks,sizeof(DD_D3DBUFCALLBACKS));
561
562 RTEST(NtGdiDdQueryDirectDrawObject( hDirectDraw, pHalInfo,
563 pCallBackFlags, puD3dCallbacks,
564 puD3dDriverData, puD3dBufferCallbacks,
565 puD3dTextureFormats, puNumHeaps,
566 puvmList, puNumFourCC,
567 puFourCC)== FALSE);
568
569 RTEST(pHalInfo != NULL);
570 ASSERT(pHalInfo != NULL);
571
572 RTEST(pCallBackFlags != NULL);
573 ASSERT(pCallBackFlags != NULL);
574
575 RTEST(puD3dCallbacks != NULL);
576 ASSERT(puD3dCallbacks != NULL);
577
578 RTEST(puD3dDriverData != NULL);
579 ASSERT(puD3dDriverData != NULL);
580
581 RTEST(puD3dBufferCallbacks != NULL);
582 ASSERT(puD3dDriverData != NULL);
583
584 RTEST(puD3dTextureFormats != NULL);
585 ASSERT(puD3dTextureFormats != NULL);
586
587 RTEST(puNumFourCC == NULL);
588 RTEST(puFourCC == NULL);
589 RTEST(puNumHeaps == NULL);
590 RTEST(puvmList == NULL);
591
592 /* We retesting the flags */
593 RTEST(pCallBackFlags[0] != 0);
594 RTEST(pCallBackFlags[1] != 0);
595 RTEST(pCallBackFlags[2] == 0);
596
597 /* We do not retesting instead we compare it */
598 RTEST(memcmp(&oldHalInfo, pHalInfo, sizeof(DD_HALINFO)) == 0);
599 RTEST(memcmp(&oldD3dCallbacks, puD3dCallbacks, sizeof(D3DNTHAL_CALLBACKS)) == 0);
600 RTEST(memcmp(&oldD3dDriverData, puD3dDriverData, sizeof(D3DNTHAL_GLOBALDRIVERDATA)) == 0);
601 RTEST(memcmp(&oldD3dBufferCallbacks, puD3dBufferCallbacks, sizeof(DD_D3DBUFCALLBACKS)) == 0);
602
603 /* start test of dwNumTextureFormats */
604 if (puD3dDriverData->dwNumTextureFormats != 0)
605 {
606 myDesc = puD3dTextureFormats;
607 for (dwTextureCounter=0;dwTextureCounter<puD3dDriverData->dwNumTextureFormats;dwTextureCounter++)
608 {
609 RTEST(myDesc->dwSize == sizeof(DDSURFACEDESC))
610 ASSERT(myDesc->dwSize == sizeof(DDSURFACEDESC));
611
612 RTEST( (myDesc->dwFlags & (~(DDSD_CAPS|DDSD_PIXELFORMAT))) == 0);
613 RTEST(myDesc->dwHeight == 0);
614 RTEST(myDesc->dwWidth == 0);
615 RTEST(myDesc->dwLinearSize == 0);
616 RTEST(myDesc->dwBackBufferCount == 0);
617 RTEST(myDesc->dwZBufferBitDepth == 0);
618 RTEST(myDesc->dwAlphaBitDepth == 0);
619 RTEST(myDesc->dwReserved == 0);
620 RTEST(myDesc->lpSurface == 0);
621 RTEST(myDesc->ddckCKDestOverlay.dwColorSpaceLowValue == 0);
622 RTEST(myDesc->ddckCKDestOverlay.dwColorSpaceHighValue == 0);
623 RTEST(myDesc->ddckCKDestBlt.dwColorSpaceLowValue == 0);
624 RTEST(myDesc->ddckCKDestBlt.dwColorSpaceHighValue == 0);
625 RTEST(myDesc->ddckCKSrcOverlay.dwColorSpaceLowValue == 0);
626 RTEST(myDesc->ddckCKSrcOverlay.dwColorSpaceHighValue == 0);
627 RTEST(myDesc->ddckCKSrcBlt.dwColorSpaceLowValue == 0);
628 RTEST(myDesc->ddckCKSrcBlt.dwColorSpaceHighValue == 0);
629 RTEST(myDesc->ddpfPixelFormat.dwSize == sizeof(DDPIXELFORMAT));
630 RTEST(myDesc->ddpfPixelFormat.dwFlags != 0);
631 if (myDesc->ddpfPixelFormat.dwFlags & DDPF_FOURCC)
632 {
633 RTEST(myDesc->ddpfPixelFormat.dwFourCC != 0);
634 }
635 RTEST(myDesc->ddsCaps.dwCaps == DDSCAPS_TEXTURE);
636
637 myDesc = (DDSURFACEDESC *) (((DWORD) myDesc) + sizeof(DDSURFACEDESC));
638 }
639 }
640
641
642 /* testing NtGdiDdQueryDirectDrawObject( hDD, pHalInfo, pCallBackFlags, puD3dCallbacks, puD3dDriverData, puD3dBufferCallbacks, puD3dTextureFormats, puNumHeaps, NULL, */
643 pHalInfo = &HalInfo;
644 pCallBackFlags = CallBackFlags;
645 puD3dCallbacks = &D3dCallbacks;
646 puD3dDriverData = &D3dDriverData;
647 puD3dBufferCallbacks = &D3dBufferCallbacks;
648 puNumHeaps = &NumHeaps;
649
650 if (puD3dDriverData->dwNumTextureFormats != 0)
651 {
652 RtlZeroMemory(puD3dTextureFormats, puD3dDriverData->dwNumTextureFormats * sizeof(DDSURFACEDESC2));
653 }
654 RtlZeroMemory(pHalInfo,sizeof(DD_HALINFO));
655 RtlZeroMemory(pCallBackFlags,sizeof(DWORD)*3);
656 RtlZeroMemory(puD3dCallbacks,sizeof(D3DNTHAL_CALLBACKS));
657 RtlZeroMemory(puD3dDriverData,sizeof(D3DNTHAL_GLOBALDRIVERDATA));
658 RtlZeroMemory(&D3dBufferCallbacks,sizeof(DD_D3DBUFCALLBACKS));
659
660 RTEST(NtGdiDdQueryDirectDrawObject( hDirectDraw, pHalInfo,
661 pCallBackFlags, puD3dCallbacks,
662 puD3dDriverData, puD3dBufferCallbacks,
663 puD3dTextureFormats, puNumHeaps,
664 puvmList, puNumFourCC,
665 puFourCC)== FALSE);
666
667 RTEST(pHalInfo != NULL);
668 ASSERT(pHalInfo != NULL);
669
670 RTEST(pCallBackFlags != NULL);
671 ASSERT(pCallBackFlags != NULL);
672
673 RTEST(puD3dCallbacks != NULL);
674 ASSERT(puD3dCallbacks != NULL);
675
676 RTEST(puD3dDriverData != NULL);
677 ASSERT(puD3dDriverData != NULL);
678
679 RTEST(puD3dBufferCallbacks != NULL);
680 ASSERT(puD3dDriverData != NULL);
681
682 RTEST(puD3dTextureFormats != NULL);
683 ASSERT(puD3dTextureFormats != NULL);
684
685 RTEST(puNumHeaps != NULL);
686 ASSERT(puNumHeaps != NULL);
687 RTEST(NumHeaps == 0);
688
689 RTEST(puNumFourCC == NULL);
690 RTEST(puFourCC == NULL);
691
692 RTEST(puvmList == NULL);
693
694 /* We retesting the flags */
695 RTEST(pCallBackFlags[0] != 0);
696 RTEST(pCallBackFlags[1] != 0);
697 RTEST(pCallBackFlags[2] == 0);
698
699 /* We do not retesting instead we compare it */
700 RTEST(memcmp(&oldHalInfo, pHalInfo, sizeof(DD_HALINFO)) == 0);
701 RTEST(memcmp(&oldD3dCallbacks, puD3dCallbacks, sizeof(D3DNTHAL_CALLBACKS)) == 0);
702 RTEST(memcmp(&oldD3dDriverData, puD3dDriverData, sizeof(D3DNTHAL_GLOBALDRIVERDATA)) == 0);
703 RTEST(memcmp(&oldD3dBufferCallbacks, puD3dBufferCallbacks, sizeof(DD_D3DBUFCALLBACKS)) == 0);
704 /* we skip resting texture */
705
706
707 /* testing NtGdiDdQueryDirectDrawObject( hDD, pHalInfo, pCallBackFlags, puD3dCallbacks, puD3dDriverData, puD3dBufferCallbacks, puD3dTextureFormats, puNumHeaps, puvmList, NULL, */
708 pHalInfo = &HalInfo;
709 pCallBackFlags = CallBackFlags;
710 puD3dCallbacks = &D3dCallbacks;
711 puD3dDriverData = &D3dDriverData;
712 puD3dBufferCallbacks = &D3dBufferCallbacks;
713 puNumHeaps = &NumHeaps;
714 puvmList = &vmList;
715
716 if (puD3dDriverData->dwNumTextureFormats != 0)
717 {
718 RtlZeroMemory(puD3dTextureFormats, puD3dDriverData->dwNumTextureFormats * sizeof(DDSURFACEDESC2));
719 }
720 RtlZeroMemory(pHalInfo,sizeof(DD_HALINFO));
721 RtlZeroMemory(pCallBackFlags,sizeof(DWORD)*3);
722 RtlZeroMemory(puD3dCallbacks,sizeof(D3DNTHAL_CALLBACKS));
723 RtlZeroMemory(puD3dDriverData,sizeof(D3DNTHAL_GLOBALDRIVERDATA));
724 RtlZeroMemory(&D3dBufferCallbacks,sizeof(DD_D3DBUFCALLBACKS));
725
726 RTEST(NtGdiDdQueryDirectDrawObject( hDirectDraw, pHalInfo,
727 pCallBackFlags, puD3dCallbacks,
728 puD3dDriverData, puD3dBufferCallbacks,
729 puD3dTextureFormats, puNumHeaps,
730 puvmList, puNumFourCC,
731 puFourCC)== FALSE);
732
733 RTEST(pHalInfo != NULL);
734 ASSERT(pHalInfo != NULL);
735
736 RTEST(pCallBackFlags != NULL);
737 ASSERT(pCallBackFlags != NULL);
738
739 RTEST(puD3dCallbacks != NULL);
740 ASSERT(puD3dCallbacks != NULL);
741
742 RTEST(puD3dDriverData != NULL);
743 ASSERT(puD3dDriverData != NULL);
744
745 RTEST(puD3dBufferCallbacks != NULL);
746 ASSERT(puD3dDriverData != NULL);
747
748 RTEST(puD3dTextureFormats != NULL);
749 ASSERT(puD3dTextureFormats != NULL);
750
751 RTEST(puNumHeaps != NULL);
752 ASSERT(puNumHeaps != NULL);
753 RTEST(NumHeaps == 0);
754
755 RTEST(puvmList != NULL);
756
757 RTEST(puNumFourCC == NULL);
758 RTEST(puFourCC == NULL);
759
760
761
762 /* We retesting the flags */
763 RTEST(pCallBackFlags[0] != 0);
764 RTEST(pCallBackFlags[1] != 0);
765 RTEST(pCallBackFlags[2] == 0);
766
767 /* We do not retesting instead we compare it */
768 RTEST(memcmp(&oldHalInfo, pHalInfo, sizeof(DD_HALINFO)) == 0);
769 RTEST(memcmp(&oldD3dCallbacks, puD3dCallbacks, sizeof(D3DNTHAL_CALLBACKS)) == 0);
770 RTEST(memcmp(&oldD3dDriverData, puD3dDriverData, sizeof(D3DNTHAL_GLOBALDRIVERDATA)) == 0);
771 RTEST(memcmp(&oldD3dBufferCallbacks, puD3dBufferCallbacks, sizeof(DD_D3DBUFCALLBACKS)) == 0);
772 /* we skip resting texture */
773
774 /* Todo
775 * adding test for
776 * puNumFourCC
777 * puFourCC
778 */
779
780 /* Cleanup ReactX setup */
781 DeleteDC(hdc);
782 Syscall(L"NtGdiDdDeleteDirectDrawObject", 1, &hDirectDraw);
783
784 return APISTATUS_NORMAL;
785 }