ShareInfo.cs 2.1 KB

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