microsoft / wdkmetadata

Tooling to generate metadata for Win32 APIs in the Windows Driver Kit (WDK).
Other
92 stars 8 forks source link

`NtCancelIoFileEx` function is missing #9

Closed kennykerr closed 1 year ago

kennykerr commented 1 year ago

The function is documented here:

https://learn.microsoft.com/en-us/windows/win32/devnotes/nt-cancel-io-file-ex

It seems like this should be included as it is clearly for desktop use and the Win32 metadata includes various other functions exported from ntdll.dll. I'm just not sure where to find the header.

Originally posted by @Thomasdezeeuw in https://github.com/tokio-rs/mio/issues/1632#issuecomment-1319942586

KalleOlaviNiemitalo commented 1 year ago

Is the documentation correct in that NtCancelIoFileEx returns BOOL? I'd expect Nt functions to return NTSTATUS.

Thomasdezeeuw commented 1 year ago

Is the documentation correct in that NtCancelIoFileEx returns BOOL? I'd expect Nt functions to return NTSTATUS.

Mio has been handling it as a NTSTATUS and it hasn't blow up yet (https://github.com/tokio-rs/mio/blob/fc2080cd0a663125b59f0afa2bc1c771a3fbec1e/src/sys/windows/afd.rs#L28).

kennykerr commented 1 year ago

Yes, the docs are not correct either. 😜

KalleOlaviNiemitalo commented 1 year ago

Huh so there is a third parameter as well.

Anyway, why would an application call NtCancelIoFileEx rather than the better-documented CancelIoEx? Does win32metadata attempt to support native NT (not Win32) applications?

mikebattista commented 1 year ago

Is this header in the WDK? I don't see it in the SDK.

kennykerr commented 1 year ago

I haven't been able to find a public version of it.

Thomasdezeeuw commented 1 year ago

Huh so there is a third parameter as well.

Anyway, why would an application call NtCancelIoFileEx rather than the better-documented CancelIoEx? Does win32metadata attempt to support native NT (not Win32) applications?

Because we use the third argument: https://github.com/tokio-rs/mio/blob/fc2080cd0a663125b59f0afa2bc1c771a3fbec1e/src/sys/windows/afd.rs#L119. Although I'm too familiar with Windows. Perhaps this can be rewritten to use CancelIoEx? For context wepoll also uses NtCancelIoFileEx: https://github.com/piscisaureus/wepoll/blob/0598a791bf9cbbf480793d778930fc635b044980/wepoll.c#L404-L405.

elachlan commented 1 year ago

Related: microsoft/wdkmetadata#1, microsoft/wdkmetadata#3, microsoft/wdkmetadata#6, microsoft/wdkmetadata#7, etc.

kennykerr commented 1 year ago

Just following up on this issue. I can't find the public header with it but since it is documented here's the correct definition:

NTSTATUS
NTAPI
NtCancelIoFileEx(
    _In_ HANDLE FileHandle,
    _In_opt_ PIO_STATUS_BLOCK IoRequestToCancel,
    _Out_ PIO_STATUS_BLOCK IoStatusBlock
    );

Perhaps we can manually include it in the WDK metadata along with all of the other NtXxx APIs that are now present.