#pragma pack(1)
struct EnvInfo
{
DWORD dwSize;
WCHAR wszAppId[128];
ULONGLONG u64Qid;
};
extern "C" int __stdcall SDK360_Init(const EnvInfo* pEnvInfo);
this c++ code
const envInfo = koffi.pack('envInfo', {
dwSize: 'uint32',
wszAppId: koffi.array('char16', 128),
u64Qid: 'uint64'
});
const arr = 'xtI7nxn';
const utf16Buffer = new Uint16Array(128);
arr.forEach((char, index) => {
utf16Buffer[index] = char.charCodeAt(0);
});
envInfo.dwSize = koffi.sizeof(envInfo);
envInfo.wszAppId = utf16Buffer;
envInfo.u64Qid = 3269309681;
const sdk360 = koffi.load(dynamicLib);
const SDK360_Init = sdk360.func('SDK360_Init', 'int', [koffi.pointer(envInfo)]);
const result = SDK360_Init(envInfo);
I tried to do this, but I get an error, I don’t know what’s wrong.
TypeError: Unexpected Type value, expected envInfo *
New contributor
jianjun wang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1