4 releases

0.1.3 Mar 8, 2024
0.1.2 Oct 16, 2022
0.1.1 Jan 19, 2022
0.1.0 Jan 19, 2022

#331 in Hardware support

Download history 3/week @ 2024-05-30 9/week @ 2024-06-06 6/week @ 2024-06-13 5/week @ 2024-06-20 2/week @ 2024-06-27 12/week @ 2024-07-04 2/week @ 2024-07-25 5/week @ 2024-08-01 5/week @ 2024-08-08 3/week @ 2024-08-15

125 downloads per month

Custom license

5KB

Rust crates.io docs.rs

kernel-log-rs

A minimalistic logger for Windows Kernel Drivers.

Usage

#![no_std]

use kernel_log::KernelLogger;

#[no_mangle]
pub extern "system" fn DriverEntry(_: PDRIVER_OBJECT, _: u64) -> NTSTATUS {
    KernelLogger::init(LevelFilter::Info).expect("Failed to initialize logger");

    log::warn!("This is an example message.")
}

lib.rs:

Implements the print!, println! and dbg! macros so they can be used in the kernel without the use of an allocator.

By default the macros are prefixed with kernel_. If you want to remove the prefix, you can enable the std_name feature.

Usage

Exactly as you'd use the original macros from the standard library.

#![no_std]

// ...

kernel_dbg!(2 + 2);
kernel_print!("{} + {} = {}\n", 2, 2, 2 + 2);
kernel_println!("{} + {} = {}", 2, 2, 2 + 2);

Features

  • std_name: Allows you to use the macros without the kernel_ prefix.
  • format: Uses the format! macro instead of the core::fmt::Write trait to convert the passed data into a string. This crate provides a simple wrapper for logging with the DbgPrint function. The logs won't be included in the final binary which helps to harden reverse engineering.

Dependencies

~0.7–1MB
~24K SLoC