Writing WDF Drivers in C++ (or Rust)

Hey Guys,
I am hearing that WDF drivers can be written in C++. I have been doing this in C all the time. I have not seen any C++ samples as well.

Any opinions on this?? Is this documented somewhere?
Thanks
-Aj

This just means you havenā€™t been paying attention, for quite a long time. Surely itā€™s time for this question to die. Multimedia drivers (audio and video) have been written in C++ for 25 years. Thereā€™s nothing special about KMDF in this regard. Itā€™s just a library. Remember, KMDF itself is all written in C++.

Iā€™m waiting for drivers to be written in Rust. I think that language has great potential.

OP: Search the archives. Weā€™ve discussed this at great length and weā€™re not going to rehash it here.

Rust: If you are sufficiently motivated, you can write Windows drivers in Rust today, because C interfaces are directly Rust callable. Iā€™ve ā€œdoneā€ it, if you can call issuing a DbgPrint from DriverEntry having ā€œwritten a Windows driver in Rust.ā€ :wink:

As enthused as I am about the concept of having a modern language for system software programming, I did not enjoy my time using Rust even a little bit. And, yes, I did quite a bit more than just ā€œwriting that driver.ā€ I found the language enormously cumbersome and frustrating. What was worse, was I found the state of Rust development chaoticā€¦ with randomly contributed, supported, discontinued, added and deprecated features and ā€œcrates.ā€ It made me insane.

My point is, I was all excited about writing drivers in Rust as wellā€¦ until I actually spent a few weeks working in the language. Now, not so much.

I still miss ā€œSystem C#ā€ā€¦.

Peter

@Tim_Roberts : Yes you are right that I have not been paying attention on this. I have written AVSTREAM drivers in C++ about 14 years back and I know it use to work. At that time it was not advisable to write other drivers in C++. I have not been writing windows drivers since then. So yes, my knowledge is not as up to date as it should be.

Thanks for the information guys. Really appreciate it.

Frustration is not always a bad thing. Rust, like Pascal, puts the focus on a terribly picky compiler. If you can express your solution in a way that satisfies the compiler, then the odds of successful execution are much improved. We C advocates are spoiled because the compiler allows almost any random sequence of characters to compile to something, and itā€™s up to us to refine that at runtime.

That seems like a false note. Making a more fussy or less fussy compiler happy seems like addressing ā€˜single lineā€™ issues. These are real problems, but usually of the least significant kind.

Being frustrated enough to spend the effort to figure out the answers to big problems never seems like a bad thing though

If you can express your solution in a way that satisfies the compiler, then the odds of successful execution are much improved

I understand that this is the intention. And I agree itā€™s a valuable thing to do. And I really wanted to like it.

Doing it in Rust, howeverā€¦ I just found it hard to grasp fully, and entirely no fun. I offer the following simple illustration of the basic precepts of std::result and matching from rust-lang.org:

I really find that unnecessarily annoying.

Ick. This reminds me of Lisp, or from even earlier APL ā€¦

I think Iā€™ll let Rust remain the thing I scrape off my grill every summer ā€¦

LOLā€¦ LOLā€¦ APL. No, no, APL is really much worse:

avgā†{+/āµĆ·ā“āµ}

:slight_smile:

Admit though - you still have your APL keyboard :slight_smile:

mm

Sent from my iPhone

1 Like

Admit though - you still have your APL keyboard

Oh, WOULD that I did.

Yep, although the 5100 that it went with has long since been retired ā€¦ let a user program both in Basic and APL, still look back fondly at the ā€œquote quadā€ for printing output ā€¦ just didnā€™t get simpler than that, and the matrix math calculations were simple to set up. There are some versions of APL which are out there still for Linux ā€¦ sigh ā€¦

Iā€™ve never actually seen one - Iā€™m too young - but my father knew Ken
Iverson a bit. He rode the train with him when Ken was an adjunct or
something (not entirely sure) at Wharton and my father was a student. My
father said clearly brilliant, not entirely a practical sort.

mm

I remember that the APL ā€œterminalā€ I used was one of those IBM typewriters with a ā€œballā€ element. Ah, here, and a better picture here. Yup, it was connected to an IBM 360.

the matrix math calculations were simple

I remember being able to write the code to perform a multiple regression analysis in, like, 4 lines or something. Because matrix invert and transpose were native symbols.

There are some versions of APL which are out there

Oh, MUCH better than that. You can try it online: https://tryapl.org/

clearly brilliant, not entirely a practical

And that would describe APL, as well.

Well, we certainly have sucked this thread off into a different universe, havenā€™t we?

Peter

Well, we certainly have sucked this thread off into a different universe, havenā€™t we?

My fault, sorry. Itā€™s a bad habit of mine.

No, no, noā€¦ not at all. Itā€™s been almost entirely me.

Well, at least we know the mods wonā€™t yell at us :wink:

P

1 Like

Wow, I am glad that we like to have some fun as well.