@@ -3699,11 +3699,15 @@ void *node_loader_impl_register(void *node_impl_ptr, void *env_ptr, void *functi
36993699#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER >= 1200)
37003700 {
37013701 /* As the library handle is correctly resolved here, either to executable, library of the executable,
3702- or the loader dependency we can directly obtain the handle of this dependency from a function pointer,
3703- use any function that is contained in node runtime, in this case we are using napi_create_array */
3704- if (!GetModuleHandleExA (GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT | GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR)&napi_create_array, &node_loader_node_dll_handle))
3702+ or the loader dependency we can directly get the handle of this dependency */
3703+ dynlink node_library = loader_impl_dependency (node_impl->impl , " node" );
3704+
3705+ node_loader_node_dll_handle = dynlink_get_impl (node_library);
3706+
3707+ if (node_loader_node_dll_handle == NULL )
37053708 {
3706- napi_throw_type_error (env, nullptr , " Failed to initialize the hooking against node extensions load mechanism" );
3709+ napi_throw_error (env, nullptr , " Failed to initialize the hooking against node extensions load mechanism" );
3710+ return NULL ;
37073711 }
37083712
37093713 detour d = detour_create (metacall_detour ());
@@ -4032,7 +4036,7 @@ loader_impl_data node_loader_impl_initialize(loader_impl impl, configuration con
40324036 /* Result will never be defined properly */
40334037 node_impl->result = 0 ;
40344038
4035- if (metacall_link_register_impl (impl, " node" , " napi_register_module_v1" , (void (*)(void ))(&node_loader_port_initialize)) != 0 )
4039+ if (metacall_link_register_loader (impl, " node" , " napi_register_module_v1" , (void (*)(void ))(&node_loader_port_initialize)) != 0 )
40364040 {
40374041 log_write (" metacall" , LOG_LEVEL_ERROR, " Node Loader failed to hook napi_register_module_v1" );
40384042 }
0 commit comments