Creating a Driver From Existing Source Files
Starting with Windows Driver Kit (WDK) 8, the WDK is fully integrated with Microsoft Visual Studio. The WDK now uses the same compiler and build tools that you use to build Visual Studio solutions and projects. MSBuild replaces the Windows Build Utility (Build.exe) that was used in previous versions of the WDK (prior to WDK 8). If you have a driver that you created using a previous version of the WDK, you can easily create a Visual Studio project and solution from your existing code.
Important Projects and solutions created with WDK 8 must be upgraded to work with the Windows Driver Kit (WDK) 8.1 and Microsoft Visual Studio 2013. Before you open the projects or solutions, run the ProjectUpgradeTool. The ProjectUpgradeTool converts the projects and solutions so that they can be built using WDK 8.1.
The WDK provides a conversion utility that generates Visual Studio solution and project files from your driver's sources, dirs, and makefile.inc files. The utility creates the Visual Studio solution and project files in the same directory as your existing sources files. The utility does not alter your source code or your earlier build files. If you need to support your driver on Windows XP, you can continue to use the former build system for Windows XP, and use WDK 8.1 or WDK 8 and Visual Studio project and solution files for Windows 8.1, Windows 8, Windows 7, and Windows Vista.
You have the following options for creating a Visual Studio driver project from existing source files:
- Using Visual Studio and choosing to open and convert an existing driver project (based upon sources and dirs files).
- Using a Visual Studio Command Prompt window and the WDK sources and dirs file converter (Nmake2MsBuild.exe).
- (Recommended) Create a new Windows driver solution in Visual Studio using one of the provided Windows driver templates. If you start with a template for your driver model, the structure of the project will be in place and the correct platform tool set will be selected. You can then add your source files to the solution. For information about selecting templates, see Creating a New Device Function Driver, Creating a New Filter Driver, or Creating a New Software Driver.
To open and convert a driver project created with a previous version of the WDK (File > Open)
- Open Microsoft Visual Studio Ultimate 2012. From the File menu, click Open and then click Convert Sources/Dirs.
- In the Open dialog box, navigate to the directory that contains the sources or dirs file for your driver, select the file and click Open. The Output window in Visual Studio Ultimate 2012 shows informational messages about the conversion and creation of the Visual Studio project. For a detailed view of how elements in the sources file were converted, you can view the conversion log (Nmake2MsBuild_sources.log). As part of the conversion, you will asked if you want to open and view the log file.
- Examine the project in Solution Explorer.
To create a driver project from existing code (Command Line)
- Open a Visual Studio Command Prompt window. If your project is under %PROGRAMFILES%, you need to open the command prompt window using elevated permissions (Run as administrator).
Run the Nmake2MsBuild conversion utility (Nmake2MsBuild.exe) and specify the name and path to the sources or dirs file for your driver.
You can specify more than one sources files at a time. All resulting projects will share the same Solution and Package Project.
If you run the Nmake2MsBuild utility on a dirs file, the utility traverses the directory tree for all sources files and and generates Visual Studio project files for each one.
The conversion tool is located in the %PROGRAMFILES%\Windows Kits\8.0\bin\x86\ directory.
For example, to generate a Visual Studio project file for an existing sources file in the directory C:\Myproj, you would enter the following command:
- Verify the conversion by opening the project file (*.vcxproj) or solution file (*.sln) in Visual Studio. Start Visual Studio and click Open and then navigate to the directory where you converted your sources file. Try building your project, using the default build configurations.
The utility creates a log file that you can use if you need to troubleshoot or verify the converted project file. The default log file is called Nmake2MSBuild_sources.log. The log file will report errors and warnings and will also describe how elements in the sources file were interpreted and translated to their Visual Studio project equivalents.
The conversion tool is located in the %PROGRAMFILES%\Windows Kits\8.0\bin\x86\ directory. For information about using the conversion utility and its options, see Nmake2MsBuild.
By default, the conversion utility configures the driver package project to use kernel debugger (Debugging Tools for Windows - Kernel Debugger). If you are converting a UMDF driver to a Visual Studio solution, you should change this setting so that you can use the user-mode (Remote) debugger instead.
To specify the user-mode (Remote) debugger
- Open the property pages for your driver project. Right-click the driver package project in Solution Explorer and select Properties.
- In the property pages for the driver package project, click Configuration Properties and then click Debugging.
- From the Debugger to launch drop-down menu, select Debugging Tools for Windows - Remote Debugging.
Note You can still use the kernel debugger to debug UMDF drivers, but the user-mode (Remote) debugger is more convenient. If you create a UMDF driver from a UMDF template, the user-mode debugger is already selected by default.
- WDK and the Visual Studio build environment
- Walkthrough: Using MSBuild
- Creating a New Device Function Driver
- Creating a New Filter Driver
- Creating a New Software Driver
Build date: 11/16/2013