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.

73 lines
2.0 KiB

  1. #include "pch.h"
  2. NTSTATUS
  3. PptFdoCreateOpen(
  4. IN PDEVICE_OBJECT DeviceObject,
  5. IN PIRP Irp
  6. )
  7. /*++
  8. Routine Description:
  9. This is the dispatch function for IRP_MJ_CREATE.
  10. Arguments:
  11. DeviceObject - The target device object for the request.
  12. Irp - The I/O request packet.
  13. Return Value:
  14. STATUS_SUCCESS - If Success.
  15. STATUS_DELETE_PENDING - If this device is in the process of being removed
  16. and will go away as soon as all outstanding
  17. requests are cleaned up.
  18. --*/
  19. {
  20. PFDO_EXTENSION fdx = DeviceObject->DeviceExtension;
  21. NTSTATUS status = STATUS_SUCCESS;
  22. PAGED_CODE();
  23. //
  24. // Verify that our device has not been SUPRISE_REMOVED. Generally
  25. // only parallel ports on hot-plug busses (e.g., PCMCIA) and
  26. // parallel ports in docking stations will be surprise removed.
  27. //
  28. // dvdf - RMT - It would probably be a good idea to also check
  29. // here if we are in a "paused" state (stop-pending, stopped, or
  30. // remove-pending) and queue the request until we either return to
  31. // a fully functional state or are removed.
  32. //
  33. if( fdx->PnpState & PPT_DEVICE_SURPRISE_REMOVED ) {
  34. return P4CompleteRequest( Irp, STATUS_DELETE_PENDING, Irp->IoStatus.Information );
  35. }
  36. //
  37. // Try to acquire RemoveLock to prevent the device object from going
  38. // away while we're using it.
  39. //
  40. status = PptAcquireRemoveLockOrFailIrp( DeviceObject, Irp );
  41. if ( !NT_SUCCESS(status) ) {
  42. return status;
  43. }
  44. //
  45. // We have the RemoveLock - handle CREATE
  46. //
  47. ExAcquireFastMutex(&fdx->OpenCloseMutex);
  48. InterlockedIncrement(&fdx->OpenCloseRefCount);
  49. ExReleaseFastMutex(&fdx->OpenCloseMutex);
  50. DD((PCE)fdx,DDT,"PptFdoCreateOpen - SUCCEED - new OpenCloseRefCount=%d\n",fdx->OpenCloseRefCount);
  51. PptReleaseRemoveLock(&fdx->RemoveLock, Irp);
  52. P4CompleteRequest( Irp, status, 0 );
  53. return status;
  54. }