Beispiel #1
0
        /// <summary>
        /// There are no secondary response messages.
        /// 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, NTTransactSecondaryRequest request, ISMBShare share, SMB1ConnectionState state)
        {
            ProcessStateObject processState = state.GetProcessState(header.PID);

            if (processState == null)
            {
                throw new InvalidDataException();
            }
            ByteWriter.WriteBytes(processState.TransactionParameters, (int)request.ParameterDisplacement, request.TransParameters);
            ByteWriter.WriteBytes(processState.TransactionData, (int)request.DataDisplacement, request.TransData);
            processState.TransactionParametersReceived += request.TransParameters.Length;
            processState.TransactionDataReceived       += request.TransData.Length;

            if (processState.TransactionParametersReceived < processState.TransactionParameters.Length ||
                processState.TransactionDataReceived < processState.TransactionData.Length)
            {
                return(new List <SMB1Command>());
            }
            else
            {
                // We have a complete command
                state.RemoveProcessState(header.PID);
                return(GetCompleteNTTransactResponse(header, processState.MaxParameterCount, processState.MaxDataCount, (NTTransactSubcommandName)processState.SubcommandID, processState.TransactionSetup, processState.TransactionParameters, processState.TransactionData, share, state));
            }
        }
        /// <summary>
        /// There are no secondary response messages.
        /// 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, TransactionSecondaryRequest request, ISMBShare share, SMB1ConnectionState state)
        {
            ProcessStateObject processState = state.GetProcessState(header.PID);

            if (processState == null)
            {
                throw new InvalidRequestException();
            }
            ByteWriter.WriteBytes(processState.TransactionParameters, request.ParameterDisplacement, request.TransParameters);
            ByteWriter.WriteBytes(processState.TransactionData, request.DataDisplacement, request.TransData);
            processState.TransactionParametersReceived += request.TransParameters.Length;
            processState.TransactionDataReceived       += request.TransData.Length;

            if (processState.TransactionParametersReceived < processState.TransactionParameters.Length ||
                processState.TransactionDataReceived < processState.TransactionData.Length)
            {
                return(new List <SMB1Command>());
            }
            else
            {
                // We have a complete command
                if (request is Transaction2SecondaryRequest)
                {
                    return(GetCompleteTransaction2Response(header, processState.TransactionSetup, processState.TransactionParameters, processState.TransactionData, share, state));
                }
                else
                {
                    return(GetCompleteTransactionResponse(header, processState.Name, processState.TransactionSetup, processState.TransactionParameters, processState.TransactionData, share, state));
                }
            }
        }
Beispiel #3
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)
     {
         // A secondary transaction request is pending
         ProcessStateObject processState = state.CreateProcessState(header.PID);
         processState.SubcommandID          = (ushort)request.Function;
         processState.MaxParameterCount     = request.MaxParameterCount;
         processState.MaxDataCount          = request.MaxDataCount;
         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.MaxParameterCount, request.MaxDataCount, request.Function, request.Setup, request.TransParameters, request.TransData, share, state));
     }
 }
        /// <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));
                }
            }
        }