Skip to content

Build failure on Windows in [email protected] due to GetModuleHandle LPCWSTR conversion issue #3126

Open
@BohdanVV

Description

@BohdanVV

Description

After upgrading to [email protected], I encountered a build failure on Windows due to an incorrect function call in win_delay_load_hook.cc. The issue is caused by GetModuleHandle, which expects a wide string (LPCWSTR) but is receiving a narrow string (char*).

This happens on both local hardware and GitHub runners.

Error Message

C:\Users\myuser\AppData\Local\Yarn\Data\global\node_modules\node-gyp\src\win_delay_load_hook.cc(32,36): error C2664: 'HMODULE GetModuleHandleW(LPCWSTR)': cannot convert argument 1 from 'const char [12]' to 'LPCWSTR'

Additional Context

This issue appears to be introduced by changes in #2834, which were merged and released as part of [email protected]

Detailed logs (GitHub Actions run): logs from the failed build

Affected Versions

  • node-gyp: 11.1.0
  • Node.js: Any, I've tested w/ 18.x, 20.x, 22.x
  • OS: Windows 10 (x64), Windows GitHub runners

Proposed Fix

I'm not a C++ expert, but I attempted a modification in win_delay_load_hook.cc to explicitly use GetModuleHandleA (ANSI) instead of GetModuleHandle, which defaults to GetModuleHandleW (wide-character version).

Change this:

m = GetModuleHandle("libnode.dll");

to this:

m = GetModuleHandleA("libnode.dll");

If this sounds like a reasonable solution, I can open a PR.

Would appreciate any comments from the maintainers.

@zombieyang

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions