Transaction2Open2Response.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 Utilities;
  11. namespace SMBLibrary.SMB1
  12. {
  13. /// <summary>
  14. /// TRANS2_OPEN2 Response
  15. /// </summary>
  16. public class Transaction2Open2Response : Transaction2Subcommand
  17. {
  18. public int ParametersLength = 30;
  19. // Parameters
  20. public ushort FID;
  21. public SMBFileAttributes FileAttributes;
  22. public DateTime CreationTime;
  23. public uint FileDataSize;
  24. public AccessModeOptions AccessMode;
  25. public ResourceType ResourceType;
  26. public NamedPipeStatus NMPipeStatus;
  27. public ActionTaken ActionTaken;
  28. public uint Reserved;
  29. public ushort ExtendedAttributeErrorOffset;
  30. public uint ExtendedAttributeLength;
  31. public Transaction2Open2Response() : base()
  32. {
  33. CreationTime = SMB1Helper.FileTimeNotSpecified;
  34. }
  35. public Transaction2Open2Response(byte[] parameters, byte[] data, bool isUnicode) : base()
  36. {
  37. FID = LittleEndianConverter.ToUInt16(parameters, 0);
  38. FileAttributes = (SMBFileAttributes)LittleEndianConverter.ToUInt16(parameters, 2);
  39. CreationTime = SMB1Helper.ReadUTime(parameters, 4);
  40. FileDataSize = LittleEndianConverter.ToUInt32(parameters, 8);
  41. AccessMode = new AccessModeOptions(parameters, 12);
  42. ResourceType = (ResourceType)LittleEndianConverter.ToUInt16(parameters, 14);
  43. NMPipeStatus = new NamedPipeStatus(parameters, 16);
  44. ActionTaken = new ActionTaken(parameters, 18);
  45. Reserved = LittleEndianConverter.ToUInt32(parameters, 20);
  46. ExtendedAttributeErrorOffset = LittleEndianConverter.ToUInt16(parameters, 24);
  47. ExtendedAttributeLength = LittleEndianConverter.ToUInt32(parameters, 26);
  48. }
  49. public override byte[] GetParameters(bool isUnicode)
  50. {
  51. byte[] parameters = new byte[ParametersLength];
  52. LittleEndianWriter.WriteUInt16(parameters, 0, FID);
  53. LittleEndianWriter.WriteUInt16(parameters, 2, (ushort)FileAttributes);
  54. SMB1Helper.WriteUTime(parameters, 4, CreationTime);
  55. LittleEndianWriter.WriteUInt32(parameters, 8, FileDataSize);
  56. AccessMode.WriteBytes(parameters, 12);
  57. LittleEndianWriter.WriteUInt16(parameters, 14, (ushort)ResourceType);
  58. NMPipeStatus.WriteBytes(parameters, 16);
  59. ActionTaken.WriteBytes(parameters, 18);
  60. LittleEndianWriter.WriteUInt32(parameters, 20, Reserved);
  61. LittleEndianWriter.WriteUInt16(parameters, 24, ExtendedAttributeErrorOffset);
  62. LittleEndianWriter.WriteUInt32(parameters, 26, ExtendedAttributeLength);
  63. return parameters;
  64. }
  65. public override Transaction2SubcommandName SubcommandName
  66. {
  67. get
  68. {
  69. return Transaction2SubcommandName.TRANS2_OPEN2;
  70. }
  71. }
  72. }
  73. }