[windows_kext] Update windows-rs

This commit is contained in:
Vladimir Stoilov 2024-06-28 16:06:30 +03:00
parent 2d9d433945
commit 81bee82b8f
12 changed files with 92 additions and 83 deletions

View file

@ -340,19 +340,20 @@ checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8"
[[package]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.52.0" version = "0.52.0"
source = "git+https://github.com/microsoft/windows-rs?rev=41ad38d8c42c92fd23fe25ba4dca76c2d861ca06#41ad38d8c42c92fd23fe25ba4dca76c2d861ca06" source = "git+https://github.com/microsoft/windows-rs?rev=dffa8b03dc4987c278d82e88015ffe96aa8ac317#dffa8b03dc4987c278d82e88015ffe96aa8ac317"
dependencies = [ dependencies = [
"windows-targets", "windows-targets",
] ]
[[package]] [[package]]
name = "windows-targets" name = "windows-targets"
version = "0.52.0" version = "0.52.5"
source = "git+https://github.com/microsoft/windows-rs?rev=41ad38d8c42c92fd23fe25ba4dca76c2d861ca06#41ad38d8c42c92fd23fe25ba4dca76c2d861ca06" source = "git+https://github.com/microsoft/windows-rs?rev=dffa8b03dc4987c278d82e88015ffe96aa8ac317#dffa8b03dc4987c278d82e88015ffe96aa8ac317"
dependencies = [ dependencies = [
"windows_aarch64_gnullvm", "windows_aarch64_gnullvm",
"windows_aarch64_msvc", "windows_aarch64_msvc",
"windows_i686_gnu", "windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc", "windows_i686_msvc",
"windows_x86_64_gnu", "windows_x86_64_gnu",
"windows_x86_64_gnullvm", "windows_x86_64_gnullvm",
@ -361,38 +362,43 @@ dependencies = [
[[package]] [[package]]
name = "windows_aarch64_gnullvm" name = "windows_aarch64_gnullvm"
version = "0.52.0" version = "0.52.5"
source = "git+https://github.com/microsoft/windows-rs?rev=41ad38d8c42c92fd23fe25ba4dca76c2d861ca06#41ad38d8c42c92fd23fe25ba4dca76c2d861ca06" source = "git+https://github.com/microsoft/windows-rs?rev=dffa8b03dc4987c278d82e88015ffe96aa8ac317#dffa8b03dc4987c278d82e88015ffe96aa8ac317"
[[package]] [[package]]
name = "windows_aarch64_msvc" name = "windows_aarch64_msvc"
version = "0.52.0" version = "0.52.5"
source = "git+https://github.com/microsoft/windows-rs?rev=41ad38d8c42c92fd23fe25ba4dca76c2d861ca06#41ad38d8c42c92fd23fe25ba4dca76c2d861ca06" source = "git+https://github.com/microsoft/windows-rs?rev=dffa8b03dc4987c278d82e88015ffe96aa8ac317#dffa8b03dc4987c278d82e88015ffe96aa8ac317"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
version = "0.52.0" version = "0.52.5"
source = "git+https://github.com/microsoft/windows-rs?rev=41ad38d8c42c92fd23fe25ba4dca76c2d861ca06#41ad38d8c42c92fd23fe25ba4dca76c2d861ca06" source = "git+https://github.com/microsoft/windows-rs?rev=dffa8b03dc4987c278d82e88015ffe96aa8ac317#dffa8b03dc4987c278d82e88015ffe96aa8ac317"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.5"
source = "git+https://github.com/microsoft/windows-rs?rev=dffa8b03dc4987c278d82e88015ffe96aa8ac317#dffa8b03dc4987c278d82e88015ffe96aa8ac317"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
version = "0.52.0" version = "0.52.5"
source = "git+https://github.com/microsoft/windows-rs?rev=41ad38d8c42c92fd23fe25ba4dca76c2d861ca06#41ad38d8c42c92fd23fe25ba4dca76c2d861ca06" source = "git+https://github.com/microsoft/windows-rs?rev=dffa8b03dc4987c278d82e88015ffe96aa8ac317#dffa8b03dc4987c278d82e88015ffe96aa8ac317"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
version = "0.52.0" version = "0.52.5"
source = "git+https://github.com/microsoft/windows-rs?rev=41ad38d8c42c92fd23fe25ba4dca76c2d861ca06#41ad38d8c42c92fd23fe25ba4dca76c2d861ca06" source = "git+https://github.com/microsoft/windows-rs?rev=dffa8b03dc4987c278d82e88015ffe96aa8ac317#dffa8b03dc4987c278d82e88015ffe96aa8ac317"
[[package]] [[package]]
name = "windows_x86_64_gnullvm" name = "windows_x86_64_gnullvm"
version = "0.52.0" version = "0.52.5"
source = "git+https://github.com/microsoft/windows-rs?rev=41ad38d8c42c92fd23fe25ba4dca76c2d861ca06#41ad38d8c42c92fd23fe25ba4dca76c2d861ca06" source = "git+https://github.com/microsoft/windows-rs?rev=dffa8b03dc4987c278d82e88015ffe96aa8ac317#dffa8b03dc4987c278d82e88015ffe96aa8ac317"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
version = "0.52.0" version = "0.52.5"
source = "git+https://github.com/microsoft/windows-rs?rev=41ad38d8c42c92fd23fe25ba4dca76c2d861ca06#41ad38d8c42c92fd23fe25ba4dca76c2d861ca06" source = "git+https://github.com/microsoft/windows-rs?rev=dffa8b03dc4987c278d82e88015ffe96aa8ac317#dffa8b03dc4987c278d82e88015ffe96aa8ac317"
[[package]] [[package]]
name = "zerocopy" name = "zerocopy"

View file

@ -22,5 +22,5 @@ hashbrown = { version = "0.14.3", default-features = false, features = ["ahash"]
# WARNING: Do not update. The version was choosen for a reason. See wdk/README.md for more detiels. # WARNING: Do not update. The version was choosen for a reason. See wdk/README.md for more detiels.
[dependencies.windows-sys] [dependencies.windows-sys]
git = "https://github.com/microsoft/windows-rs" git = "https://github.com/microsoft/windows-rs"
rev = "41ad38d8c42c92fd23fe25ba4dca76c2d861ca06" rev = "dffa8b03dc4987c278d82e88015ffe96aa8ac317"
features = ["Wdk_Foundation", "Wdk_Storage_FileSystem", "Wdk_System_SystemServices", "Win32_Foundation", "Win32_Security", "Win32_System_IO", "Win32_System_Kernel", "Win32_System_Power", "Win32_System_WindowsProgramming", "Win32_NetworkManagement_IpHelper", "Win32_Networking_WinSock", "Win32_NetworkManagement_WindowsFilteringPlatform"] features = ["Wdk_Foundation", "Wdk_Storage_FileSystem", "Wdk_System_SystemServices", "Win32_Foundation", "Win32_Security", "Win32_System_IO", "Win32_System_Kernel", "Win32_System_Power", "Win32_System_WindowsProgramming", "Win32_NetworkManagement_IpHelper", "Win32_Networking_WinSock", "Win32_NetworkManagement_WindowsFilteringPlatform"]

View file

@ -38,10 +38,10 @@ pub extern "system" fn driver_entry(
}; };
// Set driver functions. // Set driver functions.
driver.set_driver_unload(driver_unload); driver.set_driver_unload(Some(driver_unload));
driver.set_read_fn(driver_read); driver.set_read_fn(Some(driver_read));
driver.set_write_fn(driver_write); driver.set_write_fn(Some(driver_write));
driver.set_device_control_fn(device_control); driver.set_device_control_fn(Some(device_control));
// Initialize device. // Initialize device.
unsafe { unsafe {
@ -70,10 +70,10 @@ unsafe extern "system" fn driver_unload(_object: *const DRIVER_OBJECT) {
// driver_read event triggered from user-space on file.Read. // driver_read event triggered from user-space on file.Read.
unsafe extern "system" fn driver_read( unsafe extern "system" fn driver_read(
_device_object: &mut DEVICE_OBJECT, _device_object: *const DEVICE_OBJECT,
irp: &mut IRP, irp: *mut IRP,
) -> NTSTATUS { ) -> NTSTATUS {
let mut read_request = ReadRequest::new(irp); let mut read_request = ReadRequest::new(irp.as_mut().unwrap());
let Some(device) = get_device() else { let Some(device) = get_device() else {
read_request.complete(); read_request.complete();
@ -86,10 +86,10 @@ unsafe extern "system" fn driver_read(
/// driver_write event triggered from user-space on file.Write. /// driver_write event triggered from user-space on file.Write.
unsafe extern "system" fn driver_write( unsafe extern "system" fn driver_write(
_device_object: &mut DEVICE_OBJECT, _device_object: *const DEVICE_OBJECT,
irp: &mut IRP, irp: *mut IRP,
) -> NTSTATUS { ) -> NTSTATUS {
let mut write_request = WriteRequest::new(irp); let mut write_request = WriteRequest::new(irp.as_mut().unwrap());
let Some(device) = get_device() else { let Some(device) = get_device() else {
write_request.complete(); write_request.complete();
return write_request.get_status(); return write_request.get_status();
@ -104,10 +104,10 @@ unsafe extern "system" fn driver_write(
/// device_control event triggered from user-space on file.deviceIOControl. /// device_control event triggered from user-space on file.deviceIOControl.
unsafe extern "system" fn device_control( unsafe extern "system" fn device_control(
_device_object: &mut DEVICE_OBJECT, _device_object: *const DEVICE_OBJECT,
irp: &mut IRP, irp: *mut IRP,
) -> NTSTATUS { ) -> NTSTATUS {
let mut control_request = DeviceControlRequest::new(irp); let mut control_request = DeviceControlRequest::new(irp.as_mut().unwrap());
let Some(device) = get_device() else { let Some(device) = get_device() else {
control_request.complete(); control_request.complete();
return control_request.get_status(); return control_request.get_status();

View file

@ -84,19 +84,20 @@ checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8"
[[package]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.52.0" version = "0.52.0"
source = "git+https://github.com/microsoft/windows-rs?rev=41ad38d8c42c92fd23fe25ba4dca76c2d861ca06#41ad38d8c42c92fd23fe25ba4dca76c2d861ca06" source = "git+https://github.com/microsoft/windows-rs?rev=dffa8b03dc4987c278d82e88015ffe96aa8ac317#dffa8b03dc4987c278d82e88015ffe96aa8ac317"
dependencies = [ dependencies = [
"windows-targets", "windows-targets",
] ]
[[package]] [[package]]
name = "windows-targets" name = "windows-targets"
version = "0.52.0" version = "0.52.5"
source = "git+https://github.com/microsoft/windows-rs?rev=41ad38d8c42c92fd23fe25ba4dca76c2d861ca06#41ad38d8c42c92fd23fe25ba4dca76c2d861ca06" source = "git+https://github.com/microsoft/windows-rs?rev=dffa8b03dc4987c278d82e88015ffe96aa8ac317#dffa8b03dc4987c278d82e88015ffe96aa8ac317"
dependencies = [ dependencies = [
"windows_aarch64_gnullvm", "windows_aarch64_gnullvm",
"windows_aarch64_msvc", "windows_aarch64_msvc",
"windows_i686_gnu", "windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc", "windows_i686_msvc",
"windows_x86_64_gnu", "windows_x86_64_gnu",
"windows_x86_64_gnullvm", "windows_x86_64_gnullvm",
@ -105,35 +106,40 @@ dependencies = [
[[package]] [[package]]
name = "windows_aarch64_gnullvm" name = "windows_aarch64_gnullvm"
version = "0.52.0" version = "0.52.5"
source = "git+https://github.com/microsoft/windows-rs?rev=41ad38d8c42c92fd23fe25ba4dca76c2d861ca06#41ad38d8c42c92fd23fe25ba4dca76c2d861ca06" source = "git+https://github.com/microsoft/windows-rs?rev=dffa8b03dc4987c278d82e88015ffe96aa8ac317#dffa8b03dc4987c278d82e88015ffe96aa8ac317"
[[package]] [[package]]
name = "windows_aarch64_msvc" name = "windows_aarch64_msvc"
version = "0.52.0" version = "0.52.5"
source = "git+https://github.com/microsoft/windows-rs?rev=41ad38d8c42c92fd23fe25ba4dca76c2d861ca06#41ad38d8c42c92fd23fe25ba4dca76c2d861ca06" source = "git+https://github.com/microsoft/windows-rs?rev=dffa8b03dc4987c278d82e88015ffe96aa8ac317#dffa8b03dc4987c278d82e88015ffe96aa8ac317"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
version = "0.52.0" version = "0.52.5"
source = "git+https://github.com/microsoft/windows-rs?rev=41ad38d8c42c92fd23fe25ba4dca76c2d861ca06#41ad38d8c42c92fd23fe25ba4dca76c2d861ca06" source = "git+https://github.com/microsoft/windows-rs?rev=dffa8b03dc4987c278d82e88015ffe96aa8ac317#dffa8b03dc4987c278d82e88015ffe96aa8ac317"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.5"
source = "git+https://github.com/microsoft/windows-rs?rev=dffa8b03dc4987c278d82e88015ffe96aa8ac317#dffa8b03dc4987c278d82e88015ffe96aa8ac317"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
version = "0.52.0" version = "0.52.5"
source = "git+https://github.com/microsoft/windows-rs?rev=41ad38d8c42c92fd23fe25ba4dca76c2d861ca06#41ad38d8c42c92fd23fe25ba4dca76c2d861ca06" source = "git+https://github.com/microsoft/windows-rs?rev=dffa8b03dc4987c278d82e88015ffe96aa8ac317#dffa8b03dc4987c278d82e88015ffe96aa8ac317"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
version = "0.52.0" version = "0.52.5"
source = "git+https://github.com/microsoft/windows-rs?rev=41ad38d8c42c92fd23fe25ba4dca76c2d861ca06#41ad38d8c42c92fd23fe25ba4dca76c2d861ca06" source = "git+https://github.com/microsoft/windows-rs?rev=dffa8b03dc4987c278d82e88015ffe96aa8ac317#dffa8b03dc4987c278d82e88015ffe96aa8ac317"
[[package]] [[package]]
name = "windows_x86_64_gnullvm" name = "windows_x86_64_gnullvm"
version = "0.52.0" version = "0.52.5"
source = "git+https://github.com/microsoft/windows-rs?rev=41ad38d8c42c92fd23fe25ba4dca76c2d861ca06#41ad38d8c42c92fd23fe25ba4dca76c2d861ca06" source = "git+https://github.com/microsoft/windows-rs?rev=dffa8b03dc4987c278d82e88015ffe96aa8ac317#dffa8b03dc4987c278d82e88015ffe96aa8ac317"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
version = "0.52.0" version = "0.52.5"
source = "git+https://github.com/microsoft/windows-rs?rev=41ad38d8c42c92fd23fe25ba4dca76c2d861ca06#41ad38d8c42c92fd23fe25ba4dca76c2d861ca06" source = "git+https://github.com/microsoft/windows-rs?rev=dffa8b03dc4987c278d82e88015ffe96aa8ac317#dffa8b03dc4987c278d82e88015ffe96aa8ac317"

View file

@ -16,5 +16,5 @@ features = ["alloc"]
# WARNING: Do not update. The version was choosen for a reason. See wdk/README.md for more detiels. # WARNING: Do not update. The version was choosen for a reason. See wdk/README.md for more detiels.
[dependencies.windows-sys] [dependencies.windows-sys]
git = "https://github.com/microsoft/windows-rs" git = "https://github.com/microsoft/windows-rs"
rev = "41ad38d8c42c92fd23fe25ba4dca76c2d861ca06" rev = "dffa8b03dc4987c278d82e88015ffe96aa8ac317"
features = ["Wdk_Foundation", "Wdk_Storage_FileSystem", "Wdk_System_SystemServices", "Win32_Foundation", "Win32_Security", "Win32_System_IO", "Win32_System_Kernel", "Win32_System_Power", "Win32_System_WindowsProgramming", "Win32_NetworkManagement_IpHelper", "Win32_Networking_WinSock", "Win32_NetworkManagement_WindowsFilteringPlatform", "Win32_System_Rpc"] features = ["Wdk_Foundation", "Wdk_Storage_FileSystem", "Wdk_System_SystemServices", "Win32_Foundation", "Win32_Security", "Win32_System_IO", "Win32_System_Kernel", "Win32_System_Power", "Win32_System_WindowsProgramming", "Win32_NetworkManagement_IpHelper", "Win32_Networking_WinSock", "Win32_NetworkManagement_WindowsFilteringPlatform", "Win32_System_Rpc"]

View file

@ -10,5 +10,7 @@ see: `wdk/src/driver.rs`
see: `wdk/src/irp_helper.rs` see: `wdk/src/irp_helper.rs`
Open issues need to be resolved: Open issues need to be resolved:
https://github.com/microsoft/wdkmetadata/issues/59
https://github.com/microsoft/windows-rs/issues/2805 https://github.com/microsoft/windows-rs/issues/2805
Resolved:
https://github.com/microsoft/wdkmetadata/issues/59

View file

@ -1,6 +1,6 @@
use windows_sys::{ use windows_sys::{
Wdk::Foundation::{DEVICE_OBJECT, DRIVER_OBJECT, IRP}, Wdk::Foundation::{DEVICE_OBJECT, DRIVER_DISPATCH, DRIVER_OBJECT, DRIVER_UNLOAD},
Win32::Foundation::{HANDLE, NTSTATUS}, Win32::Foundation::HANDLE,
}; };
use crate::{ use crate::{
@ -23,11 +23,6 @@ pub struct Driver {
} }
unsafe impl Sync for Driver {} unsafe impl Sync for Driver {}
// This is a workaround for current state of wdk bindings.
// TODO: replace with official version when they are correct: https://github.com/microsoft/wdkmetadata/issues/59
pub type UnloadFnType = unsafe extern "system" fn(driver_object: *const DRIVER_OBJECT);
pub type MjFnType = unsafe extern "system" fn(&mut DEVICE_OBJECT, &mut IRP) -> NTSTATUS;
impl Driver { impl Driver {
pub(crate) fn new( pub(crate) fn new(
driver_object: *mut DRIVER_OBJECT, driver_object: *mut DRIVER_OBJECT,
@ -50,54 +45,54 @@ impl Driver {
return unsafe { self.device_object.as_mut() }; return unsafe { self.device_object.as_mut() };
} }
pub fn set_driver_unload(&mut self, driver_unload: UnloadFnType) { pub fn set_driver_unload(&mut self, driver_unload: DRIVER_UNLOAD) {
if let Some(driver) = unsafe { self.driver_object.as_mut() } { if let Some(driver) = unsafe { self.driver_object.as_mut() } {
driver.DriverUnload = Some(unsafe { core::mem::transmute(driver_unload) }) driver.DriverUnload = driver_unload
} }
} }
pub fn set_read_fn(&mut self, mj_fn: MjFnType) { pub fn set_read_fn(&mut self, mj_fn: DRIVER_DISPATCH) {
self.set_major_fn(windows_sys::Wdk::System::SystemServices::IRP_MJ_READ, mj_fn); self.set_major_fn(windows_sys::Wdk::System::SystemServices::IRP_MJ_READ, mj_fn);
} }
pub fn set_write_fn(&mut self, mj_fn: MjFnType) { pub fn set_write_fn(&mut self, mj_fn: DRIVER_DISPATCH) {
self.set_major_fn( self.set_major_fn(
windows_sys::Wdk::System::SystemServices::IRP_MJ_WRITE, windows_sys::Wdk::System::SystemServices::IRP_MJ_WRITE,
mj_fn, mj_fn,
); );
} }
pub fn set_create_fn(&mut self, mj_fn: MjFnType) { pub fn set_create_fn(&mut self, mj_fn: DRIVER_DISPATCH) {
self.set_major_fn( self.set_major_fn(
windows_sys::Wdk::System::SystemServices::IRP_MJ_CREATE, windows_sys::Wdk::System::SystemServices::IRP_MJ_CREATE,
mj_fn, mj_fn,
); );
} }
pub fn set_device_control_fn(&mut self, mj_fn: MjFnType) { pub fn set_device_control_fn(&mut self, mj_fn: DRIVER_DISPATCH) {
self.set_major_fn( self.set_major_fn(
windows_sys::Wdk::System::SystemServices::IRP_MJ_DEVICE_CONTROL, windows_sys::Wdk::System::SystemServices::IRP_MJ_DEVICE_CONTROL,
mj_fn, mj_fn,
); );
} }
pub fn set_close_fn(&mut self, mj_fn: MjFnType) { pub fn set_close_fn(&mut self, mj_fn: DRIVER_DISPATCH) {
self.set_major_fn( self.set_major_fn(
windows_sys::Wdk::System::SystemServices::IRP_MJ_CLOSE, windows_sys::Wdk::System::SystemServices::IRP_MJ_CLOSE,
mj_fn, mj_fn,
); );
} }
pub fn set_cleanup_fn(&mut self, mj_fn: MjFnType) { pub fn set_cleanup_fn(&mut self, mj_fn: DRIVER_DISPATCH) {
self.set_major_fn( self.set_major_fn(
windows_sys::Wdk::System::SystemServices::IRP_MJ_CLEANUP, windows_sys::Wdk::System::SystemServices::IRP_MJ_CLEANUP,
mj_fn, mj_fn,
); );
} }
fn set_major_fn(&mut self, fn_index: u32, mj_fn: MjFnType) { fn set_major_fn(&mut self, fn_index: u32, mj_fn: DRIVER_DISPATCH) {
if let Some(driver) = unsafe { self.driver_object.as_mut() } { if let Some(driver) = unsafe { self.driver_object.as_mut() } {
driver.MajorFunction[fn_index as usize] = Some(unsafe { core::mem::transmute(mj_fn) }) driver.MajorFunction[fn_index as usize] = mj_fn
} }
} }
} }

View file

@ -270,7 +270,7 @@ impl WdfObjectAttributes {
evt_destroy_callback: None, evt_destroy_callback: None,
execution_level: WdfExecutionLevel::InheritFromParent, execution_level: WdfExecutionLevel::InheritFromParent,
synchronization_scope: WdfSynchronizationScope::InheritFromParent, synchronization_scope: WdfSynchronizationScope::InheritFromParent,
parent_object: 0, parent_object: core::ptr::null_mut(),
context_size_override: 0, context_size_override: 0,
context_type_info: core::ptr::null(), context_type_info: core::ptr::null(),
} }

View file

@ -1,7 +1,7 @@
use super::{callout_data::CalloutData, ffi, layer::Layer}; use super::{callout_data::CalloutData, ffi, layer::Layer};
use crate::ffi::FwpsCalloutClassifyFn; use crate::ffi::FwpsCalloutClassifyFn;
use alloc::{borrow::ToOwned, format, string::String}; use alloc::{borrow::ToOwned, format, string::String};
use windows_sys::Wdk::Foundation::DEVICE_OBJECT; use windows_sys::{Wdk::Foundation::DEVICE_OBJECT, Win32::Foundation::HANDLE};
pub enum FilterType { pub enum FilterType {
Resettable, Resettable,
@ -49,13 +49,13 @@ impl Callout {
pub fn register_filter( pub fn register_filter(
&mut self, &mut self,
filter_engine_handle: isize, filter_engine_handle: HANDLE,
sublayer_guid: u128, sublayer_guid: u128,
) -> Result<(), String> { ) -> Result<(), String> {
match ffi::register_filter( match ffi::register_filter(
filter_engine_handle, filter_engine_handle,
sublayer_guid, sublayer_guid,
&format!("{}-filter", self.name), &self.name,
&self.description, &self.description,
self.guid, self.guid,
self.layer, self.layer,
@ -75,14 +75,14 @@ impl Callout {
pub(crate) fn register_callout( pub(crate) fn register_callout(
&mut self, &mut self,
filter_engine_handle: isize, filter_engine_handle: HANDLE,
device_object: *mut DEVICE_OBJECT, device_object: *mut DEVICE_OBJECT,
callout_fn: FwpsCalloutClassifyFn, callout_fn: FwpsCalloutClassifyFn,
) -> Result<(), String> { ) -> Result<(), String> {
match ffi::register_callout( match ffi::register_callout(
device_object, device_object,
filter_engine_handle, filter_engine_handle,
&format!("{}-callout", self.name), &self.name,
&self.description, &self.description,
self.guid, self.guid,
self.layer, self.layer,

View file

@ -140,7 +140,7 @@ impl<'a> CalloutData<'a> {
packet_list: Option<TransportPacketList>, packet_list: Option<TransportPacketList>,
) -> Result<ClassifyDefer, String> { ) -> Result<ClassifyDefer, String> {
unsafe { unsafe {
let mut completion_context = 0; let mut completion_context: HANDLE = core::ptr::null_mut();
if let Some(completion_handle) = (*self.metadata).get_completion_handle() { if let Some(completion_handle) = (*self.metadata).get_completion_handle() {
let status = FwpsPendOperation0(completion_handle, &mut completion_context); let status = FwpsPendOperation0(completion_handle, &mut completion_context);
check_ntstatus(status)?; check_ntstatus(status)?;

View file

@ -192,7 +192,7 @@ impl Drop for FilterEngine {
} }
} }
if self.handle != 0 && self.handle != INVALID_HANDLE_VALUE { if !self.handle.is_null() && self.handle != INVALID_HANDLE_VALUE {
_ = ffi::filter_engine_close(self.handle); _ = ffi::filter_engine_close(self.handle);
} }
} }

View file

@ -163,7 +163,7 @@ impl Injector {
let status = if packet_list.inbound { let status = if packet_list.inbound {
FwpsInjectTransportReceiveAsync0( FwpsInjectTransportReceiveAsync0(
self.transport_inject_handle, self.transport_inject_handle,
0, core::ptr::null_mut(),
core::ptr::null_mut(), core::ptr::null_mut(),
0, 0,
address_family, address_family,
@ -177,7 +177,7 @@ impl Injector {
} else { } else {
FwpsInjectTransportSendAsync1( FwpsInjectTransportSendAsync1(
self.transport_inject_handle, self.transport_inject_handle,
0, core::ptr::null_mut(),
packet_list.endpoint_handle, packet_list.endpoint_handle,
0, 0,
&mut send_params, &mut send_params,
@ -222,7 +222,7 @@ impl Injector {
unsafe { unsafe {
FwpsInjectNetworkReceiveAsync0( FwpsInjectNetworkReceiveAsync0(
inject_handle, inject_handle,
0, core::ptr::null_mut(),
0, 0,
UNSPECIFIED_COMPARTMENT_ID, UNSPECIFIED_COMPARTMENT_ID,
inject_info.interface_index, inject_info.interface_index,
@ -237,7 +237,7 @@ impl Injector {
unsafe { unsafe {
FwpsInjectNetworkSendAsync0( FwpsInjectNetworkSendAsync0(
inject_handle, inject_handle,
0, core::ptr::null_mut(),
0, 0,
UNSPECIFIED_COMPARTMENT_ID, UNSPECIFIED_COMPARTMENT_ID,
nbl, nbl,
@ -269,7 +269,7 @@ impl Injector {
} else { } else {
self.packet_inject_handle_v4 self.packet_inject_handle_v4
}; };
if inject_handle == INVALID_HANDLE_VALUE || inject_handle == 0 { if inject_handle == INVALID_HANDLE_VALUE || inject_handle.is_null() {
return false; return false;
} }
@ -309,19 +309,19 @@ impl Drop for Injector {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
if self.transport_inject_handle != INVALID_HANDLE_VALUE if self.transport_inject_handle != INVALID_HANDLE_VALUE
&& self.transport_inject_handle != 0 && !self.transport_inject_handle.is_null()
{ {
FwpsInjectionHandleDestroy0(self.transport_inject_handle); FwpsInjectionHandleDestroy0(self.transport_inject_handle);
self.transport_inject_handle = INVALID_HANDLE_VALUE; self.transport_inject_handle = INVALID_HANDLE_VALUE;
} }
if self.packet_inject_handle_v4 != INVALID_HANDLE_VALUE if self.packet_inject_handle_v4 != INVALID_HANDLE_VALUE
&& self.packet_inject_handle_v4 != 0 && !self.packet_inject_handle_v4.is_null()
{ {
FwpsInjectionHandleDestroy0(self.packet_inject_handle_v4); FwpsInjectionHandleDestroy0(self.packet_inject_handle_v4);
self.packet_inject_handle_v4 = INVALID_HANDLE_VALUE; self.packet_inject_handle_v4 = INVALID_HANDLE_VALUE;
} }
if self.packet_inject_handle_v6 != INVALID_HANDLE_VALUE if self.packet_inject_handle_v6 != INVALID_HANDLE_VALUE
&& self.packet_inject_handle_v6 != 0 && !self.packet_inject_handle_v6.is_null()
{ {
FwpsInjectionHandleDestroy0(self.packet_inject_handle_v6); FwpsInjectionHandleDestroy0(self.packet_inject_handle_v6);
self.packet_inject_handle_v6 = INVALID_HANDLE_VALUE; self.packet_inject_handle_v6 = INVALID_HANDLE_VALUE;