Problem to configure the latest WDK

Hello Friends!

I pushed to move huge project set to the latest VS2022.
I spent 2.5 days, got over a lot of problems and till now I have one with configuration VS2022 + WDK. :frowning:

Application layer Projects compilation is OK.
But kernel Projects (Libs + Drivers), which use Platform Toolset WindowsKernelModeDriver10.0, gives error:

1>C:\Program Files (x86)\Windows Kits\10\build\10.0.22621.0\WindowsDriver.common.targets(314,5): error MSB4044: The “ValidateNTTargetVersion” task was not given a value for the required parameter “ValidNTTargetVersions”.

I found Microsoft’s recommendation https://github.com/microsoft/DMF/issues/224 to use

! set MSBuildUserExtensionsPath=%VSINSTALLDIR%\MsBuild

It’s only add additional warning to the error list about double imports. :frowning:

I setup the latest version of MS2022, SDK and DDK:

! Microsoft Visual Studio Professional 2022
! Version 17.7.5
! VisualStudio.17.Release/17.7.5+34202.233
! Microsoft .NET Framework
! Version 4.8.04084
!
! Installed Version: Professional
!
! Visual C++ 2022 00476-80000-00000-AA406
! Microsoft Visual C++ 2022
!
! …
!
! Windows Driver Kit 10.0.22621.311
! Headers, libraries, and tools needed to develop, debug, and test Windows drivers (msdn.microsoft.com/en-us/windows/hardware/gg487428.aspx)

Where is the problem?
How it may be fixed?

Thanks & Best Regards,
Michael Grabelkovsky.

No recommendations here? :frowning:

If so, somebody may recommend the address in Microsoft Driver Support, where really may help?

What is WindowsTargetPlatformVersion set to in your vcxproj files?

Mark,
Thanks a lot!
Your idea was not right. But you hint me the direction where to looking for the problem! And I found it. :smile:

Peter,
if you read it. It’s bug Microsoft and it must be fixed!
How to report Microsoft about?

The details follows.

Problem Solution
Add into vcxproj file two lines:

  • <TargetVersion>Windows10</TargetVersion>
    
  • <DriverTargetPlatform>Universal</DriverTargetPlatform>
    

(1st is obligated, 2nd is recommended)

Problem Source
My Project went from VS2012 → VS2017 → VS2022.
What is interesting, if open VS2017 and go Project → Properties → Driver Settings.
Target OS Version is written Windows 10 or higher.
But!!! Appropriate vcxproj file has not or this option is empty!?!

It’s seen as this value is default for VS2017, but not default for VS2022.
Unfortunately the error message does not hint the source of problem. :neutral:

How to Found
It’s impossible to find error in key which really absent in vcxproj, means absent. :smile:
I built new, alternative project inside VS2022 (which works!) and compare it with my native.

Other problems
My 1st fix project was static lib for driver (build with WindowsKernelModeDriver10.0).
Currently I see problems in others, driver projects.
VS202 inside GUI Project → Properties does not show drivers sections: Driver Settings, Driver Install, Inf2Vat etc. :neutral:
But currently I know how to find the problems. :smile:

FWIW, I recommend you REBUILD your projects and solutions when you change your tool chain to a new version of VS. Going the “upgrade” route rarely works well, at least for me.

It’s always been thus…

Peter

Peter,
Thanks!

It’s exactly what I asked. And reason for going to VS2022 is important - future support ARM…

The problem, I have set from ~170 Projects, including applications, drivers, libs, plugins, C++, C# etc.
I have no other way: try to use “upgrade” route and fix the problems other…

By the way, the next problem:
Driver Projects does not seen as Driver in GUI. Means there are absent sections such as Driver Settings, Driver Install, Inf2Cat etc.
I did not start to solve it yet, but it’s seen Microsoft Project Convertor can’t support Platform Toolset: WindowsKernelModeDriver10.0. :frowning:
I may report when will find. :slight_smile:

Some additional information for fellows…

After few attempt I resume, that Microsoft completely not checked Project Convertor on VS2022 for case kernel components (drivers, static libs) which are built with Platform Toolset WindowsKernelModeDriver10.0.

I must agree with Piter, on VS2022 it’s easier to create new project from template and fill it up by hand then spend a time to understand problems after Project Converter.
As bonus you would immediately receive support for ARM… :slight_smile:

PS. I have not (yet) same problems with toolset Visual Studio 2022 (v143) , only with WindowsKernelModeDriver…

In general user mode C# and C++ projects are well tested in VS and conversion works. On the other hand, there has been a long standing disconnect between the VS release process and the WDK. My guess is that there are two different teams involved, and the VS team does not have responsibility for the WDK release and as a consequence VS gets released despite breaking WDK components.

Mark,
I guess you right.
The problem that Microsoft is great firm and it must integrate components better. :frowning:

I give now some hints for fellows who will need to move old driver to VS2022.

  1. Microsoft gives few templates for drivers. KMDF driver template is good. WDM Driver template is empty and has not all needed components for real driver!
    But my driver is written a time ago, I need WDM.
    What I had done, I took KMDF template, deleted all code, such as remined only Driver.c module with 2 functions DriverEntry() and UnloadDriver().
    Inside vcxproj I replaced in DriverType all KMDF on WDM.
    So I received good compiled template for WDM driver.

  2. I replaced all source files on my sources and carefully arranged vcxproj. Carefully means step by step with checking that driver build process is OK after every change.

  3. Pay attention on INF file, It must be correct! Microsoft adds few checking which works with INF file inside building process. Fоr example, I even don’t know which components press inside log the lines:
    Stamping C:\MG\epw-f1e_22\temp\Release.x64\WEP\Common\nep\src\driver\obj\cwnep.inf
    Stamping [Version] section with DriverVer=10/30/2023,15.11.22.2_83

but when I took my old INF (not generated by template), it even does not start code compilation!?!

Other utility which use INF is binplace.exe.
The problem its errors does not described! I run into one problem, which did not solved and finally took INF from template.
I guess I will need arrange it too, but it’s my future task, not now…

4, I returned Warning Level from VS2022 Level4(/W4) back on Level 3 which used for WDK drivers compilation previously. The reason, I received s much error on level 4 - I have not time to fix all this… :slight_smile:

I just don’t bother with the templates. I grab samples from the msft git hub repo and use those as ‘templates’. As an amusement I created some powershell scripts that automate grabbing a sample project and copying it to its own git repo and fixing up some of the junk that msft puts in their samples that break building them (e.g. the Sample class and guid in inf files.)

There are issues you still have to deal with, like the endless turmoil in Infverify. The samples are behind the latest wdk at this point. But that is just a minor annoyance.

The stampinf and infverify tasks are run if your project has an inf file listed in the vcxproj file.

My guess is that there are two different teams involved, and the VS team does not have responsibility for the WDK release

I can confirm that this is exactly how it works.

WDK team does the WDK; The Visual Studio team does… Visual Studio.

some hints for fellows who will need to move old driver to VS2022.

Hmmmm… In VS, just create a new project with an empty driver of the type that you want to build. From Solution Explorer, add the source and header files comprising your driver. At that point, you are pretty much done, right?? (Pro tip: In Solution Explorer, you can “add” multiple source files at once… sort your project directory by file type, and in a single step you can add all your CPP files… release for .H files… then it’s time to make yourself some a Mai Tai or two, no conversion required ;-)).

Peter

Piter,
it’s not so direct.

After I took WDK Template (empty) and even added into file Device.c with single (empty too) function DriverEntry(), it’s did not start to compil even!
Output:

Build started…
1>------ Build started: Project: MyDriver1, Configuration: Debug x64 ------
1>Building ‘MyDriver1’ with toolset ‘WindowsKernelModeDriver10.0’ and the ‘Desktop’ target platform.
1>Stamping x64\Debug\MyDriver1.inf
1>Stamping [Version] section with DriverVer=10/31/2023,10.24.5.380
1>C:\Tmp\MyDriver1\MyDriver1\MyDriver1.inf : error 1297: Device driver does not install on any devices, use primitive driver if this is intended.
1>Done building project “MyDriver1.vcxproj” – FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 10:24 and took 00.518 seconds ==========

There is exist option try to fix generated INF. But I even don’t know which utility generates lines “Stamping …”. It’s something new which absent in previous versions which I worked.

I prefered to start from “working” KMDF template and modify it.
Obviously try to fix INF also is alternative way. :slight_smile:

Question:
Who knows which utility generate “Stamping…” lines?
Id’ like to understand which checking it does…

Inf stamping has been a feature of the wdk build for a very long time. The utility is ‘stampinf’, and the msbuild task is documented here: https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/stampinf-task

Error 1297 is coming from infverif, not stampinf https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/inf-validation-errors-and-warnings#syntax-in-the-inf-file-1100-1299

Yes, but he asked specifically what was generating the ‘stamping…’ line.

Doron,
nice to meet you again! :slight_smile:
And Thank you for really interesting reference!

Unfortunately Google does not find error such as 1297, error text did not helped me too. :frowning:
(Compiler errors C9999 - no problem).

The page directly references your error https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/inf-validation-errors-and-warnings#syntax-in-the-inf-file-1100-1299:~:text=1297%3A%20Device%20driver,driver%20INF.