TransCallNamedPipe.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. namespace SharpCifs.Smb
  19. {
  20. internal class TransCallNamedPipe : SmbComTransaction
  21. {
  22. private byte[] _pipeData;
  23. private int _pipeDataOff;
  24. private int _pipeDataLen;
  25. internal TransCallNamedPipe(string pipeName, byte[] data, int off, int len)
  26. {
  27. Name = pipeName;
  28. _pipeData = data;
  29. _pipeDataOff = off;
  30. _pipeDataLen = len;
  31. Command = SmbComTransaction;
  32. SubCommand = TransCallNamedPipe;
  33. Timeout = unchecked((int)(0xFFFFFFFF));
  34. MaxParameterCount = 0;
  35. MaxDataCount = unchecked(0xFFFF);
  36. MaxSetupCount = unchecked(unchecked(0x00));
  37. SetupCount = 2;
  38. }
  39. internal override int WriteSetupWireFormat(byte[] dst, int dstIndex)
  40. {
  41. dst[dstIndex++] = SubCommand;
  42. dst[dstIndex++] = unchecked(unchecked(0x00));
  43. // this says "Transaction priority" in netmon
  44. dst[dstIndex++] = unchecked(unchecked(0x00));
  45. // no FID
  46. dst[dstIndex++] = unchecked(unchecked(0x00));
  47. return 4;
  48. }
  49. internal override int ReadSetupWireFormat(byte[] buffer, int bufferIndex, int len
  50. )
  51. {
  52. return 0;
  53. }
  54. internal override int WriteParametersWireFormat(byte[] dst, int dstIndex)
  55. {
  56. return 0;
  57. }
  58. internal override int WriteDataWireFormat(byte[] dst, int dstIndex)
  59. {
  60. if ((dst.Length - dstIndex) < _pipeDataLen)
  61. {
  62. if (Log.Level >= 3)
  63. {
  64. Log.WriteLine("TransCallNamedPipe data too long for buffer");
  65. }
  66. return 0;
  67. }
  68. Array.Copy(_pipeData, _pipeDataOff, dst, dstIndex, _pipeDataLen);
  69. return _pipeDataLen;
  70. }
  71. internal override int ReadParametersWireFormat(byte[] buffer, int bufferIndex, int
  72. len)
  73. {
  74. return 0;
  75. }
  76. internal override int ReadDataWireFormat(byte[] buffer, int bufferIndex, int len)
  77. {
  78. return 0;
  79. }
  80. public override string ToString()
  81. {
  82. return "TransCallNamedPipe[" + base.ToString() + ",pipeName=" + Name +
  83. "]";
  84. }
  85. }
  86. }