Geoff Chappell, Software Analyst
The DRIVER_EXTENSION structure is an adjunct to the well-known (though partially opaque) DRIVER_OBJECT. It was added when introduction of the PnP Manager for Windows 2000 needed that drivers implement another calling point through which to learn of device addition. The address to call might be set into the DRIVER_OBJECT except for compatibility constraints. Pre-existing drivers depended on at least some members, which therefore could not shift. Members could not be appended without risking a future problem for the MajorFunction array were new types of I/O request ever to be defined. The solution was to replace the Count member, which no drivers should have been accessing, by a pointer to an extension. Thereafter, the Count and anything new that is ever wanted for the DRIVER_OBJECT go to the extension.
Because writers of device drivers that actually do drive a physical device, here meaning one that’s known to the PnP Manager, need to know of the DRIVER_EXTENSION so that they can set the AddDevice member, the DRIVER_EXTENSION has always been documented—but with programmers being told that AddDevice is the only accessible member.
No definition in the WDM.H from any Device Driver Kit (DDK) or Windows Driver Kit (WDK) has yet extended beyond the ServiceKeyName member. This also is the extent of the definition in the NTOSP.H from the WDK for Windows 10.
The DRIVER_EXTENSION has varied from version to version only by appending new members. The following table summarises the growing size:
Version | Size (x86) | Size (x64) |
---|---|---|
5.0 | 0x18 | |
5.1 to 6.1 | 0x1C | 0x38 |
6.2 | 0x24 | 0x48 |
6.3 to 10.0 | 0x28 | 0x50 |
These sizes, and the offsets, types and names in the tables that follow, are from Microsoft’s symbol files for the kernel starting with Windows 2000 SP3.
Offset (x86) | Offset (x64) | Definition | Versions |
---|---|---|---|
0x00 | 0x00 |
DRIVER_OBJECT *DriverObject; |
5.0 and higher |
0x04 | 0x08 |
PDRIVER_ADD_DEVICE AddDevice; |
5.0 and higher |
0x08 | 0x10 |
ULONG Count; |
5.0 and higher |
0x0C | 0x18 |
UNICODE_STRING ServiceKeyName; |
5.0 and higher |
0x14 | 0x28 |
IO_CLIENT_EXTENSION *ClientDriverExtension; |
5.0 and higher |
0x18 | 0x30 |
FS_FILTER_CALLBACKS *FsFilterCallbacks; |
5.1 and higher |
0x1C | 0x38 |
PVOID KseCallbacks; |
6.2 and higher |
0x20 | 0x40 |
PVOID DvCallbacks; |
6.2 and higher |
0x24 | 0x48 |
PVOID VerifierContext; |
6.3 and higher |