Windows: Rework kernel32 apis
To facilitate https://github.com/ziglang/zig/issues/1840, this commit slims std.windows.kernel32 to only have the functions needed by the standard library. Since this will break projects that relied on these, I offer these solutions:
-
Make an argument as to why certain functions should be added back in. Note that they may just be wrappers around
ntdllAPIs, which would go against https://github.com/ziglang/zig/issues/1840.If necessary I'll add them back in and make wrappers in
std.windowsfor it. -
Maintain your own list of APIs. This is the option taken by bun, where they wrap functions with tracing.
-
Use
zigwin32.
I've also added TODO comments that specify which functions can be reimplemented using ntdll APIs in the future.
Other changes:
- Group functions into groups (I/O, process management etc.).
- Synchronize definitions against Microsoft documentation to use the proper parameter types/names.
- Break all functions with parameters over multiple lines.
I've added fleshed out the comments on the remaining APIs. I've categorised them into three groups:
- Forwarders: The function puts the arguments into place and jumps directly into the ntdll function.
- Wrappers: The function sets up local variables and calls the ntdll function. Typically
OBJECT_ATTRIBUTESorUNICODE_STRING, but can be more involved. - Unnamed: Functions that are too hard to simply replace.
@andrewrk This pr has been open for a couple months now, since then a couple Windows API changes have been made. I've kept this branch up-to-date but I'd like it to be merged before I do any more changes (specifically, adding a linkat implementation). I think it would also help future contributors who want to tackle #1840.
Do you have any objections to these changes?
Sorry for the delay, I hadn't seen it until now. Looks good! Thanks for your patience on the merge.