diff --git a/project/node/CMakeLists.txt b/project/node/CMakeLists.txt index 4def122d..9e405984 100644 --- a/project/node/CMakeLists.txt +++ b/project/node/CMakeLists.txt @@ -38,6 +38,7 @@ add_dependencies(pv_recorder_napi node_headers) if (${PV_RECORDER_PLATFORM} STREQUAL "windows") add_dependencies(pv_recorder_napi node_win_lib) + target_sources(pv_recorder_napi PRIVATE delayhook.c) endif() target_include_directories(pv_recorder_napi PUBLIC ${PROJECT_SOURCE_DIR}/../include) diff --git a/project/node/delayhook.c b/project/node/delayhook.c new file mode 100644 index 00000000..0c26fe28 --- /dev/null +++ b/project/node/delayhook.c @@ -0,0 +1,21 @@ +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif + +#include +#include +#include + +static FARPROC WINAPI delayHook(unsigned int dliNotify, DelayLoadInfo* dli) { + HMODULE m; + if (dliNotify != dliNotePreLoadLibrary) + return NULL; + + if (_stricmp(dli->szDll, "node.exe") != 0) + return NULL; + + m = GetModuleHandle(NULL); + return (FARPROC) m; +} + +PfnDliHook __pfnDliNotifyHook2 = delayHook; \ No newline at end of file