Skip to content

Commit

Permalink
added delayhook to fix delay-load issues
Browse files Browse the repository at this point in the history
  • Loading branch information
matt200-ok committed Jun 21, 2024
1 parent 7179b3d commit 1e1129b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions project/node/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions project/node/delayhook.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif

#include <windows.h>
#include <delayimp.h>
#include <string.h>

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;

0 comments on commit 1e1129b

Please sign in to comment.