FindInformation.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. 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 static FindInformation ReadEntry(byte[] buffer, ref int offset, FindInformationLevel informationLevel, bool isUnicode, bool returnResumeKeys)
  29. {
  30. switch (informationLevel)
  31. {
  32. case FindInformationLevel.SMB_FIND_FILE_DIRECTORY_INFO:
  33. return new FindFileDirectoryInfo(buffer, ref offset, isUnicode);
  34. case FindInformationLevel.SMB_FIND_FILE_FULL_DIRECTORY_INFO:
  35. return new FindFileFullDirectoryInfo(buffer, ref offset, isUnicode);
  36. case FindInformationLevel.SMB_FIND_FILE_NAMES_INFO:
  37. return new FindFileNamesInfo(buffer, ref offset, isUnicode);
  38. case FindInformationLevel.SMB_FIND_FILE_BOTH_DIRECTORY_INFO:
  39. return new FindFileBothDirectoryInfo(buffer, ref offset, isUnicode);
  40. default:
  41. throw new InvalidRequestException();;
  42. }
  43. }
  44. }
  45. }