klib-rs 0.1.1

kernel mode function export library and inline hook kernel
Documentation
  • Coverage
  • 0.01%
    1 out of 14096 items documented0 out of 2990 items with examples
  • Size
  • Source code size: 9.21 MB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 457.16 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2m 8s Average build duration of successful builds.
  • all releases: 2m 7s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Niyka1/klib-rs
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Niyka1

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.h
  • ntddk.h
  • ntifs.h

Access to these APIs is controlled via Cargo features, allowing fine-grained control over what is included:

[dependencies]

klib-rs = { version = "*", features = ["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 klib_rs::khook::Hook;
let hook = match Hook::set_hook(target_function as _, my_random_hook as *const () as u64, false) {
    Ok(o) => o,
    Err(e) => todo!(),
};

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 klib_rs::kalloc::KernelAllocator;

#[global_allocator]
static GLOBAL_ALLOCATOR: KernelAllocator = KernelAllocator;