FileStandardInformation.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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.4.38 - FileStandardInformation
  14. /// </summary>
  15. public class FileStandardInformation : FileInformation
  16. {
  17. public const int FixedLength = 24;
  18. public ulong AllocationSize;
  19. public ulong EndOfFile;
  20. public uint NumberOfLinks;
  21. public bool DeletePending;
  22. public bool Directory;
  23. public ushort Reserved;
  24. public FileStandardInformation()
  25. {
  26. }
  27. public FileStandardInformation(byte[] buffer, int offset)
  28. {
  29. AllocationSize = LittleEndianConverter.ToUInt64(buffer, offset + 0);
  30. EndOfFile = LittleEndianConverter.ToUInt64(buffer, offset + 8);
  31. NumberOfLinks = LittleEndianConverter.ToUInt32(buffer, offset + 16);
  32. DeletePending = (ByteReader.ReadByte(buffer, offset + 20) > 0);
  33. Directory = (ByteReader.ReadByte(buffer, offset + 21) > 0);
  34. Reserved = LittleEndianConverter.ToUInt16(buffer, offset + 22);
  35. }
  36. public override void WriteBytes(byte[] buffer, int offset)
  37. {
  38. LittleEndianWriter.WriteUInt64(buffer, offset + 0, AllocationSize);
  39. LittleEndianWriter.WriteUInt64(buffer, offset + 8, EndOfFile);
  40. LittleEndianWriter.WriteUInt32(buffer, offset + 16, NumberOfLinks);
  41. ByteWriter.WriteByte(buffer, offset + 20, Convert.ToByte(DeletePending));
  42. ByteWriter.WriteByte(buffer, offset + 21, Convert.ToByte(Directory));
  43. LittleEndianWriter.WriteUInt16(buffer, offset + 22, Reserved);
  44. }
  45. public override FileInformationClass FileInformationClass
  46. {
  47. get
  48. {
  49. return FileInformationClass.FileStandardInformation;
  50. }
  51. }
  52. public override int Length
  53. {
  54. get
  55. {
  56. return FixedLength;
  57. }
  58. }
  59. }
  60. }