| 32 | #endif |
| 33 | |
| 34 | PEXT2_IRP_CONTEXT |
| 35 | Ext2AllocateIrpContext (IN PDEVICE_OBJECT DeviceObject, |
| 36 | IN PIRP Irp ) |
| 37 | { |
| 38 | PIO_STACK_LOCATION irpSp; |
| 39 | PEXT2_IRP_CONTEXT IrpContext; |
| 40 | |
| 41 | ASSERT(DeviceObject != NULL); |
| 42 | ASSERT(Irp != NULL); |
| 43 | |
| 44 | irpSp = IoGetCurrentIrpStackLocation(Irp); |
| 45 | |
| 46 | IrpContext = (PEXT2_IRP_CONTEXT) ( |
| 47 | ExAllocateFromNPagedLookasideList( |
| 48 | &(Ext2Global->Ext2IrpContextLookasideList))); |
| 49 | |
| 50 | if (IrpContext == NULL) { |
| 51 | return NULL; |
| 52 | } |
| 53 | |
| 54 | RtlZeroMemory(IrpContext, sizeof(EXT2_IRP_CONTEXT) ); |
| 55 | |
| 56 | IrpContext->Identifier.Type = EXT2ICX; |
| 57 | IrpContext->Identifier.Size = sizeof(EXT2_IRP_CONTEXT); |
| 58 | |
| 59 | IrpContext->Irp = Irp; |
| 60 | IrpContext->MajorFunction = irpSp->MajorFunction; |
| 61 | IrpContext->MinorFunction = irpSp->MinorFunction; |
| 62 | IrpContext->DeviceObject = DeviceObject; |
| 63 | IrpContext->FileObject = irpSp->FileObject; |
| 64 | if (NULL != IrpContext->FileObject) { |
| 65 | IrpContext->Fcb = (PEXT2_FCB)IrpContext->FileObject->FsContext; |
| 66 | IrpContext->Ccb = (PEXT2_CCB)IrpContext->FileObject->FsContext2; |
| 67 | } |
| 68 | |
| 69 | if (IrpContext->FileObject != NULL) { |
| 70 | IrpContext->RealDevice = IrpContext->FileObject->DeviceObject; |
| 71 | } else if (IrpContext->MajorFunction == IRP_MJ_FILE_SYSTEM_CONTROL) { |
| 72 | if (irpSp->Parameters.MountVolume.Vpb) { |
| 73 | IrpContext->RealDevice = irpSp->Parameters.MountVolume.Vpb->RealDevice; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | if (IsFlagOn(irpSp->Flags, SL_WRITE_THROUGH)) { |
| 78 | SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_WRITE_THROUGH); |
| 79 | } |
| 80 | |
| 81 | if (IsFlagOn(irpSp->Flags, SL_OVERRIDE_VERIFY_VOLUME)) { |
| 82 | SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_VERIFY_READ); |
| 83 | } |
| 84 | |
| 85 | if (IrpContext->MajorFunction == IRP_MJ_CLEANUP || |
| 86 | IrpContext->MajorFunction == IRP_MJ_CLOSE || |
| 87 | IrpContext->MajorFunction == IRP_MJ_SHUTDOWN || |
| 88 | IrpContext->MajorFunction == IRP_MJ_FILE_SYSTEM_CONTROL || |
| 89 | IrpContext->MajorFunction == IRP_MJ_PNP ) { |
| 90 | |
| 91 | if (IrpContext->MajorFunction == IRP_MJ_FILE_SYSTEM_CONTROL || |