NetShareEnum.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // This code is derived from jcifs smb client library <jcifs at samba dot org>
  2. // Ported by J. Arturo <webmaster at komodosoft dot net>
  3. //
  4. // This library is free software; you can redistribute it and/or
  5. // modify it under the terms of the GNU Lesser General Public
  6. // License as published by the Free Software Foundation; either
  7. // version 2.1 of the License, or (at your option) any later version.
  8. //
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. // Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public
  15. // License along with this library; if not, write to the Free Software
  16. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. using System;
  18. using SharpCifs.Util.Sharpen;
  19. namespace SharpCifs.Smb
  20. {
  21. internal class NetShareEnum : SmbComTransaction
  22. {
  23. private static readonly string Descr = "WrLeh\u0000B13BWz\u0000";
  24. public NetShareEnum()
  25. {
  26. Command = SmbComTransaction;
  27. SubCommand = NetShareEnum;
  28. // not really true be used by upper logic
  29. Name ="\\PIPE\\LANMAN";
  30. MaxParameterCount = 8;
  31. // maxDataCount = 4096; why was this set?
  32. MaxSetupCount = 0x00;
  33. SetupCount = 0;
  34. Timeout = 5000;
  35. }
  36. internal override int WriteSetupWireFormat(byte[] dst, int dstIndex)
  37. {
  38. return 0;
  39. }
  40. internal override int WriteParametersWireFormat(byte[] dst, int dstIndex)
  41. {
  42. int start = dstIndex;
  43. byte[] descr;
  44. try
  45. {
  46. //descr = Runtime.GetBytesForString(Descr, "ASCII");
  47. descr = Runtime.GetBytesForString(Descr, "UTF-8");
  48. }
  49. catch (UnsupportedEncodingException)
  50. {
  51. return 0;
  52. }
  53. WriteInt2(NetShareEnum, dst, dstIndex);
  54. dstIndex += 2;
  55. Array.Copy(descr, 0, dst, dstIndex, descr.Length);
  56. dstIndex += descr.Length;
  57. WriteInt2(unchecked(0x0001), dst, dstIndex);
  58. dstIndex += 2;
  59. WriteInt2(MaxDataCount, dst, dstIndex);
  60. dstIndex += 2;
  61. return dstIndex - start;
  62. }
  63. internal override int WriteDataWireFormat(byte[] dst, int dstIndex)
  64. {
  65. return 0;
  66. }
  67. internal override int ReadSetupWireFormat(byte[] buffer, int bufferIndex, int len
  68. )
  69. {
  70. return 0;
  71. }
  72. internal override int ReadParametersWireFormat(byte[] buffer, int bufferIndex, int
  73. len)
  74. {
  75. return 0;
  76. }
  77. internal override int ReadDataWireFormat(byte[] buffer, int bufferIndex, int len)
  78. {
  79. return 0;
  80. }
  81. public override string ToString()
  82. {
  83. return "NetShareEnum[" + base.ToString() + "]";
  84. }
  85. }
  86. }