TransactionSubcommandHelper.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  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 SMBLibrary.RPC;
  11. using SMBLibrary.SMB1;
  12. using SMBLibrary.Services;
  13. using Utilities;
  14. namespace SMBLibrary.Server.SMB1
  15. {
  16. public class TransactionSubcommandHelper
  17. {
  18. internal static TransactionTransactNamedPipeResponse GetSubcommandResponse(SMB1Header header, TransactionTransactNamedPipeRequest subcommand, NamedPipeShare share, SMB1ConnectionState state)
  19. {
  20. OpenedFileObject openedFile = state.GetOpenedFileObject(subcommand.FID);
  21. if (openedFile == null)
  22. {
  23. header.Status = NTStatus.STATUS_INVALID_HANDLE;
  24. return null;
  25. }
  26. TransactionTransactNamedPipeResponse response = new TransactionTransactNamedPipeResponse();
  27. openedFile.Stream.Write(subcommand.WriteData, 0, subcommand.WriteData.Length);
  28. response.ReadData = ByteReader.ReadAllBytes(openedFile.Stream);
  29. return response;
  30. }
  31. }
  32. }