klib-rs
klib-rs is a Rust library developed and used for my Windows kernel-mode projects.
It serves as a shared foundation to avoid rewriting common low-level components, and I decided to make it public as it may be useful to others.
The library mainly provides bindings and utilities around Windows kernel APIs, along with a few practical abstractions for low-level Rust development.
Features
Windows Kernel Headers Exposure
klib-rs exposes functions and structures from the following Windows kernel headers:
wdm.hntddk.hntifs.h
Access to these APIs is controlled via Cargo features, allowing fine-grained control over what is included:
[]
= { = "*", = ["ntifs"] }
Inline Hooking
klib-rs includes an inline hooking implementation designed for Windows kernel-mode environments.
It allows intercepting kernel functions in a controlled manner while remaining compatible with Rust constraints and kernel execution rules.
Example usage:
use Hook;
let hook = match set_hook ;
Kernel Global Allocator
klib-rs provides a built-in global allocator designed for Windows kernel-mode Rust development.
It can be used as the crate-wide global allocator and removes the need to implement a custom allocation backend in each project.
Example:
use KernelAllocator;
static GLOBAL_ALLOCATOR: KernelAllocator = KernelAllocator;