Examples on how to write Windows kernel drivers in Rust

Overview

windows-kernel-rs

Note: this is still work in progress!

This is a Windows kernel framework in Rust that consists of windows-kernel-sys, a crate that provides low-level unsafe bindings generated using bindgen, and windows-kernel-rs, a crate that provides safe abstractions in Rust on top.

In addition, there are articles that covers implementing Windows kernel drivers in Rust from the ground up, including corresponding examples provided as part of this repository:

  1. Prerequisites
  2. Hello World - 02-hello-world
  3. Generating Bindings - 03-generating-bindings
  4. Safe Framework - 04-safe-framework
  5. Creating Devices - 05-creating-devices
You might also like...
Rux - An x86_64 toy operating system kernel written in Rust
Rux - An x86_64 toy operating system kernel written in Rust

Rux - An x86_64 toy operating system kernel written in Rust. Rux is a port of the Hux kernel, my x86 32-bit single-CPU toy kernel written in C, following the OSTEP book structure and terminology.

An super minimal kernel written in rust

Grisha This project depends on this blog serie Philipp Oppermann's blog Required Knowlege I don't know what you really need to know to learn efficient

An x86-64 kernel with ~100% Rust (originally) in a week
An x86-64 kernel with ~100% Rust (originally) in a week

litchi-rs An x86-64 kernel with ~100% Rust (originally) in a week. The continuation of Litchi. Try it Make sure the Rust toolchains and qemu-system-x8

Linux ABI-compatible kernel written in Rust
Linux ABI-compatible kernel written in Rust

Linux ABI-compatible kernel written in Rust 🖼️ Screenshot (v0.1.0-alpha.1) 📦 Build dependencies To compile GalaxyOS kernel and create basic OS ISO i

Kernel density estimation in Rust.
Kernel density estimation in Rust.

kernel-density-estimation Kernel density estimation in Rust. Kernel density estimation (KDE) is a non-parametric method to estimate the probability de

💻 An x86_64 kernel in the works

BruhOS a basic x86_64 kernel in the works. cool stuff written in rust boots with any stivale2-compliant bootloader framebuffer bitmap font renderer pm

The official kernel for Popcorn OS, and operating system designed for handheld devices.

About Popkern is the kernel for Popcorn OS, an operating system designed for handheld devices. As such, the kernel is (to be) optimised at all levels

The kernel for LibertyOS.
The kernel for LibertyOS.

This is the official repository of the LibertyOS kernel. LibertyOS is an operating system, built with Rust, that is open-source, free-to-use, and open to new contributors.

A custom kernel for educational reasons

A custom kernel for educational reasons

Comments
  • When a workspace depends on this repository via a `git` reference, Cargo prints warnings

    When a workspace depends on this repository via a `git` reference, Cargo prints warnings

    When any crate in a workspace depends on this repository via a git reference...

    [dependencies]
    windows-kernel-sys = { git = "https://github.com/StephanvanSchaik/windows-kernel-rs" }
    

    ...every invocation of cargo within that same workspace prints these warnings:

    warning: skipping duplicate package `driver` found at `/home/my-username/.cargo/git/checkouts/windows-kernel-rs-bc6ca3e049eb46e4/f27c008/02-hello-world`
    warning: skipping duplicate package `driver` found at `/home/my-username/.cargo/git/checkouts/windows-kernel-rs-bc6ca3e049eb46e4/f27c008/05-creating-devices`
    warning: skipping duplicate package `driver` found at `/home/my-username/.cargo/git/checkouts/windows-kernel-rs-bc6ca3e049eb46e4/f27c008/07-io-controls`
    warning: skipping duplicate package `driver` found at `/home/my-username/.cargo/git/checkouts/windows-kernel-rs-bc6ca3e049eb46e4/f27c008/04-safe-framework`
    warning: skipping duplicate package `example` found at `/home/my-username/.cargo/git/checkouts/windows-kernel-rs-bc6ca3e049eb46e4/f27c008/user/06-reading-and-writing`
    warning: skipping duplicate package `driver` found at `/home/my-username/.cargo/git/checkouts/windows-kernel-rs-bc6ca3e049eb46e4/f27c008/06-reading-and-writing`
    

    This is because git dependencies scan the entire repository, so that crates can be referred to by name rather than by path.

    opened by rgprog 0
  • warning: unused return value of `Box::<T>::from_raw` that must be used

    warning: unused return value of `Box::::from_raw` that must be used

    https://github.com/StephanvanSchaik/windows-kernel-rs/blob/060cb6aa37136180cb8afbcd5bf2383240702b39/windows-kernel-rs/src/device.rs#L411

    Remove the warning like this

            let _ = Box::from_raw(ptr as *mut T);
    
    opened by edsky 0
  • untagged_unions feature has been removed

    untagged_unions feature has been removed

    https://github.com/StephanvanSchaik/windows-kernel-rs/blob/060cb6aa37136180cb8afbcd5bf2383240702b39/windows-kernel-sys/src/lib.rs#L3

    It has been removed in the latest nightly version and should be deleted.

    opened by edsky 0
  • Comparison or collaboration with DMF?

    Comparison or collaboration with DMF?

    Interesting work!

    Could you say something how you envisioned this - do you aim to have it similar to https://github.com/microsoft/DMF? Have you considered looking at a collaboration with them?

    opened by hansmbakker 2
Owner
S.J.R. van Schaik
S.J.R. van Schaik
An OS kernel written in rust. Non POSIX

"Tifflin" Experimental Kernel (and eventually Operating System) This is an experiment in writing an OS Kernel in rust (http://rust-lang.org). Mostly t

John Hodge (Mutabah) 618 Jan 8, 2023
A tiny 32 bit kernel written in Rust

rustboot A tiny 32 bit kernel written in Rust. I was inspired to download Rust and try to do this after seeing zero.rs - a stub that lets Rust program

Charlie Somerville 1.5k Dec 30, 2022
Experimental kernel for embedded devices written in Rust

bkernel is an experimental kernel for embedded devices written in Rust. I'm mostly trying out Rust now to see how it applies to kernel development. Pr

Alexey Shmalko 84 Dec 13, 2022
Open Source Rust kernel; Runs WASM and WASI as lightweight containers.

?? etheryal Kernel etheryal kernel is an Open Source capability-based Kernel written in the Rust programming language. The kernel allows implementing

null 32 Dec 4, 2022
Basic Rust kernel using Limine

Rust Limine Barebones This is a small kernel that boots using Limine. Build First of all, download Rust ! (I guess you already did it if you are here

Quentincestino 16 Dec 23, 2022
A new operating system kernel with Linux binary compatibility written in Rust.

Kerla Kerla is a monolithic operating system kernel from scratch in Rust which aims to be compatible with the Linux ABI, that is, runs Linux binaries

Seiya Nuta 3.1k Jan 1, 2023
Minimal x86_64 OS kernel written in Rust

rkernel A minimal x86_64 Rust OS kernel. Multiboot2 VGA driver PIC PIT PS/2 Keyboard driver PS/2 Mouse driver TSC RTC Allocator ATA PIO (In progress..

Divy Srivastava 36 Apr 26, 2022
🍒 Small, simple, and fast kernel written in Rust. 🌸

?? Small, simple, and fast kernel written in Rust. ??

Cherry Developers 5 May 20, 2022
Xrs is a POSIX-subset operating system kernel written in Rust.

XRS-OS ( ?? WIP) Xrs is a POSIX-subset operating system kernel written in Rust. Current project team members 0x5459 core developer (he/him) 0x5457 cor

null 7 Nov 16, 2022
Linux kernel modules written in Rust

Linux kernel modules written in Rust A collection of in-progress experimental Linux kernel modules written for the Rust for Linux project To run the o

Milan 10 Nov 13, 2022