Microsoft Visual Studio's linker has a /DRIVER
flag specifically for building drivers:
Use the
/DRIVER
linker option to build a Windows NT kernel mode driver.
However, Microsoft says:
You must not build drivers by using the compiler or linker that Microsoft Visual Studio provides.
which begs the question:
Why should I not compile/link drivers with Visual Studio?
Is the output generated by the DDK/WDK tools different from that generated by Visual Studio?
If so, how is it different?
Notice that I'm talking about using Visual Studio's compiler and linker, not libraries!
I use the WDK headers and libraries with VS's compilers and linkers, but Microsoft specifically says that I need to avoid this:
You must not build drivers by using the compiler or linker that Microsoft Visual Studio provides.
They didn't even mention headers and libraries, so of course that's not my question.
Why?
Create and build a driver. Open Microsoft Visual Studio. On the File menu, choose New > Project. In the Create a new project dialog box, select C++ in the left dropdown, choose Windows in the middle dropdown, and choose Driver in the right dropdown.
Enterprise WDK (EWDK) The EWDK is a standalone, self-contained command-line environment for building drivers. It includes Visual Studio Build Tools, the SDK, and the WDK. The latest public version of the EWDK contains Visual Studio 2022 Build Tools 17.1.
This article put me on the right track, I think. That's because the DDK tools use different runtime libraries than Visual Studio.
Visual Studio will link the driver with the runtime libraries it provides (or optionally, the latest version of the runtime installed on the system), but a driver should arguably be linked with the exact same runtime used to build the operating system itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With