node-ffi

using a dll with node-ffi

时光总嘲笑我的痴心妄想 提交于 2021-02-10 07:07:55
问题 I'm using node-ffi to access a dll supplied by a custom hardware i bought, the dll uses device driver to do things, they don't supply dll docs but they have a sample app in c#, the dll is used in c# like this: [DllImport("POS_CIDR.dll", CharSet = CharSet.Unicode)] private static extern IntPtr CIDR_Info(); ... result = Marshal.PtrToStringUni(CIDR.CIDR_Info()); ... now i try to access CIDR_Info function of dll with following node code: var ffi = require('ffi') var ref = require('ref') var int =

using a dll with node-ffi

对着背影说爱祢 提交于 2021-02-10 07:07:27
问题 I'm using node-ffi to access a dll supplied by a custom hardware i bought, the dll uses device driver to do things, they don't supply dll docs but they have a sample app in c#, the dll is used in c# like this: [DllImport("POS_CIDR.dll", CharSet = CharSet.Unicode)] private static extern IntPtr CIDR_Info(); ... result = Marshal.PtrToStringUni(CIDR.CIDR_Info()); ... now i try to access CIDR_Info function of dll with following node code: var ffi = require('ffi') var ref = require('ref') var int =

using a dll with node-ffi

最后都变了- 提交于 2021-02-10 07:07:09
问题 I'm using node-ffi to access a dll supplied by a custom hardware i bought, the dll uses device driver to do things, they don't supply dll docs but they have a sample app in c#, the dll is used in c# like this: [DllImport("POS_CIDR.dll", CharSet = CharSet.Unicode)] private static extern IntPtr CIDR_Info(); ... result = Marshal.PtrToStringUni(CIDR.CIDR_Info()); ... now i try to access CIDR_Info function of dll with following node code: var ffi = require('ffi') var ref = require('ref') var int =

C parser in Javascript

孤街醉人 提交于 2021-02-07 02:47:22
问题 I'd like to parse C header files in Javascript. Is there any such library available? Otherwise, any tips to help me get started? Update: My ultimate goal is to automatically build interfaces for node-ffi. The parser doesn't necessarily have to be in Javascript as long as it can spit out a format understandable by Javascript. If it's very hard to develop by myself, I'll probably have to go with an off the shelf solution...? 回答1: You should check out clang. For a simple command-line invocation,

C parser in Javascript

允我心安 提交于 2021-02-07 02:47:17
问题 I'd like to parse C header files in Javascript. Is there any such library available? Otherwise, any tips to help me get started? Update: My ultimate goal is to automatically build interfaces for node-ffi. The parser doesn't necessarily have to be in Javascript as long as it can spit out a format understandable by Javascript. If it's very hard to develop by myself, I'll probably have to go with an off the shelf solution...? 回答1: You should check out clang. For a simple command-line invocation,

How can I take a window screenshot in Node.js?

只愿长相守 提交于 2020-04-08 09:49:06
问题 I'm in a research to find a way to take a screenshot of a window using Node.js, and I'm trying to do this with node-ffi, but I don't know how... at a time I'm stuck here: var ffi = require('ffi'); var user32 = new ffi.Library("user32", { FindWindowA: [ 'uint32' , [ 'string', 'string' ]] , PrintWindow: [ 'int32' , [ 'int32', 'string', 'int32' ]] }); var IMG; var windowHandle = user32.FindWindowA(null, "Calculator"); var printWin = user32.PrintWindow(windowHandle, IMG, 0); console.log(printWin)

How to copy raw memory to Buffer in nodejs?

蓝咒 提交于 2020-03-14 19:01:12
问题 I use node and node-ffi . I get a callback from native/C that passes a (void *,size_t) to indicate a memory region with interesting data. I'd like to take that and create Buffer with the same contents. Basically: function callback_on_write(ptr, size) { var buffer = new Buffer(size); buffer.somehow_copy_from_memory(ptr, size); } How do I copy raw memory to Buffer ? 回答1: Use ref.reinterpret(buffer, size, offset). Returns a new Buffer instance with the specified size , with the same memory

How to copy raw memory to Buffer in nodejs?

回眸只為那壹抹淺笑 提交于 2020-03-14 19:01:11
问题 I use node and node-ffi . I get a callback from native/C that passes a (void *,size_t) to indicate a memory region with interesting data. I'd like to take that and create Buffer with the same contents. Basically: function callback_on_write(ptr, size) { var buffer = new Buffer(size); buffer.somehow_copy_from_memory(ptr, size); } How do I copy raw memory to Buffer ? 回答1: Use ref.reinterpret(buffer, size, offset). Returns a new Buffer instance with the specified size , with the same memory

Setting focus to a Windows application from Node-JS

蹲街弑〆低调 提交于 2020-02-26 09:22:24
问题 I have a NodeJS application running on Windows that needs to display and switch the focus to a running Windows application when a user does a certain action. I have been using the node-ffi package to make windows API calls but have not been able to make it switch focus consistently. Here is the code I am using. It successfully gets the HWND of a running Calculator app, but then tries to switch focus to that HWND and it only works sometimes: var ffi = require('ffi'); var intPtr = ref.refType(

Node ffi pointer to struct

荒凉一梦 提交于 2019-12-24 18:59:04
问题 FIrst of all, I'm asking here because there's neither a fast answer to usage of pointers in node ffi neither about pointers to structs, this is going to help Here's my node ffi: const struct_in_addr = Struct({ 's_addr': 'ulong', }); const struct_sockaddr_in = Struct({ 'sin_family': 'short', 'sin_port' : 'ushort', 'in_addr' : struct_in_addr, 'sin_zero' : 'char', }); var redir = ffi.Library('./libredir', { //'main' : [ 'int' , [ 'int', 'char* []' ] ], //'parse_args' : [ 'void', [ 'int', 'char*