FileNetworkOpenInformation.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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.12 - FileNetworkOpenInformation
  14. /// </summary>
  15. public class FileNetworkOpenInformation : FileInformation
  16. {
  17. public const int FixedLength = 56;
  18. public DateTime? CreationTime;
  19. public DateTime? LastAccessTime;
  20. public DateTime? LastWriteTime;
  21. public DateTime? ChangeTime;
  22. public ulong AllocationSize;
  23. public ulong EndOfFile;
  24. public FileAttributes FileAttributes;
  25. public uint Reserved;
  26. public FileNetworkOpenInformation()
  27. {
  28. }
  29. public FileNetworkOpenInformation(byte[] buffer, int offset)
  30. {
  31. CreationTime = FileTimeHelper.ReadNullableFileTime(buffer, offset + 0);
  32. LastAccessTime = FileTimeHelper.ReadNullableFileTime(buffer, offset + 8);
  33. LastWriteTime = FileTimeHelper.ReadNullableFileTime(buffer, offset + 16);
  34. ChangeTime = FileTimeHelper.ReadNullableFileTime(buffer, offset + 24);
  35. AllocationSize = LittleEndianConverter.ToUInt64(buffer, offset + 32);
  36. EndOfFile = LittleEndianConverter.ToUInt64(buffer, offset + 40);
  37. FileAttributes = (FileAttributes)LittleEndianConverter.ToUInt32(buffer, offset + 48);
  38. Reserved = LittleEndianConverter.ToUInt32(buffer, offset + 52);
  39. }
  40. public override void WriteBytes(byte[] buffer, int offset)
  41. {
  42. FileTimeHelper.WriteFileTime(buffer, offset + 0, CreationTime);
  43. FileTimeHelper.WriteFileTime(buffer, offset + 8, LastAccessTime);
  44. FileTimeHelper.WriteFileTime(buffer, offset + 16, LastWriteTime);
  45. FileTimeHelper.WriteFileTime(buffer, offset + 24, ChangeTime);
  46. LittleEndianWriter.WriteUInt64(buffer, offset + 32, AllocationSize);
  47. LittleEndianWriter.WriteUInt64(buffer, offset + 40, EndOfFile);
  48. LittleEndianWriter.WriteUInt32(buffer, offset + 48, (uint)FileAttributes);
  49. LittleEndianWriter.WriteUInt32(buffer, offset + 52, Reserved);
  50. }
  51. public override FileInformationClass FileInformationClass
  52. {
  53. get
  54. {
  55. return FileInformationClass.FileNetworkOpenInformation;
  56. }
  57. }
  58. public override int Length
  59. {
  60. get
  61. {
  62. return FixedLength;
  63. }
  64. }
  65. }
  66. }