aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorpravic <[email protected]>2016-04-28 23:19:31 +0300
committerpravic <[email protected]>2016-04-28 23:19:31 +0300
commit0b6b4bc02a1ea7bd6034c59d5627916779296b6d (patch)
treeb346be429689fd774f4c99512e882e882c979b94 /examples
parenttypo (diff)
downloadwinapi-kmd-rs-0b6b4bc02a1ea7bd6034c59d5627916779296b6d.tar.xz
winapi-kmd-rs-0b6b4bc02a1ea7bd6034c59d5627916779296b6d.zip
small updates for samples
Diffstat (limited to 'examples')
-rw-r--r--examples/01.minimal/driver.rs5
-rw-r--r--examples/03.urandom/driver.rs11
2 files changed, 12 insertions, 4 deletions
diff --git a/examples/01.minimal/driver.rs b/examples/01.minimal/driver.rs
index d446ff0..32e2dad 100644
--- a/examples/01.minimal/driver.rs
+++ b/examples/01.minimal/driver.rs
@@ -8,9 +8,10 @@ use core::mem;
use km::*;
#[no_mangle]
-pub extern "system" fn DriverEntry(_obj: *mut km::DRIVER_OBJECT, _path: *const km::string::UnicodeString) -> Status
+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", _obj, mem::size_of::<km::DRIVER_OBJECT>());
+ let cb = mem::size_of::<km::DRIVER_OBJECT>();
+ KdPrint!("[rs] we are DriverObject at 0x%p, sizeof 0x%X (%d bytes), expected size 0xA8 or 0x150\n", driver, cb, cb);
return Status::unsuccessful; // return error to unload driver now
}
diff --git a/examples/03.urandom/driver.rs b/examples/03.urandom/driver.rs
index 7a98e48..09192a0 100644
--- a/examples/03.urandom/driver.rs
+++ b/examples/03.urandom/driver.rs
@@ -7,9 +7,12 @@
#[macro_use] extern crate collections;
use km::*;
+use km::irp::IRP_MJ;
+
use core::mem;
use core::ptr;
+
// Helper for converting b"string" to UNICODE_STRING
fn a2u(s: &[u8]) -> UnicodeString {
let a = AnsiString::from(s);
@@ -71,7 +74,6 @@ pub extern "system" fn DriverEntry(driver: &mut km::DRIVER_OBJECT, _path: &km::s
}
// setup I/O processing handlers
- use km::irp::IRP_MJ;
driver.MajorFunction[IRP_MJ::CREATE as usize] = Some(DispatchCreateClose);
driver.MajorFunction[IRP_MJ::CLOSE as usize] = Some(DispatchCreateClose);
driver.MajorFunction[IRP_MJ::READ as usize] = Some(DispatchRead);
@@ -106,7 +108,12 @@ extern "system" fn DriverUnload(driver: &mut km::DRIVER_OBJECT)
}
extern "system" fn DispatchCreateClose(_device: &mut DEVICE_OBJECT, irp: &mut IRP) -> NTSTATUS {
- KdPrint!("[rs] dispatch create/close \n");
+ let code = { irp.get_current_stack_location().MajorFunction };
+ if code == IRP_MJ::CREATE as u8 {
+ KdPrint!("[rs] dispatch create\n");
+ } else {
+ KdPrint!("[rs] dispatch close\n");
+ }
irp.IoStatus.Information = 0;
return irp.complete_request(Status::success);
}