123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using Utilities;
- namespace SMBLibrary.SMB1
- {
-
-
-
-
- public class ReadAndXRequest : SMBAndXCommand
- {
- public const int ParametersFixedLength = 20;
-
-
-
-
- public ushort FID;
- public ulong Offset;
- private ushort MaxCountOfBytesToReturn;
- public ushort MinCountOfBytesToReturn;
-
-
-
-
-
- public uint Timeout_or_MaxCountHigh;
- public ushort Remaining;
- public ReadAndXRequest() : base()
- {
- }
- public ReadAndXRequest(byte[] buffer, int offset) : base(buffer, offset, false)
- {
- FID = LittleEndianConverter.ToUInt16(this.SMBParameters, 4);
- Offset = LittleEndianConverter.ToUInt32(this.SMBParameters, 6);
- MaxCountOfBytesToReturn = LittleEndianConverter.ToUInt16(this.SMBParameters, 10);
- MinCountOfBytesToReturn = LittleEndianConverter.ToUInt16(this.SMBParameters, 12);
- Timeout_or_MaxCountHigh = LittleEndianConverter.ToUInt32(this.SMBParameters, 14);
- Remaining = LittleEndianConverter.ToUInt16(this.SMBParameters, 18);
- if (SMBParameters.Length == ParametersFixedLength + 4)
- {
- uint offsetHigh = LittleEndianConverter.ToUInt32(this.SMBParameters, 20);
- Offset |= ((ulong)offsetHigh << 32);
- }
- }
- public override byte[] GetBytes(bool isUnicode)
- {
- int parametersLength = ParametersFixedLength;
- if (Offset > UInt32.MaxValue)
- {
- parametersLength += 4;
- }
- this.SMBParameters = new byte[parametersLength];
- LittleEndianWriter.WriteUInt16(this.SMBParameters, 4, FID);
- LittleEndianWriter.WriteUInt32(this.SMBParameters, 6, (uint)(Offset & 0xFFFFFFFF));
- LittleEndianWriter.WriteUInt16(this.SMBParameters, 10, (ushort)(MaxCountOfBytesToReturn & 0xFFFF));
- LittleEndianWriter.WriteUInt16(this.SMBParameters, 12, MinCountOfBytesToReturn);
- LittleEndianWriter.WriteUInt32(this.SMBParameters, 14, Timeout_or_MaxCountHigh);
- LittleEndianWriter.WriteUInt16(this.SMBParameters, 18, Remaining);
- if (Offset > UInt32.MaxValue)
- {
- uint offsetHigh = (uint)(Offset >> 32);
- LittleEndianWriter.WriteUInt32(this.SMBParameters, 20, offsetHigh);
- }
- return base.GetBytes(isUnicode);
- }
-
-
-
- public uint MaxCountLarge
- {
- get
- {
- ushort maxCountHigh = (ushort)(Timeout_or_MaxCountHigh & 0xFFFF);
- return (uint)(maxCountHigh << 16) | MaxCountOfBytesToReturn;
- }
- set
- {
- MaxCountOfBytesToReturn = (ushort)(value & 0xFFFF);
- Timeout_or_MaxCountHigh = (ushort)(value >> 16);
- }
- }
-
-
-
- public ushort MaxCount
- {
- get
- {
- return MaxCountOfBytesToReturn;
- }
- set
- {
- MaxCountOfBytesToReturn = value;
- }
- }
- public override CommandName CommandName
- {
- get
- {
- return CommandName.SMB_COM_READ_ANDX;
- }
- }
- }
- }
|