OpenAndXResponse.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* Copyright (C) 2014-2017 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  2. *
  3. * You can redistribute this program and/or modify it under the terms of
  4. * the GNU Lesser Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. using Utilities;
  11. namespace SMBLibrary.SMB1
  12. {
  13. /// <summary>
  14. /// SMB_COM_OPEN_ANDX Response
  15. /// </summary>
  16. public class OpenAndXResponse : SMBAndXCommand
  17. {
  18. public const int ParametersLength = 30;
  19. // Parameters:
  20. //CommandName AndXCommand;
  21. //byte AndXReserved;
  22. //ushort AndXOffset;
  23. public ushort FID;
  24. public SMBFileAttributes FileAttrs;
  25. public DateTime? LastWriteTime; // UTime
  26. public uint FileDataSize;
  27. public AccessRights AccessRights;
  28. public ResourceType ResourceType;
  29. public NamedPipeStatus NMPipeStatus;
  30. public OpenResults OpenResults;
  31. public byte[] Reserved; // 6 bytes
  32. public OpenAndXResponse() : base()
  33. {
  34. Reserved = new byte[6];
  35. }
  36. public OpenAndXResponse(byte[] buffer, int offset) : base(buffer, offset, false)
  37. {
  38. throw new NotImplementedException();
  39. }
  40. public override byte[] GetBytes(bool isUnicode)
  41. {
  42. this.SMBParameters = new byte[ParametersLength];
  43. int parametersOffset = 4;
  44. LittleEndianWriter.WriteUInt16(this.SMBParameters, ref parametersOffset, FID);
  45. LittleEndianWriter.WriteUInt16(this.SMBParameters, ref parametersOffset, (ushort)FileAttrs);
  46. UTimeHelper.WriteUTime(this.SMBParameters, ref parametersOffset, LastWriteTime);
  47. LittleEndianWriter.WriteUInt32(this.SMBParameters, ref parametersOffset, FileDataSize);
  48. LittleEndianWriter.WriteUInt16(this.SMBParameters, ref parametersOffset, (ushort)AccessRights);
  49. LittleEndianWriter.WriteUInt16(this.SMBParameters, ref parametersOffset, (ushort)ResourceType);
  50. NMPipeStatus.WriteBytes(this.SMBParameters, ref parametersOffset);
  51. OpenResults.WriteBytes(this.SMBParameters, ref parametersOffset);
  52. ByteWriter.WriteBytes(this.SMBParameters, ref parametersOffset, Reserved, 6);
  53. return base.GetBytes(isUnicode);
  54. }
  55. public override CommandName CommandName
  56. {
  57. get
  58. {
  59. return CommandName.SMB_COM_OPEN_ANDX;
  60. }
  61. }
  62. }
  63. }