QueryInformation.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* Copyright (C) 2014 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. /// <summary>
  21. /// SMB_INFO_IS_NAME_VALID will return null
  22. /// </summary>
  23. public static QueryInformation GetQueryInformation(byte[] buffer, QueryInformationLevel informationLevel)
  24. {
  25. switch (informationLevel)
  26. {
  27. case QueryInformationLevel.SMB_INFO_QUERY_ALL_EAS:
  28. return new QueryAllExtendedAttributes(buffer, 0);
  29. case QueryInformationLevel.SMB_QUERY_FILE_BASIC_INFO:
  30. return new QueryFileBasicInfo(buffer, 0);
  31. case QueryInformationLevel.SMB_QUERY_FILE_STANDARD_INFO:
  32. return new QueryFileStandardInfo(buffer, 0);
  33. case QueryInformationLevel.SMB_QUERY_FILE_EA_INFO:
  34. return new QueryFileExtendedAttributeInfo(buffer, 0);
  35. case QueryInformationLevel.SMB_QUERY_FILE_NAME_INFO:
  36. return new QueryFileNameInfo(buffer, 0);
  37. case QueryInformationLevel.SMB_QUERY_FILE_ALL_INFO:
  38. return new QueryFileAllInfo(buffer, 0);
  39. case QueryInformationLevel.SMB_QUERY_FILE_ALT_NAME_INFO:
  40. return new QueryFileAltNameInfo(buffer, 0);
  41. case QueryInformationLevel.SMB_QUERY_FILE_STREAM_INFO:
  42. return new QueryFileStreamInfo(buffer, 0);
  43. case QueryInformationLevel.SMB_QUERY_FILE_COMPRESSION_INFO:
  44. return new QueryFileCompressionInfo(buffer, 0);
  45. default:
  46. throw new InvalidRequestException();
  47. }
  48. }
  49. }
  50. }