diff --git a/general/echo/kmdf/driver/DriverSync/src/device.rs b/general/echo/kmdf/driver/DriverSync/src/device.rs index b0e4f63..e5ef6cd 100644 --- a/general/echo/kmdf/driver/DriverSync/src/device.rs +++ b/general/echo/kmdf/driver/DriverSync/src/device.rs @@ -59,13 +59,13 @@ pub fn echo_device_create(mut device_init: &mut WDFDEVICE_INIT) -> NTSTATUS { // Register the PnP and power callbacks. Power policy related callbacks will be // registered later in SotwareInit. - let [()] = [unsafe { + unsafe { call_unsafe_wdf_function_binding!( WdfDeviceInitSetPnpPowerEventCallbacks, device_init, &mut pnp_power_callbacks ); - }]; + }; let mut attributes = WDF_OBJECT_ATTRIBUTES { Size: core::mem::size_of::() as ULONG, @@ -75,13 +75,13 @@ pub fn echo_device_create(mut device_init: &mut WDFDEVICE_INIT) -> NTSTATUS { ..WDF_OBJECT_ATTRIBUTES::default() }; - let [()] = [unsafe { + unsafe { call_unsafe_wdf_function_binding!( WdfDeviceInitSetRequestAttributes, device_init, &mut attributes ); - }]; + }; let mut attributes = WDF_OBJECT_ATTRIBUTES { Size: core::mem::size_of::() as ULONG, @@ -161,7 +161,7 @@ extern "C" fn echo_evt_device_self_managed_io_start(device: WDFDEVICE) -> NTSTAT // Restart the queue and the periodic timer. We stopped them before going // into low power state. - let [()] = [unsafe { call_unsafe_wdf_function_binding!(WdfIoQueueStart, queue) }]; + unsafe { call_unsafe_wdf_function_binding!(WdfIoQueueStart, queue) }; let due_time: i64 = -(100) * (10000); @@ -203,10 +203,7 @@ unsafe extern "C" fn echo_evt_device_self_managed_io_suspend(device: WDFDEVICE) let queue_context = unsafe { queue_get_context(queue as WDFOBJECT) }; unsafe { - let [()] = [call_unsafe_wdf_function_binding!( - WdfIoQueueStopSynchronously, - queue - )]; + call_unsafe_wdf_function_binding!(WdfIoQueueStopSynchronously, queue); // Stop the watchdog timer and wait for DPC to run to completion if it's already // fired. let _ = (*queue_context).timer.stop(true); diff --git a/general/echo/kmdf/driver/DriverSync/src/driver.rs b/general/echo/kmdf/driver/DriverSync/src/driver.rs index 6c53ab3..d87d5d6 100644 --- a/general/echo/kmdf/driver/DriverSync/src/driver.rs +++ b/general/echo/kmdf/driver/DriverSync/src/driver.rs @@ -3,7 +3,24 @@ use wdk::{nt_success, paged_code, println}; use wdk_sys::{ - call_unsafe_wdf_function_binding, ntddk::KeGetCurrentIrql, APC_LEVEL, DRIVER_OBJECT, NTSTATUS, PCUNICODE_STRING, PDRIVER_OBJECT, PWDFDEVICE_INIT, STATUS_SUCCESS, ULONG, UNICODE_STRING, WDFDRIVER, WDFOBJECT, WDFSTRING, WDF_DRIVER_CONFIG, WDF_DRIVER_VERSION_AVAILABLE_PARAMS, WDF_NO_HANDLE, WDF_NO_OBJECT_ATTRIBUTES + call_unsafe_wdf_function_binding, + ntddk::KeGetCurrentIrql, + APC_LEVEL, + DRIVER_OBJECT, + NTSTATUS, + PCUNICODE_STRING, + PDRIVER_OBJECT, + PWDFDEVICE_INIT, + STATUS_SUCCESS, + ULONG, + UNICODE_STRING, + WDFDRIVER, + WDFOBJECT, + WDFSTRING, + WDF_DRIVER_CONFIG, + WDF_DRIVER_VERSION_AVAILABLE_PARAMS, + WDF_NO_HANDLE, + WDF_NO_OBJECT_ATTRIBUTES, }; use crate::device; @@ -136,9 +153,9 @@ fn echo_print_driver_version() -> NTSTATUS { return nt_status; } - let [()] = [unsafe { + unsafe { call_unsafe_wdf_function_binding!(WdfStringGetUnicodeString, string, &mut us); - }]; + }; let driver_version = String::from_utf16_lossy(unsafe { slice::from_raw_parts( us.Buffer, @@ -147,9 +164,9 @@ fn echo_print_driver_version() -> NTSTATUS { }); println!("Echo Sample {driver_version}"); - let [()] = [unsafe { + unsafe { call_unsafe_wdf_function_binding!(WdfObjectDelete, string as WDFOBJECT); - }]; + }; // string = core::ptr::null_mut(); // 2) Find out to which version of framework this driver is bound to. diff --git a/general/echo/kmdf/driver/DriverSync/src/queue.rs b/general/echo/kmdf/driver/DriverSync/src/queue.rs index a5011e9..95431be 100644 --- a/general/echo/kmdf/driver/DriverSync/src/queue.rs +++ b/general/echo/kmdf/driver/DriverSync/src/queue.rs @@ -325,14 +325,14 @@ extern "C" fn echo_evt_request_cancel(request: WDFREQUEST) { // Complete the request outside of holding any locks if complete_request { - let [()] = [unsafe { + unsafe { call_unsafe_wdf_function_binding!( WdfRequestCompleteWithInformation, request, STATUS_CANCELLED, 0 ); - }]; + } } } @@ -386,12 +386,12 @@ fn echo_set_current_request(request: WDFREQUEST, queue: WDFQUEUE) { unsafe { // Complete the request with an error when unable to mark it cancelable. if !nt_success(status) { - let [()] = [call_unsafe_wdf_function_binding!( + call_unsafe_wdf_function_binding!( WdfRequestCompleteWithInformation, request, status, 0 - )]; + ); } } } @@ -427,12 +427,12 @@ extern "C" fn echo_evt_io_read(queue: WDFQUEUE, request: WDFREQUEST, mut length: // No data to read unsafe { if (*queue_context).buffer.is_null() { - let [()] = [call_unsafe_wdf_function_binding!( + call_unsafe_wdf_function_binding!( WdfRequestCompleteWithInformation, request, STATUS_SUCCESS, 0, - )]; + ); return; } } @@ -451,12 +451,12 @@ extern "C" fn echo_evt_io_read(queue: WDFQUEUE, request: WDFREQUEST, mut length: if !nt_success(nt_status) { println!("echo_evt_io_read Could not get request memory buffer {nt_status:#010X}"); - let [()] = [call_unsafe_wdf_function_binding!( + call_unsafe_wdf_function_binding!( WdfRequestCompleteWithInformation, request, nt_status, 0 - )]; + ); return; } } @@ -473,11 +473,7 @@ extern "C" fn echo_evt_io_read(queue: WDFQUEUE, request: WDFREQUEST, mut length: if !nt_success(nt_status) { println!("echo_evt_io_read: WdfMemoryCopyFromBuffer failed {nt_status:#010X}"); - let [()] = [call_unsafe_wdf_function_binding!( - WdfRequestComplete, - request, - nt_status - )]; + call_unsafe_wdf_function_binding!(WdfRequestComplete, request, nt_status); return; } } @@ -528,18 +524,18 @@ extern "C" fn echo_evt_io_write(queue: WDFQUEUE, request: WDFREQUEST, length: us ); if length > MAX_WRITE_LENGTH { - let [()] = [unsafe { - println!( - "echo_evt_io_write Buffer Length to big {:?}, Max is {:?}", - length, MAX_WRITE_LENGTH - ); + println!( + "echo_evt_io_write Buffer Length to big {:?}, Max is {:?}", + length, MAX_WRITE_LENGTH + ); + unsafe { call_unsafe_wdf_function_binding!( WdfRequestCompleteWithInformation, request, STATUS_BUFFER_OVERFLOW, 0 ); - }]; + } } // Get the memory buffer @@ -548,11 +544,7 @@ extern "C" fn echo_evt_io_write(queue: WDFQUEUE, request: WDFREQUEST, length: us call_unsafe_wdf_function_binding!(WdfRequestRetrieveInputMemory, request, &mut memory); if !nt_success(status) { println!("echo_evt_io_write Could not get request memory buffer {status:#010X}"); - let [()] = [call_unsafe_wdf_function_binding!( - WdfRequestComplete, - request, - status - )]; + call_unsafe_wdf_function_binding!(WdfRequestComplete, request, status); return; } } @@ -573,11 +565,11 @@ extern "C" fn echo_evt_io_write(queue: WDFQUEUE, request: WDFREQUEST, length: us "echo_evt_io_write Could not allocate {:?} byte buffer", length ); - let [()] = [call_unsafe_wdf_function_binding!( + call_unsafe_wdf_function_binding!( WdfRequestComplete, request, STATUS_INSUFFICIENT_RESOURCES - )]; + ); return; } } @@ -597,11 +589,7 @@ extern "C" fn echo_evt_io_write(queue: WDFQUEUE, request: WDFREQUEST, length: us ExFreePool((*queue_context).buffer); (*queue_context).buffer = core::ptr::null_mut(); (*queue_context).length = 0; - let [()] = [call_unsafe_wdf_function_binding!( - WdfRequestComplete, - request, - status - )]; + call_unsafe_wdf_function_binding!(WdfRequestComplete, request, status); return; } @@ -610,11 +598,7 @@ extern "C" fn echo_evt_io_write(queue: WDFQUEUE, request: WDFREQUEST, length: us // Set transfer information unsafe { - let [()] = [call_unsafe_wdf_function_binding!( - WdfRequestSetInformation, - request, - length as u64 - )]; + call_unsafe_wdf_function_binding!(WdfRequestSetInformation, request, length as u64); } // Mark the request is cancelable. This must be the last thing we do because @@ -732,11 +716,7 @@ unsafe extern "C" fn echo_evt_timer_func(timer: WDFTIMER) { unsafe { (*queue_context).spin_lock.release() }; unsafe { - let [()] = [call_unsafe_wdf_function_binding!( - WdfRequestComplete, - request, - status - )]; + call_unsafe_wdf_function_binding!(WdfRequestComplete, request, status); } } }