2
0

SmbComNtTransaction.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. namespace SharpCifs.Smb
  18. {
  19. internal abstract class SmbComNtTransaction : SmbComTransaction
  20. {
  21. private const int NttPrimarySetupOffset = 69;
  22. private const int NttSecondaryParameterOffset = 51;
  23. internal const int NtTransactQuerySecurityDesc = 6;
  24. internal int Function;
  25. public SmbComNtTransaction()
  26. {
  27. // relative to headerStart
  28. primarySetupOffset = NttPrimarySetupOffset;
  29. secondaryParameterOffset = NttSecondaryParameterOffset;
  30. }
  31. internal override int WriteParameterWordsWireFormat(byte[] dst, int dstIndex)
  32. {
  33. int start = dstIndex;
  34. if (Command != SmbComNtTransactSecondary)
  35. {
  36. dst[dstIndex++] = MaxSetupCount;
  37. }
  38. else
  39. {
  40. dst[dstIndex++] = unchecked(unchecked(0x00));
  41. }
  42. // Reserved
  43. dst[dstIndex++] = unchecked(unchecked(0x00));
  44. // Reserved
  45. dst[dstIndex++] = unchecked(unchecked(0x00));
  46. // Reserved
  47. WriteInt4(TotalParameterCount, dst, dstIndex);
  48. dstIndex += 4;
  49. WriteInt4(TotalDataCount, dst, dstIndex);
  50. dstIndex += 4;
  51. if (Command != SmbComNtTransactSecondary)
  52. {
  53. WriteInt4(MaxParameterCount, dst, dstIndex);
  54. dstIndex += 4;
  55. WriteInt4(MaxDataCount, dst, dstIndex);
  56. dstIndex += 4;
  57. }
  58. WriteInt4(ParameterCount, dst, dstIndex);
  59. dstIndex += 4;
  60. WriteInt4((ParameterCount == 0 ? 0 : ParameterOffset), dst, dstIndex);
  61. dstIndex += 4;
  62. if (Command == SmbComNtTransactSecondary)
  63. {
  64. WriteInt4(ParameterDisplacement, dst, dstIndex);
  65. dstIndex += 4;
  66. }
  67. WriteInt4(DataCount, dst, dstIndex);
  68. dstIndex += 4;
  69. WriteInt4((DataCount == 0 ? 0 : DataOffset), dst, dstIndex);
  70. dstIndex += 4;
  71. if (Command == SmbComNtTransactSecondary)
  72. {
  73. WriteInt4(DataDisplacement, dst, dstIndex);
  74. dstIndex += 4;
  75. dst[dstIndex++] = unchecked(unchecked(0x00));
  76. }
  77. else
  78. {
  79. // Reserved1
  80. dst[dstIndex++] = unchecked((byte)SetupCount);
  81. WriteInt2(Function, dst, dstIndex);
  82. dstIndex += 2;
  83. dstIndex += WriteSetupWireFormat(dst, dstIndex);
  84. }
  85. return dstIndex - start;
  86. }
  87. }
  88. }