SetInformation.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. using Utilities;
  11. namespace SMBLibrary.SMB1
  12. {
  13. public abstract class SetInformation
  14. {
  15. public abstract byte[] GetBytes();
  16. public abstract SetInformationLevel InformationLevel
  17. {
  18. get;
  19. }
  20. public static SetInformation GetSetInformation(byte[] buffer, SetInformationLevel informationLevel)
  21. {
  22. switch (informationLevel)
  23. {
  24. case SetInformationLevel.SMB_INFO_STANDARD:
  25. return new SetInfoStandard(buffer);
  26. case SetInformationLevel.SMB_INFO_SET_EAS:
  27. return new SetExtendedAttributes(buffer);
  28. case SetInformationLevel.SMB_SET_FILE_BASIC_INFO:
  29. return new SetFileBasicInfo(buffer);
  30. case SetInformationLevel.SMB_SET_FILE_DISPOSITION_INFO:
  31. return new SetFileDispositionInfo(buffer);
  32. case SetInformationLevel.SMB_SET_FILE_ALLOCATION_INFO:
  33. return new SetFileAllocationInfo(buffer);
  34. case SetInformationLevel.SMB_SET_FILE_END_OF_FILE_INFO:
  35. return new SetFileEndOfFileInfo(buffer);
  36. default:
  37. throw new UnsupportedInformationLevelException();
  38. }
  39. }
  40. }
  41. }