windows: Delete obsolete environment variable kernel32 wrappers and bindings

These functions have been unused for a long time (since cfffb9c5e96eeeae43cd724e2d02ec8c2b7714e0; the PEB is used for this stuff now), and the GetEnvironmentVariableW wrapper's parameter types don't make much sense to boot.

Contributes towards:
- https://github.com/ziglang/zig/issues/4426
- https://github.com/ziglang/zig/issues/1840
This commit is contained in:
Ryan Liptak 2025-06-01 18:56:48 -07:00 committed by Alex Rønne Petersen
parent fa8073795a
commit 8709326088
2 changed files with 0 additions and 41 deletions

View File

@ -1905,32 +1905,6 @@ pub fn SetFileCompletionNotificationModes(handle: HANDLE, flags: UCHAR) !void {
}
}
pub const GetEnvironmentStringsError = error{OutOfMemory};
pub fn GetEnvironmentStringsW() GetEnvironmentStringsError![*:0]u16 {
return kernel32.GetEnvironmentStringsW() orelse return error.OutOfMemory;
}
pub fn FreeEnvironmentStringsW(penv: [*:0]u16) void {
assert(kernel32.FreeEnvironmentStringsW(penv) != 0);
}
pub const GetEnvironmentVariableError = error{
EnvironmentVariableNotFound,
Unexpected,
};
pub fn GetEnvironmentVariableW(lpName: LPWSTR, lpBuffer: [*]u16, nSize: DWORD) GetEnvironmentVariableError!DWORD {
const rc = kernel32.GetEnvironmentVariableW(lpName, lpBuffer, nSize);
if (rc == 0) {
switch (GetLastError()) {
.ENVVAR_NOT_FOUND => return error.EnvironmentVariableNotFound,
else => |err| return unexpectedError(err),
}
}
return rc;
}
pub const CreateProcessError = error{
FileNotFound,
AccessDenied,

View File

@ -340,21 +340,6 @@ pub extern "kernel32" fn GetExitCodeProcess(
// TODO: Already a wrapper for this, see `windows.GetCurrentProcess`.
pub extern "kernel32" fn GetCurrentProcess() callconv(.winapi) HANDLE;
// TODO: memcpy peb().ProcessParameters.Environment, mem.span(0). Requires locking the PEB.
pub extern "kernel32" fn GetEnvironmentStringsW() callconv(.winapi) ?LPWSTR;
// TODO: RtlFreeHeap on the output of GetEnvironmentStringsW.
pub extern "kernel32" fn FreeEnvironmentStringsW(
penv: LPWSTR,
) callconv(.winapi) BOOL;
// TODO: Wrapper around RtlQueryEnvironmentVariable.
pub extern "kernel32" fn GetEnvironmentVariableW(
lpName: ?LPCWSTR,
lpBuffer: ?[*]WCHAR,
nSize: DWORD,
) callconv(.winapi) DWORD;
// TODO: Wrapper around RtlSetEnvironmentVar.
pub extern "kernel32" fn SetEnvironmentVariableW(
lpName: LPCWSTR,