Windows driver kit setup

Download the Windows Driver Kit (WDK)

The WDK is used to develop, test, and deploy Windows drivers.

Runtime requirements

You can run the Windows 10, version 2004 WDK on Windows 7 and later, and use it to develop drivers for these operating systems:

Client OS Server OS
Windows 10 Windows Server 2019, Windows Server 2016
Windows 8.1 Windows Server 2012 R2
Windows 8 Windows Server 2012
Windows 7 Windows Server 2008 R2 SP1

WDK for Windows 10, version 2004

Step 1: Install Visual Studio 2019

The WDK requires Visual Studio. For more information about system requirements for Visual Studio, see Visual Studio 2019 System Requirements.

The following editions of Visual Studio 2019 support driver development for this release:

When you install Visual Studio 2019, select the Desktop development with C++ workload. The Windows 10 Software Development Kit (SDK) is automatically included, and is displayed in the right-hand Summary pane. Note that the version of the SDK that is compatible with the WDK for Windows 10, version 2004 may not be the default SDK. To select the correct SDK:

In Visual Studio Installer, on the Individual components tab, search for Windows 10 SDK (10.0.19041.0), select this version and continue with install. Note that Visual Studio will automatically install Windows 10 SDK (10.0.19041.1) on your machine.

If you already have Visual Studio 2019 installed, you can install the Windows 10 SDK (10.0.19041.1) by using the Modify button in Visual Studio install.

WDK has Spectre mitigation enabled by default but requires spectre mitigated libraries to be installed with Visual Studio for each architecture you are developing for. Additionally, developing drivers for ARM/ARM64 require the build tools for these architectures to also be installed with Visual Studio. To locate these items you will need to know the latest version of MSVC installed on your system.

To find the latest version of MSVC installed on your system, in Visual Studio Installer go to workload page, on the right pane under installation details, expand Desktop development with C++ and locate the MSVC v142 — VS 2019 C++ x64/x86 build tools (V14.xx) — note where xx should be the highest version available.

With this information (v14.xx), go to Individual components and search for v14.xx. This will return the tool sets for all architectures, including Spectre mitigated libs. Select the driver architecture you are developing for.

For example, searching for v14.25 returns the following:

Step 1.5 Install Refreshed Windows SDK 10.0.19041.685 for Windows 10, version 2004

This SDK is strongly recommended and will eventually be made available through Visual Studio

Step 2: Install Refreshed WDK for Windows 10, version 2004

The WDK Visual Studio extension is included in the default WDK installation.

If you can’t find driver project templates in Visual Studio, the WDK Visual Studio extension didn’t install properly. To resolve this, run the WDK.vsix file from this location: C:\Program Files (x86)\Windows Kits\10\Vsix\VS2019\WDK.vsix.

Enterprise WDK (EWDK) for Windows 10, version 2004

The EWDK is a standalone, self-contained command-line environment for building drivers. It includes the Visual Studio Build Tools, the SDK, and the WDK. The latest public version of the EWDK contains Visual Studio 2019 Build Tools 16.7.0 and MSVC toolset v14.23. To get started, mount the ISO and run LaunchBuildEnv.

The EWDK also requires the .NET Framework version 4.7.2. For more information about other requirements for the .NET Framework, see .NET Framework system requirements.

EWDK with Visual Studio Build Tools

You can use the Visual Studio interface with the build tools provided in the EWDK.

  1. Mount the EWDK ISO.
  2. Run LaunchBuildEnv.cmd .
  3. In the environment created in step 2, type SetupVSEnv, and then press Enter.
  4. Launch devenv.exe from the same environment, using the full file path. Example: «C:\Program Files (x86)\Microsoft Visual Studio\2019\\%Community|Professional|Enterprise%\Common7\IDE\devenv.exe»

Note that the Visual Studio major version should match with the version in the EWDK. For example, Visual Studio 2019 works with the EWDK that contain VS16.X build tools.

Driver samples for Windows 10

To download the driver samples, do one of the following:

  • Go to the driver samples page on GitHub, click Clone or download, and then click Download ZIP.
  • Download the GitHub Extension for Visual Studio, and then connect to the GitHub repositories.
  • Browse the driver samples on the Microsoft Samples portal.

Installing preview versions of the Windows Driver Kit (WDK)

This page contains installation instructions for Insider Preview (pre-release) versions of the Windows Driver Kit (WDK). The download links for the latest pre-release version of the WDK and the EWDK are on https://www.microsoft.com/software-download/windowsinsiderpreviewWDK.

For info about the latest released versions of the WDK, see Download the Windows Driver Kit (WDK). For downloads of earlier versions of the WDK, see Other WDK downloads.

Install Windows Driver Kit (WDK) Insider Preview

1. Install Visual Studio

  • The WDK now supports Visual Studio 2019. All editions are supported. The WDK no longer supports Visual Studio 2017.
  • Download from https://visualstudio.microsoft.com/vs/preview/.
  • Select workload: Development with C++.
  • ARM: To build ARM drivers you must additionally install the component: Individual components -> Compilers, build tools, and runtimes -> Visual C++ compilers and libraries for ARM.
  • ARM64: Currently not supported.

2. Disable strong name validation

The WDK Visual Studio Extensions are currently not strong name signed. Run the following commands from an elevated command prompt to disable strong name validation:

3. Install SDK Insider Preview

4. Install WDK Insider Preview

During installation you will see the Visual Studio installer install the WDK Visual Studio Extensions.

Install Enterprise WDK (EWDK) Insider Preview

The EWDK is a standalone self-contained command-line environment for building drivers. It includes Build Tools for Visual Studio 2019, the SDK, the WDK and support for ARM64 driver development. See more at Installing the Enterprise WDK.

To get started, disable strong name validation by running the following commands from an elevated command prompt:

Then mount the ISO that you downloaded from the Insider Preview page and select LaunchBuildEnv to use the EWDK.

Run-time requirements for the WDK and the EWDK

The WDK requires Visual Studio. For more info about system requirements for Visual Studio, see Visual Studio 2019 System Requirements.

In addition, the EWDK requires .NET 4.7.2. For more info about what .NET runs on, see .NET Framework system requirements.

You can use the WDK Insider Preview and the EWDK Insider Preview to develop drivers for these operating systems:

Installing the WDK 8.1 Build Environment in a Lab

The Windows Driver Kit (WDK)В 8.1 provides a feature that enables you to copy components of Visual Studio and the WDK to a new location and then launch the build environment from the command line. From here you can build Windows drivers without having to run the Visual Studio or WDK installation programs.

You might find this feature useful if you need to integrate the WDK with your build process, or if you want to distribute the build process in a lab or test environment.

NoteВ В You can only use this feature for building drivers and applications that use C and C++. This feature cannot be used for managed code or UWP apps.

1. Download the Visual Studio and WDK and SDK setup files

To run the set up script that enables this feature, you need to provide the paths to the Visual Studio and WDK setup files. Be sure to save these files (rather than install them).

  1. Download Visual Studio Professional 2013 or Visual Studio Ultimate 2013. Download the Product Layout (for example, vs_ultimate_download.exe ). When you are asked if you want to run or save vs_ultimate_download.exe, select Run and then select the download option and specify the download path as C:\VSSetup (this makes the later steps easier). Select Download to download and install a local copy of the DVD layout on the computer.
  2. Download the standalone SDK. When you are asked if you want to run or save sdksetup.exe, select Run and then specify the download location as C:\Kits\SDK. Select Next and follow the instructions to download the standalone SDK.
  3. Download the WDK 8.1. When you are asked if you want to run or save wdksetup.exe, select Run and then specify the download location as C:\Kits\WDK. Select Next and follow the instructions to download the WDK. If you have already installed the WDK on the computer, the web installation program will tell you that the features installed on the computer are up-to-date. To download the WDK setup files so that you can deploy the build environment, select Next and specify the C:\Kits\WDK path.

2. Download the BuildLabSupport files

To be able install the WDK build environment on computers in a lab, you need to first download the build lab support files on your computer.

  1. Download BuildLabSupportfiles.zip.
  2. Extract the contents of the compressed file to your computer. The extracted files include the BuildLabSupport directory and include the setup files and utilities you need.

3. Install the WDKВ 8.1 build environment

The build lab support files include the setup.ps1 PowerShell command file, which extracts the needed Visual Studio and WDK components and copies them to a target directory (folder). You can then copy this directory to another location, from which you can build projects in a Visual Studio command-line interface (CLI) development environment.

Open a Command Prompt window with elevated privileges (Run as administrator) and go to the directory where you extracted build lab support files. The PowerShell command script setup.ps1 is in the \BuildLabSupport directory.

The syntax for the PowerShell command is as follows:

PowerShell
  • The is the path to the Visual Studio installation program (for example, Vs_ultimate.exe) and directory that contains the product layout.
  • The is the path to the WDK and SDK setup files.
  • The is the target directory for the extracted content.
  • The is the target destination for the log file.
  • is the name of the CatalogFile, which contains a list of Microsoft Windows installation files (MSI) to expand as part of the installation. The name of the file is files.xml.

For example, the following command runs the script from BuildLabSupport directory and installs the build environment in C:\BuildLabInstall directory.

4. Build Windows driver projects and solutions

Using the build environment command script

Open a Command Prompt window. Locate the LaunchBuildEnv.cmd file located in the target directory (for example, C:\BuildLabInstall).

Launch the build environment by running LaunchBuildEnv.cmd.

Use MSBuild commands to build your driver projects and solutions. For example:

WinDDK-7 вот , что нужно для создания драйвера

У нас Windows 10-64.

Задача разработать например драйвер устройства под Windows.
Устанавливаем Windows Device Driver Kit 7 :
Скачиваем с офф.сайта microsoft ISO, разархивируем , запустим KitSetup.exe

Так выглядят в Панель управления\Программы\Программы и компоненты

Установлен у меня в C:\WinDDK\7600.16385.1

В C:\WinDDK\7600.16385.1\src много примеров исходных кодов.
Примечание : если у вас уже установлен Win Driver Kit 10 , то придется удалить.

Фишка в том , что сборку надо запускать через запуск сначала командного файла (который устанавливает переменные среды) :
см. Пуск->Windows Driver

Открывается консоль, где и надо ввести build (в каталоге вашего проекта). Процесс сборки выглядит примерно так:

Для x64 входим через C:\Windows\System32\cmd.exe /k C:\WinDDK\7600.16385.1\bin\setenv.bat C:\WinDDK\7600.16385.1\ fre x32-64

Windows 10 — надо сначала отключить проверку цифровой подписи (у меня срабатывает при нажатой SHIFT + клик Перезагрузка)
Отключаем.

Далее просто пробуем написать простейший kernel драйвер

На самом деле в дальнейшем в этой ветке сайта мы будем заниматься UMDF драйверами, но для проверки первого драйвера подвернулся пример driver.sys (kernel драйвер, драйвер уровня ядра)

Компилируем простейший драйвер (sys — кернел драйвер)

Для варианта сборки x86 пробуем зарегистрировать драйвер

Для варианта сборки amd64 получаем

Теперь по другому пробуем проверить запущен ли все-таки драйвер через программу OSR Driver Loader:

Получается драйвер все-таки запускается несмотря на ругань по поводу сертификата.

Смотрим например еще так :

Osr driver loader — прекрасно и сама регистрирует / запускает / останавливает / удаляет драйвер. Только не забывайте перезагружаться.

Отладка

У нас на сайте см. отдельный раздел по отладке драйверов.

Читайте также:  Microsoft windows print server
Оцените статью