BOOL STDCALL NtGdiD3dContextCreate( HANDLE hDirectDrawLocal, HANDLE hSurfColor, HANDLE hSurfZ, D3DNTHAL_CONTEXTCREATEDATA* pdcci)
The Function NtGdiD3dContextCreate checks if you can create a context 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.
- HANDLE hDirectDrawLocal
- The handle we receive from NtGdiDdCreateDirectDrawObject
- HANDLE hSurfColor
- Handle to DD_SURFACE_LOCAL to be used for the rendering target
- HANDLE hSurfZ
- Handle to a DD_SURFACE_LOCAL. It is the Z deep buffer.
- According MSDN if it is set to NULL nothing should happen.
- LPD3DNTHAL_CONTEXTCREATEDATA pdcci
- The buffer to create the context data
- DDHAL_DRIVER_HANDLED or DDHAL_DRIVER_NOTHANDLED if the driver supports this function.
- A full check is done by checking if the return value is DDHAL_DRIVER_HANDLED
To check if the function has been successful, do a full check by seeing if the return value is DDHAL_DRIVER_HANDLED and pdcci->ddRVal is set to DD_OK.
dxg.sys NtGdiD3dContextCreate calls are redirected to the same function in the dxg.sys. As such they all work the same way.
Before calling this function set the pdcci->ddRVal to an error value such as DDERR_NOTSUPORTED, or the ddRVal will otherwise be unchanged, even if an error occurs inside the driver.
- pdcci->lpDDLcl is a pointer to DDRAWI_DIRECTDRAW_LCL, not DD_DIRECTDRAW_LOCAL as MSDN claims.
- pdcci->lpDDSLcl is a pointer to DDRAWI_DDRAWSURFACE_LCL, not DD_DDDRAWSURFACE_LOCAL as MSDN claims.
- pdcci->lpDDSZLcl is a pointer to DDRAWI_DDRAWSURFACE_LCL, not DD_DDRAWSURFACE_LOCAL as MSDN claims.
- pdcci->dwhContext also needs to be filled with the handle we receive from NtGdiDdCreateDirectDrawObject.
- pdcci->dwPID is the ProcessId it belongs to, that you need to fill in.
Do not forget that LPD3DNTHAL_CONTEXTCREATEDATA is typecasted to LPD3DHAL_CONTEXTCREATEDATA and those two structs are of different size. The correct struct is LPD3DHAL_CONTEXTCREATEDATA.