Exemple #1
0
        public Scan(Program.Options options)
        {
            log.Debug("creating scan host");

            log.DebugFormat("create interprocess input pipe (handle={0})", options.pipeIn);
            pipeIn = new AnonymousPipeClientStream(PipeDirection.In, options.pipeIn);

            log.DebugFormat("create interprocess output pipe (handle={0})", options.pipeOut);
            pipeOut = new AnonymousPipeClientStream(PipeDirection.Out, options.pipeOut);

            log.Debug("create sync event");
            sync = new ManualResetEvent(false);

            log.Debug("create native messaging port");
            port = new Port(pipeIn, pipeOut);

            log.Debug("create stop event");
            stop = new ManualResetEvent(false);

            log.Debug("create form");
            form         = new Form();
            form.TopMost = true;
            form.BringToFront();

            log.Debug("create hook");
            hook = new WinFormsWindowMessageHook(form);

            log.Debug("create image acquired and image transferred events");
            imageAcquired    = new ManualResetEvent(false);
            imageTransferred = new ManualResetEvent(false);

            log.Debug("scan host created");
        }
Exemple #2
0
        public Relay(Program.Options options)
        {
            log.Debug("creating relay host");

            log.Debug("create interprocess input pipe");
            pipeIn = new AnonymousPipeServerStream(PipeDirection.In, HandleInheritability.Inheritable);

            log.Debug("create interprocess output pipe");
            pipeOut = new AnonymousPipeServerStream(PipeDirection.Out, HandleInheritability.Inheritable);

            log.Debug("create sync event");
            sync = new ManualResetEvent(false);

            log.Debug("create processor host");
            processor = new Process();
            processor.StartInfo.FileName = System.Reflection.Assembly.GetExecutingAssembly().Location;
            log.DebugFormat("StartInfo.FileName={0}", processor.StartInfo.FileName);
            processor.StartInfo.Arguments = String.Format("--pipe-in={0} --pipe-out={1} process", pipeOut.GetClientHandleAsString(), pipeIn.GetClientHandleAsString());
            log.DebugFormat("StartInfo.Arguments={0}", processor.StartInfo.Arguments);
            processor.StartInfo.UseShellExecute = false;
            //// processor.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;  ???? do we really need this ????

            log.Debug("start processor host");
            try
            {
                processor.Start();
            }
            catch (Exception ex)
            {
                log.Fatal("Exception while starting processor host.", ex);
                throw ex;
            }
            log.DebugFormat("processor host process id : {0}", processor.Id);

            log.Debug("join processes into a job so processor host dies together with relay host");
            job = new Job();
            job.AddProcess(Process.GetCurrentProcess().Id);
            job.AddProcess(processor.Id);

            log.Debug("create native messaging ports");
            portA           = new Port();
            portB           = new Port(pipeIn, pipeOut);
            portsExceptions = new List <Exception>();

            log.Debug("create stop event");
            stop = new ManualResetEvent(false);

            log.Debug("relay host created");
        }