CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2008
    Posts
    42

    Combine WDK with Visual Studio

    I want to start working on driver development, but trying to set up build for WDK seems to be too complicated. I can't even find documentation on the commands to build a project. Can someone explain very nicely how to combine the WDK environment with Visual Studio when I choose? And how do I make it so that I can add the header files like ntddk.h to my project if I use Visual Studio?

  2. #2
    Join Date
    Sep 2005
    Location
    London
    Posts
    208

    Re: Combine WDK with Visual Studio

    Hi Shady,

    Let's start from the beginning.

    WDK (Windows Driver Kit) is a fully integrated driver development system for the Microsoft Windows platforms. The kit contain samples, documentation, tools and most important the build environments.

    If you want Visual Studio to use WDK files, you will have to tell VS where to fine them.

    The default installation directories of WDK header and library files are:
    WDKInstallationPath\BuildNumber\ inc
    and
    WDKInstallationPath\BuildNumber\ lib

    Setting it up is easy.
    I'll show you how to do it under VS2005 and you can adapt it to the version you are using.

    1. Run VS2005
    2. Select Tools->Options->Project and Solutions->VC++ Directories
    3. On the right side choose Include file (from show directories from)
    4. Add WDKInstallationPath\BuildNumber\ inc to the list
    5. On the right side choose Library file (from show directories from)
    6. Add WDKInstallationPath\BuildNumber\ lib to the list
    7. Press OK

    You're done.
    Now when you include a header file from WDK (like ntddk.h), VS will look for it according to the directories you've selected.

    After you write your driver, You will need to create 2 more files to be able to build it.

    The first file is a simple text file contain a single line which you should NEVER change.
    Code:
    # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
    # file to this component. This file merely indirect to the real make file
    # that is shared by all the driver components of the Windows NT DDK
    !INCLUDE $(NTMAKEENV)\makefile.def
    Name the file:
    makefile

    It is very important that the makefile WILL NOT have an extention after the file name (My advice is to allow windows to show file extensions from the folder options).

    The second file is another text file (again with no file extention) called sources which is simply a list of source files and builds options.
    It contains the (minimum) following lines:
    Code:
    TARGETNAME = myapp
    TARGETPATH = obj
    TARGETTYPE = DRIVER
    
    INCLUDES   =..\inc       // Set it to the include dir
    LIBS=..\lib                    // Set it to the lib dir
    
    SOURCES= main.c    
                    send.c        
                    recv.c   
                    ...
    To build the driver simply open the WDK build command prompt (Checked Build Environment) from Windows start menu and go to your application directory.
    Code:
    cd\Myapp
    c:\Myapp
    Finally run the command build.exe.
    You're driver is built and ready to use.


    Best regards
    Doron Moraz
    Last edited by Doron Moraz; March 15th, 2008 at 08:40 AM.

  3. #3
    Join Date
    Feb 2008
    Posts
    42

    Re: Combine WDK with Visual Studio

    Thank you so much for replying with such a stunningly helpful response. You are the absolute best. Thanks a whole lot!!!!!!

  4. #4
    Join Date
    Sep 2005
    Location
    London
    Posts
    208

    Wink Re: Combine WDK with Visual Studio

    You are more than welcome.

  5. #5
    Join Date
    Nov 2010
    Posts
    1

    Re: Combine WDK with Visual Studio

    This is just what I need, except how to I import the commands to c#? There are several sources that either say it can't be done or don't give a clear example..

    I have included the WDK inc and lib, now what would I need to do to import
    HardwareDeviceInfo = SetupDiGetClassDevs(
    InterfaceGuid,
    NULL,
    NULL,
    (DIGCF_PRESENT | DIGCF_DEVICEINTERFACE));
    Quote Originally Posted by Doron Moraz View Post
    Hi Shady,

    Let's start from the beginning.

    WDK (Windows Driver Kit) is a fully integrated driver development system for the Microsoft Windows platforms. The kit contain samples, documentation, tools and most important the build environments.

    If you want Visual Studio to use WDK files, you will have to tell VS where to fine them.

    The default installation directories of WDK header and library files are:
    WDKInstallationPath\BuildNumber\ inc
    and
    WDKInstallationPath\BuildNumber\ lib

    Setting it up is easy.
    I'll show you how to do it under VS2005 and you can adapt it to the version you are using.

    1. Run VS2005
    2. Select Tools->Options->Project and Solutions->VC++ Directories
    3. On the right side choose Include file (from show directories from)
    4. Add WDKInstallationPath\BuildNumber\ inc to the list
    5. On the right side choose Library file (from show directories from)
    6. Add WDKInstallationPath\BuildNumber\ lib to the list
    7. Press OK

    You're done.
    Now when you include a header file from WDK (like ntddk.h), VS will look for it according to the directories you've selected.

    After you write your driver, You will need to create 2 more files to be able to build it.

    The first file is a simple text file contain a single line which you should NEVER change.
    Code:
    # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
    # file to this component. This file merely indirect to the real make file
    # that is shared by all the driver components of the Windows NT DDK
    !INCLUDE $(NTMAKEENV)\makefile.def
    Name the file:
    makefile

    It is very important that the makefile WILL NOT have an extention after the file name (My advice is to allow windows to show file extensions from the folder options).

    The second file is another text file (again with no file extention) called sources which is simply a list of source files and builds options.
    It contains the (minimum) following lines:
    Code:
    TARGETNAME = myapp
    TARGETPATH = obj
    TARGETTYPE = DRIVER
    
    INCLUDES   =..\inc       // Set it to the include dir
    LIBS=..\lib                    // Set it to the lib dir
    
    SOURCES= main.c    
                    send.c        
                    recv.c   
                    ...
    To build the driver simply open the WDK build command prompt (Checked Build Environment) from Windows start menu and go to your application directory.
    Code:
    cd\Myapp
    c:\Myapp
    Finally run the command build.exe.
    You're driver is built and ready to use.


    Best regards
    Doron Moraz

  6. #6
    Join Date
    Dec 2002
    Location
    La Plata, Buenos Aires
    Posts
    615

    Re: Combine WDK with Visual Studio

    I prefer to use VisualDDK. Supports IDE debugging through remote connection, and to VMWare/VBox machines via VirtualKD or emulated serial/IEEE1394 ports.

    http://visualddk.sysprogs.org/

  7. #7
    Join Date
    Apr 2011
    Posts
    2

    Re: Combine WDK with Visual Studio

    Hi,

    After you write your driver, You will need to create 2 more files to be able to build it.

    The first file is a simple text file contain a single line which you should NEVER change.
    Code:
    # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
    # file to this component. This file merely indirect to the real make file
    # that is shared by all the driver components of the Windows NT DDK
    !INCLUDE $(NTMAKEENV)\makefile.def
    Name the file:
    makefile

    It is very important that the makefile WILL NOT have an extention after the file name (My advice is to allow windows to show file extensions from the folder options).

    The second file is another text file (again with no file extention) called sources which is simply a list of source files and builds options.
    It contains the (minimum) following lines:
    Code:
    TARGETNAME = myapp
    TARGETPATH = obj
    TARGETTYPE = DRIVER
    
    INCLUDES   =..\inc       // Set it to the include dir
    LIBS=..\lib                    // Set it to the lib dir
    
    SOURCES= main.c    
                    send.c        
                    recv.c   
                    ...
    To build the driver simply open the WDK build command prompt (Checked Build Environment) from Windows start menu and go to your application directory.
    Code:
    cd\Myapp
    c:\Myapp
    Finally run the command build.exe.
    You're driver is built and ready to use.


    I performed the above mentioned seven steps , now what is the meaning of these two more steps. Where we have to save these two files?

    Can you experts have link for driver development (especially printer driver) for beginners. I am referring the WDK samples. But I am interested in knowing the link for WDK with Visual Studio.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured