Building NT kernel mode drivers in MS Visual Studio 8.0 (VS 2005)
for x64 (AMD64) platform
Hi, people! Now I'm publishing instruction for creating 64-bit (x64)
NT kernel-mode driver project in MS Visual Studio 8.0
Contents
Set environment variables
Set BASEDIRNT4, BASEDIR2K, BASEDIRXP, BASEDIR2K3 environment variables (I would recommend system ones,
not user-specific) like this:
BASEDIRNT4 = C:\Develop\DDKNT4
BASEDIR2K = C:\Develop\DDK2000
BASEDIRXP = C:\Develop\DDKXP
BASEDIR2K3 = C:\Develop\DDK2003
Set BASEDIR environment variable to point to your favorite DDK (I prefer NT4, because I'm writing highly compatible drivers).
But latest time DDK 2003 is oftenly used. So we shall tune template project for DDK 2003.
See migrating VC6 driver project to VC8 with DDK 2003 for DDK 2003 specific details.
Attention! If you want to build driver under VC8, make sure that x64 platform support is installed there.
Also note, that DKK 2003 is mandatory.
BASEDIR = %BASEDIR2K3%
Create project
-
File -> New... -> Project
-
Chose Visual C++ -> Win32 in Project Types tree.
-
Chose Win32 Project in Templates list.
-
Enter project name, directory path and solution name. As usually. You can also uncheck Create directory for solution
box. Then both project file (.VCPROJ) and .SLN will be created in same directory. By default Visual Studio 8 creates separate
subdirectory for project.
-
OK -> DLL, Empty project -> Finish
Adding files
-
Just add files to your project.
Project -> Add Existing Item or Project -> Add Item
-
If you decided to use .PCH, do not forget to insert the following line in all added *.C and *.CPP files
#include "stdafx.h"
instead of
#include <ntddk.h>
.....
Change project settings
Comments to the sample
Along with main thing - pch_cpp_x64 archive includes previous driver project for Win32 with some updates.
Inside pch_cpp_x64 you can find VC8 project with both Win32 and x64 configurations. This project requires
you to install x64 support in VC8. There is also Makefile which can be used with nmake from either VC6 or VC8.
There is no VC6 project for x64 since I don't know how to set alternative compiler for x64 configurations.
Makefile expects DDK 2003 presence for x64 configuration and DDK NT4 for Win32.
| Folder | Platform | VStudio | Sources | Precompiled headers | Makefile |
| pch_cpp_x64 | x86/x64 | VC8 | .CPP | Yes | Yes |
| vc8_pch_cpp | x86 | VC8 | .CPP | Yes | No |
| pch_cpp | x86 | VC6/VC8 | .CPP | Yes | Yes |
| pch_c | x86 | VC6 | .C | Yes | Yes |
| simple | x86 | VC6 | .C | No | Yes |
2007.10.30
See also:
|