Porting Steps for Printer Drivers

This section contains porting notes that pertain to print drivers only.

In general, print drivers have become more complex than display drivers, largely due to fonts. However, Windows NT kernel-mode drivers should be as simple as possible, dealing only with the tasks required to render an image. Tasks unrelated to rendering should be moved, if possible, into the User Interface (UI) portion of the driver or into the print processor. The UI portion of the driver still runs in user mode. If you have a library that is shared by both DLLs, you need to write it so that it can be built and run in both kernel- and user-mode.

EMF Printing

Journaling has been replaced by metafile spooling, making the Windows NT model more similar to Windows 95. Metafile spooling also allows GDI to have a single recording model. See the reference pages for EngMarkBandingSurface, DrvStartBanding, and DrvNextBand for more details.

More on Replacing Calls to the Win32 API

New kernel-mode GDI functions have been implemented to replace some of the Win32 functions commonly used by print drivers. References pages for these functions are provided in this package. Parameters and usage should be checked in all cases, as the new GDI functions are not exact replacement functions.The following table shows the old Win32 functions and their corresponding new kernel-mode engine functions:

Win32 Function

Kernel-mode Engine Function

GetLastError

EngGetLastError

EnumForms, GetForm, GetPrinter, GetPrinterData, SetPrinterData, WritePrinterData

EngEnumForms, EngGetForm, EngGetPrinter, EngGetPrinterData, EngSetPrinterData, EngWritePrinter

FindResource

EngFindResource

LoadLibrary, GetProcAddress

EngLoadImage, EngFindImageProcAddress

GetFileTime, GetLocalTime

EngGetFileChangeTime, EngQueryLocalTime

QueryPerformanceCounter, QueryPerformanceFrequency

EngQueryPerformanceCounter, EngQueryPerformanceFrequency

MultiByteToWideChar, WideCharToMultiByte

EngMultiByteToWideChar, EngWideCharToMultiByte

MulDiv

EngMulDiv

Version Marking

To ensure that the driver’s correct version is run on the corresponding version of Windows NT, each print driver must be marked with a version number in the resource file; for example:
#include <ntverp.h>
#define VER_FILEVERSION 0,2,0,0
 

Version 2 drivers runs in kernel mode. The spooler ensures that the driver is kept separate from the older, non-kernel-mode drivers.

UNICODE Conversion

Limited ANSI-to UNICODE and UNICODE-to ANSI translation is available through GDI. See the EngMultiByteToUnicodeN and EngUnicodeToMultiByteN reference pages for more details.

Spooler Functions

The set of spooler functions is limited to UNICODE and those from a driver that make sense.

Impersonation

Impersonate client and RevertToSelf are handled automatically by spooler functions.

Registry

There are no plans to support registry functions passing data to kernel-mode drivers. Settings from the driver should be retrieved using EngGetPrinterData.

File Operations

GDI now supplies file mapping support. See the reference pages for EngLoadModule, EngLoadModuleForWrite, EngMapFontFile, EngMapModule, and EngUnmapFontFile for more information.

There are no plans to support file read/write/create, file path, or file find functions.

Resource Functions

See the reference page for EngFindResource for more details.