Skip to content

Missing null terminator on various kernel32 signatures #19949

@Pyrolistical

Description

@Pyrolistical

Zig Version

0.13.0-dev.75+5c9eb4081

Mismatched signatures

  1. GetCurrentDirectoryW
    pub extern "kernel32" fn GetCurrentDirectoryW(nBufferLength: DWORD, lpBuffer: ?[*]WCHAR) callconv(WINAPI) DWORD;

    lpBuffer should be null-terminated according to https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getcurrentdirectory
  2. FormatMessageW
    pub extern "kernel32" fn FormatMessageW(dwFlags: DWORD, lpSource: ?LPVOID, dwMessageId: Win32Error, dwLanguageId: DWORD, lpBuffer: [*]u16, nSize: DWORD, Arguments: ?*va_list) callconv(WINAPI) DWORD;

    lpBuffer should be null-terminated according to https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-formatmessagew
  3. GetEnvironmentVariableW
    pub extern "kernel32" fn GetEnvironmentVariableW(lpName: LPWSTR, lpBuffer: [*]u16, nSize: DWORD) callconv(WINAPI) DWORD;

    lpBuffer should be null-terminated according to https://learn.microsoft.com/en-us/windows/win32/api/processenv/nf-processenv-getenvironmentvariablew
  4. GetModuleFileNameW
    pub extern "kernel32" fn GetModuleFileNameW(hModule: ?HMODULE, lpFilename: [*]u16, nSize: DWORD) callconv(WINAPI) DWORD;

    lpFilename should be null-terminated according to https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulefilenamew
  5. GetFullPathNameW
    pub extern "kernel32" fn GetFullPathNameW(
    lpFileName: [*:0]const u16,
    nBufferLength: u32,
    lpBuffer: [*]u16,
    lpFilePart: ?*?[*:0]u16,
    ) callconv(@import("std").os.windows.WINAPI) u32;

    lpBuffer should be null-terminated according to https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfullpathnamew

Fixing these would be a breaking change.

Expected Behavior

extern signatures should be correct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.os-windows

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions