Skip to content

Missing null terminator on various kernel32 signatures #19949

Description

@Pyrolistical

Zig Version

0.13.0-dev.75+5c9eb4081

Mismatched signatures

  1. GetCurrentDirectoryW
    pubextern"kernel32"fnGetCurrentDirectoryW(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
    pubextern"kernel32"fnFormatMessageW(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
    pubextern"kernel32"fnGetEnvironmentVariableW(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
    pubextern"kernel32"fnGetModuleFileNameW(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
    pubextern"kernel32"fnGetFullPathNameW(
    lpFileName: [*:0]constu16,
    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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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-windowsMicrosoft Windows

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions