Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing null terminator on various kernel32 signatures #19949

Open
Pyrolistical opened this issue May 12, 2024 · 0 comments
Open

Missing null terminator on various kernel32 signatures #19949

Pyrolistical opened this issue May 12, 2024 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@Pyrolistical
Copy link
Contributor

Pyrolistical commented May 12, 2024

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

@Pyrolistical Pyrolistical added the bug Observed behavior contradicts documented or intended behavior label May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

1 participant