FileFsFullSizeInformation.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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.4 - FileFsFullSizeInformation
  14. /// </summary>
  15. public class FileFsFullSizeInformation : FileSystemInformation
  16. {
  17. public const int FixedLength = 32;
  18. public long TotalAllocationUnits;
  19. public long CallerAvailableAllocationUnits;
  20. public long ActualAvailableAllocationUnits;
  21. public uint SectorsPerAllocationUnit;
  22. public uint BytesPerSector;
  23. public FileFsFullSizeInformation()
  24. {
  25. }
  26. public FileFsFullSizeInformation(byte[] buffer, int offset)
  27. {
  28. TotalAllocationUnits = LittleEndianConverter.ToInt64(buffer, offset + 0);
  29. CallerAvailableAllocationUnits = LittleEndianConverter.ToInt64(buffer, offset + 8);
  30. ActualAvailableAllocationUnits = LittleEndianConverter.ToInt64(buffer, offset + 16);
  31. SectorsPerAllocationUnit = LittleEndianConverter.ToUInt32(buffer, offset + 24);
  32. BytesPerSector = LittleEndianConverter.ToUInt32(buffer, offset + 28);
  33. }
  34. public override void WriteBytes(byte[] buffer, int offset)
  35. {
  36. LittleEndianWriter.WriteInt64(buffer, offset + 0, TotalAllocationUnits);
  37. LittleEndianWriter.WriteInt64(buffer, offset + 8, CallerAvailableAllocationUnits);
  38. LittleEndianWriter.WriteInt64(buffer, offset + 16, ActualAvailableAllocationUnits);
  39. LittleEndianWriter.WriteUInt32(buffer, offset + 24, SectorsPerAllocationUnit);
  40. LittleEndianWriter.WriteUInt32(buffer, offset + 28, BytesPerSector);
  41. }
  42. public override FileSystemInformationClass FileSystemInformationClass
  43. {
  44. get
  45. {
  46. return FileSystemInformationClass.FileFsFullSizeInformation;
  47. }
  48. }
  49. public override int Length
  50. {
  51. get
  52. {
  53. return FixedLength;
  54. }
  55. }
  56. }
  57. }