TransCallNamedPipe.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. return 0;
  52. }
  53. internal override int WriteParametersWireFormat(byte[] dst, int dstIndex)
  54. {
  55. return 0;
  56. }
  57. internal override int WriteDataWireFormat(byte[] dst, int dstIndex)
  58. {
  59. if ((dst.Length - dstIndex) < _pipeDataLen)
  60. {
  61. if (Log.Level >= 3)
  62. {
  63. Log.WriteLine("TransCallNamedPipe data too long for buffer");
  64. }
  65. return 0;
  66. }
  67. Array.Copy(_pipeData, _pipeDataOff, dst, dstIndex, _pipeDataLen);
  68. return _pipeDataLen;
  69. }
  70. internal override int ReadParametersWireFormat(byte[] buffer,
  71. int bufferIndex,
  72. int 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["
  83. + base.ToString()
  84. + ",pipeName=" + Name + "]";
  85. }
  86. }
  87. }