// SPDX-FileCopyrightText: 2026 Alexander Bates // // SPDX-License-Identifier: 0BSD // Lets a native module built with MinGW find Node-API in the app's own // executable, whatever it's named. The module links against node.exe, as // node-gyp's do, but loads it lazily, and this hook hands the loader the // running executable instead. node-gyp's own hook only compiles under MSVC. #define WIN32_LEAN_AND_MEAN #include #include #include static FARPROC WINAPI load_exe_hook(unsigned int event, DelayLoadInfo* info) { if (event != dliNotePreLoadLibrary || _stricmp(info->szDll, "node.exe") != 0) return NULL; return (FARPROC) GetModuleHandle(NULL); } PfnDliHook __pfnDliNotifyHook2 = load_exe_hook;