I need to execute the LogonUserA function from Advapi32.dll ( https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-logonusera ) using ffi on NodeJS.

Library loading and initialization function:

var ffi = require('ffi'); var ref = require('ref'); var Advapi32 = new ffi.Library ('Advapi32', { LogonUserA: ['bool', ['string', 'string', 'string', 'ulong', 'ulong', 'pointer']] }); module.exports = { Advapi32: Advapi32 }; 

Well, actually call

 const platform = require('./lib/win32.js'); let logon = platform.Advapi32.LogonUserA('name', 'domain', 'test123', 0, 0, НЕЧТО_ТИПА_PHANDLE) 

So, the actual question itself, I had not previously encountered the tasks of using ffi and did not directly knock a node from a cn library function from a node, and absolutely can not figure out how to correctly set the last, fifth argument. As an example from Microsoft Doks, this should be a pointer to the "& hToken" descriptor variable. I can not understand how to get a satisfying variable in nodeJs? I tried differently, used ref types, but the result can be either none (the process is simply interrupted) or give an error:

 error setting argument 5 - writePointer: Buffer instance expected as third argument 

    1 answer 1

    Understood himself. The last argument was to be a buffer.