Windows: Rework kernel32 apis #19641
Merged
andrewrk merged 2 commits intoziglang:masterfrom Jul 18, 2024
Merged
Conversation
b987c2e to
edcbf9d
Compare
Contributor
Author
|
I've added fleshed out the comments on the remaining APIs. I've categorised them into three groups:
|
3e99b86 to
ab020f0
Compare
squeek502
reviewed
Apr 22, 2024
60252bb to
7615944
Compare
squeek502
reviewed
Apr 22, 2024
57f8ff0 to
6fb865e
Compare
3999adb to
98b3e14
Compare
aa26b64 to
44b364c
Compare
44b364c to
4ac10cd
Compare
To facilitate ziglang#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 two solutions: - Make an argument as to why certain functions should be added back in. Note that they may just be wrappers around `ntdll` APIs, which would go against ziglang#1840. If necessary I'll add them back in *and* make wrappers in `std.windows` for it. - Maintain your own list of APIs. This is the option taken by bun[1], 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.
4ac10cd to
3095e83
Compare
Contributor
Author
|
@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 Do you have any objections to these changes? |
Member
|
Sorry for the delay, I hadn't seen it until now. Looks good! Thanks for your patience on the merge. |
squeek502
added a commit
to squeek502/zig
that referenced
this pull request
Jul 29, 2024
In ziglang#19641, this binding changed from `[*]u16` to `LPWSTR` which made it a sentinel-terminated pointer. This introduced a compiler error in the `std.os.windows.GetModuleFileNameW` wrapper since it takes a `[*]u16` pointer. This commit changes the binding back to what it was before instead of introducing a breaking change to `std.os.windows.GetModuleFileNameW` Related: ziglang#20858
andrewrk
pushed a commit
that referenced
this pull request
Jul 29, 2024
In #19641, this binding changed from `[*]u16` to `LPWSTR` which made it a sentinel-terminated pointer. This introduced a compiler error in the `std.os.windows.GetModuleFileNameW` wrapper since it takes a `[*]u16` pointer. This commit changes the binding back to what it was before instead of introducing a breaking change to `std.os.windows.GetModuleFileNameW` Related: #20858
igor84
pushed a commit
to igor84/zig
that referenced
this pull request
Aug 11, 2024
In ziglang#19641, this binding changed from `[*]u16` to `LPWSTR` which made it a sentinel-terminated pointer. This introduced a compiler error in the `std.os.windows.GetModuleFileNameW` wrapper since it takes a `[*]u16` pointer. This commit changes the binding back to what it was before instead of introducing a breaking change to `std.os.windows.GetModuleFileNameW` Related: ziglang#20858
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To facilitate #1840, this commit slims
std.windows.kernel32to 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 Prefer depending on NtDll rather than kernel32 or other higher level DLLs #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
TODOcomments that specify which functions can be reimplemented usingntdllAPIs in the future.Other changes: