koffi 2.3.7 → 2.3.8
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 +8 -0
- package/package.json +2 -2
- package/src/koffi/build/2.3.8/koffi_darwin_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.8/koffi_darwin_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.8/koffi_freebsd_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.8/koffi_freebsd_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.8/koffi_freebsd_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.8/koffi_linux_arm32hf/koffi.node +0 -0
- package/src/koffi/build/2.3.8/koffi_linux_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.8/koffi_linux_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.8/koffi_linux_riscv64hf64/koffi.node +0 -0
- package/src/koffi/build/2.3.8/koffi_linux_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.8/koffi_openbsd_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.8/koffi_openbsd_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.8/koffi_win32_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.8/koffi_win32_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.8/koffi_win32_x64/koffi.node +0 -0
- package/src/koffi/src/abi_arm64.cc +8 -2
- package/src/koffi/src/abi_x64_win.cc +8 -2
- package/src/koffi/src/abi_x86.cc +8 -2
- package/src/koffi/src/ffi.cc +5 -24
- package/src/koffi/src/index.d.ts +3 -3
- package/src/koffi/src/win32.hh +10 -4
- package/src/koffi/build/2.3.7/koffi_darwin_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_darwin_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_freebsd_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_freebsd_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_freebsd_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_linux_arm32hf/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_linux_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_linux_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_linux_riscv64hf64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_linux_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_openbsd_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_openbsd_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_win32_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_win32_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_win32_x64/koffi.node +0 -0
- /package/src/koffi/build/{2.3.7 → 2.3.8}/koffi_win32_arm64/koffi.exp +0 -0
- /package/src/koffi/build/{2.3.7 → 2.3.8}/koffi_win32_arm64/koffi.lib +0 -0
- /package/src/koffi/build/{2.3.7 → 2.3.8}/koffi_win32_ia32/koffi.exp +0 -0
- /package/src/koffi/build/{2.3.7 → 2.3.8}/koffi_win32_ia32/koffi.lib +0 -0
- /package/src/koffi/build/{2.3.7 → 2.3.8}/koffi_win32_x64/koffi.exp +0 -0
- /package/src/koffi/build/{2.3.7 → 2.3.8}/koffi_win32_x64/koffi.lib +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
### Koffi 2.3
|
|
6
6
|
|
|
7
|
+
#### Koffi 2.3.8
|
|
8
|
+
|
|
9
|
+
**Main fixes:**
|
|
10
|
+
|
|
11
|
+
- Disable non-ready union support
|
|
12
|
+
- Simplify Windows stack allocation and drop NOACCESS and GUARD pages
|
|
13
|
+
- Adjust Windows TEB SEH chain and GuaranteedStackBytes for Koffi calls
|
|
14
|
+
|
|
7
15
|
#### Koffi 2.3.7
|
|
8
16
|
|
|
9
17
|
**Main fixes:**
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -559,18 +559,24 @@ void CallData::Execute(const FunctionInfo *func)
|
|
|
559
559
|
TEB *teb = GetTEB();
|
|
560
560
|
|
|
561
561
|
// Restore previous stack limits at the end
|
|
562
|
-
RG_DEFER_C(
|
|
562
|
+
RG_DEFER_C(exception_list = teb->ExceptionList,
|
|
563
|
+
base = teb->StackBase,
|
|
563
564
|
limit = teb->StackLimit,
|
|
564
|
-
dealloc = teb->DeallocationStack
|
|
565
|
+
dealloc = teb->DeallocationStack,
|
|
566
|
+
guaranteed = teb->GuaranteedStackBytes) {
|
|
567
|
+
teb->ExceptionList = exception_list;
|
|
565
568
|
teb->StackBase = base;
|
|
566
569
|
teb->StackLimit = limit;
|
|
567
570
|
teb->DeallocationStack = dealloc;
|
|
571
|
+
teb->GuaranteedStackBytes = guaranteed;
|
|
568
572
|
};
|
|
569
573
|
|
|
570
574
|
// Adjust stack limits so SEH works correctly
|
|
575
|
+
teb->ExceptionList = (void *)-1; // EXCEPTION_CHAIN_END
|
|
571
576
|
teb->StackBase = mem->stack0.end();
|
|
572
577
|
teb->StackLimit = mem->stack0.ptr;
|
|
573
578
|
teb->DeallocationStack = mem->stack0.ptr;
|
|
579
|
+
teb->GuaranteedStackBytes = 0;
|
|
574
580
|
#endif
|
|
575
581
|
|
|
576
582
|
#define PERFORM_CALL(Suffix) \
|
|
@@ -221,18 +221,24 @@ void CallData::Execute(const FunctionInfo *func)
|
|
|
221
221
|
TEB *teb = GetTEB();
|
|
222
222
|
|
|
223
223
|
// Restore previous stack limits at the end
|
|
224
|
-
RG_DEFER_C(
|
|
224
|
+
RG_DEFER_C(exception_list = teb->ExceptionList,
|
|
225
|
+
base = teb->StackBase,
|
|
225
226
|
limit = teb->StackLimit,
|
|
226
|
-
dealloc = teb->DeallocationStack
|
|
227
|
+
dealloc = teb->DeallocationStack,
|
|
228
|
+
guaranteed = teb->GuaranteedStackBytes) {
|
|
229
|
+
teb->ExceptionList = exception_list;
|
|
227
230
|
teb->StackBase = base;
|
|
228
231
|
teb->StackLimit = limit;
|
|
229
232
|
teb->DeallocationStack = dealloc;
|
|
233
|
+
teb->GuaranteedStackBytes = guaranteed;
|
|
230
234
|
};
|
|
231
235
|
|
|
232
236
|
// Adjust stack limits so SEH works correctly
|
|
237
|
+
teb->ExceptionList = (void *)-1; // EXCEPTION_CHAIN_END
|
|
233
238
|
teb->StackBase = mem->stack0.end();
|
|
234
239
|
teb->StackLimit = mem->stack0.ptr;
|
|
235
240
|
teb->DeallocationStack = mem->stack0.ptr;
|
|
241
|
+
teb->GuaranteedStackBytes = 0;
|
|
236
242
|
|
|
237
243
|
#define PERFORM_CALL(Suffix) \
|
|
238
244
|
([&]() { \
|
package/src/koffi/src/abi_x86.cc
CHANGED
|
@@ -306,18 +306,24 @@ void CallData::Execute(const FunctionInfo *func)
|
|
|
306
306
|
TEB *teb = GetTEB();
|
|
307
307
|
|
|
308
308
|
// Restore previous stack limits at the end
|
|
309
|
-
RG_DEFER_C(
|
|
309
|
+
RG_DEFER_C(exception_list = teb->ExceptionList,
|
|
310
|
+
base = teb->StackBase,
|
|
310
311
|
limit = teb->StackLimit,
|
|
311
|
-
dealloc = teb->DeallocationStack
|
|
312
|
+
dealloc = teb->DeallocationStack,
|
|
313
|
+
guaranteed = teb->GuaranteedStackBytes) {
|
|
314
|
+
teb->ExceptionList = exception_list;
|
|
312
315
|
teb->StackBase = base;
|
|
313
316
|
teb->StackLimit = limit;
|
|
314
317
|
teb->DeallocationStack = dealloc;
|
|
318
|
+
teb->GuaranteedStackBytes = guaranteed;
|
|
315
319
|
};
|
|
316
320
|
|
|
317
321
|
// Adjust stack limits so SEH works correctly
|
|
322
|
+
teb->ExceptionList = (void *)-1; // EXCEPTION_CHAIN_END
|
|
318
323
|
teb->StackBase = mem->stack0.end();
|
|
319
324
|
teb->StackLimit = mem->stack0.ptr;
|
|
320
325
|
teb->DeallocationStack = mem->stack0.ptr;
|
|
326
|
+
teb->GuaranteedStackBytes = 0;
|
|
321
327
|
#endif
|
|
322
328
|
|
|
323
329
|
#define PERFORM_CALL(Suffix) \
|
package/src/koffi/src/ffi.cc
CHANGED
|
@@ -1144,30 +1144,11 @@ static InstanceMemory *AllocateMemory(InstanceData *instance, Size stack_size, S
|
|
|
1144
1144
|
stack_size = AlignLen(stack_size, Kibibytes(64));
|
|
1145
1145
|
|
|
1146
1146
|
#if defined(_WIN32)
|
|
1147
|
-
static const int PageSize = ([]() {
|
|
1148
|
-
SYSTEM_INFO info = {};
|
|
1149
|
-
|
|
1150
|
-
GetNativeSystemInfo(&info);
|
|
1151
|
-
RG_ASSERT(info.dwPageSize);
|
|
1152
|
-
|
|
1153
|
-
return (int)info.dwPageSize;
|
|
1154
|
-
})();
|
|
1155
|
-
|
|
1156
1147
|
// Allocate stack memory
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
mem->stack.ptr = (uint8_t *)VirtualAlloc(nullptr, mem->stack.len + 2 * PageSize, MEM_RESERVE, PAGE_NOACCESS);
|
|
1160
|
-
|
|
1161
|
-
RG_CRITICAL(mem->stack.ptr, "Failed to allocate %1 of memory", mem->stack.len);
|
|
1162
|
-
|
|
1163
|
-
bool success = true;
|
|
1164
|
-
|
|
1165
|
-
success &= !!VirtualAlloc(mem->stack.ptr + 0 * PageSize, PageSize, MEM_COMMIT, PAGE_NOACCESS);
|
|
1166
|
-
success &= !!VirtualAlloc(mem->stack.ptr + 1 * PageSize, PageSize, MEM_COMMIT, PAGE_READWRITE | PAGE_GUARD);
|
|
1167
|
-
success &= !!VirtualAlloc(mem->stack.ptr + 2 * PageSize, mem->stack.len, MEM_COMMIT, PAGE_READWRITE);
|
|
1148
|
+
mem->stack.len = stack_size;
|
|
1149
|
+
mem->stack.ptr = (uint8_t *)VirtualAlloc(nullptr, mem->stack.len, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
|
|
1168
1150
|
|
|
1169
|
-
|
|
1170
|
-
}
|
|
1151
|
+
RG_CRITICAL(mem->stack.ptr, "Failed to allocate %1 of memory", mem->stack.len);
|
|
1171
1152
|
#else
|
|
1172
1153
|
mem->stack.len = stack_size;
|
|
1173
1154
|
mem->stack.ptr = (uint8_t *)mmap(nullptr, mem->stack.len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_STACK, -1, 0);
|
|
@@ -2021,8 +2002,8 @@ static void SetExports(Napi::Env env, Func func)
|
|
|
2021
2002
|
|
|
2022
2003
|
func("struct", Napi::Function::New(env, CreatePaddedStructType));
|
|
2023
2004
|
func("pack", Napi::Function::New(env, CreatePackedStructType));
|
|
2024
|
-
func("union", Napi::Function::New(env, CreateUnionType));
|
|
2025
|
-
func("Union", Napi::Function::New(env, InstantiateUnion));
|
|
2005
|
+
// func("union", Napi::Function::New(env, CreateUnionType));
|
|
2006
|
+
// func("Union", Napi::Function::New(env, InstantiateUnion));
|
|
2026
2007
|
func("opaque", Napi::Function::New(env, CreateOpaqueType));
|
|
2027
2008
|
func("pointer", Napi::Function::New(env, CreatePointerType));
|
|
2028
2009
|
func("array", Napi::Function::New(env, CreateArrayType));
|
package/src/koffi/src/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ declare module 'koffi' {
|
|
|
20
20
|
|
|
21
21
|
type PrimitiveKind = 'Void' | 'Bool' | 'Int8' | 'UInt8' | 'Int16' | 'Int16S' | 'UInt16' | 'UInt16S' |
|
|
22
22
|
'Int32' | 'Int32S' | 'UInt32' | 'UInt32S' | 'Int64' | 'Int64S' | 'UInt64' | 'UInt64S' |
|
|
23
|
-
'String' | 'String16' | 'Pointer' | 'Record' | 'Union' | 'Array' | 'Float32' | 'Float64' |
|
|
23
|
+
'String' | 'String16' | 'Pointer' | 'Record' /* | 'Union' */ | 'Array' | 'Float32' | 'Float64' |
|
|
24
24
|
'Prototype' | 'Callback';
|
|
25
25
|
type ArrayHint = 'Array' | 'Typed' | 'String';
|
|
26
26
|
|
|
@@ -78,8 +78,8 @@ declare module 'koffi' {
|
|
|
78
78
|
export function pack(name: string, def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
|
|
79
79
|
export function pack(def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
|
|
80
80
|
|
|
81
|
-
export function union(name: string, def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
|
|
82
|
-
export function union(def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
|
|
81
|
+
// export function union(name: string, def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
|
|
82
|
+
// export function union(def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
|
|
83
83
|
|
|
84
84
|
export function array(ref: TypeSpec, len: number, hint?: ArrayHint | null): IKoffiCType;
|
|
85
85
|
|
package/src/koffi/src/win32.hh
CHANGED
|
@@ -22,24 +22,30 @@ namespace RG {
|
|
|
22
22
|
#if _WIN64
|
|
23
23
|
|
|
24
24
|
struct TEB {
|
|
25
|
-
|
|
25
|
+
void *ExceptionList;
|
|
26
26
|
void *StackBase;
|
|
27
27
|
void *StackLimit;
|
|
28
|
-
char
|
|
28
|
+
char _pad1[5216];
|
|
29
29
|
void *DeallocationStack;
|
|
30
|
+
char _pad2[712];
|
|
31
|
+
uint32_t GuaranteedStackBytes;
|
|
30
32
|
};
|
|
31
33
|
RG_STATIC_ASSERT(RG_OFFSET_OF(TEB, DeallocationStack) == 0x1478);
|
|
34
|
+
RG_STATIC_ASSERT(RG_OFFSET_OF(TEB, GuaranteedStackBytes) == 0x1748);
|
|
32
35
|
|
|
33
36
|
#else
|
|
34
37
|
|
|
35
38
|
struct TEB {
|
|
36
|
-
|
|
39
|
+
void *ExceptionList;
|
|
37
40
|
void *StackBase;
|
|
38
41
|
void *StackLimit;
|
|
39
|
-
char
|
|
42
|
+
char _pad1[3584];
|
|
40
43
|
void *DeallocationStack;
|
|
44
|
+
char _pad2[360];
|
|
45
|
+
uint32_t GuaranteedStackBytes;
|
|
41
46
|
};
|
|
42
47
|
RG_STATIC_ASSERT(RG_OFFSET_OF(TEB, DeallocationStack) == 0xE0C);
|
|
48
|
+
RG_STATIC_ASSERT(RG_OFFSET_OF(TEB, GuaranteedStackBytes) == 0x0F78);
|
|
43
49
|
|
|
44
50
|
#endif
|
|
45
51
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|