Programming the Microsoft Windows Driver Model

Determining the Operating System Version

Windows 2000 and later systems provide a routine, PsGetVersion, which seems ideally suited for determining which platform you re running on. Unfortunately, Windows 98/Me doesn t support this function. All platforms do, however, have in common this function:

BOOLEAN IoIsWdmVersionAvailable(major, minor);

This function returns TRUE if the platform supports the WDM driver interfaces at the specified level. The WHICHOS sample in the companion content illustrates one way you might use IoIsWdmVersionAvailable to distinguish among platforms, based on the information in Table A-1.

Table A-1. WDM Versions by Platform

Platform

WDM Version Supported

Windows 98 Gold and Second Edition

1.0

Windows Me

1.05

Windows 2000

1.10

Windows XP

1.20

Windows .NET

1.30

For example, you can determine whether you re running under Windows XP by making this function call:

BOOLEAN isXP = IoIsWdmVersionAvailable(1, 0x20);

Windows 98 was issued in two versions: the original, or gold, version, and the Second Edition. IoIsWdmVersionAvailable will indicate version 1.0 on both systems. If you need to distinguish between the two, you can use the trick illustrated in WHICHOS of checking the ServiceKeyName member of the Driver Extension structure:

BOOLEAN Win98SE = DriverObject->DriverExtension->ServiceKeyName.Length != 0;

I ve used this trick only in my DriverEntry function, by the way. For all I know, the ServiceKeyName member might change afterward.

The biggest distinction between platforms is, of course, between the Windows 2000 line of systems and Windows 98/Me. All of the sample drivers in the companion content define a global variable named win98, which DriverEntry initializes based on the result of calling IoIsWdmVersionAvailable:

win98 = !IoIsWdmVersionAvailable(1, 0x10);

Категории