FileFsSectorSizeInformation.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 - FileFsSectorSizeInformation
  14. /// </summary>
  15. public class FileFsSectorSizeInformation : FileSystemInformation
  16. {
  17. public const int FixedLength = 28;
  18. public uint LogicalBytesPerSector;
  19. public uint PhysicalBytesPerSectorForAtomicity;
  20. public uint PhysicalBytesPerSectorForPerformance;
  21. public uint FileSystemEffectivePhysicalBytesPerSectorForAtomicity;
  22. public SectorSizeInformationFlags Flags;
  23. public uint ByteOffsetForSectorAlignment;
  24. public uint ByteOffsetForPartitionAlignment;
  25. public FileFsSectorSizeInformation()
  26. {
  27. }
  28. public FileFsSectorSizeInformation(byte[] buffer, int offset)
  29. {
  30. LogicalBytesPerSector = LittleEndianConverter.ToUInt32(buffer, offset + 0);
  31. PhysicalBytesPerSectorForAtomicity = LittleEndianConverter.ToUInt32(buffer, offset + 4);
  32. PhysicalBytesPerSectorForPerformance = LittleEndianConverter.ToUInt32(buffer, offset + 8);
  33. FileSystemEffectivePhysicalBytesPerSectorForAtomicity = LittleEndianConverter.ToUInt32(buffer, offset + 12);
  34. Flags = (SectorSizeInformationFlags)LittleEndianConverter.ToUInt32(buffer, offset + 16);
  35. ByteOffsetForSectorAlignment = LittleEndianConverter.ToUInt32(buffer, offset + 20);
  36. ByteOffsetForPartitionAlignment = LittleEndianConverter.ToUInt32(buffer, offset + 24);
  37. }
  38. public override void WriteBytes(byte[] buffer, int offset)
  39. {
  40. LittleEndianWriter.WriteUInt32(buffer, offset + 0, LogicalBytesPerSector);
  41. LittleEndianWriter.WriteUInt32(buffer, offset + 4, PhysicalBytesPerSectorForAtomicity);
  42. LittleEndianWriter.WriteUInt32(buffer, offset + 8, PhysicalBytesPerSectorForPerformance);
  43. LittleEndianWriter.WriteUInt32(buffer, offset + 12, FileSystemEffectivePhysicalBytesPerSectorForAtomicity);
  44. LittleEndianWriter.WriteUInt32(buffer, offset + 16, (uint)Flags);
  45. LittleEndianWriter.WriteUInt32(buffer, offset + 20, ByteOffsetForSectorAlignment);
  46. LittleEndianWriter.WriteUInt32(buffer, offset + 24, ByteOffsetForPartitionAlignment);
  47. }
  48. public override FileSystemInformationClass FileSystemInformationClass
  49. {
  50. get
  51. {
  52. return FileSystemInformationClass.FileFsSectorSizeInformation;
  53. }
  54. }
  55. public override int Length
  56. {
  57. get
  58. {
  59. return FixedLength;
  60. }
  61. }
  62. }
  63. }