Architektur im Wandel c't 6/2010 S.220 
Writing Kernel Drivers for 32 and 64 Bit Windows
***************************************************************

Solution for Visual Studio 2008 32 and 64 Bit with sample driver ctpci 
and the open source program lspci from Martin Mares <mj@ucw.cz>, which is extended, 
so that it can use ctpci32.sys or ctpci64.sys.  
 
ctpci uses PCI-access via the (deprecated) Kernel function
HalGetBusDataByOffset(). 

For compilation of ctpci you need Microsoft DDK or WDK and 
the current SDK. Please include pathes to WDK or DDK and SDK in 
Tools/Options/Projects and Solutions/VC++-Directories
for instance for WDK 7600.16385.0 and SDK 7.0: 

Includes: 
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include
$(VCInstallDir)include
C:\WINDDK\7600.16385.0\inc\ddk
C:\WINDDK\7600.16385.0\inc\api
...

Libs (64 Bit)
C:\Program Files\Microsoft SDKs\Windows\v7.0\Lib\x64
C:\WINDDK\7600.16385.0\lib\win7\amd64
... 

Libs (32 Bit)
C:\Program Files\Microsoft SDKs\Windows\v7.0\Lib\i386
C:\WINDDK\7600.16385.0\lib\win7\i386

if you want to use intrinsics in your driver, like __rdmsr or __wrmsr, you have to 
patch intrin.h in order to run with ntddk.h (see ctpci.cpp) 

The procedures to communicate with the driver are included in the library pci.lib, so 
lspci.c and other tools have not to be changed. lspic.c is compiled in C++, setpci in pure C.  

To start drivers under 64 Bit Windows you must either: 
a) press F8 during boot and allow not certified drivers 
b) use atsiv.exe to install the driver 
c) make a testsignature and use testmode (easiest way is with dseo13b from NGO) 

The use of the software is on your own risk. 

Much fun 
Andreas Stiller (as@ct.de) 

