2 * FFS File System Driver for Windows
8 * Lee Jae-Hong, http://www.pyrasis.com
19 extern PFFS_GLOBAL FFSGlobal
;
25 //#pragma alloc_text(PAGE, FFSExceptionFilter)
26 //#pragma alloc_text(PAGE, FFSExceptionHandler)
32 IN PFFS_IRP_CONTEXT IrpContext
,
33 IN PEXCEPTION_POINTERS ExceptionPointer
)
35 NTSTATUS Status
, ExceptionCode
;
36 PEXCEPTION_RECORD ExceptRecord
;
38 ExceptRecord
= ExceptionPointer
->ExceptionRecord
;
40 ExceptionCode
= ExceptRecord
->ExceptionCode
;
45 // Check IrpContext is valid or not
50 if ((IrpContext
->Identifier
.Type
!= FFSICX
) ||
51 (IrpContext
->Identifier
.Size
!= sizeof(FFS_IRP_CONTEXT
)))
58 if (FsRtlIsNtstatusExpected(ExceptionCode
))
60 return EXCEPTION_EXECUTE_HANDLER
;
64 FFSBugCheck(FFS_BUGCHK_EXCEPT
, (ULONG_PTR
)ExceptRecord
,
65 (ULONG_PTR
)ExceptionPointer
->ContextRecord
,
66 (ULONG_PTR
)ExceptRecord
->ExceptionAddress
);
71 // For the purposes of processing this exception, let's mark this
72 // request as being able to wait, and neither write through nor on
73 // removable media if we aren't posting it.
76 SetFlag(IrpContext
->Flags
, IRP_CONTEXT_FLAG_WAIT
);
78 if (FsRtlIsNtstatusExpected(ExceptionCode
))
81 // If the exception is expected execute our handler
84 FFSPrint((DBG_ERROR
, "FFSExceptionFilter: Catching exception %xh\n",
87 Status
= EXCEPTION_EXECUTE_HANDLER
;
91 IrpContext
->ExceptionInProgress
= TRUE
;
92 IrpContext
->ExceptionCode
= ExceptionCode
;
98 // Continue search for an higher level exception handler
101 FFSPrint((DBG_ERROR
, "FFSExceptionFilter: Passing on exception %#x\n",
104 Status
= EXCEPTION_CONTINUE_SEARCH
;
108 FFSFreeIrpContext(IrpContext
);
118 IN PFFS_IRP_CONTEXT IrpContext
)
126 if ((IrpContext
->Identifier
.Type
!= FFSICX
) ||
127 (IrpContext
->Identifier
.Size
!= sizeof(FFS_IRP_CONTEXT
)))
130 return STATUS_UNSUCCESSFUL
;
133 Status
= IrpContext
->ExceptionCode
;
138 // Check if this error is a result of user actions
141 PIRP Irp
= IrpContext
->Irp
;
144 if (IoIsErrorUserInduced(Status
))
147 // Now we will generate a pop-up to user
150 PDEVICE_OBJECT RealDevice
;
154 if (IoGetCurrentIrpStackLocation(Irp
)->FileObject
!= NULL
)
156 Vpb
= IoGetCurrentIrpStackLocation(Irp
)->FileObject
->Vpb
;
160 // Get the initial thread
163 Thread
= Irp
->Tail
.Overlay
.Thread
;
164 RealDevice
= IoGetDeviceToVerify(Thread
);
166 if (RealDevice
== NULL
)
169 // Get current thread
172 Thread
= PsGetCurrentThread();
173 RealDevice
= IoGetDeviceToVerify(Thread
);
175 ASSERT(RealDevice
!= NULL
);
178 if (RealDevice
!= NULL
)
181 // Now we pop-up the error dialog ...
184 IoMarkIrpPending(Irp
);
185 IoRaiseHardError(Irp
, Vpb
, RealDevice
);
187 IoSetDeviceToVerify(Thread
, NULL
);
189 Status
= STATUS_PENDING
;
194 IrpContext
->Irp
->IoStatus
.Status
= Status
;
196 FFSCompleteRequest(IrpContext
->Irp
, FALSE
, IO_NO_INCREMENT
);
201 FFSFreeIrpContext(IrpContext
);
205 Status
= STATUS_INSUFFICIENT_RESOURCES
;