FindInformation.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. public uint NextEntryOffset;
  15. public FindInformation()
  16. {
  17. }
  18. public abstract void WriteBytes(byte[] buffer, ref int offset, bool isUnicode);
  19. public abstract int GetLength(bool isUnicode);
  20. public abstract FindInformationLevel InformationLevel
  21. {
  22. get;
  23. }
  24. public static FindInformation ReadEntry(byte[] buffer, int offset, FindInformationLevel informationLevel, bool isUnicode)
  25. {
  26. switch (informationLevel)
  27. {
  28. case FindInformationLevel.SMB_FIND_FILE_DIRECTORY_INFO:
  29. return new FindFileDirectoryInfo(buffer, offset, isUnicode);
  30. case FindInformationLevel.SMB_FIND_FILE_FULL_DIRECTORY_INFO:
  31. return new FindFileFullDirectoryInfo(buffer, offset, isUnicode);
  32. case FindInformationLevel.SMB_FIND_FILE_NAMES_INFO:
  33. return new FindFileNamesInfo(buffer, offset, isUnicode);
  34. case FindInformationLevel.SMB_FIND_FILE_BOTH_DIRECTORY_INFO:
  35. return new FindFileBothDirectoryInfo(buffer, offset, isUnicode);
  36. case FindInformationLevel.SMB_FIND_FILE_ID_FULL_DIRECTORY_INFO:
  37. return new FindFileIDFullDirectoryInfo(buffer, offset, isUnicode);
  38. case FindInformationLevel.SMB_FIND_FILE_ID_BOTH_DIRECTORY_INFO:
  39. return new FindFileIDBothDirectoryInfo(buffer, offset, isUnicode);
  40. default:
  41. throw new UnsupportedInformationLevelException();
  42. }
  43. }
  44. }
  45. }