On Wed, Mar 7, 2018 at 1:36 PM, xxxxx@osr.com wrote:
>
>
> Well, I think that’s right. And a generally helpful comment.
>
> I also think, however, it is overly generous to call these samples “curated” if that implies they generally do not suck. Because to a large extent, they most certainly do.
>
>
>
> If it’s stupid, and you THINK it works but it doesn’t REALLY work, it’s WORSE than stupid. It’s both stupid and dangerous. THAT’S THE PRIMARY PROBLEM WITH WDM.
>
“Kernel code is dangerous” should be no surprise.
>
>
> This. KMDF was introduced in 2005, after a loong period of collaborative design and development with the Driver Development Community. Dozens of devs from the community took part. It was really a landmark project, because I am not aware of any major OS internals development effort undertaken by MSFT before or since, to take input from the community so seriously.
>
>
>
> Oh, stop it. That’s just silly on its face.
>
> No workflow can be simpler than VS “Create Project” – a template project gets created – “Build Solution” – the project gets built. The you copy it to the target machine, install it, and you’re done.
>
> And the workflow doesn’t change based on the driver model, so the whole argument is specious.
>
My entire life I have been very unlucky when it comes to computers. I
will or would try these things, and in this case I have tried these
things, and had them not work. It is impossible for me to explain why
or to troubleshoot the issue as I can’t see the source code of the
components involved. I’ve tried asking for help in this regard but all
people can tell me to do is follow the instructions. I repeat the
procedure with the same result. (At this point I’ve decided I will
wait until I finish more of my hardware and can buy a separate test
computer, but the issue is still unresolved. For now I do all driver
testing in Linux, which I may have done anyway.)
Some of the WDM driver tutorials use older EWDK (or maybe just WDK)
releases that are more approachable than the Visual Studio workflow.
The individual components are obvious and in some cases instructions
are given for producing functioning drivers with MinGW.
I don’t expect that level of detail but it does show how well WDK
drivers were/are understood. At this point those samples do seem
ancient, and connecting them to newer APIs is hard.
> I’ve been writing drivers for Windows for about 20 years. I think I’m pretty good at it. WDM? Yeah, I know how to write a reasonably reliable WDM driver at this point. But it’s really, really, painful, and it requires dragging soooo much ancient shit around. There is no chance – none –
> exactly zero probability – of a newb writing a properly reliable WDM driver from scratch. That is not true for WDF.
>
> LOOK… back when WDM was the only option, I was personally involved, working with MSFT, for YEARS trying to get the community to write reliable drivers. We tried shaming vendors, we tried praising vendors, we tried educating vendors, we tried writing samples, we tried bringing vendors in to labs and showing them the errors of their ways. Nothing, nothing, was successful in moving the needle in terms of driver reliability.
>
> It got so bad Microsoft finally acknowledged the problem, and invested in designing and implementing an entirely new driver model, that was modern, easier to use, and made writing reliable drivers something a reasonable engineer can accomplish. That new model was WDF.
>
> People need to stop fucking with a model that’s been proven to be impractical, and use what we all know works.
>
The model isn’t impractical. It is used by Linux. The difference is
most drivers are not written at that level: there is a strong tendency
to push everything into userspace as quickly as possible. If I want to
create a fake hardware device, I can do so relatively safely by
talking to a driver. If I want to monitor kernel driver events, I can
usually do that in userspace. In some cases these things are ported
backwards into kernel drivers, but not always. When they are, there is
a very transparent framework bolted on top of the WDM-like model.
WDF is not very transparent. Sadly I don’t know what to ask for. It’s
not like I expect someone to write precisely what I want so I can copy
it, but at the same time, knowing what you need is harder than
knowing what exists.
I will take your advice to heart as best I can and give up on trying
to do anything with WDM.
Cheers,
R0b0t1