ShareInfo2Entry.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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_2
  16. /// </summary>
  17. public class ShareInfo2Entry : IShareInfoEntry
  18. {
  19. public const uint UnlimitedConnections = 0xFFFFFFFF;
  20. public NDRUnicodeString NetName;
  21. public ShareTypeExtended ShareType;
  22. public NDRUnicodeString Remark;
  23. public Permissions Permissions; // Windows will leave this field empty (0)
  24. public uint MaxUses; // Maximum number of concurrent connections that the shared resource can accommodate.
  25. public uint CurrentUses; // Number of current connections to the resource.
  26. public NDRUnicodeString Path; // Windows will set this field to the on-disk path (.e.g 'D:\Shared')
  27. public NDRUnicodeString Password; // Windows will set it to null
  28. public ShareInfo2Entry()
  29. {
  30. }
  31. public ShareInfo2Entry(string shareName, ShareTypeExtended shareType)
  32. {
  33. NetName = new NDRUnicodeString(shareName);
  34. ShareType = shareType;
  35. Remark = new NDRUnicodeString(String.Empty);
  36. MaxUses = UnlimitedConnections;
  37. Path = new NDRUnicodeString(String.Empty);
  38. Password = null;
  39. }
  40. public ShareInfo2Entry(NDRParser parser)
  41. {
  42. Read(parser);
  43. }
  44. public void Read(NDRParser parser)
  45. {
  46. parser.BeginStructure();
  47. parser.ReadEmbeddedStructureFullPointer(ref NetName);
  48. ShareType = new ShareTypeExtended(parser);
  49. parser.ReadEmbeddedStructureFullPointer(ref Remark);
  50. Permissions = (Permissions)parser.ReadUInt32();
  51. MaxUses = parser.ReadUInt32();
  52. CurrentUses = parser.ReadUInt32();
  53. parser.ReadEmbeddedStructureFullPointer(ref Path);
  54. parser.ReadEmbeddedStructureFullPointer(ref Password);
  55. parser.EndStructure();
  56. }
  57. public void Write(NDRWriter writer)
  58. {
  59. writer.BeginStructure();
  60. writer.WriteEmbeddedStructureFullPointer(NetName);
  61. ShareType.Write(writer);
  62. writer.WriteEmbeddedStructureFullPointer(Remark);
  63. writer.WriteUInt32((uint)Permissions);
  64. writer.WriteUInt32(MaxUses);
  65. writer.WriteUInt32(CurrentUses);
  66. writer.WriteEmbeddedStructureFullPointer(Path);
  67. writer.WriteEmbeddedStructureFullPointer(Password);
  68. writer.EndStructure();
  69. }
  70. public uint Level
  71. {
  72. get
  73. {
  74. return 2;
  75. }
  76. }
  77. }
  78. }