QueryFSInformation.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* Copyright (C) 2014-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 System.Text;
  10. using Utilities;
  11. namespace SMBLibrary.SMB1
  12. {
  13. public abstract class QueryFSInformation
  14. {
  15. public abstract byte[] GetBytes(bool isUnicode);
  16. public abstract int Length
  17. {
  18. get;
  19. }
  20. public abstract QueryFSInformationLevel InformationLevel
  21. {
  22. get;
  23. }
  24. public static QueryFSInformation GetQueryFSInformation(byte[] buffer, QueryFSInformationLevel informationLevel, bool isUnicode)
  25. {
  26. switch (informationLevel)
  27. {
  28. case QueryFSInformationLevel.SMB_QUERY_FS_VOLUME_INFO:
  29. return new QueryFSVolumeInfo(buffer, 0);
  30. case QueryFSInformationLevel.SMB_QUERY_FS_SIZE_INFO:
  31. return new QueryFSSizeInfo(buffer, 0);
  32. case QueryFSInformationLevel.SMB_QUERY_FS_DEVICE_INFO:
  33. return new QueryFSDeviceInfo(buffer, 0);
  34. case QueryFSInformationLevel.SMB_QUERY_FS_ATTRIBUTE_INFO:
  35. return new QueryFSAttibuteInfo(buffer, 0);
  36. default:
  37. throw new UnsupportedInformationLevelException();
  38. }
  39. }
  40. }
  41. }