Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


how to compile NDIS using mingw,

turmukaturmuka Member Posts: 16

I want to use layer 2 to create and receive raw sockets on a network adapter on my laptop. Yet I do not want to use Visual Studio.. It is not my favorite.. Are there header files for ndis to be compiled using mingw32 or 64 ? ndis 6.0+ is preffered, and I would also look for ndis 5.1 for NT family, (if the code syntax doesnt change, I can compile for both.)
Thank you in advance

Comments

  • turmukaturmuka Member Posts: 16

    I do not know where to start which ndis on mingw(gcc), if there is any files you can forward me with sample startup codes, would be appreciated.

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,727

    You don't have to use the IDE. I never run the Visual Studio IDE -- I do all my editing in gvim or VSCode, and then compile on the command line. Really, you don't want to use another compiler. Microsoft does not support drivers compiled with other compilers, so if you file a support event that ends up being compiler-related, they won't help.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • turmukaturmuka Member Posts: 16

    @Tim_Roberts Thank you for the answer. what compiler do you use ? do you use mingw as well? if you don't mind sharing, what would an example command of your compilation?
    such as gcc myDriver.c -lndis or something like that ?

  • turmukaturmuka Member Posts: 16

    also any tips on where i can get ddk/ ndis headers for mingw 32/64 bits.. thank you very much

  • turmukaturmuka Member Posts: 16

    I also found this library by Jeffrey Tippet, what would be a sample compilation command by mingw using this. Seems a very good one https://github.com/microsoft/ndis-driver-library

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,727

    I don't use gcc because, as I said, Microsoft doesn't support it. I use the Visual Studio compilers. I just don't use the IDE.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Mark_RoddyMark_Roddy Member - All Emails Posts: 4,712

    User the EWDK toolchain. It is specifically geared toward command line builds, it is free, etc. As Tim said, the only supported compilers are the microsoft ones., and as he noted vscode is free and super easy top get to work with the EWDK. You are just going to increase the cost/effort to do whatever it is you are trying to do by at least a factor of 10, and then it will likely never work correctly anyway.

  • turmukaturmuka Member Posts: 16
    edited March 5

    @Mark_Roddy Is there any tutorial on where to get started, because I can't find useful source for this subject.. It is like I can write code but I cannot compile them. That is why I asked for a sample command line to compile NDIS. EWDK comes with VS components, yes ? what do I need to do to compile my template (from command line)? Do you ever use cmake ?Thank you for all the help @Tim_Roberts @Mark_Roddy

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,727

    The EWDK comes with the Visual C++ toolchain, compilers, includes, and libraries, but not the IDE.

    cmake is perfectly happy to create Visual Studio project files, but typical driver projects vary only slightly from each other. Once you have a project file that works, you can just edit that one for the slight differences. Just type "msbuild" at a command line.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • turmukaturmuka Member Posts: 16
    edited March 6

    A numeric comparison was attempted on "$(_NT_TARGET_VERSION)" that evaluates to "" instead of a number, in condition "$(_NT_TARGET_VERSION) < $(_NT_TARGET_VERSION_WIN7)

    I try to compile https://github.com/microsoft/Windows-driver-samples/tree/main/network/ndis/filter this with msbuild, hence I get the error above, is it due to missing libraries, or something else ?

    My Command: msbuild.exe ndislwf.vcxproj /t:build /p:TargetVersion="Windows10"

    Thanks for all the help..

  • turmukaturmuka Member Posts: 16
    edited March 6

    also, in this link, it says WDK requires visual studio and EWDK doesn't apparently. https://learn.microsoft.com/tr-tr/windows-hardware/drivers/download-the-wdk

    Insight question, why is it that, EWDK is 15 GB whereas WDK is only 2? Also it says, Mount the ISO file for EWDK, where do I mount it exactly? @Mark_Roddy

    Thank you for giving me start push.

  • Mark_RoddyMark_Roddy Member - All Emails Posts: 4,712

    The 'WDK' is not a full tool chain, it is an extension to the full visual studio tool chain. The EWDK is a full toolchain without support for the VS IDE and C#.
    You can mount an iso file on a windows system using a lot of different methods. Here is how to do it with powershell:

    $iso = "C:\Users\foo\Downloads\EWDK_vb_release_svc_prod1_19041_201201-2105.iso"
    $vol = mount-diskimage -ImagePath $iso -PassThru
    (Get-DiskImage -DevicePath $vol.DevicePath | Get-Volume).DriveLetter
    
  • Mark_RoddyMark_Roddy Member - All Emails Posts: 4,712
    edited March 6

    This thread points out just how awful the EWDK documentation is. It's too bad as it really is, in my opinion, a much better way to build drivers. No mystery updates, no massive bloat, easy to build identically on dev and build systems, simple to switch to new versions, easy to integrate into VSCode.

    @turmuka you need to have a whole set of environment variables set before your build from the command line will work. Unfortunately the EWDK does not support powershell directly, so you need to use the awful DOS command shell and run 'LaunchBuildEnv.cmd' from the root of the EWDK volume first, then you should be able to run 'msbuild.exe ndislwf.vcxproj /t:build /p:TargetVersion="Windows10"' and not have it fail. (Actually that '/p:TargetVersion="Windows10"' looks wrong to me.)

    Someday I'll make my buildtools repo on github public. Sigh...

  • Phil_BarilaPhil_Barila Member - All Emails Posts: 169

    @Mark_Roddy said:

    @turmuka you need to have a whole set of environment variables set before your build from the command line will work. Unfortunately the EWDK does not support powershell directly, so you need to use the awful DOS command shell and run 'LaunchBuildEnv.cmd' from the root of the EWDK volume first, then you should be able to run 'msbuild.exe ndislwf.vcxproj /t:build /p:TargetVersion="Windows10"' and not have it fail. (Actually that '/p:TargetVersion="Windows10"' looks wrong to me.)

    All true, though you can mitigate that a bit by running powershell (or better yet, pwsh) from the resulting CMD and get the best of both worlds ...

    Phil Barila
    Not speaking for AMD

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,727

    It's worth pointing out that, if you have the time, all of the driver documentation is in a git repository, and they accept pull requests with improvements. I've had a number of my suggested rewrites merged in, and rather quickly.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 9,133

    It's too bad as it really is, in my opinion, a much better way to build drivers

    And, even better... If you're one of those (like me) who are inclined to use Visual Studio, I've been told that you can use it from within the EWDK environment... I've been meaning to try this and write a blog post about it.

    I have friends a MSFT who SWEAR this is THE best way to write drivers.

    Peter Viscarola
    OSR
    @OSRDrivers

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 13-17 May 2024 Live, Online
Developing Minifilters 1-5 Apr 2024 Live, Online
Internals & Software Drivers 11-15 Mar 2024 Live, Online
Writing WDF Drivers 26 Feb - 1 Mar 2024 Live, Online