zig icon indicating copy to clipboard operation
zig copied to clipboard

Remove `std.os.windows.QueryInformationFile` (a wrapper of `NtQueryInformationFile`)

Open squeek502 opened this issue 2 years ago • 0 comments

This function is unused, it doesn't provide much over a direct call to NtQueryInformationFile, and the current implementation contains a few footguns:

  • The current wrapper treats all possible errors as unexpected, even likely ones like BUFFER_OVERFLOW (which is returned if the size of the out_buffer is too small to contain all the variable-length members of the requested info, which the user may not actually care about, see https://github.com/ziglang/zig/pull/14841/commits/6d74c0d1b41b52bca3d66092a48660f2ee4ae4f8)
  • Each caller may need to handle errors differently, different errors might be possible depending on the FILE_INFORMATION_CLASS, etc, and making a wrapper that handles all of those different use-cases nicely seems like it'd be more trouble than it's worth (FILE_INFORMATION_CLASS has 76 different possible values)

If a wrapper for NtQueryInformationFile is wanted, then it should probably have wrapper functions per-use-case, like how QueryObjectName wraps NtQueryObject for the ObjectNameInformation class:

https://github.com/ziglang/zig/blob/e3cf9d165081533524927cebf8a92ac6fee097f2/lib/std/os/windows.zig#L1015-L1042

squeek502 avatar Mar 08 '23 12:03 squeek502