Transaction2Open2Response.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* Copyright (C) 2014-2017 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. }
  34. public Transaction2Open2Response(byte[] parameters, byte[] data, bool isUnicode) : base()
  35. {
  36. FID = LittleEndianConverter.ToUInt16(parameters, 0);
  37. FileAttributes = (SMBFileAttributes)LittleEndianConverter.ToUInt16(parameters, 2);
  38. CreationTime = UTimeHelper.ReadNullableUTime(parameters, 4);
  39. FileDataSize = LittleEndianConverter.ToUInt32(parameters, 8);
  40. AccessMode = new AccessModeOptions(parameters, 12);
  41. ResourceType = (ResourceType)LittleEndianConverter.ToUInt16(parameters, 14);
  42. NMPipeStatus = new NamedPipeStatus(parameters, 16);
  43. ActionTaken = new ActionTaken(parameters, 18);
  44. Reserved = LittleEndianConverter.ToUInt32(parameters, 20);
  45. ExtendedAttributeErrorOffset = LittleEndianConverter.ToUInt16(parameters, 24);
  46. ExtendedAttributeLength = LittleEndianConverter.ToUInt32(parameters, 26);
  47. }
  48. public override byte[] GetParameters(bool isUnicode)
  49. {
  50. byte[] parameters = new byte[ParametersLength];
  51. LittleEndianWriter.WriteUInt16(parameters, 0, FID);
  52. LittleEndianWriter.WriteUInt16(parameters, 2, (ushort)FileAttributes);
  53. UTimeHelper.WriteUTime(parameters, 4, CreationTime);
  54. LittleEndianWriter.WriteUInt32(parameters, 8, FileDataSize);
  55. AccessMode.WriteBytes(parameters, 12);
  56. LittleEndianWriter.WriteUInt16(parameters, 14, (ushort)ResourceType);
  57. NMPipeStatus.WriteBytes(parameters, 16);
  58. ActionTaken.WriteBytes(parameters, 18);
  59. LittleEndianWriter.WriteUInt32(parameters, 20, Reserved);
  60. LittleEndianWriter.WriteUInt16(parameters, 24, ExtendedAttributeErrorOffset);
  61. LittleEndianWriter.WriteUInt32(parameters, 26, ExtendedAttributeLength);
  62. return parameters;
  63. }
  64. public override Transaction2SubcommandName SubcommandName
  65. {
  66. get
  67. {
  68. return Transaction2SubcommandName.TRANS2_OPEN2;
  69. }
  70. }
  71. }
  72. }