Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.2 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. cancel.cxx
  5. Abstract:
  6. This module contains the code to for Falcon Cancel routine.
  7. Author:
  8. Erez Haba (erezh) 3-Aug-95
  9. Environment:
  10. Kernel mode
  11. Revision History:
  12. --*/
  13. #include "internal.h"
  14. #ifndef MQDUMP
  15. #include "cancel.tmh"
  16. #endif
  17. BOOL
  18. NTAPI
  19. ACCancelIrp(
  20. PIRP irp,
  21. KIRQL irql,
  22. NTSTATUS status
  23. )
  24. {
  25. //
  26. // This routine MUST be called with the cancel spin lock held
  27. //
  28. irp->Cancel = TRUE;
  29. //
  30. // Obtain the address of the cancel routine, and if one was specified,
  31. // invoke it.
  32. //
  33. PDRIVER_CANCEL cr;
  34. cr = (PDRIVER_CANCEL)InterlockedExchangePointer((PVOID*)&irp->CancelRoutine, 0);
  35. if(cr != 0)
  36. {
  37. irp->CancelIrql = irql;
  38. irp->IoStatus.Status = status;
  39. cr(irp->Tail.Overlay.CurrentStackLocation->DeviceObject, irp);
  40. //
  41. // The cancel spinlock should have been released by the cancel routine.
  42. //
  43. return TRUE;
  44. }
  45. else
  46. {
  47. //
  48. // There is no cancel routine, so release the cancel spinlock and
  49. // return indicating the Irp was not currently cancelable.
  50. //
  51. IoReleaseCancelSpinLock(irql);
  52. return FALSE;
  53. }
  54. }