OSRLogoOSRLogoOSRLogo x Subscribe to The NT Insider

Everything Windows Driver Development

GoToHomePage xLoginx

    Thu, 14 Mar 2019     118020 members


  Online Dump Analyzer
OSR Dev Blog
The NT Insider
The Basics
File Systems
ListServer / Forum
  Express Links
  · The NT Insider Digital Edition - May-June 2016 Now Available!
  · Windows 8.1 Update: VS Express Now Supported
  · HCK Client install on Windows N versions
  · There's a WDFSTRING?
  · When CAN You Call WdfIoQueueP...ously

DDKBUILD -- Visual Studio .CMD Procedure For Building Drivers


Let's say you actually like using Visual Studio, and you want to use it to write drivers. You could configure all the VS options to match what's in the DDK... but you'll still be using the version of the compiler and linker that Visual Studio provides (which is, by the way, not the same as that used in any official DDK). What do you do?

OSR's DDKBUILD.BAT file to the rescue!? Just use this as an external build procedure, and you'll be able to build and browse drivers from within Visual Studio, but still use the DDK to ensure that the drivers you build will load and run flawlessly.

Associated article published in The NT Insider, May-June 2002 issue.

V7.4? R43 DDKBUILD.CMD (Updated?Nov 2009)

It adds support for the Windows 7 WDK(s) and introduces the option -CUV to invoke the Call Usage Verifier from PREfast. It implies -PREFAST, so that only -CUV needs to be given in such a case.


The Windows 7 WDK location is declared by using the variable W7BASE or WIN7BASE.

V6.12 DDKBUILD.BAT (Updated April 2008)

Add support for long file names.?? This updated was provided to us by Oliver Schneider.

V7.3? R27 DDKBUILD.CMD (Updated?Nov 2008)

Fixes problems outlined in NTDEV. This updated was provided to us by Oliver Schneider

Version: V6.12
Support: XP DDK to VISTA DDK
Date Updated: April 2008
Author: OSR

Version: V7.4 R43
Support: XP DDK to?WIN7 WDK
Date Updated: Nov?2009
Author: OSR, Oliver Schneider


DDKBUILD V6.12, ZIP Archive, 5KB

DDKBUILD V7.4 R43?Final, ZIP Archive, 11.6KB

Number Of Downloads
This utility has been downloaded 27838 times.

User Comments
Rate this utility and tell the community how well you like it. Is it a worthwhile download? Does it work as described?? Does it help you in your job as a driver writer or tester?
Click Here To Post Your Comment

"This thing is just useless S?I? !!!!"

17-Jul-13, actual alias

"thank you!"
thank you for sharing

28-Mar-12, wang junjie

Setting ERRORLEVEL=0 in the batch screws up ("hides") CMD "intrinsic" ERRORLEVEL, so that it doesn't get set as a result of BUILD invocation.

15-Apr-11, Alex Grig

Might it be possible to set a download link to the R31? While it is possible to download it, it might be conveniant to have it available the dummy-way, too.

14-Oct-09, Andreas Bock

"Building for Win7 and WDK 7000+"
Since WDK 7000+ is so similar to 6000, maybe it is desirable to reuse the WLH prefix for 7000, in the following way:

- If WLHBASE points to WDK 7000+ *and* a certain environment variable is set, all WLH... targets will actually build for Win7.

Otherwise, -WLHWIN7 indicates Win7 target.

- Also, turn off OACR by default ( If WLHBASE points to WDK 7000+, add no_oacr arg to setenv.bat )

Regards, Pavel

11-May-09, Pavel A

"Regexp strings in v7.3 R27 need to be updated"
Regexp string findstr "warning[^.][DRCLU][0-9][0-9]* error[^.][DRCLU][0-9][0-9]*" "build%OSR_EXT%.log" is really not enough. Please look into https://svn.assarbad.net/ddkbuild/trunk/ for testing different codes.

findstr "warning[^.][CDMRU][0-9][0-9]* warning[^.][BRP][KCWG][0-9][0-9]* warning[^.][ACLPS][DNRTVX][JKLTX][0-9][0-9]* error[^.][CDMRU][0-9][0-9]* error[^.][BRP][KCWG][0-9][0-9]* error[^.][ACLPS][DNRTVX][JKLTX][0-9][0-9]*" "build%OSR_EXT%.log" works well.

10-Apr-09, Eugene Lomovsky

"win7 support?"
When will we have the support for Win7?

30-Mar-09, Ice Yu

"Fails on -WDF"
Changing NMake build command line to: ddkbuild.cmd -WXP chk . -WDF

Results in the following error:

"fatal error C1083: Cannot open include file: "wdf.h": No such file or directory.

setenv.bet is being called, and the wdf.h file is in the kmdf\1.7 directory. I've even set the WDF_ROOT environment variable. Anyone know what I'm doing wrong?

My project compiles fine if I comment out all the wdf code and just build for ddk.

17-Mar-09, Montana Reid

"Link to documentation"
It would be useful to have a link to documentation is. I've found something useful, at http://ddkwizard.assarbad.net/, even if not using ddkwizard itself. And some of the questions asked here are answered there.

11-Mar-09, Steve Kovner

"Documentation? Bad zip file?"
Is there somewhere for documentation that is up to date and doesn't subscribing to the NT Insider? Also, I get an empty zip file.

12-Feb-09, Steve Kovner

Hi, I have to use the MFC lib in a printer driver (user mode driver). Unfortunately I get the following error during the installation (but only when I include stdafx.cpp into my source file): R6034 An application has made an attempt to load the C runtime library incorrectly. Please contact the ... .

I assume that the solution will be a manifest, but how can I add a manifest with the OSR build tool ? Any ideas ?

I added a manifest into my setupkit routine, but I get still the same error.

System environment: VS 2005 SP1 DDK6000 OS: windows XP SP2

Many thanks in advance Michel

02-Jan-09, Michael Völkel

"ddkbuild.cmd' is not recognized"
dev environment:visual studio 2008 + Vista WDK 6000 + ddkbuild.cmd It's the first time for me to use it. what's problem ? thanks in advance. output:

1>------ Build started: Project: Driver1.WNET, Configuration: WNET checked (PREfast) Win32 ------ 1>Performing Makefile project actions 1>'ddkbuild.cmd' is not recognized as an internal or external command, 1>operable program or batch file. 1>Project : error PRJ0019: A tool returned an error code from "Performing Makefile project actions"

14-Oct-08, Alvin Hu

"DDK version autodetection"
Let's say I'm building my project for win2k3, and I have DDK for win2k8 installed. So, in batch file for build I have to do two things - set WLHBASE to DDK path and set "WLHNet" type for building project.

My point is, isn't it a bit redundant? I mean, if WLHBASE and only it is set, ddkbuild.cmd has all the information necessary to understand that if I'm using "ddkbuild.cmd WNET" I actually mean "ddkbuild.cmd WLHNet", doesn't it?

It's not a big deal really, but I wonder - am I doing something wrong?

29-Sep-08, Bogdan Opanchuk

"Possible bug with -jpath flag"
This is a great utility, I've been using it for months and it saved me a lot of time and trouble! :) But now I've faced a situation that might be a bug when using the -jpath flag.

DDKBuild doesn't work as it should with the -jpath flag of the build utility. The ddkbuild.cmd appears to consider that each flag is grouped with others (such as in "-cefZ") or separated by " " ("-c -e -f -Z"), but doesn't address flags that has parameters, such as the -jpath flag (-jpath ).

I fixed it by removing the "-e" appended to the bflags var (line 597) as it is already part of the bflags (the bflags is initialized as "-Ze", line 587).

Here in my project I didn't have any problem with this approach, but I wonder if there is a specific situation where the "-e" flag must be appended to every flag passed to the build utility.

PS: I'm using ddkbuild v7.2 (April 2008)

12-Aug-08, Thiago Figueredo Cardoso

"vc++ 2008"
Hello, could you please inform on how to perform on a vc++ 2008 express edition? Thanks

05-Jun-08, Doug Funny

"WDK6001 & AMD64 config."
Oliver : Yes. You are right. But the same problem exists with the WLHNETX64 configuration (i.e. "AMD64" parameter must be replaced by "x64").

22-Feb-08, Vladimir Zinin

"Warning messages not parsed by VS2005"
The compiler warning messages get emitted by DDKBUILD with a prefix of DDKBLD: before them. This seems to be tripping up VS2005 when it parses the build output - the warnings do not end up being parsed.

Perhaps when build*.wrn file is parsed and emitted, instead of using %OSR_ECHO% just simply ECHO could would do?

The resulting output seems to show up in the VS2005 Error List pane correctly (as warnings) if that minor tweak is made.

21-Dec-07, David R. Cattley

"WDK 6001 problem"
It's very convenient utility. Thanks. There is a small problem when using it for build WNETAMD64 by using WDK 6001. Setenv.bat (which is called internally by ddkbuild) does not recognize "AMD64" parameter. It must be replaced by "x64". For ddkbuild.cmd it's solved by fixing the following line: set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% AMD64 WNET

19-Oct-07, Vladimir Zinin

"The browse files ..."
To be honest I deactivate browse files in all my driver projects. Instead I use Visual AssistX, which will - after pointing it to the DDK/WDK headers - parse the actual header files and provide a much enhanced version of IntelliSense allong with a lot more improvements in the IDE. I'd not want to work without it anymore, although it is kind of expensive for "just" a plugin. And yes, they are known to be incompatible. Until I found VAX, I had even problems between some "older" IDE version (2003, if I recall correctly) and the "newer" tools in the Windows 2003 SP1 DDK.

06-Sep-07, Oliver Schneider

"BROWSERFILE and DdkBuild.bat"
I found one small but annoying problem for DdkBuild.bat version 6.10. It seems to me that there is lack of flexibility in regards of building browser information using features that build utility already provides.

The problem that setenv.bat from WDK 6000 by default sets NO_BROWSER_FILE variable into “TRUE” value. Please have a look into usage description below:

Usage: "setenv [fre|chk] [64|AMD64] [hal] [WLH|WXP|WNET|W2K] [bscmake]" By default, setenv.bat will set the environment variable NO_BROWSER_FILE. Using the "bscmake" option will cause setenv.bat to not define this variable. Example: setenv d:\ddk chk set checked environment Example: setenv d:\ddk set free environment for Windows Vista (default) Example: setenv d:\ddk fre WLH Same Example: setenv d:\ddk fre 64 sets IA-64 bit free environment Example: setenv d:\ddk fre AMD64 sets x86 bit free environment Example: setenv d:\ddk fre x86-64 sets x86 bit free environment Example: setenv d:\ddk fre WXP sets free build environment for Windows XP Example: setenv d:\ddk hal sets free hal environment Example: setenv d:\ddk fre hal Same

As result defining BROWSERFILE variable in SOURCES file has no effect. Could you add “bscmake” option into features of DdkBuild.bat? I.e. could you add some environment variable for setenv.bat, e.g. SETENV_ADDITIONAL_PARAMETERS, that can pass "bscmake" option.

Actually I know how to use sbrList.txt file too but I would like to use native features from build utility makefiles.

26-Jul-07, Al Shatilo

"VC6.0 bscmake incompatible with WDK 6000?"
My VC6.0 bscmake complains the *.sbr files generated by WDK 6000 are corrupted. Anyone would like to share?

02-Apr-07, Eng Ban Ong

"Support for UMDF"
How about the support for UMDF builds?

05-Dec-06, Amloorp Anand

"Problem with WNETX64 and WNETI64 switches (DDKBUILD V7.0 Beta 3a)"
I founded that this switches is probably not functional. Build utility can not found label with this name. I hope that only one thing you have to do is to rename WNETX64Build (line 262) and WNETI64Build (line 260) to their proper name WNETX64Check and WNETI64Check.

06-Nov-06, Ondrej Slanina

"Very beginner ?"
Hi, how can we use this file ?. i don't understand exactly.

18-Sep-06, selcuk yazar

"A fix is in the works along with some other updates"
Hi, A fix is in the works for this. Thanks for pointing this out.

03-May-06, Mark Cariddi

"Build flags problem"
Great utility, but I found one problem. The batch file assumes that the flags passed to "build" are all in one parameter. My directory tree has several directories that are not built for each project, and I use the ~ operator to exclude them. For example:

build ~dir1 ~dir2

Since bflags is reset for each flag, my build only gets executed as

build ~dir2 -e

It's easy enough to fix -- Essentially bflags should have each flag appended instead of replacing the whole thing. (This is at line 304 in ddkbuild.cmd, and line 522 in ddkbuild.bat v6.5.)

03-May-06, Jeff Claar

"Another way to build"
Place this in the build cmd line of VS: cmd /c "C:\WINDDK\3790~1.183\bin\setenv.bat C:\WINDDK\3790~1.183 chk WXP && cd $(InputDir) && C:\WINDDK\3790~1.183\bin\x86\build -eMI". The arguments for setenv.bat come from the shortcuts placed in the start menu. This allows you to build from VS as if you just clicked the shortcuts changed to the directory and ran the build command, the recommended way to do it.

21-Jan-06, Kwadwo Mireku

"DDKBUILD V7.0 Beta"
Thanks for the comments on this, I'll look into it.

17-Jan-06, Mark Cariddi

"DDKBUILD V7.0 Beta"
Further to yesterdays comment. It appears to me that in: :WDFFound shift if "%WDF_ROOT%" == "" goto :ErrNoWdfRoot pushd . call %WDF_ROOT%\set_wdf_env.cmd popd set DEBUG=on goto :ContinueParsing the call to set_wdf_env.cmd is not neccesary as that cmd erroneously resets WDF_ROOT with a trailing backslash because it uses: set WDF_ROOT=%~dp0 instead of set WDF_ROOT=%CD% but it is not neccesary anyway because DDKBuild requires WDF_ROOT to be set if building WDF.

All this was tested using VS 2005 Team Suite Evaluation. Thanks for listening.

13-Jan-06, Cornelis van Rikxoort

"DDKBUILD V7.0 Beta"
Great script, but with one small typeo - %%BASEDIR% below is missing a %.

:: WNET build for 64bit (AMD) using WNET DDK :WNETAMD64Build set OSR_BUILDNAME=WNET 64 BIT BUILD using WNET DDK set BASEDIR=%WNETBASE% set OSR_CMDLINE=%%BASEDIR%%\bin\setenv.bat %%BASEDIR% %%mode%% AMD64 WNET goto :EOF

12-Jan-06, Cornelis van Rikxoort

"Building for Win 2k with WNET3790.1830 DDK"
Looks like a tiny inconsquential bug for those of us still writing for windows 2000

I was getting an error on the line: call %BASEDIR%\bin\w2k\set2k.bat %BASEDIR% %mode%

changed to: call %BASEDIR%\bin\setenv.bat %BASEDIR% %mode%

and was troubled no more.

20-Dec-05, Eric Zweighaft

"flags enhancement"
currently, build options with blanks can not be specified with the [flags] parameter. E.g. the following command fails: ddkbuild -NT4 free . "-ceZj mylogfile" This can be fixed in ddkbuild.bat by adding '~' to %3 in the ContinueParsing "function": if "%~3" == "" goto done if "%~3" == "/a" goto RebuildallFound ...

Greetings, :)Dieter

19-Dec-05, Dieter Pfeuffer

"Thanks for the comments"
Thanks for the comments, I'll look into correcting this.

07-Dec-05, Mark Cariddi

"Simpler way"
There's a simpler and more reliable way. Follow the steps to create a makefile project and place cmd.exe /c "C:\WINDDK\3790\bin\setenv.bat C:\WINDDK\3790 chk WXP && cd $(InputDir) && C:\WINDDK\3790\bin\x86\build" in the Build Command Line project setting. Replace chk with fre for release builds and replace 3790 with your DDK version.

28-Aug-05, Kwadwo Mireku

"Browse niggle"
Of course this is just brilliant stuff!

One tiny niggle on the browse:

Currently you get the headers from the last build you made and not those for the currently active configuration. Not a big deal, except when your half asleep after a long shift, but it doesn't look too hard to fix either?

Just add plaform and buildtype options into the sbrList name, and we can use /o to identify configuration specific .bsc files. I see you already do this for %CPU% so your nearly there!

Two other VC 6 'features' can trip up the casual browser (I think its the same on .NET too)

1. VC uses include paths from the devstudio settings to locate header files (if you right click on the #include and select open include file) its 'pot-luck' where you end up.

2. Anything that writes "error" or "warning" to the output stream will result in VC counting up the number of errors/warnings. Gee that's smart programming by the VC team (not!)

'anything' in this context, happens to include old versions of resource compilers (they emit "compiling error log file" or something similar). So if you include resources like you should, and still use (say) the W2K DDK, like you should NOT, then you'll see this.

And really that is absolutely ALL I've found wrong with this approach, over many years trying things this way, and various other alternatives for best productivity.

And lets face it that isn't much wrong at all. Congratulations!

16-Mar-05, Jack Heeley

Are you sure you'll get all those switches right? And what happens when the DDK version changes, and it uses slightly different switches and settings -- With your method, I'm afraid, the switches are embdeed in your VS project? And how about building your driver for different build environments?

The fact of the matter is: NEVER build a driver directly from within VS by attempting to copy the switches and compiler settings. There's no guarantee you'll get it right, and the DDK's setting change from release to release and build environment to build environment.

WHY would you not want to do this the RIGHT WAY and use build, from within Visual Stuido if that's what you want to do. THEN you're assured that everything will always be correct.

10-Mar-05, Peter Viscarola

"building drivers with visual studio"
'But you'll still be using the version of the compiler and linker that Visual Studio provides '

Not true.

To use visual studio to build drivers: In project settings set 'ignore default directories' for compiler and linker. Set all the driver related defines, includes, linker switches etc.

In Tools-Options-Directories-Executable Files set a path to the DDK bin and move it to the top of the list. Copy BSCMAKE.EXE from the VS bin dir to the DDK bin dir.

Now you can build a driver with browse info etc from VS with EXACTLY the same binary image as using build.exe.

10-Mar-05, matt sykes

"How to set WXPBASE?"
When I tried to build WDM driver under Windwos XP(SP2), I got an error below. error: BASEDIR, W2KBASE, WXPBASE, or WNETBASE environment variable not set.

How to set WXPBASE?

Thank you in advance for help.

10-Feb-05, Jimmy Chen

"Any fix for WXPBASE etc not defined issue?"

16-Nov-04, k mk


09-Aug-04, Thanh Truong

"setting of WXPBASE"
I am trying to build the nothing_wdm project using my Visual C++ version 5 . My Question is what value should I set to the WXPBASE variable ? is it the root directory of the ddk ? if it is so, it does not work . The Visual C++ output this error message :

--------------------Configuration: NOTHING_WDM - Win32 Debug-------------------- OSR DDKBUILD.BAT V5.3 - OSR, Open Systems Resources, Inc. WXP 32 BIT BUILD using WXP DDK error: BASEDIR, W2KBASE, WXPBASE, or WNETBASE environment variable not set.

Best Regards

Tzachi orpaz

19-Jun-04, tzachi orpaz

"RE: Proposed fix"
This fix has been incorporated into V5.3 of DDKBUILD.

19-May-03, Scott Noone

Post Your Comments.
Email this article.
bottom nav links