Share via

WDK Include Path

Amartya, Shreyank 1 Reputation point
2025-09-23T07:19:11.84+00:00

I'm having trouble compiling my driver solution on VS 2022 + WDK. On some systems, the compilation works fine but on others I get this error:

Cannot open include file: 'ntifs.h': No such file or directory

After including this folder in the project settings (on system where I don't face issues these directories are automatically added to the Include directories) I get these errors:

'SDDL_UPROF_STR': undeclared identifier
'DECLARE_CONST_UNICODE_STRING': identifier not found
'SDDL_UPROF_STR': undeclared identifier
'SDDL_UPROF_STR': undeclared identifier
'DECLARE_CONST_UNICODE_STRING': identifier not found
'SDDL_UPROF_STR': undeclared identifier
'KeQuerySystemTime': identifier not found
'KeQuerySystemTime': identifier not found
'SDDL_UPROF_STR': undeclared identifier

I have tried looking into these and they are declared under ntdef.h with condition

#if _WIN32_WINNT >= 0x0500

and jumping to declaration for reveals

#if !defined(_WIN32_WINNT) && !defined(_CHICAGO_)
#define  _WIN32_WINNT   0x0A00
#endif

which indicates it should be declared and found, but the declaration is greyed out.

All the systems are windows 11 24H2

Comparing the settings with systems on which the compilation works fine I can observe that the following macros are added automatically into the include path

$(CRT_IncludePath);

$(KM_IncludePath);

$(KIT_SHARED_IncludePath);

and on the systems where compilation is broken, these macros are missing. Where are these defined? and what do they depend on ?

I have followed all steps to insure the WDK and SDK version match. I also install Windows Driver Kit.

Driver is compiled for x64.

Windows development | Windows Driver Kit (WDK)

2 answers

Sort by: Most helpful
  1. Harry Vo (WICLOUD CORPORATION) 4,750 Reputation points Microsoft External Staff Moderator
    2026-01-16T09:00:22.0333333+00:00

    Hi @Amartya, Shreyank , here is my new response for your recent update:

    I created a new empty WDM project, but it also doesn't have "Driver Settings" under Project Properties.

    If Driver Settings is missing even for a newly created WDM project, then Visual Studio is not loading the WDK project system at all on this machine.


    Since this project wasn’t created using Visual Studio’s WDK templates, the WDK build logic isn’t automatically set up. So, I believe the only option left is to manually configure MSBuild:

    For each driver (.sys) project, please edit the .vcxproj and add:

    • Import WDK props/targets
    <Import Project="$(WDKTargetsPath)\Microsoft.DriverKit.props" />
    …
    <Import Project="$(WDKTargetsPath)\Microsoft.DriverKit.targets" />
    
    • Force the kernel toolset
    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
    

    These two steps are both required; doing only one is not sufficient.

    For static libraries used by the driver:

    Keep ConfigurationType = StaticLibrary

    Add:

    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
    

    Do not import DriverKit props/targets into static libs.

    After editing the .vcxproj files, close and reload the solution, then rebuild all configurations so MSBuild picks up the new imports and toolset.


    You can also create a new Kernel Mode Driver (WDM) sample project (have to a real WDM working project, use other working machine to create) and compare its .vcxproj with your existing projects to ensure your manual edits (imports, <PlatformToolset>, property groups) match a correctly configured driver project.


  2. Harry Vo (WICLOUD CORPORATION) 4,750 Reputation points Microsoft External Staff Moderator
    2026-01-12T03:58:16.27+00:00

    Hi @Amartya, Shreyank , thanks for your update!

    This issue is not caused by missing headers or _WIN32_WINNT definitions, but by WDK MSBuild integration not being loaded correctly on some systems.

    In a properly configured driver project, Visual Studio automatically imports WDK .props/.targets files. These define macros such as: $(KM_IncludePath), $(KIT_SHARED_IncludePath), $(CRT_IncludePath)

    If these macros are missing, Visual Studio is not recognizing the project as a kernel-mode driver project, even though the WDK is installed. As a result, the compiler uses incomplete or incorrect headers, which leads to errors like ntifs.h not found and kernel symbols (e.g. KeQuerySystemTime, DECLARE_CONST_UNICODE_STRING) being undefined.

    On some systems, the compilation works fine but on others I get this error

    On working systems, the WDK is correctly registered with Visual Studio, so the driver targets are imported automatically. On broken systems, the WDK installation exists but its VS integration is incomplete or mismatched (often due to install order, multiple SDK/WDK versions, or a corrupted VS component).


    So, to fix this issue, simply register the WDK correctly by installing the WDK via NuGet (as you discovered). This explicitly injects the required MSBuild properties and avoids global VS registration issues.

    In addition, ensure the project is created as a Driver (KMDF/UMDF) project, not a generic C++ project and verify that the WDK and Windows SDK versions match and that the WDK Visual Studio extension is installed. If the issue still persists, I highly advice you reinstall everything to make sure nothing is corrupted.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.