The project I am working on needs to compile 32bits, 64bits, and ARM64 drivers. I am shifting the build environment from VS2019 and VS2022. For Driver Compilation I am using the newer WDK (version 22H2 WDK). Now the problem is that newer WDK doesn't support 32 bits driver compilation. I am thinking of using olde WDK (version 21H2 WDK) but it is not supported by VS2022. What can be done in this case. Is there any possibility I can copile 32 bits driver using VS2022 (maybe using older WDK).
我正在进行的项目需要编译32位、64位和ARM64驱动程序。我将构建环境从VS2019和VS2022转移。对于驱动程序编译,我使用较新的WDK(版本22H2 WDK)。现在的问题是,较新的WDK不支持32位驱动程序编译。我正在考虑使用旧的WDK(版本21H2 WDK),但VS2022不支持它。在这种情况下可以做些什么。有没有可能我可以复制32位驱动程序使用VS2022(可能使用较旧的WDK)。
https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk :
Visual Studio 2022 is not supported by the Windows 11, version 21H2 WDK. To use Visual Studio 2022 to develop and test drivers, download the Windows 11, version 22H2 WDK. For details, see Download the Windows Driver Kit (WDK).
Https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk:Windows 11版本21H2 WDK不支持Visual Studio 2022。要使用Visual Studio 2022开发和测试驱动程序,请下载Windows 11,版本22H2 WDK。有关详细信息,请参阅下载Windows驱动程序工具包(WDK)。
更多回答
优秀答案推荐
The Windows 11 does not have a 32-bit version, thus the WDK for Win11 doesn't support 32-bit, i thought. However, I can't understand that the newer (22H2) WDK can still compiling code targeting an older Windows (lowest to Windows 10) with 32-bit support, but it can't produce a 32-bit things for the older Windows.
Windows 11没有32位版本,所以我想Win11的WDK不支持32位。然而,我不能理解较新的(22H2)WDK仍然可以编译针对具有32位支持的旧Windows(最低到Windows 10)的代码,但它不能为旧Windows生成32位的东西。
We can use an older EWDK version to build 32-bit driver. The latest EWDK that works is EWDK for Windows Server 2022 with Visual Studio Build Tools 16.9.2.
我们可以使用较旧的EWDK版本来构建32位驱动程序。可以工作的最新EWDK是用于Windows Server2022的EWDK,带有Visual Studio构建工具16.9.2。
In theory, developing with latest VS/WDK, and building with EWDK, is just fine. The drawback is we need to keep our code base compatitable with the older WDK. But if the two version diffs so much, the newer WDK may refuse to work with the deprecated/abandanded API, this sucks.
从理论上讲,使用最新的VS/WDK进行开发,并使用EWDK进行构建,这是很好的。缺点是我们需要保持我们的代码库与较旧的WDK兼容。但是,如果两个版本的差异如此之大,较新的WDK可能会拒绝使用已弃用/废弃的API,这很糟糕。
I Found a hack which allows to build 32 bit drivers using this WDK.
One need edit file: "C:\Program Files (x86)\Windows Kits\10\build\10.0.22621.0\WindowsDriver.Common.targets"
我发现了一个黑客,它允许使用这个WDK构建32位驱动程序。一个需要编辑的文件:“C:\Program Files(X86)\Windows Kits\10\build\10.0.22621.0\WindowsDriver.Common.targets”
Find there a string: "Error out if Arch x86 or ARM is used with KM drivers"
You'll see the following:
找到一个字符串:“Error Out if Arch x86 or ARM is use with KM Driver”,您将看到以下内容:
<Error Text=" '$(Platform)' is not a valid architecture for Kernel mode drivers or UMDF drivers"
Condition="'$(WindowsTargetPlatformVersion)' > '$(TargetPlatformVersion_CO)' and ('$(DDKPlatform)' == 'x86' or '$(DDKPlatform)' == 'ARM') and ('$(PlatformToolset)' == 'WindowsKernelModeDriver10.0' or '$(DriverType)' == 'UMDF') " />
Replace 'x86' by 'xx86'
将‘x86’替换为‘xx86’
And you'll be able to build 32 bit drivers
并且您将能够构建32位驱动程序
更多回答
我是一名优秀的程序员,十分优秀!