Example #1
0
        private void SendData(byte[] data, DataPriorityType priorityType)
        {
            BaseClientTransportManager.tracer.WriteLine("Command sending data of size : {0}", new object[] { data.Length });
            byte[] buffer = data;
            bool   flag   = true;

            if (commandSendRedirect != null)
            {
                object[] objArray3 = new object[2];
                objArray3[1] = buffer;
                object[] args = objArray3;
                flag   = (bool)commandSendRedirect.DynamicInvoke(args);
                buffer = (byte[])args[0];
            }
            if (flag)
            {
                using (WSManNativeApi.WSManData data2 = new WSManNativeApi.WSManData(buffer))
                {
                    PSEtwLog.LogAnalyticInformational(PSEventId.WSManSendShellInputEx, PSOpcode.Send, PSTask.None, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic, new object[] { base.RunspacePoolInstanceId.ToString(), this.powershellInstanceId.ToString(), data2.BufferLength.ToString(CultureInfo.InvariantCulture) });
                    lock (base.syncObject)
                    {
                        if (base.isClosed)
                        {
                            BaseClientTransportManager.tracer.WriteLine("Client Session TM: Transport manager is closed. So returning", new object[0]);
                        }
                        else
                        {
                            this.sendToRemoteCompleted = new WSManNativeApi.WSManShellAsync(new IntPtr(this.cmdContextId), cmdSendCallback);
                            WSManNativeApi.WSManSendShellInputEx(this.wsManShellOperationHandle, this.wsManCmdOperationHandle, 0, (priorityType == DataPriorityType.Default) ? "stdin" : "pr", data2, (IntPtr)this.sendToRemoteCompleted, ref this.wsManSendOperationHandle);
                        }
                    }
                }
            }
        }
        private void SendData(byte[] data, DataPriorityType priorityType)
        {
            BaseClientTransportManager.tracer.WriteLine("Session sending data of size : {0}", (object)data.Length);
            byte[] data1 = data;
            bool   flag  = true;

            if ((object)WSManClientSessionTransportManager.sessionSendRedirect != null)
            {
                object[] objArray = new object[2]
                {
                    null,
                    (object)data1
                };
                flag  = (bool)WSManClientSessionTransportManager.sessionSendRedirect.DynamicInvoke(objArray);
                data1 = (byte[])objArray[0];
            }
            if (!flag)
            {
                return;
            }
            using (WSManNativeApi.WSManData streamData = new WSManNativeApi.WSManData(data1))
            {
                BaseTransportManager.ETWTracer.AnalyticChannel.WriteInformation(PSEventId.WSManSendShellInputEx, PSOpcode.Send, PSTask.None, (object)this.RunspacePoolInstanceId, (object)Guid.Empty, (object)streamData.BufferLength.ToString((IFormatProvider)CultureInfo.InvariantCulture));
                lock (this.syncObject)
                {
                    if (this.isClosed)
                    {
                        BaseClientTransportManager.tracer.WriteLine("Client Session TM: Transport manager is closed. So returning", new object[0]);
                    }
                    else
                    {
                        this.sendToRemoteCompleted = new WSManNativeApi.WSManShellAsync(new IntPtr(this.sessionContextID), WSManClientSessionTransportManager.sessionSendCallback);
                        WSManNativeApi.WSManSendShellInputEx(this.wsManShellOperationHandle, IntPtr.Zero, 0, priorityType == DataPriorityType.Default ? "stdin" : "pr", streamData, (IntPtr)this.sendToRemoteCompleted, ref this.wsManSendOperationHandle);
                    }
                }
            }
        }