QueryFSSizeInfo.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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_QUERY_FS_SIZE_INFO
  15. /// </summary>
  16. public class QueryFSSizeInfo : QueryFSInformation
  17. {
  18. public const int Length = 24;
  19. public ulong TotalAllocationUnits;
  20. public ulong TotalFreeAllocationUnits;
  21. public uint SectorsPerAllocationUnit;
  22. public uint BytesPerSector;
  23. public QueryFSSizeInfo()
  24. {
  25. }
  26. public QueryFSSizeInfo(byte[] buffer, int offset)
  27. {
  28. TotalAllocationUnits = LittleEndianConverter.ToUInt64(buffer, 0);
  29. TotalFreeAllocationUnits = LittleEndianConverter.ToUInt64(buffer, 8);
  30. SectorsPerAllocationUnit = LittleEndianConverter.ToUInt32(buffer, 16);
  31. BytesPerSector = LittleEndianConverter.ToUInt32(buffer, 20);
  32. }
  33. public override byte[] GetBytes(bool isUnicode)
  34. {
  35. byte[] buffer = new byte[Length];
  36. LittleEndianWriter.WriteUInt64(buffer, 0, TotalAllocationUnits);
  37. LittleEndianWriter.WriteUInt64(buffer, 8, TotalFreeAllocationUnits);
  38. LittleEndianWriter.WriteUInt32(buffer, 16, SectorsPerAllocationUnit);
  39. LittleEndianWriter.WriteUInt32(buffer, 20, BytesPerSector);
  40. return buffer;
  41. }
  42. }
  43. }