From 0b6b4bc02a1ea7bd6034c59d5627916779296b6d Mon Sep 17 00:00:00 2001 From: pravic Date: Thu, 28 Apr 2016 23:19:31 +0300 Subject: small updates for samples --- examples/01.minimal/driver.rs | 5 +++-- examples/03.urandom/driver.rs | 11 +++++++++-- 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::()); + let cb = mem::size_of::(); + 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); } -- cgit v1.2.3