Coder Social home page Coder Social logo

Comments (6)

kennykerr avatar kennykerr commented on August 19, 2024 1

Looks like a metadata bug. There's Windows.Wdk.System.SystemServices.DRIVER_UNLOAD which appears to be correct and then there's Windows.Wdk.Foundation.PDRIVER_UNLOAD which appears to be incorrect.

from wdkmetadata.

mikebattista avatar mikebattista commented on August 19, 2024

DRIVER_UNLOAD is in the metadata. Does that work as expected?

from wdkmetadata.

kennykerr avatar kennykerr commented on August 19, 2024

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.

from wdkmetadata.

HoShiMin avatar HoShiMin commented on August 19, 2024

@kennykerr, I can't found this. I setted windows-sys using a git link:

[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

from wdkmetadata.

vlabo avatar vlabo commented on August 19, 2024

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);

from wdkmetadata.

mikebattista avatar mikebattista commented on August 19, 2024
//
// Define driver unload routine type.
//
_Function_class_(DRIVER_UNLOAD)
_IRQL_requires_(PASSIVE_LEVEL)
_IRQL_requires_same_
typedef
VOID
DRIVER_UNLOAD (
    _In_ struct _DRIVER_OBJECT *DriverObject
    );

typedef DRIVER_UNLOAD *PDRIVER_UNLOAD;

@tannergooding is there anything we can do to scrape these pointer-to-delegate typedefs in a better way? PDRIVER_UNLOAD and other typedefs like this result in an empty delegate, and then wherever these typedefs are referenced results in an empty delegate rather than a pointer to the real delegate.

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?

from wdkmetadata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.