OpenAndXResponseExtended.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* Copyright (C) 2014 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 Extended
  15. /// </summary>
  16. public class OpenAndXResponseExtended : SMBAndXCommand
  17. {
  18. public const int ParametersLength = 38;
  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 uint ServerFID;
  32. public ushort Reserved;
  33. public AccessMask MaximalAccessRights;
  34. public AccessMask GuestMaximalAccessRights;
  35. public OpenAndXResponseExtended() : base()
  36. {
  37. }
  38. public OpenAndXResponseExtended(byte[] buffer, int offset) : base(buffer, offset, false)
  39. {
  40. throw new NotImplementedException();
  41. }
  42. public override byte[] GetBytes(bool isUnicode)
  43. {
  44. this.SMBParameters = new byte[ParametersLength];
  45. int parametersOffset = 4;
  46. LittleEndianWriter.WriteUInt16(this.SMBParameters, ref parametersOffset, FID);
  47. LittleEndianWriter.WriteUInt16(this.SMBParameters, ref parametersOffset, (ushort)FileAttrs);
  48. UTimeHelper.WriteUTime(this.SMBParameters, ref parametersOffset, LastWriteTime);
  49. LittleEndianWriter.WriteUInt32(this.SMBParameters, ref parametersOffset, FileDataSize);
  50. LittleEndianWriter.WriteUInt16(this.SMBParameters, ref parametersOffset, (ushort)AccessRights);
  51. LittleEndianWriter.WriteUInt16(this.SMBParameters, ref parametersOffset, (ushort)ResourceType);
  52. NMPipeStatus.WriteBytes(this.SMBParameters, ref parametersOffset);
  53. OpenResults.WriteBytes(this.SMBParameters, ref parametersOffset);
  54. LittleEndianWriter.WriteUInt32(this.SMBParameters, ref parametersOffset, ServerFID);
  55. LittleEndianWriter.WriteUInt16(this.SMBParameters, ref parametersOffset, Reserved);
  56. LittleEndianWriter.WriteUInt32(this.SMBParameters, ref parametersOffset, (uint)MaximalAccessRights);
  57. LittleEndianWriter.WriteUInt32(this.SMBParameters, ref parametersOffset, (uint)GuestMaximalAccessRights);
  58. return base.GetBytes(isUnicode);
  59. }
  60. public override CommandName CommandName
  61. {
  62. get
  63. {
  64. return CommandName.SMB_COM_OPEN_ANDX;
  65. }
  66. }
  67. }
  68. }