FileFsSizeInformation.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* Copyright (C) 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 Utilities;
  10. namespace SMBLibrary
  11. {
  12. /// <summary>
  13. /// [MS-FSCC] 2.5.8 - FileFsSizeInformation
  14. /// </summary>
  15. public class FileFsSizeInformation : FileSystemInformation
  16. {
  17. public const int FixedLength = 24;
  18. public long TotalAllocationUnits;
  19. public long AvailableAllocationUnits;
  20. public uint SectorsPerAllocationUnit;
  21. public uint BytesPerSector;
  22. public FileFsSizeInformation()
  23. {
  24. }
  25. public FileFsSizeInformation(byte[] buffer, int offset)
  26. {
  27. TotalAllocationUnits = LittleEndianConverter.ToInt64(buffer, offset + 0);
  28. AvailableAllocationUnits = LittleEndianConverter.ToInt64(buffer, offset + 8);
  29. SectorsPerAllocationUnit = LittleEndianConverter.ToUInt32(buffer, offset + 16);
  30. BytesPerSector = LittleEndianConverter.ToUInt32(buffer, offset + 20);
  31. }
  32. public override void WriteBytes(byte[] buffer, int offset)
  33. {
  34. LittleEndianWriter.WriteInt64(buffer, offset + 0, TotalAllocationUnits);
  35. LittleEndianWriter.WriteInt64(buffer, offset + 8, AvailableAllocationUnits);
  36. LittleEndianWriter.WriteUInt32(buffer, offset + 16, SectorsPerAllocationUnit);
  37. LittleEndianWriter.WriteUInt32(buffer, offset + 20, BytesPerSector);
  38. }
  39. public override FileSystemInformationClass FileSystemInformationClass
  40. {
  41. get
  42. {
  43. return FileSystemInformationClass.FileFsSizeInformation;
  44. }
  45. }
  46. public override int Length
  47. {
  48. get
  49. {
  50. return FixedLength;
  51. }
  52. }
  53. }
  54. }