From 98b2015b4ca5c7329202e746f55777e0814137ef Mon Sep 17 00:00:00 2001 From: matt200-ok Date: Wed, 26 Jun 2024 14:23:59 -0700 Subject: [PATCH] added delayhook to fix delay-load issues (#100) * added delayhook to fix delay-load issues * added FARPROC to dict.txt * removed nodejs support for beaglebone * switched macos-latest to pv-ios for nodejs * removed c support for beaglebone in workflows * switched mac architecture to mac-arm64 for c demo * reverting changes * added support for beaglebone back * changed Beaglebone to BeagleBone in README --- .github/workflows/c-demo.yml | 2 +- .github/workflows/nodejs-demos.yml | 4 ++-- .github/workflows/nodejs.yml | 4 ++-- project/node/CMakeLists.txt | 1 + project/node/delayhook.c | 21 +++++++++++++++++++++ resources/.lint/spell-check/dict.txt | 1 + 6 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 project/node/delayhook.c diff --git a/.github/workflows/c-demo.yml b/.github/workflows/c-demo.yml index a1751569..ea6c7d4f 100644 --- a/.github/workflows/c-demo.yml +++ b/.github/workflows/c-demo.yml @@ -33,7 +33,7 @@ jobs: - os: windows-latest pv_recorder_platform: windows - os: macos-latest - pv_recorder_platform: mac-x86_64 + pv_recorder_platform: mac-arm64 steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/nodejs-demos.yml b/.github/workflows/nodejs-demos.yml index 68a0f42a..f0eb8ca6 100644 --- a/.github/workflows/nodejs-demos.yml +++ b/.github/workflows/nodejs-demos.yml @@ -25,7 +25,7 @@ jobs: strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest] node-version: [16.x, 18.x, 20.x] steps: @@ -52,7 +52,7 @@ jobs: strategy: matrix: - machine: [rpi2, rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64, jetson, beaglebone, pv-windows] + machine: [rpi2, rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64, jetson, beaglebone, pv-windows, pv-ios] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index b357a636..8c75c441 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -27,7 +27,7 @@ jobs: strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest] node-version: [16.x, 18.x, 20.x] steps: @@ -60,7 +60,7 @@ jobs: strategy: matrix: - machine: [rpi2, rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64, jetson, beaglebone, pv-windows] + machine: [rpi2, rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64, jetson, beaglebone, pv-windows, pv-ios] steps: - uses: actions/checkout@v3 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 diff --git a/resources/.lint/spell-check/dict.txt b/resources/.lint/spell-check/dict.txt index 0f963bb3..3ad6a39a 100644 --- a/resources/.lint/spell-check/dict.txt +++ b/resources/.lint/spell-check/dict.txt @@ -13,6 +13,7 @@ dlsym DOUTPUT dylib ERRORLEVEL +FARPROC fprintf fvisibility gendef