QueryEASize.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_INFO_QUERY_EA_SIZE
  15. /// </summary>
  16. public class QueryEASize : QueryInformation
  17. {
  18. public const int Length = 26;
  19. public DateTime CreationDateTime;
  20. public DateTime LastAccessDateTime;
  21. public DateTime LastWriteDateTime;
  22. public uint FileDataSize;
  23. public uint AllocationSize;
  24. public SMBFileAttributes Attributes;
  25. public uint EASize;
  26. public QueryEASize()
  27. {
  28. }
  29. public QueryEASize(byte[] buffer, int offset)
  30. {
  31. CreationDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset);
  32. LastAccessDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset);
  33. LastWriteDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset);
  34. FileDataSize = LittleEndianReader.ReadUInt32(buffer, ref offset);
  35. AllocationSize = LittleEndianReader.ReadUInt32(buffer, ref offset);
  36. Attributes = (SMBFileAttributes)LittleEndianReader.ReadUInt16(buffer, ref offset);
  37. EASize = LittleEndianReader.ReadUInt32(buffer, ref offset);
  38. }
  39. public override byte[] GetBytes()
  40. {
  41. byte[] buffer = new byte[Length];
  42. int offset = 0;
  43. SMB1Helper.WriteSMBDateTime(buffer, ref offset, CreationDateTime);
  44. SMB1Helper.WriteSMBDateTime(buffer, ref offset, LastAccessDateTime);
  45. SMB1Helper.WriteSMBDateTime(buffer, ref offset, LastWriteDateTime);
  46. LittleEndianWriter.WriteUInt32(buffer, ref offset, FileDataSize);
  47. LittleEndianWriter.WriteUInt32(buffer, ref offset, AllocationSize);
  48. LittleEndianWriter.WriteUInt16(buffer, ref offset, (ushort)Attributes);
  49. LittleEndianWriter.WriteUInt32(buffer, ref offset, EASize);
  50. return buffer;
  51. }
  52. public override QueryInformationLevel InformationLevel
  53. {
  54. get
  55. {
  56. return QueryInformationLevel.SMB_INFO_QUERY_EA_SIZE;
  57. }
  58. }
  59. }
  60. }