Skip to content

Commit c5b5de0

Browse files
committed
build: drop the libnode.dll module preference from the hook
GetModuleHandle("libnode.dll") cannot fire for the hosts the suite runs against, none of which load a shared libnode.dll, and node-gyp's own hook resolves every delay-loaded name to the process image the same way. The libnode.dll name match stays, so an addon whose import table names it is still redirected rather than left to the loader. Signed-off-by: hexbinoct <abubakarm@gmail.com>
1 parent a1394ef commit c5b5de0

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

‎src/win_delay_load_hook.cc‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* When this file is linked to a DLL, it sets up a delay-load hook that
33
* intervenes when the DLL is trying to load 'node.exe' or 'libnode.dll'
44
* dynamically. Instead of trying to locate the file it'll just return a
5-
* handle to the process image (or to libnode.dll if the host loaded one).
5+
* handle to the process image.
66
*
77
* This allows the test addons to load into any Node-API host executable,
88
* regardless of its file name. Same approach as node-gyp's
@@ -21,18 +21,14 @@
2121
#include <string.h>
2222

2323
static FARPROC WINAPI load_exe_hook(unsigned int event, DelayLoadInfo* info) {
24-
HMODULE m;
2524
if (event != dliNotePreLoadLibrary)
2625
return NULL;
2726

2827
if (_stricmp(info->szDll, "node.exe") != 0 &&
2928
_stricmp(info->szDll, "libnode.dll") != 0)
3029
return NULL;
3130

32-
// Prefer libnode.dll to support a Node.js built as a shared library.
33-
m = GetModuleHandle(TEXT("libnode.dll"));
34-
if (m == NULL) m = GetModuleHandle(NULL);
35-
return (FARPROC) m;
31+
return (FARPROC) GetModuleHandle(NULL);
3632
}
3733

3834
decltype(__pfnDliNotifyHook2) __pfnDliNotifyHook2 = load_exe_hook;

0 commit comments

Comments
 (0)