microsoft / windows-drivers-rs

Platform that enables Windows driver development in Rust. Developed by Surface.
Apache License 2.0
1.49k stars 65 forks source link

Driver installation crashes when using `EvtIoInternalDeviceControl` #100

Open lurebat opened 8 months ago

lurebat commented 8 months ago

I'm trying to use the repo to write a keyboard driver - https://github.com/lurebat/interustception

My problem is as such:

When using WDF_IO_QUEUE_CONFIG, everything is fine as long as I use EvtIoDeviceControl.

But as soon as I try to set EvtIoInternalDeviceControl, installing hangs forever. The setup file in C:\windows\inf writes binary gibberish.

The callback function has the correct signature, and marked with

        #[no_mangle]
        #[link_section = "PAGE"]
        pub unsafe extern "C"

I can gurantee the object is initialized correctly (as I have debug prints). The device_create functions returns with a successful code, it hangs later on when trying to start the device.

I even tried marking all of my user-made functions with link_section=PAGE, and I suspect it might be something in this area, or something deallocates before it needs to - but I can't figure it out.

The callback isn't even called as far as I can tell - breakpoints don't set, prints don't print, etc.

I haven't found anything online on a similar problem, and at this point I'm desperate - so maybe it's the framework or rust.

Even ideas to how to debug it would be great help.

Thanks!