File tree 2 files changed +57
-0
lines changed
2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
'target_defaults' : {
3
3
'type' : 'loadable_module' ,
4
+ 'win_delay_load_hook' : 'false' ,
4
5
'product_prefix' : '' ,
6
+
5
7
'include_dirs' : [
6
8
'<(node_root_dir)/src' ,
7
9
'<(node_root_dir)/deps/uv/include' ,
13
15
'product_extension' : 'node' ,
14
16
'defines' : [ 'BUILDING_NODE_EXTENSION' ],
15
17
}],
18
+
16
19
['_type=="static_library"' , {
17
20
# set to `1` to *disable* the -T thin archive 'ld' flag.
18
21
# older linkers don't support this flag.
19
22
'standalone_static_library' : '<(standalone_static_library)'
20
23
}],
24
+
25
+ ['_win_delay_load_hook=="true"' , {
26
+ # If the has the 'win_delay_load_hook' option set to 'true', link a
27
+ # delay-load hook into the DLL. That hook ensures that the addon
28
+ # will work regardless of whether the node/iojs binary is named
29
+ # node.exe, iojs.exe, or something else.
30
+ 'conditions' : [
31
+ [ 'OS=="win"' , {
32
+ 'sources' : [
33
+ 'src/win_delay_load_hook.c' ,
34
+ ],
35
+ 'msvs_settings' : {
36
+ 'VCLinkerTool' : {
37
+ 'DelayLoadDLLs' : [ 'iojs.exe' , 'node.exe' ],
38
+ # Don't print a linker warning when no imports from either .exe
39
+ # are used.
40
+ 'AdditionalOptions' : [ '/ignore:4199' ],
41
+ },
42
+ },
43
+ }],
44
+ ],
45
+ }],
21
46
],
22
47
23
48
'conditions' : [
Original file line number Diff line number Diff line change
1
+ /*
2
+ * When this file is linked to a DLL, it sets up a delay-load hook that
3
+ * intervenes when the DLL is trying to load 'node.exe' or 'iojs.exe'
4
+ * dynamically. Instead of trying to locate the .exe file it'll just return
5
+ * a handle to the process image.
6
+ *
7
+ * This allows compiled addons to work when node.exe or iojs.exe is renamed.
8
+ */
9
+
10
+ #ifdef _MSC_VER
11
+
12
+ #define WIN32_LEAN_AND_MEAN
13
+ #include <windows.h>
14
+
15
+ #include <delayimp.h>
16
+ #include <string.h>
17
+
18
+ static FARPROC WINAPI load_exe_hook (unsigned int event , DelayLoadInfo * info ) {
19
+ if (event != dliNotePreLoadLibrary )
20
+ return NULL ;
21
+
22
+ if (_stricmp (info -> szDll , "iojs.exe" ) != 0 &&
23
+ _stricmp (info -> szDll , "node.exe" ) != 0 )
24
+ return NULL ;
25
+
26
+ HMODULE m = GetModuleHandle (NULL );
27
+ return (FARPROC ) m ;
28
+ }
29
+
30
+ PfnDliHook __pfnDliNotifyHook2 = load_exe_hook ;
31
+
32
+ #endif
You can’t perform that action at this time.
0 commit comments