1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using Utilities;
- namespace SMBLibrary.SMB1
- {
-
-
-
- public class TreeConnectAndXResponseExtended : SMBAndXCommand
- {
- public const int ParametersLength = 14;
-
-
-
-
- public OptionalSupportFlags OptionalSupport;
- public AccessMask MaximalShareAccessRights;
- public AccessMask GuestMaximalShareAccessRights;
-
- public ServiceName Service;
- public string NativeFileSystem;
- public TreeConnectAndXResponseExtended() : base()
- {
- }
- public TreeConnectAndXResponseExtended(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)
- {
- int parametersOffset = 4;
- OptionalSupport = (OptionalSupportFlags)LittleEndianReader.ReadUInt16(this.SMBParameters, ref parametersOffset);
- MaximalShareAccessRights = (AccessMask)LittleEndianReader.ReadUInt32(this.SMBParameters, ref parametersOffset);
- GuestMaximalShareAccessRights = (AccessMask)LittleEndianReader.ReadUInt32(this.SMBParameters, ref parametersOffset);
- int dataOffset = 0;
- string serviceString = ByteReader.ReadNullTerminatedAnsiString(this.SMBData, ref dataOffset);
- NativeFileSystem = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
- Service = ServiceNameHelper.GetServiceName(serviceString);
- }
- public override byte[] GetBytes(bool isUnicode)
- {
- this.SMBParameters = new byte[ParametersLength];
- int parametersOffset = 4;
- LittleEndianWriter.WriteUInt16(this.SMBParameters, ref parametersOffset, (ushort)OptionalSupport);
- LittleEndianWriter.WriteUInt32(this.SMBParameters, ref parametersOffset, (uint)MaximalShareAccessRights);
- LittleEndianWriter.WriteUInt32(this.SMBParameters, ref parametersOffset, (uint)GuestMaximalShareAccessRights);
-
- string serviceString = ServiceNameHelper.GetServiceString(Service);
- if (isUnicode)
- {
- this.SMBData = new byte[serviceString.Length + NativeFileSystem.Length * 2 + 3];
- }
- else
- {
- this.SMBData = new byte[serviceString.Length + NativeFileSystem.Length + 2];
- }
- int offset = 0;
- ByteWriter.WriteNullTerminatedAnsiString(this.SMBData, ref offset, serviceString);
- SMB1Helper.WriteSMBString(this.SMBData, ref offset, isUnicode, NativeFileSystem);
- return base.GetBytes(isUnicode);
- }
- public override CommandName CommandName
- {
- get
- {
- return CommandName.SMB_COM_TREE_CONNECT_ANDX;
- }
- }
- }
- }
|