Leaked source code of windows server 2003
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.

37 lines
1.0 KiB

  1. #include "pch.h"
  2. NTSTATUS
  3. PptFdoClose(
  4. IN PDEVICE_OBJECT DeviceObject,
  5. IN PIRP Irp
  6. )
  7. {
  8. PFDO_EXTENSION fdx = DeviceObject->DeviceExtension;
  9. PAGED_CODE();
  10. //
  11. // Always succeed an IRP_MJ_CLOSE.
  12. //
  13. //
  14. // Keep running count of CREATE requests vs CLOSE requests.
  15. //
  16. ExAcquireFastMutex( &fdx->OpenCloseMutex );
  17. if( fdx->OpenCloseRefCount > 0 ) {
  18. //
  19. // prevent rollover - strange as it may seem, it is perfectly
  20. // legal for us to receive more closes than creates - this
  21. // info came directly from Mr. PnP himself
  22. //
  23. if( ((LONG)InterlockedDecrement( &fdx->OpenCloseRefCount )) < 0 ) {
  24. // handle underflow
  25. InterlockedIncrement( &fdx->OpenCloseRefCount );
  26. }
  27. }
  28. ExReleaseFastMutex( &fdx->OpenCloseMutex );
  29. DD((PCE)fdx,DDT,"PptFdoClose - OpenCloseRefCount after close = %d\n", fdx->OpenCloseRefCount);
  30. return P4CompleteRequest( Irp, STATUS_SUCCESS, 0 );
  31. }