Comments (1)
So basically something like the following (Untested though):
In node:
diff --git a/src/node_binding.cc b/src/node_binding.cc
index 00493f03f1..6f56f79dc5 100644
--- a/src/node_binding.cc
+++ b/src/node_binding.cc
@@ -457,6 +457,27 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
return; // Exception pending.
}
+#if defined(_WIN32) && defined(NODE_SHARED_MODE)
+ HMODULE mod;
+ if (!GetModuleHandleExA(
+ GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
+ &DLOpen,
+ &mod
+ )) {
+ THROW_ERR_DLOPEN_FAILED(env, "TODO.");
+ return false;
+ }
+
+ // TODO Might want a dynamic allocation, with the possibility to opt into long path support in the future
+ char nodeLibrary[MAX_PATH];
+ if (!GetModuleFileNameA(mod, &nodeLibrary, sizeof(nodeLibrary))) {
+ THROW_ERR_DLOPEN_FAILED(env, "TODO.");
+ return false;
+ }
+
+ std::setenv("NODE_LIBRARY", nodeLibrary);
+#endif // _WIN32
+
node::Utf8Value filename(env->isolate(), args[1]); // Cast
env->TryLoadAddon(*filename, flags, [&](DLib* dlib) {
static Mutex dlib_load_mutex;
In node-gyp:
diff --git a/src/win_delay_load_hook.cc b/src/win_delay_load_hook.cc
index 169f802..0c136ed 100644
--- a/src/win_delay_load_hook.cc
+++ b/src/win_delay_load_hook.cc
@@ -28,7 +28,7 @@ static FARPROC WINAPI load_exe_hook(unsigned int event, DelayLoadInfo* info) {
if (_stricmp(info->szDll, HOST_BINARY) != 0)
return NULL;
- m = GetModuleHandle(NULL);
+ m = GetModuleHandle(std::getenv("NODE_LIBRARY"));
return (FARPROC) m;
}
from node.
Related Issues (20)
- FixedCircularBuffer isFull(), isEmpty() and wrapping off by one HOT 4
- possible mistaken commit in v20.x branch webstreams HOT 4
- Verify env parameter when napi_get_uv_event_loop functions is called. HOT 2
- TypeError: Missing internal module 'node:crypto' HOT 14
- Disable `NODE_OPTIONS` via CLI HOT 4
- Node 20 not supporting prepack script HOT 2
- Passing `-j32` for ninja no longer works HOT 24
- Tracking issue: latest ESM Integration support
- Module Hooks cannot be registered from worker thread in 22.2.0+ HOT 16
- [REG 20.9->20.10] stream: Pipe is stopped after error on another pipe from the same source HOT 5
- Update Undici to backport a fix in Node.js 20.x HOT 1
- Not able to download nodejs for windows HOT 1
- Unhandled Error on Start HOT 3
- Support registering worker specific custom ESM loader hooks (Regression from #52706) HOT 4
- Lambdas in node 18.x (18.20.3) and problems with axios HPE_INVALID_HEADER_TOKEN HOT 2
- Xcode
- Relative `require()` in `commonjs` source not processed by ESM Loader HOT 2
- test_runner: `before` hook runs even if it's not followed by any test HOT 4
- The registration order of http server listen depends on the Node.js version HOT 2
- Ambiguous steps in `PACKAGE_IMPORTS_EXPORTS_RESOLVE` reference documentation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node.