/// <summary>
        /// The client MUST send as many secondary requests as are needed to complete the transfer of the transaction request.
        /// The server MUST respond to the transaction request as a whole.
        /// </summary>
        internal static List <SMB1Command> GetTransactionResponse(SMB1Header header, TransactionRequest request, ISMBShare share, SMB1ConnectionState state)
        {
            ProcessStateObject processState = state.ObtainProcessState(header.PID);

            processState.MaxDataCount = request.MaxDataCount;

            if (request.TransParameters.Length < request.TotalParameterCount ||
                request.TransData.Length < request.TotalDataCount)
            {
                // A secondary transaction request is pending
                processState.Name                  = request.Name;
                processState.TransactionSetup      = request.Setup;
                processState.TransactionParameters = new byte[request.TotalParameterCount];
                processState.TransactionData       = new byte[request.TotalDataCount];
                ByteWriter.WriteBytes(processState.TransactionParameters, 0, request.TransParameters);
                ByteWriter.WriteBytes(processState.TransactionData, 0, request.TransData);
                processState.TransactionParametersReceived += request.TransParameters.Length;
                processState.TransactionDataReceived       += request.TransData.Length;
                if (request is Transaction2Request)
                {
                    return(new Transaction2InterimResponse());
                }
                else
                {
                    return(new TransactionInterimResponse());
                }
            }
            else
            {
                // We have a complete command
                if (request is Transaction2Request)
                {
                    return(GetCompleteTransaction2Response(header, request.Setup, request.TransParameters, request.TransData, share, state));
                }
                else
                {
                    return(GetCompleteTransactionResponse(header, request.Name, request.Setup, request.TransParameters, request.TransData, share, state));
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// The client MUST send as many secondary requests as are needed to complete the transfer of the transaction request.
 /// </summary>
 internal static List <SMB1Command> GetNTTransactResponse(SMB1Header header, NTTransactRequest request, ISMBShare share, SMB1ConnectionState state)
 {
     if (request.TransParameters.Length < request.TotalParameterCount ||
         request.TransData.Length < request.TotalDataCount)
     {
         ProcessStateObject processState = state.ObtainProcessState(header.PID);
         // A secondary transaction request is pending
         processState.SubcommandID          = (ushort)request.Function;
         processState.TransactionSetup      = request.Setup;
         processState.TransactionParameters = new byte[request.TotalParameterCount];
         processState.TransactionData       = new byte[request.TotalDataCount];
         ByteWriter.WriteBytes(processState.TransactionParameters, 0, request.TransParameters);
         ByteWriter.WriteBytes(processState.TransactionData, 0, request.TransData);
         processState.TransactionParametersReceived += request.TransParameters.Length;
         processState.TransactionDataReceived       += request.TransData.Length;
         return(new NTTransactInterimResponse());
     }
     else
     {
         // We have a complete command
         return(GetCompleteNTTransactResponse(header, request.Function, request.Setup, request.TransParameters, request.TransData, share, state));
     }
 }