Using the Visual Studio 6.0 Driver Build Environment

Ive already borrowed so much information from CodeGuru that Ive started getting frustrated that I haven't contributed anything myself to the site. Therefore, I respectfully offer this articles to my fellow programmers.

Some time ago, I had to write an NT 4.0 device driver. Since I was already used to the comfort of Visual Studio 6, it was hard to me to fall back to the free build and checked build environments, provided by the DDK. Especially I missed the browser possibilities that Visual Studio provides.

So, I started around digging into the DDK build environment to find out how it works, and if I could extend the environment to be usable within the Visual Studio. My primary goal was to keep the existing environment intact, and furthermore, I want to use this environment within VS 6.

The solution was simpler than I expected. I only need to set up some additional files.

_build.bat

. This *.bat is directly called by VS 6 and has the same command parameters as the DDK setenv.bat. This *.bat will clean up some existing files ( i.e. build.dat which I do wish to rebuild every time ), saves the actual directory ( see PrCHDIR ) and calls the original setenv.bat from the DDK. The _build.bat calls bscmake.exe at the end. This enables me to browse to the source code afterwards. The _build.bat is not project-depended.

PrCDIR.exe

On starting setenv.bat, one is move into the DDK root directory. And this not so good if you want to automate the environment. The small PrCHDIR program prints the actual directory and drive letter. The _build.bat catches it output and stores it into a @temp.bat. Once the setenv.bat has been called, the @temp.bat puts you back into your proper build directory.

I386mk.inc

The DDK build environment use this file which resides in the %DDKROOT%\Inc directory. If you copy this file into your proper build directory, the Build will use this file instead. I extended this file with following lines
!IF "$(ASM_LST)"=="YES" 
DBGFLAGS=$(DBGFLAGS) /FAcs 
/Fa$(TARGETPATH)\$(TARGET_DIRECTORY)\$(TARGETNAME).asm
!ENDIF

!IF "$(GEN_SBR)"=="YES" 
DBGFLAGS=$(DBGFLAGS) /FR$(TARGETPATH)\$(TARGET_DIRECTORY)\$(TARGETNAME).sbr
!END

When I define now ASM_LST=YES and GEN_SBR=YES into the sources file, I get my *.asm and *.sbr. The *.sbr is needed by bscmake.exe.

BASEDIR

The BASEDIR is a define internally generated during the build. This define is not available upon start of _build.bat. To make the _build.bat somewhat universal, I defined the BASEDIR within the NT 4.0 environment and set it equal to the DDKROOT.

Some restrictions: the _build.bat expects that the generated files are stored into sub directories of the actual build directory: the sources should contain TARGETPATH=. instead of TARGETPATH=$(BASEDIR)\lib

See the downloadable file more details. It contains an example of this build environment for the KBDCLASS driver provided within the DDK and the PrCHDIR.exe tool plus source code.

Downloads

Download demo project - 224 Kb