1

I'm working on a Google Chrome Twain Plugin and actually it's is almost done. The only major problem remains: the plugin does not work under Windows XP. And this is not what is desired.

The plugin uses Chrome Native Messaging to establish communications between Chrome and separate scanning process, and TwainDotNet to interface with TWAIN.

Unfortunately, nothing can prevent TWAIN drivers from sending any text to stdout/stderr, so I was forced to use a two-stage solution: the first process of the native messaging host communicates with Chrome via stdin/stdout, and the second process communicates with the first via anonymous pipes and really does the job (i.e. process messages and interfaces with TWAIN).

Somehow the pipes of the second process become a problem to TWAIN. After some experimenting, I found that if I do not create any pipe in the second process, or if I create the pipes but do not use them - i.e. I do not read from or write to the pipes, everything goes okay. But if there was a single read or write on the pipes, any operation with TWAIN hangs like as if there was no message loop running in the thread.

Thus, I think that working with pipes, I mean performing read and write operations on the pipes, somehow breaks message loop required for TWAIN to work properly.

I am a novice to Windows message processing, so

  1. I don't have a complete understanding what's going on there in the application when I use anonymous pipes, and
  2. How using pipes can interfere with TWAIN, and
  3. Why the problem appears under Windows XP only.

The only idea I have is that anonymous pipes asynchronous IO is implemented through windows messages. So, I will appreciate info and/or suggestions that help to solve this problem.

The plugin sources can be found in my GitHub repository (solution TwainScan): https://github.com/ballamuth/Chrome4Net/tree/master/examples

bmth
  • 23
  • 2
  • I'm pretty sure that it's not answerable without relevant code, or at least more details on the algorithm of how you're establishing communication. "My code is available at [link]" is not an acceptable practice on SO. – Xan May 08 '15 at 11:28
  • Long stories really don't fit into comments: edit your question instead. – Xan May 08 '15 at 21:17
  • I agree, but the code is too big to post it here, so I'll try to make a short example demonstrating the problem. And now, the long story short: 1. If I create the TwainDotNet.Twain object, but do not create anonymous pipes (System.IO.Pipes.AnonymousPipeClientStream), everything works as expected. 2. If I create the Twain object and AnonymousPipeClientStream objects, but do not send or recieive a byte via pipes - again, everything works. 3. But if I communicate via pipes and then try to create Twain object, the process hangs as if there was no message processing loop running. – bmth May 08 '15 at 21:18
  • It would be helpful for potential answerers to have that, on multiple lines for readability, _in the question_. – Xan May 08 '15 at 21:19

0 Answers0