FindInformation.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. namespace SMBLibrary.SMB1
  11. {
  12. public abstract class FindInformation
  13. {
  14. private bool m_returnResumeKeys;
  15. public FindInformation(bool returnResumeKeys)
  16. {
  17. m_returnResumeKeys = returnResumeKeys;
  18. }
  19. public abstract void WriteBytes(byte[] buffer, ref int offset, bool isUnicode);
  20. public abstract int GetLength(bool isUnicode);
  21. public bool ReturnResumeKeys
  22. {
  23. get
  24. {
  25. return m_returnResumeKeys;
  26. }
  27. }
  28. public abstract FindInformationLevel InformationLevel
  29. {
  30. get;
  31. }
  32. public static FindInformation ReadEntry(byte[] buffer, ref int offset, FindInformationLevel informationLevel, bool isUnicode, bool returnResumeKeys)
  33. {
  34. switch (informationLevel)
  35. {
  36. case FindInformationLevel.SMB_FIND_FILE_DIRECTORY_INFO:
  37. return new FindFileDirectoryInfo(buffer, ref offset, isUnicode);
  38. case FindInformationLevel.SMB_FIND_FILE_FULL_DIRECTORY_INFO:
  39. return new FindFileFullDirectoryInfo(buffer, ref offset, isUnicode);
  40. case FindInformationLevel.SMB_FIND_FILE_NAMES_INFO:
  41. return new FindFileNamesInfo(buffer, ref offset, isUnicode);
  42. case FindInformationLevel.SMB_FIND_FILE_BOTH_DIRECTORY_INFO:
  43. return new FindFileBothDirectoryInfo(buffer, ref offset, isUnicode);
  44. default:
  45. throw new UnsupportedInformationLevelException();;
  46. }
  47. }
  48. }
  49. }