QueryInformation.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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_STANDARD:
  28. return new QueryInfoStandard(buffer, 0);
  29. case QueryInformationLevel.SMB_INFO_QUERY_EA_SIZE:
  30. return new QueryEASize(buffer, 0);
  31. case QueryInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST:
  32. return new QueryExtendedAttributesFromList(buffer, 0);
  33. case QueryInformationLevel.SMB_INFO_QUERY_ALL_EAS:
  34. return new QueryAllExtendedAttributes(buffer, 0);
  35. case QueryInformationLevel.SMB_QUERY_FILE_BASIC_INFO:
  36. return new QueryFileBasicInfo(buffer, 0);
  37. case QueryInformationLevel.SMB_QUERY_FILE_STANDARD_INFO:
  38. return new QueryFileStandardInfo(buffer, 0);
  39. case QueryInformationLevel.SMB_QUERY_FILE_EA_INFO:
  40. return new QueryFileExtendedAttributeInfo(buffer, 0);
  41. case QueryInformationLevel.SMB_QUERY_FILE_NAME_INFO:
  42. return new QueryFileNameInfo(buffer, 0);
  43. case QueryInformationLevel.SMB_QUERY_FILE_ALL_INFO:
  44. return new QueryFileAllInfo(buffer, 0);
  45. case QueryInformationLevel.SMB_QUERY_FILE_ALT_NAME_INFO:
  46. return new QueryFileAltNameInfo(buffer, 0);
  47. case QueryInformationLevel.SMB_QUERY_FILE_STREAM_INFO:
  48. return new QueryFileStreamInfo(buffer, 0);
  49. case QueryInformationLevel.SMB_QUERY_FILE_COMPRESSION_INFO:
  50. return new QueryFileCompressionInfo(buffer, 0);
  51. default:
  52. throw new InvalidRequestException();
  53. }
  54. }
  55. }
  56. }