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
125 downloads per month
5KB
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 thekernel_
prefix.format
: Uses theformat!
macro instead of thecore::fmt::Write
trait to convert the passed data into a string. This crate provides a simple wrapper for logging with theDbgPrint
function. The logs won't be included in the final binary which helps to harden reverse engineering.
Dependencies
~0.7–1MB
~24K SLoC