QueryInformation.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 QueryInformation
  14. {
  15. public abstract byte[] GetBytes();
  16. public abstract QueryInformationLevel InformationLevel
  17. {
  18. get;
  19. }
  20. public static QueryInformation GetQueryInformation(byte[] buffer, QueryInformationLevel informationLevel)
  21. {
  22. switch (informationLevel)
  23. {
  24. case QueryInformationLevel.SMB_QUERY_FILE_BASIC_INFO:
  25. return new QueryFileBasicInfo(buffer, 0);
  26. case QueryInformationLevel.SMB_QUERY_FILE_STANDARD_INFO:
  27. return new QueryFileStandardInfo(buffer, 0);
  28. case QueryInformationLevel.SMB_QUERY_FILE_EA_INFO:
  29. return new QueryFileExtendedAttributeInfo(buffer, 0);
  30. case QueryInformationLevel.SMB_QUERY_FILE_NAME_INFO:
  31. return new QueryFileNameInfo(buffer, 0);
  32. case QueryInformationLevel.SMB_QUERY_FILE_ALL_INFO:
  33. return new QueryFileAllInfo(buffer, 0);
  34. case QueryInformationLevel.SMB_QUERY_FILE_ALT_NAME_INFO:
  35. return new QueryFileAltNameInfo(buffer, 0);
  36. case QueryInformationLevel.SMB_QUERY_FILE_STREAM_INFO:
  37. return new QueryFileStreamInfo(buffer, 0);
  38. case QueryInformationLevel.SMB_QUERY_FILE_COMPRESSION_INFO:
  39. return new QueryFileCompressionInfo(buffer, 0);
  40. default:
  41. throw new InvalidRequestException();
  42. }
  43. }
  44. }
  45. }