aboutsummaryrefslogtreecommitdiff
path: root/examples/02.unload
diff options
context:
space:
mode:
authorpravic <[email protected]>2016-04-12 16:41:56 +0300
committerpravic <[email protected]>2016-04-12 16:41:56 +0300
commit56c8fa0af0c451febf43a94a6993f81ad364f9c8 (patch)
tree2cfc94f7606079e2f507bed6740b841fe4990c07 /examples/02.unload
parentWindows Kernel-Mode library (diff)
downloadwinapi-kmd-rs-56c8fa0af0c451febf43a94a6993f81ad364f9c8.tar.xz
winapi-kmd-rs-56c8fa0af0c451febf43a94a6993f81ad364f9c8.zip
add driver examples
Diffstat (limited to 'examples/02.unload')
-rw-r--r--examples/02.unload/Cargo.toml28
-rw-r--r--examples/02.unload/build.rs0
-rw-r--r--examples/02.unload/driver.rs22
-rw-r--r--examples/02.unload/exports.def3
4 files changed, 53 insertions, 0 deletions
diff --git a/examples/02.unload/Cargo.toml b/examples/02.unload/Cargo.toml
new file mode 100644
index 0000000..69a1c49
--- /dev/null
+++ b/examples/02.unload/Cargo.toml
@@ -0,0 +1,28 @@
+[package]
+name = "rust.drv.examples.unload"
+description = "Simple Windows kernel driver which can be unloaded."
+version = "0.1.0"
+authors = ["pravic <[email protected]>"]
+readme = "../README.md"
+
+build = "build.rs"
+links = "ntoskrnl"
+
+[lib]
+path = "driver.rs"
+name = "unload"
+crate-type = ["dylib"]
+
+test = false
+bench = false
+
+[profile.release]
+opt-level = 3
+debug = true
+rpath = false
+lto = true
+debug-assertions = false
+
+[dependencies]
+winapi-km = { path = "../../../km", version="*" }
+core = { path = "../../../libcore", version = "*" }
diff --git a/examples/02.unload/build.rs b/examples/02.unload/build.rs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/examples/02.unload/build.rs
diff --git a/examples/02.unload/driver.rs b/examples/02.unload/driver.rs
new file mode 100644
index 0000000..6336045
--- /dev/null
+++ b/examples/02.unload/driver.rs
@@ -0,0 +1,22 @@
+#![crate_type = "dylib"]
+#![no_std]
+#![allow(bad_style)]
+
+#[macro_use] extern crate km;
+
+use core::mem;
+use km::*;
+
+#[no_mangle]
+pub extern "system" fn DriverEntry(driver: &mut km::DRIVER_OBJECT, _path: *const km::string::UnicodeString) -> Status {
+
+ KdPrint!("[rs] hello, rust!\n");
+ KdPrint!("[rs] we are DriverObject at 0x%p, sizeof %d\n", driver as *mut km::DRIVER_OBJECT , mem::size_of::<km::DRIVER_OBJECT>());
+
+ driver.DriverUnload = Some(DriverUnload);
+ return Status::success;
+}
+
+extern "system" fn DriverUnload(_obj: &mut km::DRIVER_OBJECT) {
+ KdPrint!("[rs] unload.\n");
+}
diff --git a/examples/02.unload/exports.def b/examples/02.unload/exports.def
new file mode 100644
index 0000000..15c494d
--- /dev/null
+++ b/examples/02.unload/exports.def
@@ -0,0 +1,3 @@
+EXPORTS
+ DriverEntry
+