Although Visual Studio is quite obviously promoted as an application development tool for C++ (and several other languages), it is nonetheless an IDE for the standard compiler and linker. Therefore, using the proper compile and link switch settings, the tool can be used to build kernel-mode device drivers. The DDAppWiz ToolThe CD that accompanies this book includes an App Wizard that conveniently provides the necessary compile and link switch settings for Visual Studio to build a device driver. The file, DDAppWiz.AWX, must be copied into the Visual Studio path: ...\Microsoft Visual Studio\Common\MSDev98\Template. Thereafter, a new Project type appears in the New Project dialog box: W2K Device Driver. The use of the App Wizard is straightforward and described in Chapter 6. This section lists the Visual Studio environment settings modified or added by the wizard. Preprocessor Symbols ModificationThe table below shows the compiler preprocessor symbols removed from the standard Win32 project, normally generated by Visual Studio.
Compiler Switch ModificationsSeveral compile switches are required for driver builds, as shown in the following table:
Compiler Include DirectoriesThe Device Driver App Wizard adds two include directories to the set of compiler options (-I switch). The paths are listed below. \NTDDK\inc and \NTDDK\inc\ddk These may require modification, depending upon choices specified when the DDK is installed. Link ModificationsAll of the standard Win32 libraries are removed from linker input and replaced with the following list of libraries:
The /nodefaultlib linker option is selected. Depending on the configuration (Debug or Release), a library path is added of either /libpath:\NTDDK\libchk\i386 or /libpath:\NTDDK\libfre\i386 Either of these link settings may require manual modification based on where the DDK is actually installed. The remaining linker switch modifications are as follows:
No MFCTo ensure that the driver project is not MFC based (for obvious reasons), the option is removed by the App Wizard.
|