diff options
| author | Fuwn <[email protected]> | 2022-01-03 03:20:12 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-01-03 03:20:12 -0800 |
| commit | 85db2b507f3f69b32811c54a89d9ac7bbbc46121 (patch) | |
| tree | 2efd66da452f8a6a2cc6c91584c925f237506ddf /crates/driver/src/lib.rs | |
| download | archived-driver-85db2b507f3f69b32811c54a89d9ac7bbbc46121.tar.xz archived-driver-85db2b507f3f69b32811c54a89d9ac7bbbc46121.zip | |
feat(driver): commit primer
Diffstat (limited to 'crates/driver/src/lib.rs')
| -rw-r--r-- | crates/driver/src/lib.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/crates/driver/src/lib.rs b/crates/driver/src/lib.rs new file mode 100644 index 0000000..09b17fc --- /dev/null +++ b/crates/driver/src/lib.rs @@ -0,0 +1,43 @@ +// Copyright (C) 2022-2022 Fuwn +// SPDX-License-Identifier: GPL-3.0-only + +#![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 {} } + +// https://users.rust-lang.org/t/solved-hello-world-no-std-build-problem/23122/4 +#[lang = "eh_personality"] +const extern "C" fn eh_personality() {} + +#[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 +} + +#[no_mangle] +pub extern "system" fn driver_exit(_driver: &mut DRIVER_OBJECT) { + unsafe { + DbgPrint("driver_exit()\0".as_ptr()); + } +} |