ShareInfo.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 SMBLibrary.RPC;
  10. using Utilities;
  11. namespace SMBLibrary.Services
  12. {
  13. /// <summary>
  14. /// [MS-SRVS] SHARE_INFO Union
  15. /// </summary>
  16. public class ShareInfo : INDRStructure
  17. {
  18. public uint Level;
  19. public IShareInfoEntry Info;
  20. public ShareInfo()
  21. {
  22. }
  23. public ShareInfo(uint level)
  24. {
  25. Level = level;
  26. }
  27. public ShareInfo(IShareInfoEntry info)
  28. {
  29. Level = info.Level;
  30. Info = info;
  31. }
  32. public ShareInfo(NDRParser parser)
  33. {
  34. Read(parser);
  35. }
  36. public void Read(NDRParser parser)
  37. {
  38. parser.BeginStructure(); // SHARE_INFO Union
  39. Level = parser.ReadUInt32();
  40. switch (Level)
  41. {
  42. case 100:
  43. ShareInfo0Entry info0 = null;
  44. parser.ReadEmbeddedStructureFullPointer<ShareInfo0Entry>(ref info0);
  45. Info = info0;
  46. break;
  47. case 101:
  48. ShareInfo1Entry info1 = null;
  49. parser.ReadEmbeddedStructureFullPointer<ShareInfo1Entry>(ref info1);
  50. Info = info1;
  51. break;
  52. default:
  53. throw new NotImplementedException();
  54. }
  55. parser.EndStructure(); // SHARE_INFO Union
  56. }
  57. public void Write(NDRWriter writer)
  58. {
  59. writer.BeginStructure(); // SHARE_INFO Union
  60. writer.WriteUInt32(Level);
  61. writer.WriteEmbeddedStructureFullPointer(Info);
  62. writer.EndStructure(); // SHARE_INFO Union
  63. }
  64. }
  65. }