mirror of https://github.com/tongzx/nt5src
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
73 lines
2.0 KiB
#include "pch.h"
|
|
|
|
NTSTATUS
|
|
PptFdoCreateOpen(
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
IN PIRP Irp
|
|
)
|
|
/*++
|
|
|
|
Routine Description:
|
|
|
|
This is the dispatch function for IRP_MJ_CREATE.
|
|
|
|
Arguments:
|
|
|
|
DeviceObject - The target device object for the request.
|
|
|
|
Irp - The I/O request packet.
|
|
|
|
Return Value:
|
|
|
|
STATUS_SUCCESS - If Success.
|
|
|
|
STATUS_DELETE_PENDING - If this device is in the process of being removed
|
|
and will go away as soon as all outstanding
|
|
requests are cleaned up.
|
|
|
|
--*/
|
|
{
|
|
PFDO_EXTENSION fdx = DeviceObject->DeviceExtension;
|
|
NTSTATUS status = STATUS_SUCCESS;
|
|
|
|
PAGED_CODE();
|
|
|
|
//
|
|
// Verify that our device has not been SUPRISE_REMOVED. Generally
|
|
// only parallel ports on hot-plug busses (e.g., PCMCIA) and
|
|
// parallel ports in docking stations will be surprise removed.
|
|
//
|
|
// dvdf - RMT - It would probably be a good idea to also check
|
|
// here if we are in a "paused" state (stop-pending, stopped, or
|
|
// remove-pending) and queue the request until we either return to
|
|
// a fully functional state or are removed.
|
|
//
|
|
if( fdx->PnpState & PPT_DEVICE_SURPRISE_REMOVED ) {
|
|
return P4CompleteRequest( Irp, STATUS_DELETE_PENDING, Irp->IoStatus.Information );
|
|
}
|
|
|
|
|
|
//
|
|
// Try to acquire RemoveLock to prevent the device object from going
|
|
// away while we're using it.
|
|
//
|
|
status = PptAcquireRemoveLockOrFailIrp( DeviceObject, Irp );
|
|
if ( !NT_SUCCESS(status) ) {
|
|
return status;
|
|
}
|
|
|
|
//
|
|
// We have the RemoveLock - handle CREATE
|
|
//
|
|
ExAcquireFastMutex(&fdx->OpenCloseMutex);
|
|
InterlockedIncrement(&fdx->OpenCloseRefCount);
|
|
ExReleaseFastMutex(&fdx->OpenCloseMutex);
|
|
|
|
DD((PCE)fdx,DDT,"PptFdoCreateOpen - SUCCEED - new OpenCloseRefCount=%d\n",fdx->OpenCloseRefCount);
|
|
|
|
PptReleaseRemoveLock(&fdx->RemoveLock, Irp);
|
|
|
|
P4CompleteRequest( Irp, status, 0 );
|
|
|
|
return status;
|
|
}
|