summaryrefslogtreecommitdiff
path: root/crates/windows-kernel-build/examples/hello_world/src/lib.rs
blob: 124c7c69eb7f9cf5f8ac981c1f3e135e5a1f2e85 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#![no_std]
#![feature(lang_items, const_extern_fn)]
#![deny(
  warnings,
  nonstandard_style,
  unused,
  future_incompatible,
  rust_2018_idioms
)]
#![deny(clippy::all, clippy::nursery, clippy::pedantic)]

use winapi::{
  km::wdm::{DbgPrint, DRIVER_OBJECT},
  shared::ntdef::{NTSTATUS, UNICODE_STRING},
};

#[panic_handler]
const fn panic(_info: &core::panic::PanicInfo<'_>) -> ! { loop {} }

#[lang = "eh_personality"]
const extern "C" fn eh_personality() {}

/// # Safety
/// `unsafe`
#[no_mangle]
pub extern "system" fn driver_entry(driver: &mut DRIVER_OBJECT, _: &UNICODE_STRING) -> NTSTATUS {
  unsafe {
    DbgPrint("driver_entry()\0".as_ptr());
  }

  driver.DriverUnload = Some(driver_exit);

  winapi::shared::ntstatus::STATUS_SUCCESS
}

/// # Safety
/// `unsafe`
#[no_mangle]
pub extern "system" fn driver_exit(_driver: &mut DRIVER_OBJECT) {
  unsafe {
    DbgPrint("driver_exit()\0".as_ptr());
  }
}