Graphics Low-Level Client Support
[These functions are subject to change with each operating system revision. Instead, use the Microsoft DirectDraw and Microsoft Direct3DAPIs; these APIs insulate applications from such operating system changes, and hide many other difficulties involved in interacting directly with display drivers. For more information, see Introduction to Display.]
DirectDraw and Direct3D use some kernel-mode routines to communicate with the operating system and the display driver.
The operating system kernel appears to be a DirectDraw/Direct3D display driver from the point of view of user-mode components. Some differences between kernel and display drivers do exist however. The kernel mode components keep a copy of structures representing DirectDraw/Direct3D objects, such as devices and surfaces. The user mode component of DirectDraw/Direct3D request the creation of those structures, which are referred to with handles returned by kernel mode. Consequently, the differences are mostly in the arguments passed to the routines: kernel accepts handles whereas drivers typically accept pointers.
- Evolution of Kernel Mode Entry Points
- Calling the Kernel
- Writing Portable Applications
- Device Creation
- Kernel Objects
- Related topics
DirectDraw makes all of its connections to kernel mode through the Gdi32.dll using several entry points. These entry points typically just marshal parameters. As part of device creation, the Gdi32.dll returns pointers to routines within itself that are then used by DirectDraw and Direct3D 7.0.
Direct3D 8.x makes a clean break from Gdi32.dll, and calls into the kernel-mode entry points directly.
These entry points are similar and, in many cases, identical to entry points in the display driver itself, so an understanding of the Driver Development Kit (DDK) materials for DirectDraw and Direct3D is an essential prerequisite to using these functions.
Calling these functions differs between operating systems. On Windows 2000, the W2KUMODE.LIB library contains routines that enable the calling thread to make the transition to kernel-mode. These routines do no parameter marshalling, and are the ideal calling mechanism on Windows 2000. The mechanism that makes the transition to kernel mode relies on the ordering of a table. This ordering will change across operating system revisions. Therefore, it is not advisable to build an application that relies on W2KUMODE.LIB for Windows 2000 and expect it to run un-modified on Windows XP. A mechanism for creating operating system portability is described in the following section.
On Windows XP, D3D8THK.DLL exports all of the kernel mode functions, but with a slightly decorated name. The following example shows how applications can alias the low-level client functions using the preprocessor. Before doing this, dynamically link to D3D8THK.DLL.
#define NtGdiDdUnlock OsThunkDdUnlock #include "ntgdi.h" // Brings in the definition of "NtGdiDdUnlock", . // which is now seen as OsThunkDdUnlock. . . OsThunkDdUnlock(hSurface, puUnlockData);
Several techniques are available to make an application portable across operating systems. The most robust is to install the Microsoft DirectX 8.x redistributable package on Windows 2000 as part of your own application's install process. This guarantees that D3D8THK.DLL will be available on Windows 2000 systems and allows a single code-path in the application, because you can use the same technique as described for Windows XP above.
Applications can also build their own insulating DLL and implement two versions of that DLL, one for Windows 2000 using the technique shown above and one for Windows XP that uses D3D8THK.DLL.
DirectDraw and Direct3D first must create an instance of the kernel's abstraction of the driver object. In Gdi32.dll and Ddraw.dll, this is achieved by calling DdCreateDirectDrawObject, DdQueryDirectDrawObject and DdReenableDirectDrawObject. In Direct3D 8.x, this is achieved by calling NtGdiDdCreateDirectDrawObject, NtGdiDdQueryDirectDrawObject and NtGdiDdReenableDirectDrawObject. Note that the GdiEntry* entry points are merely marshallers for the kernel-mode entry points.
After calling these functions, a handle is returned that represents the kernel object's abstraction of a DirectDraw device. This kernel object represents a driver instance owned by the display driver. This handle can be used in subsequent calls such as DdCreateSurfaceObject (or NtGdiDdCreateSurfaceObject in Direct3D 8.x) to build further objects.
A few entry points are used to manage the kernel mode representations of certain objects. DdCreateSurfaceObject (or NtGdiDdCreateSurfaceObject in Direct3D 8.x) is a good example. This entry point creates a kernel mode object representing a piece of system memory. The entry point returns a handle, and this handle can be used in subsequent drawing calls. The kernel derives a pointer to its own structure from these handles, and passes that pointer to the display driver, which then carries out the operation.
This table lists functions that represent kernel-mode entry points, and the user-mode helper routines in Gdi32.dll that wrap these entry points.
The DdAttachSurface function attaches two kernel-mode surface representations.
Creates a DIBSECTION structure that shares its color table with the device.
GdiEntry9 is #defined as an alias for this function.
Wrapper for the NtGdiDdCreateDirectDrawObject function and creates a kernel-side representation of the DirectDraw object. A handle to this representation will be stored in pDirectDrawGlobal->hDD.
GdiEntry1 is defined as an alias for this function.
Wrapper for the NtGdiDdCreateSurfaceObject function and creates a kernel-mode surface object.
GdiEntry4 is defined as an alias for this function.
GdiEntry3 is defined as an alias for this function.
GdiEntry5 is defined as an alias for this function.
Wrapper for the NtGdiDdGetDC function and returns a Windows Graphics Device Interface (GDI) device context (DC) that represents the DirectDraw surface indicated.
GdiEntry7 is defined as an alias for this function.
The DdGetDxHandle returns the kernel-mode Microsoft DirectX API handle to use in subsequent calls to the kernel-mode entry points that control the DirectX API mechanism.
Wrapper for the NtGdiDdQueryDirectDrawObject function and queries a previously created kernel-mode representation for capabilities.
GdiEntry2 is defined as an alias for this function.
Returns the current value of an integer that is incremented whenever a mode switch occurs, such as when there is a desktop switch, a Fast User Switch, or a full-screen Microsoft MS-DOS box. The application can call this function repeatedly and compare the old and new values of the return value to determine whether display settings have changed.
GdiEntry13 is defined as an alias for this function.
Wrapper for the NtGdiDdReenableDirectDrawObject function. It re-enables a DirectDraw driver instance after a mode switch-style event such as a true mode switch, appearance of a full-screen MS-DOS box, or change of display driver.
GdiEntry10 is defined as an alias for this function.
GdiEntry8 is defined as an alias for this function.
Wrapper for the NtGdiDdResetVisrgn function and enables timely user-mode information on the clipping region for windows on the desktop.
GdiEntry6 is defined as an alias for this function.
The DdSetGammaRamp function sets the gamma ramp for the device.
Developed for device driver interfaces (DDIs) prior to Microsoft DirectDraw 7.0 and does nothing on Microsoft Windows NT systems. All parameters are ignored.
GdiEntry16 is defined as an alias for this function.
Creates a context.
Deletes the specified context.
Queries the amount of free memory in the driver-managed memory heap.
Renders primitives and returns the updated render state.
Used by both the DirectDraw and Direct3D runtimes to obtain information from the driver about its current state.
Returns the number of passes where the hardware can perform the blending operations specified in the current state.
Attaches a surface to another surface.
Attaches two kernel-mode surface representations.
Starts decoding a new frame.
Performs a bit-block transfer.
Determines whether the driver can create a driver-level command or vertex buffer of the specified description.
Indicates whether the driver can create a surface of the specified surface description.
Controls the luminance and brightness controls of an overlay surface.
Used to create a driver-level command or vertex buffer of the specified description.
Creates a kernel-side representation of the DirectDraw object.
Notifies the driver that a software decoder will start using motion compensation with the specified GUID.
Attaches a surface to another surface.
Creates a Direct3D surface from a DirectDraw surface and associates a requested handle value to it.
Creates a kernel-mode surface object that represents the user-mode surface object referenced by puSurfaceLocal.
Destroys a previously created kernel-mode DirectDraw device object.
NtGdiDdDeleteSurfaceObject deletes a previously created kernel-mode surface object.
Destroys a previously allocated kernel-mode DirectDraw surface object that was created with the dwCaps member of the DDSCAPS structure set to DDSCAPS_EXECUTEBUFFER.
Notifies the driver that this motion compensation object will no longer be used. The driver now needs to perform any necessary cleanup.
Destroys a previously allocated kernel-mode DirectDraw surface object.
Completes a decoded frame.
Causes the surface memory associated with the target and current surfaces to be interchanged.
Notifies the driver when DirectDraw is flipping to or from a GDI surface.
Queries the amount of free memory in all video memory heaps.
Queries the blit status of the specified surface.
Creates a DC for the specified surface.
Queries the driver for additional DirectDraw and Direct3D functionality that the driver supports.
Returns the kernel-mode DirectX API handle to use in subsequent calls to the kernel-mode entry points that control the DirectX API mechanism.
Determines whether the most recently requested flip on a surface has occurred.
Allows the driver to report that it internally allocates display memory to perform motion compensation.
Allows the driver to specify how many interim surfaces are required to support the specified GUID, and the size, location, and format of each of these surfaces.
Indicates the uncompressed formats to which the hardware can decode the data.
Retrieves the number of GUIDs the driver supports.
Returns the number of the current physical scan line.
Locks a specified area of surface memory and provides a valid pointer to a block of memory associated with a surface.
Used to lock a specified area of buffer memory and to provide a valid pointer to a block of memory associated with the buffer.
Queries a previously created kernel-mode representation of a DirectDraw object for its capabilities.
Queries the status of the most recent rendering operation to the specified surface.
Re-enables a DirectDraw kernel-mode device object after a mode switch.
Releases the previously created DC for the indicated kernel-mode DirectDraw surface object.
Tells the driver what macroblocks to render by specifying the surfaces containing the macroblocks, the offsets in each surface where the macroblocks exist, and the size of the macroblock data to be rendered.
Used to enable the user mode to gain a valid understanding of the clipping region for windows on the desktop. This clipping can change asynchronously from the point of view of user-mode threads.
Sets the color key value for the specified surface.
Notifies the driver when a DirectDraw application is switching to or from exclusive mode.
Sets the gamma ramp for the device.
Sets the position for an overlay.
Removes an attachment, created with NtGdiDdAttachSurface, between two kernel-mode surface objects.
Releases the lock held on the specified surface.
Used to release a lock held on a specified area of buffer memory.
Repositions or modifies the visual attributes of an overlay surface.
Returns the vertical blank status of the device.
Build date: 12/7/2012