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.

126 lines
3.8 KiB

  1. /***************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. Dot4Usb.sys - Lower Filter Driver for Dot4.sys for USB connected
  5. IEEE 1284.4 devices.
  6. File Name:
  7. OpenClos.c
  8. Abstract:
  9. Dispatch routines for IRP_MJ_CREATE and IRP_MJ_CLOSE
  10. Environment:
  11. Kernel mode only
  12. Notes:
  13. THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  14. KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  15. IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  16. PURPOSE.
  17. Copyright (c) 2000 Microsoft Corporation. All Rights Reserved.
  18. Revision History:
  19. 01/18/2000 : created
  20. Author(s):
  21. Doug Fritz (DFritz)
  22. Joby Lafky (JobyL)
  23. ****************************************************************************/
  24. #include "pch.h"
  25. /************************************************************************/
  26. /* DispatchCreate */
  27. /************************************************************************/
  28. //
  29. // Routine Description:
  30. //
  31. // Dispatch routine for IRP_MJ_CREATE
  32. //
  33. // Arguments:
  34. //
  35. // DevObj - pointer to Device Object that is the target of the create
  36. // Irp - pointer to the create IRP
  37. //
  38. // Return Value:
  39. //
  40. // NTSTATUS
  41. //
  42. /************************************************************************/
  43. NTSTATUS
  44. DispatchCreate(
  45. IN PDEVICE_OBJECT DevObj,
  46. IN PIRP Irp
  47. )
  48. {
  49. PDEVICE_EXTENSION devExt = DevObj->DeviceExtension;
  50. NTSTATUS status = IoAcquireRemoveLock( &devExt->RemoveLock, Irp );
  51. TR_VERBOSE(("DispatchCreate"));
  52. if( NT_SUCCESS(status) ) {
  53. IoSkipCurrentIrpStackLocation( Irp );
  54. status = IoCallDriver( devExt->LowerDevObj, Irp );
  55. IoReleaseRemoveLock( &devExt->RemoveLock, Irp );
  56. } else {
  57. // unable to acquire RemoveLock - fail CREATE
  58. Irp->IoStatus.Status = status;
  59. IoCompleteRequest( Irp, IO_NO_INCREMENT );
  60. }
  61. return status;
  62. }
  63. /************************************************************************/
  64. /* DispatchClose */
  65. /************************************************************************/
  66. //
  67. // Routine Description:
  68. //
  69. // Dispatch routine for IRP_MJ_CLOSE
  70. //
  71. // Arguments:
  72. //
  73. // DevObj - pointer to Device Object that is the target of the close
  74. // Irp - pointer to the close IRP
  75. //
  76. // Return Value:
  77. //
  78. // NTSTATUS
  79. //
  80. /************************************************************************/
  81. NTSTATUS
  82. DispatchClose(
  83. IN PDEVICE_OBJECT DevObj,
  84. IN PIRP Irp
  85. )
  86. {
  87. PDEVICE_EXTENSION devExt = DevObj->DeviceExtension;
  88. NTSTATUS status = IoAcquireRemoveLock( &devExt->RemoveLock, Irp );
  89. TR_VERBOSE(("DispatchClose"));
  90. if( NT_SUCCESS(status) ) {
  91. IoSkipCurrentIrpStackLocation( Irp );
  92. status = IoCallDriver( devExt->LowerDevObj, Irp );
  93. IoReleaseRemoveLock( &devExt->RemoveLock, Irp );
  94. } else {
  95. // unable to acquire RemoveLock - succeed CLOSE anyway
  96. Irp->IoStatus.Status = STATUS_SUCCESS;
  97. IoCompleteRequest( Irp, IO_NO_INCREMENT );
  98. }
  99. return status;
  100. }