internal OutOfProcessClientCommandTransportManager(ClientRemotePowerShell cmd, bool noInput, OutOfProcessClientSessionTransportManager sessnTM, OutOfProcessTextWriter stdInWriter) : base(cmd, sessnTM.CryptoHelper, sessnTM) { this.stdInWriter = stdInWriter; this.onDataAvailableToSendCallback = new System.Management.Automation.Remoting.PrioritySendDataCollection.OnDataAvailableCallback(this.OnDataAvailableCallback); this.signalTimeOutTimer = new Timer(60000.0); this.signalTimeOutTimer.Elapsed += new ElapsedEventHandler(this.OnSignalTimeOutTimerElapsed); }
private OutOfProcessMediator() { Console.SetIn(TextReader.Null); this.originalStdOut = new OutOfProcessTextWriter(Console.Out); Console.SetOut(TextWriter.Null); this.originalStdErr = new OutOfProcessTextWriter(Console.Error); Console.SetError(TextWriter.Null); this.callbacks = new OutOfProcessUtils.DataProcessingDelegates(); this.callbacks.DataPacketReceived = (OutOfProcessUtils.DataPacketReceived) Delegate.Combine(this.callbacks.DataPacketReceived, new OutOfProcessUtils.DataPacketReceived(this.OnDataPacketReceived)); this.callbacks.DataAckPacketReceived = (OutOfProcessUtils.DataAckPacketReceived) Delegate.Combine(this.callbacks.DataAckPacketReceived, new OutOfProcessUtils.DataAckPacketReceived(this.OnDataAckPacketReceived)); this.callbacks.CommandCreationPacketReceived = (OutOfProcessUtils.CommandCreationPacketReceived) Delegate.Combine(this.callbacks.CommandCreationPacketReceived, new OutOfProcessUtils.CommandCreationPacketReceived(this.OnCommandCreationPacketReceived)); this.callbacks.CommandCreationAckReceived = (OutOfProcessUtils.CommandCreationAckReceived) Delegate.Combine(this.callbacks.CommandCreationAckReceived, new OutOfProcessUtils.CommandCreationAckReceived(this.OnCommandCreationAckReceived)); this.callbacks.ClosePacketReceived = (OutOfProcessUtils.ClosePacketReceived) Delegate.Combine(this.callbacks.ClosePacketReceived, new OutOfProcessUtils.ClosePacketReceived(this.OnClosePacketReceived)); this.callbacks.CloseAckPacketReceived = (OutOfProcessUtils.CloseAckPacketReceived) Delegate.Combine(this.callbacks.CloseAckPacketReceived, new OutOfProcessUtils.CloseAckPacketReceived(this.OnCloseAckPacketReceived)); this.callbacks.SignalPacketReceived = (OutOfProcessUtils.SignalPacketReceived) Delegate.Combine(this.callbacks.SignalPacketReceived, new OutOfProcessUtils.SignalPacketReceived(this.OnSignalPacketReceived)); this.callbacks.SignalAckPacketReceived = (OutOfProcessUtils.SignalAckPacketReceived) Delegate.Combine(this.callbacks.SignalAckPacketReceived, new OutOfProcessUtils.SignalAckPacketReceived(this.OnSignalAckPacketReceived)); this.allcmdsClosedEvent = new ManualResetEvent(true); }
internal override void CreateAsync() { if (this.connectionInfo != null) { this._processInstance = this.connectionInfo.Process ?? new PowerShellProcessInstance(this.connectionInfo.PSVersion, this.connectionInfo.Credential, this.connectionInfo.InitializationScript, this.connectionInfo.RunAs32); if (this.connectionInfo.Process != null) { this._processCreated = false; } } PSEtwLog.LogAnalyticInformational(PSEventId.WSManCreateShell, PSOpcode.Connect, PSTask.CreateRunspace, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic, new object[] { base.RunspacePoolInstanceId.ToString() }); try { lock (base.syncObject) { if (base.isClosed) { return; } this.serverProcess = this._processInstance.Process; if (this._processInstance.RunspacePool != null) { this._processInstance.RunspacePool.Close(); this._processInstance.RunspacePool.Dispose(); } this.stdInWriter = this._processInstance.StdInWriter; this.serverProcess.OutputDataReceived += new DataReceivedEventHandler(this.OnOutputDataReceived); this.serverProcess.ErrorDataReceived += new DataReceivedEventHandler(this.OnErrorDataReceived); this.serverProcess.Exited += new EventHandler(this.OnExited); this._processInstance.Start(); if (this.stdInWriter != null) { this.serverProcess.CancelErrorRead(); this.serverProcess.CancelOutputRead(); } this.serverProcess.BeginOutputReadLine(); this.serverProcess.BeginErrorReadLine(); this.stdInWriter = new OutOfProcessTextWriter(this.serverProcess.StandardInput); this._processInstance.StdInWriter = this.stdInWriter; } } catch (Win32Exception exception) { PSRemotingTransportException e = new PSRemotingTransportException(exception, RemotingErrorIdStrings.IPCExceptionLaunchingProcess, new object[] { exception.Message }) { ErrorCode = exception.ErrorCode }; TransportErrorOccuredEventArgs eventArgs = new TransportErrorOccuredEventArgs(e, TransportMethodEnum.CreateShellEx); this.RaiseErrorHandler(eventArgs); return; } catch (Exception exception3) { CommandProcessorBase.CheckForSevereException(exception3); PSRemotingTransportException exception4 = new PSRemotingTransportException(PSRemotingErrorId.IPCExceptionLaunchingProcess, RemotingErrorIdStrings.IPCExceptionLaunchingProcess, new object[] { exception3.Message }); TransportErrorOccuredEventArgs args2 = new TransportErrorOccuredEventArgs(exception4, TransportMethodEnum.CreateShellEx); this.RaiseErrorHandler(args2); return; } this.SendOneItem(); }
internal OutOfProcessServerTransportManager(OutOfProcessTextWriter stdOutWriter, Guid powershellInstanceId, TypeTable typeTableToUse, int fragmentSize, PSRemotingCryptoHelper cryptoHelper) : base(fragmentSize, cryptoHelper) { this.stdOutWriter = stdOutWriter; this.powershellInstanceId = powershellInstanceId; base.TypeTable = typeTableToUse; }
internal OutOfProcessServerSessionTransportManager(OutOfProcessTextWriter outWriter) : base(0x8000, new PSRemotingCryptoHelperServer()) { this.syncObject = new object(); this.stdOutWriter = outWriter; this.cmdTransportManagers = new Dictionary<Guid, OutOfProcessServerTransportManager>(); }