summaryrefslogtreecommitdiff
path: root/crates/windows-kernel-build/examples/hello_world/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-01-04 13:48:00 -0800
committerFuwn <[email protected]>2022-01-04 13:48:00 -0800
commitc33b9e296ab9563f2b180a8fa63155665055261e (patch)
tree086cf2702939fd25769fea83e117d7058af2e75a /crates/windows-kernel-build/examples/hello_world/src
parentfix(makefile.toml): tidy up (diff)
downloaddriver-c33b9e296ab9563f2b180a8fa63155665055261e.tar.xz
driver-c33b9e296ab9563f2b180a8fa63155665055261e.zip
feat(examples): lots of new examples
Thanks, StephanvanSchaik.
Diffstat (limited to 'crates/windows-kernel-build/examples/hello_world/src')
-rw-r--r--crates/windows-kernel-build/examples/hello_world/src/lib.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/crates/windows-kernel-build/examples/hello_world/src/lib.rs b/crates/windows-kernel-build/examples/hello_world/src/lib.rs
new file mode 100644
index 0000000..124c7c6
--- /dev/null
+++ b/crates/windows-kernel-build/examples/hello_world/src/lib.rs
@@ -0,0 +1,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());
+ }
+}