diff --git a/SMBLibrary/Client/SMB1FileStore.cs b/SMBLibrary/Client/SMB1FileStore.cs index bac0bbb..58240e8 100644 --- a/SMBLibrary/Client/SMB1FileStore.cs +++ b/SMBLibrary/Client/SMB1FileStore.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2017 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2019 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -460,8 +460,8 @@ namespace SMBLibrary.Client TransactionRequest request = new TransactionRequest(); request.Setup = subcommand.GetSetup(); - request.TransParameters = subcommand.GetParameters(m_client.Unicode); - request.TransData = subcommand.GetData(); + request.TransParameters = subcommand.GetParameters(); + request.TransData = subcommand.GetData(m_client.Unicode); request.TotalDataCount = (ushort)request.TransData.Length; request.TotalParameterCount = (ushort)request.TransParameters.Length; request.MaxParameterCount = 0; diff --git a/SMBLibrary/SMB1/TransactionSubcommands/TransactionCallNamedPipeRequest.cs b/SMBLibrary/SMB1/TransactionSubcommands/TransactionCallNamedPipeRequest.cs index d6929a1..2ad40d9 100644 --- a/SMBLibrary/SMB1/TransactionSubcommands/TransactionCallNamedPipeRequest.cs +++ b/SMBLibrary/SMB1/TransactionSubcommands/TransactionCallNamedPipeRequest.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2017 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2019 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -40,7 +40,7 @@ namespace SMBLibrary.SMB1 return setup; } - public override byte[] GetData() + public override byte[] GetData(bool isUnicode) { return WriteData; } diff --git a/SMBLibrary/SMB1/TransactionSubcommands/TransactionCallNamedPipeResponse.cs b/SMBLibrary/SMB1/TransactionSubcommands/TransactionCallNamedPipeResponse.cs index 3eb9fce..bcab2b6 100644 --- a/SMBLibrary/SMB1/TransactionSubcommands/TransactionCallNamedPipeResponse.cs +++ b/SMBLibrary/SMB1/TransactionSubcommands/TransactionCallNamedPipeResponse.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2019 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -28,7 +28,7 @@ namespace SMBLibrary.SMB1 ReadData = data; } - public override byte[] GetData() + public override byte[] GetData(bool isUnicode) { return ReadData; } diff --git a/SMBLibrary/SMB1/TransactionSubcommands/TransactionPeekNamedPipeResponse.cs b/SMBLibrary/SMB1/TransactionSubcommands/TransactionPeekNamedPipeResponse.cs index 7f9a1a7..7cbe1b1 100644 --- a/SMBLibrary/SMB1/TransactionSubcommands/TransactionPeekNamedPipeResponse.cs +++ b/SMBLibrary/SMB1/TransactionSubcommands/TransactionPeekNamedPipeResponse.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2019 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -36,7 +36,7 @@ namespace SMBLibrary.SMB1 ReadData = data; } - public override byte[] GetParameters(bool isUnicode) + public override byte[] GetParameters() { byte[] parameters = new byte[ParametersLength]; LittleEndianWriter.WriteUInt16(parameters, 0, ReadDataAvailable); @@ -45,7 +45,7 @@ namespace SMBLibrary.SMB1 return parameters; } - public override byte[] GetData() + public override byte[] GetData(bool isUnicode) { return ReadData; } diff --git a/SMBLibrary/SMB1/TransactionSubcommands/TransactionQueryNamedPipeInfoRequest.cs b/SMBLibrary/SMB1/TransactionSubcommands/TransactionQueryNamedPipeInfoRequest.cs index d51e7bc..ace413d 100644 --- a/SMBLibrary/SMB1/TransactionSubcommands/TransactionQueryNamedPipeInfoRequest.cs +++ b/SMBLibrary/SMB1/TransactionSubcommands/TransactionQueryNamedPipeInfoRequest.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2017 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2019 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -40,7 +40,7 @@ namespace SMBLibrary.SMB1 return setup; } - public override byte[] GetParameters(bool isUnicode) + public override byte[] GetParameters() { return LittleEndianConverter.GetBytes(Level); } diff --git a/SMBLibrary/SMB1/TransactionSubcommands/TransactionQueryNamedPipeInfoResponse.cs b/SMBLibrary/SMB1/TransactionSubcommands/TransactionQueryNamedPipeInfoResponse.cs index c0da875..4734842 100644 --- a/SMBLibrary/SMB1/TransactionSubcommands/TransactionQueryNamedPipeInfoResponse.cs +++ b/SMBLibrary/SMB1/TransactionSubcommands/TransactionQueryNamedPipeInfoResponse.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2019 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -16,7 +16,8 @@ namespace SMBLibrary.SMB1 /// public class TransactionQueryNamedPipeInfoResponse : TransactionSubcommand { - // Parameters: + public const int ParametersLength = 0; + // Data: public ushort OutputBufferSize; public ushort InputBufferSize; public byte MaximumInstances; @@ -27,18 +28,18 @@ namespace SMBLibrary.SMB1 public TransactionQueryNamedPipeInfoResponse() : base() {} - public TransactionQueryNamedPipeInfoResponse(byte[] parameters, bool isUnicode) : base() + public TransactionQueryNamedPipeInfoResponse(byte[] data, bool isUnicode) : base() { - OutputBufferSize = LittleEndianConverter.ToUInt16(parameters, 0); - InputBufferSize = LittleEndianConverter.ToUInt16(parameters, 2); - MaximumInstances = ByteReader.ReadByte(parameters, 4); - CurrentInstances = ByteReader.ReadByte(parameters, 5); - PipeNameLength = ByteReader.ReadByte(parameters, 6); + OutputBufferSize = LittleEndianConverter.ToUInt16(data, 0); + InputBufferSize = LittleEndianConverter.ToUInt16(data, 2); + MaximumInstances = ByteReader.ReadByte(data, 4); + CurrentInstances = ByteReader.ReadByte(data, 5); + PipeNameLength = ByteReader.ReadByte(data, 6); // Note: Trans_Parameters is aligned to 4 byte boundary - PipeName = SMB1Helper.ReadSMBString(parameters, 8, isUnicode); + PipeName = SMB1Helper.ReadSMBString(data, 8, isUnicode); } - public override byte[] GetParameters(bool isUnicode) + public override byte[] GetData(bool isUnicode) { int length = 8; if (isUnicode) @@ -49,14 +50,14 @@ namespace SMBLibrary.SMB1 { length += PipeName.Length + 1; } - byte[] parameters = new byte[length]; - LittleEndianWriter.WriteUInt16(parameters, 0, OutputBufferSize); - LittleEndianWriter.WriteUInt16(parameters, 2, InputBufferSize); - ByteWriter.WriteByte(parameters, 4, MaximumInstances); - ByteWriter.WriteByte(parameters, 5, CurrentInstances); - ByteWriter.WriteByte(parameters, 6, PipeNameLength); - SMB1Helper.WriteSMBString(parameters, 8, isUnicode, PipeName); - return parameters; ; + byte[] data = new byte[length]; + LittleEndianWriter.WriteUInt16(data, 0, OutputBufferSize); + LittleEndianWriter.WriteUInt16(data, 2, InputBufferSize); + ByteWriter.WriteByte(data, 4, MaximumInstances); + ByteWriter.WriteByte(data, 5, CurrentInstances); + ByteWriter.WriteByte(data, 6, PipeNameLength); + SMB1Helper.WriteSMBString(data, 8, isUnicode, PipeName); + return data; } public override TransactionSubcommandName SubcommandName diff --git a/SMBLibrary/SMB1/TransactionSubcommands/TransactionQueryNamedPipeStateResponse.cs b/SMBLibrary/SMB1/TransactionSubcommands/TransactionQueryNamedPipeStateResponse.cs index a5972f9..0e20f9f 100644 --- a/SMBLibrary/SMB1/TransactionSubcommands/TransactionQueryNamedPipeStateResponse.cs +++ b/SMBLibrary/SMB1/TransactionSubcommands/TransactionQueryNamedPipeStateResponse.cs @@ -34,7 +34,7 @@ namespace SMBLibrary.SMB1 return new byte[0]; } - public override byte[] GetParameters(bool isUnicode) + public override byte[] GetParameters() { byte[] parameters = new byte[2]; NMPipeStatus.WriteBytes(parameters, 0); diff --git a/SMBLibrary/SMB1/TransactionSubcommands/TransactionRawReadNamedPipeResponse.cs b/SMBLibrary/SMB1/TransactionSubcommands/TransactionRawReadNamedPipeResponse.cs index 1b2092f..05d5d4b 100644 --- a/SMBLibrary/SMB1/TransactionSubcommands/TransactionRawReadNamedPipeResponse.cs +++ b/SMBLibrary/SMB1/TransactionSubcommands/TransactionRawReadNamedPipeResponse.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2019 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -29,7 +29,7 @@ namespace SMBLibrary.SMB1 BytesRead = data; } - public override byte[] GetData() + public override byte[] GetData(bool isUnicode) { return BytesRead; } diff --git a/SMBLibrary/SMB1/TransactionSubcommands/TransactionRawWriteNamedPipeRequest.cs b/SMBLibrary/SMB1/TransactionSubcommands/TransactionRawWriteNamedPipeRequest.cs index 0e2e221..b600a5b 100644 --- a/SMBLibrary/SMB1/TransactionSubcommands/TransactionRawWriteNamedPipeRequest.cs +++ b/SMBLibrary/SMB1/TransactionSubcommands/TransactionRawWriteNamedPipeRequest.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2017 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2019 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -40,7 +40,7 @@ namespace SMBLibrary.SMB1 return setup; } - public override byte[] GetData() + public override byte[] GetData(bool isUnicode) { return WriteData; } diff --git a/SMBLibrary/SMB1/TransactionSubcommands/TransactionRawWriteNamedPipeResponse.cs b/SMBLibrary/SMB1/TransactionSubcommands/TransactionRawWriteNamedPipeResponse.cs index 88cab96..e3bbc50 100644 --- a/SMBLibrary/SMB1/TransactionSubcommands/TransactionRawWriteNamedPipeResponse.cs +++ b/SMBLibrary/SMB1/TransactionSubcommands/TransactionRawWriteNamedPipeResponse.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2019 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -29,7 +29,7 @@ namespace SMBLibrary.SMB1 BytesWritten = LittleEndianConverter.ToUInt16(parameters, 0); } - public override byte[] GetParameters(bool isUnicode) + public override byte[] GetParameters() { return LittleEndianConverter.GetBytes(BytesWritten); } diff --git a/SMBLibrary/SMB1/TransactionSubcommands/TransactionReadNamedPipeResponse.cs b/SMBLibrary/SMB1/TransactionSubcommands/TransactionReadNamedPipeResponse.cs index 20fb7bb..7347a33 100644 --- a/SMBLibrary/SMB1/TransactionSubcommands/TransactionReadNamedPipeResponse.cs +++ b/SMBLibrary/SMB1/TransactionSubcommands/TransactionReadNamedPipeResponse.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2019 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -29,7 +29,7 @@ namespace SMBLibrary.SMB1 ReadData = data; } - public override byte[] GetData() + public override byte[] GetData(bool isUnicode) { return ReadData; } diff --git a/SMBLibrary/SMB1/TransactionSubcommands/TransactionSetNamedPipeStateRequest.cs b/SMBLibrary/SMB1/TransactionSubcommands/TransactionSetNamedPipeStateRequest.cs index b051bd8..8a8ba3a 100644 --- a/SMBLibrary/SMB1/TransactionSubcommands/TransactionSetNamedPipeStateRequest.cs +++ b/SMBLibrary/SMB1/TransactionSubcommands/TransactionSetNamedPipeStateRequest.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2017 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2019 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -40,7 +40,7 @@ namespace SMBLibrary.SMB1 return setup; } - public override byte[] GetParameters(bool isUnicode) + public override byte[] GetParameters() { return LittleEndianConverter.GetBytes((ushort)PipeState); } diff --git a/SMBLibrary/SMB1/TransactionSubcommands/TransactionSubcommand.cs b/SMBLibrary/SMB1/TransactionSubcommands/TransactionSubcommand.cs index 54019a6..7e5009d 100644 --- a/SMBLibrary/SMB1/TransactionSubcommands/TransactionSubcommand.cs +++ b/SMBLibrary/SMB1/TransactionSubcommands/TransactionSubcommand.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2017 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2019 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -22,12 +22,12 @@ namespace SMBLibrary.SMB1 return new byte[0]; } - public virtual byte[] GetParameters(bool isUnicode) + public virtual byte[] GetParameters() { return new byte[0]; } - public virtual byte[] GetData() + public virtual byte[] GetData(bool isUnicode) { return new byte[0]; } diff --git a/SMBLibrary/SMB1/TransactionSubcommands/TransactionTransactNamedPipeRequest.cs b/SMBLibrary/SMB1/TransactionSubcommands/TransactionTransactNamedPipeRequest.cs index e634e60..28d7459 100644 --- a/SMBLibrary/SMB1/TransactionSubcommands/TransactionTransactNamedPipeRequest.cs +++ b/SMBLibrary/SMB1/TransactionSubcommands/TransactionTransactNamedPipeRequest.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2019 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -39,7 +39,7 @@ namespace SMBLibrary.SMB1 return setup; } - public override byte[] GetData() + public override byte[] GetData(bool isUnicode) { return WriteData; } diff --git a/SMBLibrary/SMB1/TransactionSubcommands/TransactionTransactNamedPipeResponse.cs b/SMBLibrary/SMB1/TransactionSubcommands/TransactionTransactNamedPipeResponse.cs index a2caaaf..f8dac1a 100644 --- a/SMBLibrary/SMB1/TransactionSubcommands/TransactionTransactNamedPipeResponse.cs +++ b/SMBLibrary/SMB1/TransactionSubcommands/TransactionTransactNamedPipeResponse.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2019 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -29,7 +29,7 @@ namespace SMBLibrary.SMB1 ReadData = data; } - public override byte[] GetData() + public override byte[] GetData(bool isUnicode) { return ReadData; } diff --git a/SMBLibrary/SMB1/TransactionSubcommands/TransactionWriteNamedPipeRequest.cs b/SMBLibrary/SMB1/TransactionSubcommands/TransactionWriteNamedPipeRequest.cs index 616df2a..8580e93 100644 --- a/SMBLibrary/SMB1/TransactionSubcommands/TransactionWriteNamedPipeRequest.cs +++ b/SMBLibrary/SMB1/TransactionSubcommands/TransactionWriteNamedPipeRequest.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2017 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2019 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -40,7 +40,7 @@ namespace SMBLibrary.SMB1 return setup; } - public override byte[] GetData() + public override byte[] GetData(bool isUnicode) { return WriteData; } diff --git a/SMBLibrary/SMB1/TransactionSubcommands/TransactionWriteNamedPipeResponse.cs b/SMBLibrary/SMB1/TransactionSubcommands/TransactionWriteNamedPipeResponse.cs index 10b11b8..a3b3925 100644 --- a/SMBLibrary/SMB1/TransactionSubcommands/TransactionWriteNamedPipeResponse.cs +++ b/SMBLibrary/SMB1/TransactionSubcommands/TransactionWriteNamedPipeResponse.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2019 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -28,7 +28,7 @@ namespace SMBLibrary.SMB1 BytesWritten = LittleEndianConverter.ToUInt16(parameters, 0); } - public override byte[] GetParameters(bool isUnicode) + public override byte[] GetParameters() { return LittleEndianConverter.GetBytes(BytesWritten); } diff --git a/SMBLibrary/Server/SMB1/TransactionHelper.cs b/SMBLibrary/Server/SMB1/TransactionHelper.cs index 695efcd..48a5513 100644 --- a/SMBLibrary/Server/SMB1/TransactionHelper.cs +++ b/SMBLibrary/Server/SMB1/TransactionHelper.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2017 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2019 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -176,8 +176,8 @@ namespace SMBLibrary.Server.SMB1 } byte[] responseSetup = subcommandResponse.GetSetup(); - byte[] responseParameters = subcommandResponse.GetParameters(header.UnicodeFlag); - byte[] responseData = subcommandResponse.GetData(); + byte[] responseParameters = subcommandResponse.GetParameters(); + byte[] responseData = subcommandResponse.GetData(header.UnicodeFlag); return GetTransactionResponse(false, responseSetup, responseParameters, responseData, state.MaxBufferSize); }