I should call a DLL (Win x64) function from JS code.
Definitions in C:
typedef void* HNDL;
ABCD_DLL_DECL DWORD WINAPI ABCD_Create(HNDL* pHNDL);
So the HNDL is a pointer and the create function will give back an object pointer (pHNDL).
I have tried to use these in JS:
const Handle = koffi.pointer("Handle", koffi.opaque());
const ABCD_Create = lib.func("uint __stdcall ABCD_Create(_Inout_ Handle *pHandle)";
let hHandle;
let err = ABCD_Create(hHandle);
or
const ABCD_Create = lib.func("uint __stdcall ABCD_Create(_Inout_ void *phandle)";
or
const Handle = koffi.opaque();
const ABCD_Create = lib.func("ABCD_Create", "uint", [koffi.out(koffi.pointer(Handle, 2))]);
I have tried a lot of combination of these and other samples in examples from documentation of koffi, but when I call the create function I always get the "Process exited with code 3221225477" in VSCode. (The original code works perfectly in VC and Delphi...) This error number is the 0xC0000005. It means access violation. So I think somewhere the parameter passing is wrong.
How should I define it and call the create function correctly (with koffi)?