From ba493fec0bad1353ee42ab8a9783e4879cac1598 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 15 Jun 2026 13:50:51 +0200 Subject: km: add wdk10 build files & GitHub windows-2022 pipeline --- .appveyor.yml | 11 +- .github/workflows/ci.yml | 54 ++++++++++ km/build/wdk10/minimal/minimal.sln | 35 ++++++ km/build/wdk10/minimal/minimal.vcxproj | 106 +++++++++++++++++++ km/build/wdk10/nt_namespace/nt_namespace.sln | 35 ++++++ km/build/wdk10/nt_namespace/nt_namespace.vcxproj | 129 +++++++++++++++++++++++ km/build/wdk10/simple/simple.sln | 35 ++++++ km/build/wdk10/simple/simple.vcxproj | 110 +++++++++++++++++++ km/src/nt_namespace/main.c | 2 + km/src/nt_namespace/nt2dos.c | 16 ++- km/src/simple/device.c | 18 ++-- 11 files changed, 532 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 km/build/wdk10/minimal/minimal.sln create mode 100644 km/build/wdk10/minimal/minimal.vcxproj create mode 100644 km/build/wdk10/nt_namespace/nt_namespace.sln create mode 100644 km/build/wdk10/nt_namespace/nt_namespace.vcxproj create mode 100644 km/build/wdk10/simple/simple.sln create mode 100644 km/build/wdk10/simple/simple.vcxproj diff --git a/.appveyor.yml b/.appveyor.yml index bcfb6f6..8b3141b 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -2,18 +2,17 @@ version: '{build}' image: Visual Studio 2013 -#environment: -# APPVEYOR_RDP_PASSWORD: 'FooBar01!' - -#on_finish: -# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) - environment: + global: + APPVEYOR_RDP_PASSWORD: 'FooBar01!' matrix: - TARGET_OS: Win7 - TARGET_OS: Win8 - TARGET_OS: Win8.1 +#on_finish: +# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) + platform: - Win32 - x64 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d477b7b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,54 @@ +name: CI + +on: + push: + workflow_dispatch: + +jobs: + build: + strategy: + matrix: + # As of June '26, WDK doesn't seem to be included in VS 2026 (windows-2026) images. + toolset: [vs2022] + platform: [x64] + configuration: [Debug, Release] + include: + - {toolset: vs2022, os: windows-2022} + runs-on: '${{ matrix.os }}' + name: 'Build: ${{ matrix.toolset }} / ${{ matrix.platform }} / ${{ matrix.configuration }}' + defaults: + run: + shell: pwsh + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + submodules: recursive + - name: Set up msbuild + uses: microsoft/setup-msbuild@v3 + - name: Build user-mode code + run: | + New-Item -Type Directory build\cmake | Out-Null + cd build\cmake + + cmake -A '${{ matrix.platform }}' ` + '-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}\build\install' ` + '${{ github.workspace }}' + + cmake --build . --target install --config '${{ matrix.configuration }}' + - name: Build kernel-mode code + run: | + .\scripts\build.ps1 ` + -InstallDir build\install ` + -Configuration '${{ matrix.configuration }}' ` + -Platform '${{ matrix.platform }}' ` + -WDK wdk10 + - name: Run tests + run: | + .\scripts\test.ps1 -InstallDir build\install + - name: Publish artifact + uses: actions/upload-artifact@v7 + with: + name: 'windows7-drivers-${{ matrix.platform }}-${{ matrix.configuration }}-Win10' + path: ./build/install/ + if-no-files-found: error diff --git a/km/build/wdk10/minimal/minimal.sln b/km/build/wdk10/minimal/minimal.sln new file mode 100644 index 0000000..497300c --- /dev/null +++ b/km/build/wdk10/minimal/minimal.sln @@ -0,0 +1,35 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36623.8 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minimal", "minimal.vcxproj", "{FB005505-E2A5-87EB-16C4-01EB3DE7A4EE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FB005505-E2A5-87EB-16C4-01EB3DE7A4EE}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {FB005505-E2A5-87EB-16C4-01EB3DE7A4EE}.Debug|ARM64.Build.0 = Debug|ARM64 + {FB005505-E2A5-87EB-16C4-01EB3DE7A4EE}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {FB005505-E2A5-87EB-16C4-01EB3DE7A4EE}.Debug|x64.ActiveCfg = Debug|x64 + {FB005505-E2A5-87EB-16C4-01EB3DE7A4EE}.Debug|x64.Build.0 = Debug|x64 + {FB005505-E2A5-87EB-16C4-01EB3DE7A4EE}.Debug|x64.Deploy.0 = Debug|x64 + {FB005505-E2A5-87EB-16C4-01EB3DE7A4EE}.Release|ARM64.ActiveCfg = Release|ARM64 + {FB005505-E2A5-87EB-16C4-01EB3DE7A4EE}.Release|ARM64.Build.0 = Release|ARM64 + {FB005505-E2A5-87EB-16C4-01EB3DE7A4EE}.Release|ARM64.Deploy.0 = Release|ARM64 + {FB005505-E2A5-87EB-16C4-01EB3DE7A4EE}.Release|x64.ActiveCfg = Release|x64 + {FB005505-E2A5-87EB-16C4-01EB3DE7A4EE}.Release|x64.Build.0 = Release|x64 + {FB005505-E2A5-87EB-16C4-01EB3DE7A4EE}.Release|x64.Deploy.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {144E8B3A-EC28-410C-A9E9-161914DFD3B3} + EndGlobalSection +EndGlobal diff --git a/km/build/wdk10/minimal/minimal.vcxproj b/km/build/wdk10/minimal/minimal.vcxproj new file mode 100644 index 0000000..7a693cd --- /dev/null +++ b/km/build/wdk10/minimal/minimal.vcxproj @@ -0,0 +1,106 @@ + + + + + Debug + x64 + + + Release + x64 + + + Debug + ARM64 + + + Release + ARM64 + + + + {FB005505-E2A5-87EB-16C4-01EB3DE7A4EE} + {dd38f7fc-d7bd-488b-9242-7d8754cde80d} + v4.5 + 12.0 + Debug + x64 + minimal + + + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + WDM + + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + WDM + + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + WDM + + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + WDM + + + + + + + + + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + obj\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + obj\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + obj\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + obj\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + + + + sha256 + + + + + sha256 + + + + + + + + + + + + diff --git a/km/build/wdk10/nt_namespace/nt_namespace.sln b/km/build/wdk10/nt_namespace/nt_namespace.sln new file mode 100644 index 0000000..1660617 --- /dev/null +++ b/km/build/wdk10/nt_namespace/nt_namespace.sln @@ -0,0 +1,35 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36623.8 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nt_namespace", "nt_namespace.vcxproj", "{CEECBBBD-A5A8-440B-9DDB-1EAA9BD485D9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CEECBBBD-A5A8-440B-9DDB-1EAA9BD485D9}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {CEECBBBD-A5A8-440B-9DDB-1EAA9BD485D9}.Debug|ARM64.Build.0 = Debug|ARM64 + {CEECBBBD-A5A8-440B-9DDB-1EAA9BD485D9}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {CEECBBBD-A5A8-440B-9DDB-1EAA9BD485D9}.Debug|x64.ActiveCfg = Debug|x64 + {CEECBBBD-A5A8-440B-9DDB-1EAA9BD485D9}.Debug|x64.Build.0 = Debug|x64 + {CEECBBBD-A5A8-440B-9DDB-1EAA9BD485D9}.Debug|x64.Deploy.0 = Debug|x64 + {CEECBBBD-A5A8-440B-9DDB-1EAA9BD485D9}.Release|ARM64.ActiveCfg = Release|ARM64 + {CEECBBBD-A5A8-440B-9DDB-1EAA9BD485D9}.Release|ARM64.Build.0 = Release|ARM64 + {CEECBBBD-A5A8-440B-9DDB-1EAA9BD485D9}.Release|ARM64.Deploy.0 = Release|ARM64 + {CEECBBBD-A5A8-440B-9DDB-1EAA9BD485D9}.Release|x64.ActiveCfg = Release|x64 + {CEECBBBD-A5A8-440B-9DDB-1EAA9BD485D9}.Release|x64.Build.0 = Release|x64 + {CEECBBBD-A5A8-440B-9DDB-1EAA9BD485D9}.Release|x64.Deploy.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {144E8B3A-EC28-410C-A9E9-161914DFD3B3} + EndGlobalSection +EndGlobal diff --git a/km/build/wdk10/nt_namespace/nt_namespace.vcxproj b/km/build/wdk10/nt_namespace/nt_namespace.vcxproj new file mode 100644 index 0000000..e760451 --- /dev/null +++ b/km/build/wdk10/nt_namespace/nt_namespace.vcxproj @@ -0,0 +1,129 @@ + + + + + Debug + x64 + + + Release + x64 + + + Debug + ARM64 + + + Release + ARM64 + + + + {CEECBBBD-A5A8-440B-9DDB-1EAA9BD485D9} + {dd38f7fc-d7bd-488b-9242-7d8754cde80d} + v4.5 + 12.0 + Debug + x64 + nt_namespace + + + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + WDM + + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + WDM + + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + WDM + + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + WDM + + + + + + + + + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + obj\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + obj\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + obj\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + obj\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + + + + sha256 + + + POOL_ZERO_DOWN_LEVEL_SUPPORT;%(PreprocessorDefinitions) + + + + + sha256 + + + POOL_ZERO_DOWN_LEVEL_SUPPORT;%(PreprocessorDefinitions) + + + + + POOL_ZERO_DOWN_LEVEL_SUPPORT;%(PreprocessorDefinitions) + + + + + POOL_ZERO_DOWN_LEVEL_SUPPORT;%(PreprocessorDefinitions) + + + + + + + + + + + + + + + + + + + diff --git a/km/build/wdk10/simple/simple.sln b/km/build/wdk10/simple/simple.sln new file mode 100644 index 0000000..004e2f9 --- /dev/null +++ b/km/build/wdk10/simple/simple.sln @@ -0,0 +1,35 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36623.8 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simple", "simple.vcxproj", "{C6B5FBE6-9E32-4006-873A-8A7091D9D992}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C6B5FBE6-9E32-4006-873A-8A7091D9D992}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {C6B5FBE6-9E32-4006-873A-8A7091D9D992}.Debug|ARM64.Build.0 = Debug|ARM64 + {C6B5FBE6-9E32-4006-873A-8A7091D9D992}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {C6B5FBE6-9E32-4006-873A-8A7091D9D992}.Debug|x64.ActiveCfg = Debug|x64 + {C6B5FBE6-9E32-4006-873A-8A7091D9D992}.Debug|x64.Build.0 = Debug|x64 + {C6B5FBE6-9E32-4006-873A-8A7091D9D992}.Debug|x64.Deploy.0 = Debug|x64 + {C6B5FBE6-9E32-4006-873A-8A7091D9D992}.Release|ARM64.ActiveCfg = Release|ARM64 + {C6B5FBE6-9E32-4006-873A-8A7091D9D992}.Release|ARM64.Build.0 = Release|ARM64 + {C6B5FBE6-9E32-4006-873A-8A7091D9D992}.Release|ARM64.Deploy.0 = Release|ARM64 + {C6B5FBE6-9E32-4006-873A-8A7091D9D992}.Release|x64.ActiveCfg = Release|x64 + {C6B5FBE6-9E32-4006-873A-8A7091D9D992}.Release|x64.Build.0 = Release|x64 + {C6B5FBE6-9E32-4006-873A-8A7091D9D992}.Release|x64.Deploy.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {144E8B3A-EC28-410C-A9E9-161914DFD3B3} + EndGlobalSection +EndGlobal diff --git a/km/build/wdk10/simple/simple.vcxproj b/km/build/wdk10/simple/simple.vcxproj new file mode 100644 index 0000000..bbb6070 --- /dev/null +++ b/km/build/wdk10/simple/simple.vcxproj @@ -0,0 +1,110 @@ + + + + + Debug + x64 + + + Release + x64 + + + Debug + ARM64 + + + Release + ARM64 + + + + {C6B5FBE6-9E32-4006-873A-8A7091D9D992} + {dd38f7fc-d7bd-488b-9242-7d8754cde80d} + v4.5 + 12.0 + Debug + x64 + simple + + + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + WDM + + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + WDM + + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + WDM + + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + WDM + + + + + + + + + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + obj\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + obj\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + obj\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + obj\$(TargetVersion)\$(PlatformShortName)\$(Configuration)\ + + + + sha256 + + + + + sha256 + + + + + + + + + + + + + + + + diff --git a/km/src/nt_namespace/main.c b/km/src/nt_namespace/main.c index a1c08e8..4c7ef74 100644 --- a/km/src/nt_namespace/main.c +++ b/km/src/nt_namespace/main.c @@ -22,6 +22,8 @@ NTSTATUS DriverEntry( { UNREFERENCED_PARAMETER(registry_path); + ExInitializeDriverRuntime(DrvRtPoolNxOptIn); + driver_object->DriverUnload = on_driver_unload; return set_up_devices(driver_object); } diff --git a/km/src/nt_namespace/nt2dos.c b/km/src/nt_namespace/nt2dos.c index d1bdb3d..be2c2f5 100644 --- a/km/src/nt_namespace/nt2dos.c +++ b/km/src/nt_namespace/nt2dos.c @@ -9,6 +9,15 @@ #include "nt2dos.h" +static PVOID allocate(SIZE_T nb) +{ +#if !defined(NTDDI_WIN10) || NTDDI_VERSION < NTDDI_WIN10 + return ExAllocatePoolWithTag(PagedPool, nb, '1l'); +#else + return ExAllocatePoolQuotaZero(PagedPool, nb, '1l'); +#endif +} + static NTSTATUS get_object_name_info( void *object, OBJECT_NAME_INFORMATION **object_name_info) @@ -21,7 +30,7 @@ static NTSTATUS get_object_name_info( if (status != STATUS_INFO_LENGTH_MISMATCH) return status; - *object_name_info = ExAllocatePoolWithTag(PagedPool, nbneeded, '1l'); + *object_name_info = allocate(nbneeded); if (*object_name_info == NULL) return STATUS_INSUFFICIENT_RESOURCES; @@ -92,8 +101,7 @@ NTSTATUS nt2dos(UNICODE_STRING *u_resolved, UNICODE_STRING *u_unresolved) if (file_object->Vpb == NULL) { - u_resolved->Buffer = ExAllocatePoolWithTag( - PagedPool, file_name_info->Name.Length, '1l'); + u_resolved->Buffer = allocate(file_name_info->Name.Length); if (u_resolved->Buffer == NULL) { @@ -120,7 +128,7 @@ NTSTATUS nt2dos(UNICODE_STRING *u_resolved, UNICODE_STRING *u_unresolved) u_resolved_size = file_name_info->Name.Length - volume_name_info->Name.Length + u_dos_name.Length; - u_resolved->Buffer = ExAllocatePoolWithTag(PagedPool, u_resolved_size, '1l'); + u_resolved->Buffer = allocate(u_resolved_size); if (u_resolved->Buffer == NULL) { diff --git a/km/src/simple/device.c b/km/src/simple/device.c index 859ba67..f632a8d 100644 --- a/km/src/simple/device.c +++ b/km/src/simple/device.c @@ -43,7 +43,7 @@ static NTSTATUS handle_say_hello( return STATUS_SUCCESS; } -static unsigned int i = 42; +static unsigned int num = 42; static NTSTATUS handle_exchange_ints( void *in_buf, @@ -52,20 +52,20 @@ static NTSTATUS handle_exchange_ints( unsigned long out_buf_size, ULONG_PTR *nbwritten) { - unsigned int temp_i; + unsigned int temp_num; - if (in_buf_size != sizeof(temp_i)) + if (in_buf_size != sizeof(temp_num)) return STATUS_INVALID_BUFFER_SIZE; - RtlCopyMemory(&temp_i, in_buf, in_buf_size); - DbgPrint("%08x\n", temp_i); + RtlCopyMemory(&temp_num, in_buf, in_buf_size); + DbgPrint("%08x\n", temp_num); - if (out_buf_size < sizeof(i)) + if (out_buf_size < sizeof(num)) return STATUS_BUFFER_TOO_SMALL; - RtlCopyMemory(out_buf, &i, sizeof(i)); - *nbwritten += sizeof(i); - i = temp_i; + RtlCopyMemory(out_buf, &num, sizeof(num)); + *nbwritten += sizeof(num); + num = temp_num; return STATUS_SUCCESS; } -- cgit v1.3