Exemplo n.º 1
0
        public string Execute(string command)
        {
            //create a new debug control and assign the new ouput handler
            IntPtr outputCallbacks;
            IntPtr PreviousCallbacks;
            //IDebugClient executionClient;
            //int hr = this.DebugClient.CreateClient(out executionClient);
            //var newDebugger = new Debugger(executionClient);
            string output = null;

            //if (FAILED(hr))
            //{
            //    this.OutputVerboseLine("SimpleOutputHandler.Install Failed creating a new debug client for execution: {0:x8}", hr);
            //    outputCallbacks = IntPtr.Zero;

            //    return null;
            //}

            //save previous callbacks
            OutputDebugInfo("executing command {0} \n", command);
            PreviousCallbacks = SavePreviousCallbacks();

            int InstallationHRESULT = InitialiezOutputHandler();

            if (FAILED(InstallationHRESULT))
            {
                this.OutputVerboseLine("Failed installing a new outputcallbacks client for execution");
                outputCallbacks = IntPtr.Zero;
                return(null);
            }
            //set the previous callback handler
            var hrExecution = this.DebugControl.Execute(DEBUG_OUTCTL.THIS_CLIENT, command, DEBUG_EXECUTE.DEFAULT | DEBUG_EXECUTE.NO_REPEAT);

            if (FAILED(hrExecution))
            {
                this.OutputVerboseLine("Failed creating a new debug client for execution:");
                outputCallbacks = IntPtr.Zero;
                return(null);
            }

            //revert previous callbacks
            InstallationHRESULT = RevertCallBacks(PreviousCallbacks);
            //getting the output from the buffer.
            output = OutHandler.ToString();
            OutputDebugInfo("command output:\n" + output);
            OutHandler.stbOutPut.Length = 0;
            //releaseing the COM object.
            //Marshal.ReleaseComObject(outHandler);
            return(output);
        }
Exemplo n.º 2
0
        public Process DoTask(string cmd, OutHandler oh)
        {
            Process ps = null;

            try
            {
                ps = this.ExecCmd();
                ps.OutputDataReceived += new DataReceivedEventHandler(oh);

                ps.Start();

                ps.StandardInput.WriteLine(cmd + "&exit");
                ps.StandardInput.AutoFlush = true;

                ps.BeginOutputReadLine();
            }
            catch
            {
                throw;
            }

            return(ps);
        }
Exemplo n.º 3
0
            public TcpStreamLogic(FlowShape <ByteString, ByteString> shape, ITcpRole role, EndPoint remoteAddress) : base(shape)
            {
                _role          = role;
                _remoteAddress = remoteAddress;
                _bytesIn       = shape.Inlet;
                _bytesOut      = shape.Outlet;

                _readHandler = new LambdaOutHandler(
                    onPull: () => _connection.Tell(Tcp.ResumeReading.Instance, StageActorRef),
                    onDownstreamFinish: () =>
                {
                    if (!IsClosed(_bytesIn))
                    {
                        _connection.Tell(Tcp.ResumeReading.Instance, StageActorRef);
                    }
                    else
                    {
                        _connection.Tell(Tcp.Abort.Instance, StageActorRef);
                        CompleteStage();
                    }
                });

                // No reading until role have been decided
                SetHandler(_bytesOut, onPull: DoNothing);
                SetHandler(_bytesIn,
                           onPush: () =>
                {
                    var elem = Grab(_bytesIn);
                    ReactiveStreamsCompliance.RequireNonNullElement(elem);
                    _connection.Tell(Tcp.Write.Create(elem, WriteAck.Instance), StageActorRef);
                },
                           onUpstreamFinish: () =>
                {
                    // Reading has stopped before, either because of cancel, or PeerClosed, so just Close now
                    // (or half-close is turned off)
                    if (IsClosed(_bytesOut) || !_role.HalfClose)
                    {
                        _connection.Tell(Tcp.Close.Instance, StageActorRef);
                    }
                    // We still read, so we only close the write side
                    else if (_connection != null)
                    {
                        _connection.Tell(Tcp.ConfirmedClose.Instance, StageActorRef);
                    }
                    else
                    {
                        CompleteStage();
                    }
                },
                           onUpstreamFailure: ex =>
                {
                    if (_connection != null)
                    {
                        if (Interpreter.Log.IsDebugEnabled)
                        {
                            Interpreter.Log.Debug(
                                $"Aborting tcp connection to {_remoteAddress} because of upstream failure: {ex.Message}\n{ex.StackTrace}");
                        }
                        _connection.Tell(Tcp.Abort.Instance, StageActorRef);
                    }
                    else
                    {
                        FailStage(ex);
                    }
                });
            }
Exemplo n.º 4
0
 public void CloseException(OutHandler phandler)
 {
     outhandler = phandler;
 }