-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Add basic support for automated WDK installation #111
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a4446d1
Add a basic support for automated WDK installation
ravenexp 6b0f743
install: Lowercase and fix kernel mode includes
ravenexp b676bff
wrappers: Add kernel mode headers and libs to INCLUDE and LIB
ravenexp 94b2599
wrappers: Set default MSBuild properties for the WDK
ravenexp df2e117
Add WDK installers download helper script
ravenexp 5a6cd9e
test: Add WDK driver build test script
ravenexp 915191f
github: Install wine32 as well as wine64 on Ubuntu
ravenexp acb31a1
github: Install WDK together with WinSDK and MSVC
ravenexp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2024 Sergey Kvachonok | ||
# | ||
# Permission to use, copy, modify, and/or distribute this software for any | ||
# purpose with or without fee is hereby granted, provided that the above | ||
# copyright notice and this permission notice appear in all copies. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
|
||
. "${0%/*}/test.sh" | ||
|
||
for config in Debug Release; do | ||
# Trailing slash is required in MSBuild directory properties. | ||
OUTDIR="Z:${CWD}/${config}/" | ||
OUTDIR="${OUTDIR//\//\\}" | ||
|
||
EXEC "" ${BIN}msbuild /p:Configuration=${config} \ | ||
/p:IntDir="${OUTDIR}" /p:OutDir="${OUTDIR}" \ | ||
"${TESTS}/wdk/test.vcxproj" | ||
done | ||
|
||
EXIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* Copyright (c) 2024 Sergey Kvachonok | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ | ||
|
||
#include <ntddk.h> | ||
#include <wdf.h> | ||
|
||
DRIVER_INITIALIZE DriverEntry; | ||
EVT_WDF_DRIVER_DEVICE_ADD test_EvtDeviceAdd; | ||
|
||
NTSTATUS | ||
DriverEntry(_In_ PDRIVER_OBJECT DriverObject, | ||
_In_ PUNICODE_STRING RegistryPath) { | ||
WDF_DRIVER_CONFIG config; | ||
WDF_DRIVER_CONFIG_INIT(&config, test_EvtDeviceAdd); | ||
WDF_OBJECT_ATTRIBUTES attributes; | ||
WDF_OBJECT_ATTRIBUTES_INIT(&attributes); | ||
|
||
return WdfDriverCreate(DriverObject, RegistryPath, &attributes, &config, | ||
WDF_NO_HANDLE); | ||
} | ||
|
||
NTSTATUS | ||
test_EvtDeviceAdd(_In_ WDFDRIVER Driver, _Inout_ PWDFDEVICE_INIT DeviceInit) { | ||
WDF_OBJECT_ATTRIBUTES deviceAttributes; | ||
WDFDEVICE device; | ||
UNREFERENCED_PARAMETER(Driver); | ||
|
||
WDF_OBJECT_ATTRIBUTES_INIT(&deviceAttributes); | ||
|
||
return WdfDeviceCreate(&DeviceInit, &deviceAttributes, &device); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
; | ||
; test.inf | ||
; | ||
|
||
[Version] | ||
Signature="$WINDOWS NT$" | ||
Class=System | ||
ClassGuid={4d36e97d-e325-11ce-bfc1-08002be10318} | ||
Provider=%ManufacturerName% | ||
CatalogFile=test.cat | ||
DriverVer= | ||
PnpLockdown=1 | ||
|
||
[DestinationDirs] | ||
DefaultDestDir = 13 | ||
|
||
[SourceDisksNames] | ||
1 = %DiskName%,,,"" | ||
|
||
[SourceDisksFiles] | ||
test.sys = 1,, | ||
|
||
;***************************************** | ||
; Install Section | ||
;***************************************** | ||
|
||
[Manufacturer] | ||
%ManufacturerName%=Standard,NT$ARCH$.10.0 | ||
|
||
[Standard.NT$ARCH$.10.0] | ||
%test.DeviceDesc%=test_Device, Root\test | ||
|
||
[test_Device.NT] | ||
CopyFiles=Drivers_Dir | ||
|
||
[Drivers_Dir] | ||
test.sys | ||
|
||
;-------------- Service installation | ||
[test_Device.NT.Services] | ||
AddService = test,%SPSVCINST_ASSOCSERVICE%, test_Service_Inst | ||
|
||
; -------------- test driver install sections | ||
[test_Service_Inst] | ||
DisplayName = %test.SVCDESC% | ||
ServiceType = 1 ; SERVICE_KERNEL_DRIVER | ||
StartType = 3 ; SERVICE_DEMAND_START | ||
ErrorControl = 1 ; SERVICE_ERROR_NORMAL | ||
ServiceBinary = %13%\test.sys | ||
|
||
[Strings] | ||
SPSVCINST_ASSOCSERVICE= 0x00000002 | ||
ManufacturerName="test manufacturer name" | ||
DiskName = "test Installation Disk" | ||
test.DeviceDesc = "test Device" | ||
test.SVCDESC = "test Service" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|x64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|x64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Debug|ARM64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>ARM64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|ARM64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>ARM64</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="test.c" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Inf Include="test.inx" /> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectName>test</ProjectName> | ||
<RootNamespace>test</RootNamespace> | ||
<ProjectVersion>0.1.0</ProjectVersion> | ||
<ProjectGuid>{b8bd0196-b985-4000-b5d1-37055e58f662}</ProjectGuid> | ||
<TemplateGuid>{497e31cb-056b-4f31-abb8-447fd55ee5a5}</TemplateGuid> | ||
<Configuration>Debug</Configuration> | ||
<Platform Condition="'$(Platform)' == ''">x64</Platform> | ||
<KMDF_VERSION_MAJOR>1</KMDF_VERSION_MAJOR> | ||
<KMDF_VERSION_MINOR>31</KMDF_VERSION_MINOR> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Label="Configuration"> | ||
<TargetVersion>Windows10</TargetVersion> | ||
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> | ||
<ConfigurationType>Driver</ConfigurationType> | ||
<DriverType>KMDF</DriverType> | ||
<DriverTargetPlatform>Universal</DriverTargetPlatform> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration"> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration"> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ItemDefinitionGroup> | ||
<DriverSign> | ||
<FileDigestAlgorithm>sha256</FileDigestAlgorithm> | ||
</DriverSign> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<Inf Exclude="@(Inf)" Include="test.inx"/> | ||
<FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver'"/> | ||
</ItemGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/> | ||
</Project> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I presume this limitation on arch is based on what is supported in the vcxproj file?
Is it possible to do a minimal-ish command line compilation of the same as well? (Not required as part of this PR, but would be nice to have.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
x86_64
andaarch64
are the only architectures supported by current Windows kernels. There used to be 32-bit versions of Windows 10, but it's not something people care about in 2024.As for the command line test, I wanted to add a plain Makefile, but it turned out it requires an enormous amount of compile and link flags even for the simplest drivers. And many of them are WDK version specific, as you can see here: https://github.com/mstorsjo/msvc-wine/actions/runs/7986251670/job/21806269948#step:5:568 Such a test would probably be very fragile wrt. WDK updates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, fair enough, thanks for explaining!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ravenexp, all versions of Windows 10 support 32-bit architectures. It's only Windows 11 that doesn't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't know that. I can add
x86
back to the test matrix if your use case requires this target.