koffi 2.5.13 → 2.5.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ### Koffi 2.5
6
6
 
7
- #### Koffi 2.5.13 (2023-08-23)
7
+ #### Koffi 2.5.14 (2023-08-23)
8
8
 
9
9
  - Fix DLL error when using Koffi from NW.js on Windows
10
10
  - Simplify NW.js Koffi example
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "2.5.13",
4
- "stable": "2.5.13",
3
+ "version": "2.5.14",
4
+ "stable": "2.5.14",
5
5
  "description": "Fast and simple C FFI (foreign function interface) for Node.js",
6
6
  "keywords": [
7
7
  "foreign",
@@ -29,24 +29,41 @@
29
29
  #include <windows.h>
30
30
  #include <delayimp.h>
31
31
 
32
+ static HMODULE node_dll;
33
+ static HMODULE nw_dll;
34
+
32
35
  static FARPROC WINAPI self_exe_hook(unsigned int event, DelayLoadInfo *info)
33
36
  {
34
- static const wchar_t *const NodeLibraries[] = {
35
- L"node.dll",
36
- NULL
37
- };
38
-
39
- if (event == dliNotePreLoadLibrary && !stricmp(info->szDll, "node.exe")) {
40
- for (int i = 0; i < sizeof(NodeLibraries) / sizeof(*NodeLibraries); i++) {
41
- const wchar_t *name = NodeLibraries[i];
42
- HMODULE h = GetModuleHandleW(name);
43
-
44
- if (h)
45
- return (FARPROC)h;
37
+ if (event == dliStartProcessing) {
38
+ node_dll = GetModuleHandleA("node.dll");
39
+ nw_dll = GetModuleHandleA("nw.dll");
40
+
41
+ return NULL;
42
+ }
43
+
44
+ if (event == dliNotePreGetProcAddress) {
45
+ if (node_dll) {
46
+ FARPROC ret = GetProcAddress(node_dll, info->dlp.szProcName);
47
+ if (ret)
48
+ return ret;
49
+ }
50
+
51
+ if (nw_dll) {
52
+ FARPROC ret = GetProcAddress(nw_dll, info->dlp.szProcName);
53
+ if (ret)
54
+ return ret;
55
+ }
56
+ }
57
+
58
+ if (event == dliNotePreLoadLibrary && _stricmp(info->szDll, "node.exe") != 0) {
59
+ if (!node_dll) {
60
+ node_dll = GetModuleHandleA(NULL);
46
61
  }
62
+ return (FARPROC)node_dll;
47
63
  }
48
64
 
49
65
  return NULL;
50
66
  }
51
67
 
52
68
  const PfnDliHook __pfnDliNotifyHook2 = self_exe_hook;
69
+ const PfnDliHook __pfnDliFailureHook2 = self_exe_hook;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cnoke",
3
- "version": "3.3.2",
3
+ "version": "3.3.3",
4
4
  "description": "Build native Node addons based on CMake, without extra dependency",
5
5
  "keywords": [
6
6
  "native",
@@ -5,6 +5,6 @@
5
5
  "author": "Niels Martignène <niels.martignene@protonmail.com>",
6
6
  "license": "MIT",
7
7
  "dependencies": {
8
- "koffi": "^2.5.9"
8
+ "koffi": "^2.5.14"
9
9
  }
10
10
  }