/// <summary>
        /// Execute a transacted exchange against a named pipe.
        /// </summary>
        /// <param name="timeout">The pending time to get server's response</param>
        /// <param name="writeData">the written data to the named pipe</param>
        /// <param name="readData">The read data from the named pipe</param>
        /// <returns>
        /// a uint value that specifies the status of response packet.
        /// </returns>
        /// <exception cref="System.InvalidOperationException">Thrown if there is any error occurred</exception>
        public uint Transaction(TimeSpan timeout, byte[] writeData, out byte[] readData)
        {
            this.internalTimeout = timeout;

            SmbTransTransactNmpipeRequestPacket request = smbClient.CreateTransTransactNamedPipeRequest(this.fid, TransSmbParametersFlags.NONE, writeData, smbClient.Capability.MaxDataCount);

            if (this.isSignRequired)
            {
                request.Sign(this.NextSequenceNumber, this.sessionKey);
            }

            uint status = 0;
            SmbTransTransactNmpipeResponsePacket response =
                this.SendAndExpectSmbPacket(request, internalTimeout, out status) as SmbTransTransactNmpipeResponsePacket;

            readData = ArrayUtility.SubArray <byte>(response.TransData.ReadData, 0);

            return(SmbMessageUtils.CheckStatus(status));
        }
示例#2
0
        /// <summary>
        /// find the transaction packet.
        /// </summary>
        /// <param name="setupCount">the count of setup</param>
        /// <param name="command">the command of transaction packet</param>
        /// <returns>the target transaction packet</returns>
        private static SmbPacket FindTheTransactionPacket(byte setupCount, TransSubCommand command)
        {
            if (setupCount == 0)
            {
                return(new SmbTransRapRequestPacket());
            }
            else if (setupCount == 3)
            {
                return(new SmbTransMailslotWriteRequestPacket());
            }

            SmbPacket smbPacket = null;

            switch ((TransSubCommand)command)
            {
            case TransSubCommand.TRANS_SET_NMPIPE_STATE:
                smbPacket = new SmbTransSetNmpipeStateRequestPacket();
                break;

            case TransSubCommand.TRANS_QUERY_NMPIPE_STATE:
                smbPacket = new SmbTransQueryNmpipeStateRequestPacket();
                break;

            case TransSubCommand.TRANS_QUERY_NMPIPE_INFO:
                smbPacket = new SmbTransQueryNmpipeInfoRequestPacket();
                break;

            case TransSubCommand.TRANS_PEEK_NMPIPE:
                smbPacket = new SmbTransPeekNmpipeRequestPacket();
                break;

            case TransSubCommand.TRANS_TRANSACT_NMPIPE:
                smbPacket = new SmbTransTransactNmpipeRequestPacket();
                break;

            case TransSubCommand.TRANS_RAW_READ_NMPIPE:
                smbPacket = new SmbTransRawReadNmpipeRequestPacket();
                break;

            case TransSubCommand.TRANS_READ_NMPIPE:
                smbPacket = new SmbTransReadNmpipeRequestPacket();
                break;

            case TransSubCommand.TRANS_WRITE_NMPIPE:
                smbPacket = new SmbTransWriteNmpipeRequestPacket();
                break;

            case TransSubCommand.TRANS_WAIT_NMPIPE:
                smbPacket = new SmbTransWaitNmpipeRequestPacket();
                break;

            case TransSubCommand.TRANS_CALL_NMPIPE:
                smbPacket = new SmbTransCallNmpipeRequestPacket();
                break;

            case TransSubCommand.TRANS_RAW_WRITE_NMPIPE:
                smbPacket = new SmbTransRawWriteNmpipeRequestPacket();
                break;

            default:
                break;
            }
            return(smbPacket);
        }
 /// <summary>
 /// Deep copy constructor.
 /// </summary>
 public SmbTransTransactNmpipeRequestPacket(SmbTransTransactNmpipeRequestPacket packet)
     : base(packet)
 {
 }