-
-
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
Changes from all commits
a4446d1
6b0f743
b676bff
94b2599
df2e117
5a6cd9e
915191f
acb31a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,6 +109,10 @@ for arch in x86 x64 arm arm64; do | |
|| -d /usr/local/share/wine/mono \ | ||
|| -d /opt/wine/mono ]]; then | ||
EXEC "" BIN=$BIN ./test-msbuild.sh | ||
|
||
if [[ -n $HAVE_WDK && ($arch == "x64" || $arch == "arm64") ]]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I think 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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I didn't know that. I can add |
||
EXEC "" BIN=$BIN ./test-wdk-msbuild.sh | ||
fi | ||
fi | ||
done | ||
|
||
|
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); | ||
} |
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" |
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> |
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.
Can you merge these two loops? It would deviate from the order in the script originally, but I think it should be harmless (fixinclude doesn't look at files outside of the given directory).
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 was not sure whether there are dependencies between
lowercase
andfixinclude
, and just assumed that all headers must be lowercased forfixinclude
to work. I'll merge them into one loop, then.