Search code examples
node.jsvisual-c++ocxnw.jsnode-ffi

Strange event behavior in Node.js and C++ DLL integration through node-ffi




I'm working on a NW.JS-based application that uses a document scanner. Since the API for that scanner is packed in a OCX component, I had to build a wrapper DLL in C++ and call this wrapper through the node-ffi module.
The scanner API is event-based, so it fires events for almost everything. From hardware initialization to image generation when processing documents.
The issue I'm facing is when the scanner notifies my wrapper layer about the images from the document being scanned. The API fires the event twice, one for the front image and another for the rear image. When testing the wrapper DLL using a console application, everything works fine and I can get the two images from the document. If I call the DLL from node-ffi (through my NW.JS application) the behavior is almost the same, except that I get only the front image from the document.
I analyzed the behavior of the two applications using WinDbg and I could notice that everything seems to be the same between the two tests. The only difference is that the event for image generation is being fired only once when testing from the NW.JS application.

It's very strange and I'm running out of ideas about what to investigate. Does anyone here have faced this kind of issue?
Any ideas and hints are welcome.

Thanks!


Solution

  • After having a hard time hitting my head on the table I discovered that the problem was caused by a typo in a configuration file.