The function NtGdiDdCanCreateD3DBuffer checks if you can create a surface for DirectX. It redirects to dxg.sys in Windows XP/2003, dxkrnl.sys in Vista and is fully implemented in win32k.sys in Windows 2000 and below.
DWORD STDCALL NtGdiDdCanCreateD3DBuffer( HANDLE hDirectDraw, PDD_CANCREATESURFACEDATA puCanCreateSurfaceData)
- HANDLE hDirectDraw
- The handle we receive from NtGdiDdCreateDirectDrawObject
- PDD_CANCREATESURFACEDATA puCanCreateSurfaceData
- This contains information to check if the driver can create buffers, surfaces, textures and vertexes, and how many of each the driver can create.
Depending on whether the driver supports this function or not, DDHAL_DRIVER_HANDLED or DDHAL_DRIVER_NOTHANDLED is returned respectively.
To check if the function has been successful, do a full check by seeing if the return value is DDHAL_DRIVER_HANDLED and puCanCreateSurfaceData->ddRVal is set to DD_OK.
NtGdiDdCanCreateD3DBuffer and NtGdiDdCanCreateSurface calls are redirected to the same function in dxg.sys. For proof, examine the memory addresses on the driver list functions table and you will see they are pointed to the same memory address.
Before calling this function please set the puCanCreateSurfaceData->ddRVal to an error value such as DDERR_NOTSUPPORTED, for the ddRVal will otherwise be unchanged even if an error occurs inside the driver.
puCanCreateSurfaceData->lpDD is a pointer to DDRAWI_DIRECTDRAW_GBL, not PDD_DIRECTDRAW_GLOBAL as MSDN claims.
puCanCreateSurfaceData->lpDD->hDD also needs be filled in with the handle we receive from NtGdiDdCreateDirectDrawObject.
puCreateSurfaceData->CanCreateSurface is a pointer to the real functions in the HAL or HEL that you need to fill in.
Do not forget that PDD_CANCREATESURFACEDATA is a typecast of LPDDHAL_CANCREATESURFACEDATA and these two structs are different size. The correct struct is LPDDHAL_CANCREATESURFACEDATA.