mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 16:33:02 -05:00
sys: FspIopDispatchPrepare
This commit is contained in:
parent
f7d6c26d4b
commit
e0c47750d9
@ -13,6 +13,7 @@ static NTSTATUS FspFsvrtCreate(
|
||||
static NTSTATUS FspFsvolCreate(
|
||||
PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp);
|
||||
FSP_DRIVER_DISPATCH FspCreate;
|
||||
FSP_IOPREP_DISPATCH FspCreatePrepare;
|
||||
FSP_IOCMPL_DISPATCH FspCreateComplete;
|
||||
|
||||
#ifdef ALLOC_PRAGMA
|
||||
@ -20,6 +21,7 @@ FSP_IOCMPL_DISPATCH FspCreateComplete;
|
||||
#pragma alloc_text(PAGE, FspFsvrtCreate)
|
||||
#pragma alloc_text(PAGE, FspFsvolCreate)
|
||||
#pragma alloc_text(PAGE, FspCreate)
|
||||
#pragma alloc_text(PAGE, FspCreatePrepare)
|
||||
#pragma alloc_text(PAGE, FspCreateComplete)
|
||||
#endif
|
||||
|
||||
@ -347,6 +349,14 @@ NTSTATUS FspCreate(
|
||||
Irp->AssociatedIrp.SystemBuffer, IrpSp->Parameters.Create.EaLength);
|
||||
}
|
||||
|
||||
NTSTATUS FspCreatePrepare(
|
||||
PIRP Irp, FSP_FSCTL_TRANSACT_REQ *Request)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
VOID FspCreateComplete(
|
||||
PIRP Irp, const FSP_FSCTL_TRANSACT_RSP *Response)
|
||||
{
|
||||
|
@ -62,6 +62,9 @@ NTSTATUS DriverEntry(
|
||||
DriverObject->MajorFunction[IRP_MJ_QUERY_SECURITY] = FspQuerySecurity;
|
||||
DriverObject->MajorFunction[IRP_MJ_SET_SECURITY] = FspSetSecurity;
|
||||
|
||||
/* setup the I/O preparation functions */
|
||||
FspIopPrepareFunction[IRP_MJ_CREATE] = FspCreatePrepare;
|
||||
|
||||
/* setup the I/O completion functions */
|
||||
FspIopCompleteFunction[IRP_MJ_CREATE] = FspCreateComplete;
|
||||
FspIopCompleteFunction[IRP_MJ_CLOSE] = FspCloseComplete;
|
||||
|
@ -197,8 +197,13 @@ _Dispatch_type_(IRP_MJ_WRITE) FSP_DRIVER_DISPATCH FspWrite;
|
||||
/* I/O processing functions */
|
||||
_IRQL_requires_max_(APC_LEVEL)
|
||||
_IRQL_requires_same_
|
||||
typedef NTSTATUS FSP_IOPREP_DISPATCH(
|
||||
_Inout_ PIRP Irp, _Inout_ FSP_FSCTL_TRANSACT_REQ *Request);
|
||||
_IRQL_requires_max_(APC_LEVEL)
|
||||
_IRQL_requires_same_
|
||||
typedef VOID FSP_IOCMPL_DISPATCH(
|
||||
_Inout_ PIRP Irp, _In_ const FSP_FSCTL_TRANSACT_RSP *Response);
|
||||
FSP_IOPREP_DISPATCH FspCreatePrepare;
|
||||
FSP_IOCMPL_DISPATCH FspCleanupComplete;
|
||||
FSP_IOCMPL_DISPATCH FspCloseComplete;
|
||||
FSP_IOCMPL_DISPATCH FspCreateComplete;
|
||||
@ -255,6 +260,7 @@ static inline VOID FspIopCompleteRequest(PIRP Irp, NTSTATUS Result)
|
||||
{
|
||||
FspIopCompleteRequestEx(Irp, Result, TRUE);
|
||||
}
|
||||
NTSTATUS FspIopDispatchPrepare(PIRP Irp, FSP_FSCTL_TRANSACT_REQ *Request);
|
||||
VOID FspIopDispatchComplete(PIRP Irp, const FSP_FSCTL_TRANSACT_RSP *Response);
|
||||
|
||||
/* device management */
|
||||
@ -371,6 +377,7 @@ const char *IoctlCodeSym(ULONG ControlCode);
|
||||
extern PDRIVER_OBJECT FspDriverObject;
|
||||
extern PDEVICE_OBJECT FspFsctlDiskDeviceObject;
|
||||
extern PDEVICE_OBJECT FspFsctlNetDeviceObject;
|
||||
extern FSP_IOPREP_DISPATCH *FspIopPrepareFunction[];
|
||||
extern FSP_IOCMPL_DISPATCH *FspIopCompleteFunction[];
|
||||
|
||||
#endif
|
||||
|
@ -378,6 +378,7 @@ static NTSTATUS FspFsvrtTransact(
|
||||
}
|
||||
|
||||
/* wait for an IRP to arrive */
|
||||
retry:
|
||||
while (0 == (PendingIrp = FspIoqNextPendingIrp(&FsvrtDeviceExtension->Ioq, (ULONG)-1L)))
|
||||
{
|
||||
if (FspIoqStopped(&FsvrtDeviceExtension->Ioq))
|
||||
@ -392,36 +393,46 @@ static NTSTATUS FspFsvrtTransact(
|
||||
{
|
||||
PendingIrpRequest = PendingIrp->Tail.Overlay.DriverContext[0];
|
||||
|
||||
NextRequest = FspFsctlTransactProduceRequest(
|
||||
Request, PendingIrpRequest->Size, SystemBufferEnd);
|
||||
/* this should not fail as we have already checked that we have enough space */
|
||||
ASSERT(0 != NextRequest);
|
||||
|
||||
RtlCopyMemory(Request, PendingIrpRequest, PendingIrpRequest->Size);
|
||||
Request = NextRequest;
|
||||
|
||||
if (!FspIoqStartProcessingIrp(&FsvrtDeviceExtension->Ioq, PendingIrp))
|
||||
Result = FspIopDispatchPrepare(PendingIrp, PendingIrpRequest);
|
||||
if (!NT_SUCCESS(Result))
|
||||
FspIopCompleteRequest(PendingIrp, Result);
|
||||
else
|
||||
{
|
||||
/*
|
||||
* This can only happen if the Ioq was stopped. Abandon everything
|
||||
* and return STATUS_CANCELLED. Any IRP's in the Pending and Process
|
||||
* queues of the Ioq will be cancelled during FspIoqStop(). We must
|
||||
* also cancel the PendingIrp we have in our hands.
|
||||
*/
|
||||
ASSERT(FspIoqStopped(&FsvrtDeviceExtension->Ioq));
|
||||
FspIopCompleteRequest(PendingIrp, STATUS_CANCELLED);
|
||||
return STATUS_CANCELLED;
|
||||
}
|
||||
NextRequest = FspFsctlTransactProduceRequest(
|
||||
Request, PendingIrpRequest->Size, SystemBufferEnd);
|
||||
/* this should not fail as we have already checked that we have enough space */
|
||||
ASSERT(0 != NextRequest);
|
||||
|
||||
/* check that we have enough space before pulling the next pending IRP off the queue */
|
||||
if ((PUINT8)Request + FSP_FSCTL_TRANSACT_REQ_SIZEMAX > SystemBufferEnd)
|
||||
break;
|
||||
RtlCopyMemory(Request, PendingIrpRequest, PendingIrpRequest->Size);
|
||||
Request = NextRequest;
|
||||
|
||||
if (!FspIoqStartProcessingIrp(&FsvrtDeviceExtension->Ioq, PendingIrp))
|
||||
{
|
||||
/*
|
||||
* This can only happen if the Ioq was stopped. Abandon everything
|
||||
* and return STATUS_CANCELLED. Any IRP's in the Pending and Process
|
||||
* queues of the Ioq will be cancelled during FspIoqStop(). We must
|
||||
* also cancel the PendingIrp we have in our hands.
|
||||
*/
|
||||
ASSERT(FspIoqStopped(&FsvrtDeviceExtension->Ioq));
|
||||
FspIopCompleteRequest(PendingIrp, STATUS_CANCELLED);
|
||||
return STATUS_CANCELLED;
|
||||
}
|
||||
|
||||
/* check that we have enough space before pulling the next pending IRP off the queue */
|
||||
if ((PUINT8)Request + FSP_FSCTL_TRANSACT_REQ_SIZEMAX > SystemBufferEnd)
|
||||
break;
|
||||
}
|
||||
|
||||
PendingIrp = FspIoqNextPendingIrp(&FsvrtDeviceExtension->Ioq, 0);
|
||||
if (0 == PendingIrp)
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (Request == SystemBuffer)
|
||||
goto retry;
|
||||
|
||||
RtlZeroMemory(Request, SystemBufferEnd - (PUINT8)Request);
|
||||
Irp->IoStatus.Information = (PUINT8)Request - (PUINT8)SystemBuffer;
|
||||
|
||||
|
@ -8,10 +8,12 @@
|
||||
|
||||
NTSTATUS FspIopCreateRequest(
|
||||
PIRP Irp, PUNICODE_STRING FileName, ULONG ExtraSize, FSP_FSCTL_TRANSACT_REQ **PRequest);
|
||||
NTSTATUS FspIopDispatchPrepare(PIRP Irp, FSP_FSCTL_TRANSACT_REQ *Request);
|
||||
VOID FspIopDispatchComplete(PIRP Irp, const FSP_FSCTL_TRANSACT_RSP *Response);
|
||||
|
||||
#ifdef ALLOC_PRAGMA
|
||||
#pragma alloc_text(PAGE, FspIopCreateRequest)
|
||||
#pragma alloc_text(PAGE, FspIopDispatchPrepare)
|
||||
#pragma alloc_text(PAGE, FspIopDispatchComplete)
|
||||
#endif
|
||||
|
||||
@ -74,6 +76,19 @@ VOID FspIopCompleteRequestEx(PIRP Irp, NTSTATUS Result, BOOLEAN DeviceRelease)
|
||||
FspDeviceRelease(DeviceObject);
|
||||
}
|
||||
|
||||
NTSTATUS FspIopDispatchPrepare(PIRP Irp, FSP_FSCTL_TRANSACT_REQ *Request)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||
|
||||
ASSERT(IRP_MJ_MAXIMUM_FUNCTION >= IrpSp->MajorFunction);
|
||||
if (0 != FspIopPrepareFunction[IrpSp->MajorFunction])
|
||||
return FspIopPrepareFunction[IrpSp->MajorFunction](Irp, Request);
|
||||
else
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
VOID FspIopDispatchComplete(PIRP Irp, const FSP_FSCTL_TRANSACT_RSP *Response)
|
||||
{
|
||||
PAGED_CODE();
|
||||
@ -86,4 +101,5 @@ VOID FspIopDispatchComplete(PIRP Irp, const FSP_FSCTL_TRANSACT_RSP *Response)
|
||||
FspIopCompleteFunction[IrpSp->MajorFunction](Irp, Response);
|
||||
}
|
||||
|
||||
FSP_IOPREP_DISPATCH *FspIopPrepareFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
|
||||
FSP_IOCMPL_DISPATCH *FspIopCompleteFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
|
||||
|
Loading…
x
Reference in New Issue
Block a user