CancelHelper.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /* Copyright (C) 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 SMBLibrary.SMB1;
  10. using Utilities;
  11. namespace SMBLibrary.Server.SMB1
  12. {
  13. internal class CancelHelper
  14. {
  15. internal static void ProcessNTCancelRequest(SMB1Header header, NTCancelRequest request, ISMBShare share, SMB1ConnectionState state)
  16. {
  17. SMB1Session session = state.GetSession(header.UID);
  18. SMB1AsyncContext context = state.GetAsyncContext(header.UID, header.TID, header.PID, header.MID);
  19. if (context != null)
  20. {
  21. NTStatus status = share.FileStore.Cancel(context.IORequest);
  22. OpenFileObject openFile = session.GetOpenFileObject(context.FileID);
  23. if (openFile != null)
  24. {
  25. state.LogToServer(Severity.Information, "Cancel: Requested cancel on '{0}{1}', NTStatus: {2}. PID: {3}. MID: {4}.", share.Name, openFile.Path, status, context.PID, context.MID);
  26. }
  27. if (status == NTStatus.STATUS_SUCCESS || status == NTStatus.STATUS_CANCELLED)
  28. {
  29. state.RemoveAsyncContext(context);
  30. }
  31. }
  32. }
  33. }
  34. }