-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invaid prototype of PDRIVER_UNLOAD and other callbacks #47
Comments
|
Although the currently published version of windows-sys 0.48 does not include this declaration, the latest version on GitHub has the expected type: pub type DRIVER_UNLOAD = ::core::option::Option<unsafe extern "system" fn(driverobject: *const super::super::Foundation::DRIVER_OBJECT) -> ()>; You can test by pointing your Cargo dependency to the git repo. |
@kennykerr, I can't found this. I setted [dependencies.windows-sys]
git = "https://github.com/microsoft/windows-rs.git"
features = [
"Win32_Foundation",
"Win32_Security",
"Win32_System_IO",
"Win32_System_Kernel",
"Win32_System_Power",
"Win32_System_WindowsProgramming",
"Win32_System_Ioctl",
"Wdk_Foundation",
"Wdk_System",
"Wdk_System_IO",
"Wdk_System_SystemServices",
"Wdk_System_Threading",
"Wdk_Storage",
"Wdk_Storage_FileSystem"
] And we still have no arguments in the master branch: https://github.com/microsoft/windows-rs/blob/master/crates/libs/sys/src/Windows/Wdk/Foundation/mod.rs#L2208 |
Looks like a metadata bug. There's |
Here is a workaround for anyone else who came across this issue until it is fixed: let driver_unload_fn: windows_sys::Wdk::System::SystemServices::DRIVER_UNLOAD = Some(the_driver_unload_function);
(*driver_object).DriverUnload = core::mem::transmute(driver_unload_fn); This also works for the Major functions array: type WriteType = Option<unsafe extern "system" fn(&mut windows_sys::Wdk::Foundation::DEVICE_OBJECT, &mut windows_sys::Wdk::Foundation::IRP) -> windows_sys::Win32::Foundation::NTSTATUS>;
let driver_write_fn: WriteType = Some(the_read_function);
(*driver_object).MajorFunction[windows_sys::Wdk::System::SystemServices::IRP_MJ_WRITE as usize] = core::mem::transmute(driver_write_fn); |
@tannergooding is there anything we can do to scrape these pointer-to-delegate typedefs in a better way? We can manually exclude these typedefs and then remap all occurrences of them to use the original delegate, but there are a lot of instances of these so it would be better if we could handle this while scraping. Is ClangSharp behaving as expected here? Are there any config options that could help us? |
As earlier was stated here: microsoft/windows-rs#2612, there are no arguments in callack definitions like PDRIVER_UNLOAD in the Foundation module of WDK.
But in C++ WDK we have this:
So, the Rust callback should be:
The text was updated successfully, but these errors were encountered: