MSDN Original: https://msdn.microsoft.com/zh-cn/library/windows/hardware/ff554695 (v=vs.85). aspx
The Windows Driver Toolkit (WDK) contains all the header files (. h files) that are required to build the kernel mode and user-mode drivers. The header file is in the Include folder in the WDK installation folder. Example: C:\Program Files (x86) \ Windows Kits\10\include.
The header file contains version information, so you can use the same set of header files regardless of which version of Windows the driver is running on.
constant that represents the version of Windows
The header file in the WDK contains conditional statements that specify that the programming elements are available only in some versions of the Windows operating system. Version-managed elements include functions, enumerations, structs, and struct members.
To specify that the programming element is available in each operating system version, the header file contains a preprocessor condition that compares the value of Ntddi_version to a predefined set of constant values defined in Sdkddkver.h.
The following are predefined constant values that represent versions of the Microsoft Windows operating system.
Constants |
Operating system version |
Ntddi_win10 |
Windows 10 |
Ntddi_winblue |
Windows 8.1 |
Ntddi_win8 |
Windows 8 |
Ntddi_win7 |
Windows 7 |
Ntddi_ws08sp4 |
Windows Server SP4 |
Ntddi_ws08sp3 |
Windows Server SP3 |
Ntddi_ws08sp2 |
Windows Server SP2 |
Ntddi_ws08 |
Windows Server 2008 |
You can see several examples of version-specific DDI elements in the WDK header file. This condition declaration appears in Wdm.h, which is a header file that may be included by a kernel-mode driver.
#if (ntddi_version >= ntddi_win7) _must_inspect_result_ntkernelapintstatuskesettargetprocessordpcex ( _Inout _ Pkdpc Dpc, _in_ pprocessor_number procnumber ); #endif
In this example, you can see that the Kesettargetprocessordpcex function is available only in Windows 7 and later versions of Windows.
This condition declaration appears in Winspool.h, which is a header file that may be included by the user-mode driver.
C++
#if (ntddi_version >= ntddi_win7) ... Boolwinapigetprintexecutiondata ( _out_ print_execution_data *pdata ); #endif//(Ntddi_version >= NTDDI_ WIN7)
In this example, you can see that the getprintexecutiondata function is available only in Windows 7 and later versions of Windows.
Header file for kernel-mode driver framework
The WDK supports multiple versions of Windows, and it also supports multiple versions of the kernel-mode driver Framework (KMDF) and the user-mode driver Framework (UMDF). The version information in the WDK header file is related to the version of Windows, but is not related to the KMDF or UMDF version. Header files for different versions of KMDF and UMDF are placed in different directories.
Header files in the Windows driver toolkit