123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using Utilities;
- namespace SMBLibrary.SMB1
- {
-
-
-
-
- public class ReadAndXResponse : SMBAndXCommand
- {
- public const int ParametersLength = 24;
-
-
-
-
- public ushort Available;
- public ushort DataCompactionMode;
- public ushort Reserved1;
-
-
- public byte[] Reserved2;
-
-
- public byte[] Data;
- public ReadAndXResponse() : base()
- {
- Reserved2 = new byte[8];
- }
- public ReadAndXResponse(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)
- {
- Available = LittleEndianConverter.ToUInt16(this.SMBParameters, 4);
- DataCompactionMode = LittleEndianConverter.ToUInt16(this.SMBParameters, 6);
- Reserved1 = LittleEndianConverter.ToUInt16(this.SMBParameters, 8);
- uint DataLength = LittleEndianConverter.ToUInt16(this.SMBParameters, 10);
- ushort DataOffset = LittleEndianConverter.ToUInt16(this.SMBParameters, 12);
- ushort dataLengthHigh = LittleEndianConverter.ToUInt16(this.SMBParameters, 14);
- Reserved2 = ByteReader.ReadBytes(buffer, 16, 8);
- DataLength |= (uint)(dataLengthHigh << 16);
- Data = ByteReader.ReadBytes(buffer, DataOffset, (int)DataLength);
- }
- public override byte[] GetBytes(bool isUnicode)
- {
- uint DataLength = (uint)Data.Length;
-
- ushort DataOffset = SMB1Header.Length + 3 + ParametersLength;
- if (isUnicode)
- {
- DataOffset++;
- }
- ushort dataLengthHigh = (ushort)(DataLength >> 16);
- this.SMBParameters = new byte[ParametersLength];
- LittleEndianWriter.WriteUInt16(this.SMBParameters, 4, Available);
- LittleEndianWriter.WriteUInt16(this.SMBParameters, 6, DataCompactionMode);
- LittleEndianWriter.WriteUInt16(this.SMBParameters, 8, Reserved1);
- LittleEndianWriter.WriteUInt16(this.SMBParameters, 10, (ushort)(DataLength & 0xFFFF));
- LittleEndianWriter.WriteUInt16(this.SMBParameters, 12, DataOffset);
- LittleEndianWriter.WriteUInt16(this.SMBParameters, 14, dataLengthHigh);
- ByteWriter.WriteBytes(this.SMBParameters, 16, Reserved2);
- int smbDataLength = Data.Length;
- if (isUnicode)
- {
- smbDataLength++;
- }
- this.SMBData = new byte[smbDataLength];
- int offset = 0;
- if (isUnicode)
- {
- offset++;
- }
- ByteWriter.WriteBytes(this.SMBData, offset, this.Data);
- return base.GetBytes(isUnicode);
- }
- public override CommandName CommandName
- {
- get
- {
- return CommandName.SMB_COM_READ_ANDX;
- }
- }
- }
- }
|