13 ms·
First Rust code in the Windows 11 kernel
- solarkraft 3y agoDamn! If I'm correctly informed, this is before Linux is doing it (actually shipping rust code, not having the infrastructure in place).
- therein 3y agoI feel like there is a way more vibrant driver developer community for Windows anyway. It could be the architecture for kernel drivers Windows has or that many people use it for malware and game cheat development. I have a fond attachment to all the tools you have in your disposal once loaded into the kernel space on Windows. win32kbase.sys being at a certain memory location for all processes, KeUserModeCallback etc. all around really fun and interesting to hack with. Doing DKOM on PEB, TEB of kernel processes or user processes to do things you shouldn't be able to do like call win32 apis from kernel pretending to be a process to draw things using GDI etc. Even though I primarily am a Linux user and I prefer using Linux on a daily basis, dabbling in Linux kernel development failed to create this feeling of awe and infinite possibilities (and exploitability) in my mind. I guess my point is, Windows Kernel development in Rust excites me. Same with Linux would be very cool but it doesn't create the same feeling of wonder in me. Perhaps that's why this is happening first.
- dilawar 3y agohttps://github.com/SubconsciousCompute/poc-windows-rust-filter https://github.com/SubconsciousCompute/poc-windows-rust-filt... We have been playing with Rust and minifilter for Windows. Its almost there. Microsoft has been working on rust driver kit.
- dagmx 3y agoNot surprising. Linux is one of the few monolithic kernels. It’s kind of a worst case scenario for adding in a new language to as a result, since it can’t be added in a very isolated way.
- kijiki 3y ago> Not surprising. Linux is one of the few monolithic kernels. This is an amusing claim, given that Microsoft's first use of Rust in the NT kernel is in win32k.sys, which is the in-kernel code that used to live in userspace back when NT was actually a microkernel. So pre-NT4, which was released in 1996.
- pjmlp 3y agoWindows still follows a microkernel like architecture with LPC across subsystems, and nowadays kernel runs on its own sandbox, while a select set from drivers are also sanboxed. Then there are the whole set of userspace drivers, including graphics. How are those X Windows driver crashes holding on?
- atq2119 3y agoThe kernel/user space split in graphics drivers is pretty much the same between Linux and Windows, and has been this way for many, many years.
- gjsman-1000 3y agoWindows under the hood with the NT Kernel is actually regarded among some experts as technically superior to Linux with the driver model and personalities subsystem; it’s just that the stuff above the kernel isn’t so great…
- waboremo 3y agoThe one place microsoft's advertising branch can't get to!
- photonbeam 3y agoFor now Syscalls powered by MSNBC
- streakfix 3y agoTheir scheduler is pure bullcrap. It favors cpu intensive applications, meaning it's good for gaming but horrible for every other use case
- pjmlp 3y agoI would agree, if we would still be talking about Windows NT 4.0 or Windows 2000.
- PaulRobinson 3y agoThat makes sense if your main target use case is desktops where a small number of CPU-intensive apps are running, right? And even in many server apps where you have one main app being the reason the server is booted, this makes broad sense. Don’t get my wrong, but me and I bleed Unix-like systems and have done for decades, but what you’re saying actually makes sense for MS as a design decision…
- AlexSW 3y agoHow so? I believe I understand Windows' thread scheduler and this conclusion isn't obvious to me at all; from my understanding it seemed perfectly reasonable.
- TazeTSchnitzel 3y agoIt's easier for Windows to do it because it only targets a small number of architectures (maybe only x86-64 and AArch64 these days?), and only Microsoft need to be able to build it. The Linux kernel has a huge number of targets and the build system needs to be solid for a huge number of people.
- jeroenhd 3y agoWindows does a lot of things in the kernel that Linux lets userspace handle. Part of that is the way UI is dealt with: for Windows UI is part of the core system, whereas on Linux it's a userspace tool you can install if you really fancy it. There's also the advantage of being able to add Rust to the build pipeline without someone complaining that you broke the build for their TI-83+ calculator because there's no Rust compiler for that platform. Windows deals with amd64, x86, aarch64, and maybe some simple 32 bit ARM, but that's about it. Nobody is going to care about support for MIPS or Power9 or Motorola 6800 or SPARC or Xtensa.
- esaym 3y agoWhy Rust? Doesn't Microsoft have their own similar language, C#? And then isn't there some lore about the reason Windows Vista took so long to release was due to them trying to write the entire OS in C# or something and then having to redo everything?
- chungy 3y agoC# isn't even remotely similar. A managed language running in a heavy VM runtime versus a direct-to-machine-code compiled language...
- 29athrowaway 3y agoHave you heard of native AOT compilation?
- saagarjha 3y agoStill requires a substantial runtime.
- pjmlp 3y agoWhich in many cases has already been proven by making it part of the kernel, even if Xerox, DEC/Olivetti, ETHZ, MSR projects weren't made available to wider audiences. One can do a Google, and push it no matter what, or give up and take the adoption path that is easier to bring the safety luddites along for the ride.
- saagarjha 3y agoI don’t fundamentally oppose such a thing, but I assume doing so would require very careful effort. It’s much harder than integrating Rust.
- pjmlp 3y agoFor me, Rust is a nicer Ada like effort, a kind of compromise. We can wait the usual progress rate of one funeral at a time until a new generation buys into fully managed OS, or another Google/Apple big spender forces them into developers no matter what, which most likely I will not live through. So we're left with the compromise of allowing only userspace for managed languages, while adopting something like Rust for the "only over my dead body folks" anti any form of automatic memory management languages. Given that even the success stories of bare metal deployments of managed runtimes doesn't change their minds anyway.
- jsheard 3y agoOn a related note, Azure just endorsed Rust to replace C/C++ as the non-garbage-collected language of choice. https://azure.microsoft.com/en-us/blog/microsoft-azure-security-evolution-embrace-secure-multitenancy-confidential-compute-and-rust/ https://azure.microsoft.com/en-us/blog/microsoft-azure-secur... > Rust as the path forward over C/C++ > Decades of vulnerabilities have proven how difficult it is to prevent memory-corrupting bugs when using C/C++. While garbage-collected languages like C# or Java have proven more resilient to these issues, there are scenarios where they cannot be used. For such cases, we’re betting on Rust as the alternative to C/C++. Rust is a modern language designed to compete with the performance C/C++, but with memory safety and thread safety guarantees built into the language. While we are not able to rewrite everything in Rust overnight, we’ve already adopted Rust in some of the most critical components of Azure’s infrastructure. We expect our adoption of Rust to expand substantially over time.
- Gigachad 3y agoRustbros just keep winning
- insanitybit 3y agoThis is great but I do wish that people could see Rust as more than a better C/C++. It's an amazing language for web services and CLIs. It's not just that it doesn't have a GC. It also doesn't have some of the worst features of OOP, it also has a sane std library, it also has an expressive type system, etc. Rust helps you write better code, even when compared to languages like Java or Python.
- CGamesPlay 3y agoI agree with this but the ownership model is really a huge learning curve for somebody who wants to make an application where it's OK if it crashes when there's a bug. It would be cool if there was a "relaxed rust" which provided interop with standard rust, but used some designated smart pointer for everything automatically (at the crate level, for example). I'm not sure how/if this could work, but I think it would make transitioning from GC languages -> Rust much easier.
- deleted 3y ago[deleted]
- usr1106 3y agoShows up? I haven't used Windows for close to 15 years, but I have not heard that their kernel would be open source now.
- dang 3y agoOk, we've made the title not show up above.
- usr1106 3y agoInteresting. I thought editorializing titles is not accepted on HN. My criticism was directed towards the article, not the submission. Edit: Ah, the guidelines say unless it is misleading. Well, I would not have called it truly misleading, just typical headline style you can often see. I did not like it, but I did not feel misled.
- dang 3y agoI'm glad you noticed the "linkbait/misleading" exception in that guideline because it's an important one!
- discerning_ 3y ago[flagged]
- sylware 3y agoHuh? linux is the windows kernel or what?
- _8j50 3y agoWin32k.sys in rust would kill so many future bugs. RIP.
- criddell 3y agoHow’s Rust for desktop application development? Are there frameworks like MFC or ATL or WTL or WinRT? Is COM development or using UWP significantly more difficult in Rust than C++ or C#?
- jenadine 3y agoThere are ok bindings to some toolkits such as Qt and Gtk, which are the most mature right now. But there is promising progress also in full rust GUI libraries for example Slint or egui
- criddell 3y agoI should have mentioned I’m only interested in native Windows APIs. I want to use UWP features, lots of COM (both as client and server), etc… I see Microsoft has done some work and there’s a Windows crate, but I’m not seeing IDL support for COM and it looks like you end up with a ton of unsafe blocks. It makes me wonder if a programmer who sticks with smart pointers in C++ is all that much worse off than a Rust developer on Windows?
- serentty 3y agoThere is a lot more to Rust than just “safety”. That gets talked about a lot, but Rust is full of great features that make it worthwhile to use even when you are working in unsafe Rust. On top of that, it should still be possible to write the application logic in safe Rust, even if you need to use unsafe for FFI with Windows stuff.
- criddell 3y agoAre there any Windows GUI applications written in Rust that are a good place to start for someone who wants to learn more?
- hawk_ 3y agoGood question. Specifically GUI code tends to have many cycles in object graphs. Do idioms already exist in Rust to deal with advanced cases of that?