ReactOS  0.4.13-dev-544-gede3fdd
except.c File Reference
#include "ntifs.h"
#include "ffsdrv.h"
Include dependency graph for except.c:

Go to the source code of this file.

Functions

NTSTATUS FFSExceptionFilter (IN PFFS_IRP_CONTEXT IrpContext, IN PEXCEPTION_POINTERS ExceptionPointer)
 
NTSTATUS FFSExceptionHandler (IN PFFS_IRP_CONTEXT IrpContext)
 

Variables

PFFS_GLOBAL FFSGlobal
 

Function Documentation

◆ FFSExceptionFilter()

NTSTATUS FFSExceptionFilter ( IN PFFS_IRP_CONTEXT  IrpContext,
IN PEXCEPTION_POINTERS  ExceptionPointer 
)

Definition at line 31 of file except.c.

34 {
36  PEXCEPTION_RECORD ExceptRecord;
37 
38  ExceptRecord = ExceptionPointer->ExceptionRecord;
39 
40  ExceptionCode = ExceptRecord->ExceptionCode;
41 
42  FFSBreakPoint();
43 
44  //
45  // Check IrpContext is valid or not
46  //
47 
48  if (IrpContext)
49  {
50  if ((IrpContext->Identifier.Type != FFSICX) ||
51  (IrpContext->Identifier.Size != sizeof(FFS_IRP_CONTEXT)))
52  {
53  IrpContext = NULL;
54  }
55  }
56  else
57  {
59  {
61  }
62  else
63  {
65  (ULONG_PTR)ExceptionPointer->ContextRecord,
66  (ULONG_PTR)ExceptRecord->ExceptionAddress);
67  }
68  }
69 
70  //
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.
74  //
75 
76  SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT);
77 
79  {
80  //
81  // If the exception is expected execute our handler
82  //
83 
84  FFSPrint((DBG_ERROR, "FFSExceptionFilter: Catching exception %xh\n",
85  ExceptionCode));
86 
88 
89  if (IrpContext)
90  {
91  IrpContext->ExceptionInProgress = TRUE;
92  IrpContext->ExceptionCode = ExceptionCode;
93  }
94  }
95  else
96  {
97  //
98  // Continue search for an higher level exception handler
99  //
100 
101  FFSPrint((DBG_ERROR, "FFSExceptionFilter: Passing on exception %#x\n",
102  ExceptionCode));
103 
105 
106  if (IrpContext)
107  {
108  FFSFreeIrpContext(IrpContext);
109  }
110  }
111 
112  return Status;
113 }
_Inout_ PIRP _In_ NTSTATUS ExceptionCode
Definition: cdprocs.h:1782
BOOLEAN NTAPI FsRtlIsNtstatusExpected(IN NTSTATUS NtStatus)
Definition: filter.c:61
#define TRUE
Definition: types.h:120
#define IRP_CONTEXT_FLAG_WAIT
Definition: cdstruc.h:1221
LONG NTSTATUS
Definition: precomp.h:26
#define FFSBugCheck(A, B, C, D)
Definition: ffsdrv.h:194
__drv_mustHoldCriticalRegion VOID FFSFreeIrpContext(IN PFFS_IRP_CONTEXT IrpContext)
Definition: memory.c:179
Definition: ffsdrv.h:283
#define FFSBreakPoint()
Definition: ffsdrv.h:43
uint32_t ULONG_PTR
Definition: typedefs.h:63
DWORD ExceptionCode
Definition: compat.h:196
#define EXCEPTION_CONTINUE_SEARCH
Definition: excpt.h:86
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define DBG_ERROR
Definition: ffsdrv.h:1031
Status
Definition: gdiplustypes.h:24
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
struct _EXCEPTION_RECORD * ExceptionRecord
Definition: compat.h:198
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define FFS_BUGCHK_EXCEPT
Definition: ffsdrv.h:177

Referenced by FFSBuildRequest(), FFSDeQueueCloseRequest(), and FFSDeQueueRequest().

◆ FFSExceptionHandler()

NTSTATUS FFSExceptionHandler ( IN PFFS_IRP_CONTEXT  IrpContext)

Definition at line 117 of file except.c.

119 {
121 
122  FFSBreakPoint();
123 
124  if (IrpContext)
125  {
126  if ((IrpContext->Identifier.Type != FFSICX) ||
127  (IrpContext->Identifier.Size != sizeof(FFS_IRP_CONTEXT)))
128  {
129  FFSBreakPoint();
130  return STATUS_UNSUCCESSFUL;
131  }
132 
133  Status = IrpContext->ExceptionCode;
134 
135  if (IrpContext->Irp)
136  {
137  //
138  // Check if this error is a result of user actions
139  //
140 
141  PIRP Irp = IrpContext->Irp;
142 
143 
145  {
146  //
147  // Now we will generate a pop-up to user
148  //
149 
150  PDEVICE_OBJECT RealDevice;
151  PVPB Vpb = NULL;
153 
155  {
157  }
158 
159  //
160  // Get the initial thread
161  //
162 
163  Thread = Irp->Tail.Overlay.Thread;
164  RealDevice = IoGetDeviceToVerify(Thread);
165 
166  if (RealDevice == NULL)
167  {
168  //
169  // Get current thread
170  //
171 
173  RealDevice = IoGetDeviceToVerify(Thread);
174 
175  ASSERT(RealDevice != NULL);
176  }
177 
178  if (RealDevice != NULL)
179  {
180  //
181  // Now we pop-up the error dialog ...
182  //
183 
185  IoRaiseHardError(Irp, Vpb, RealDevice);
186 
188 
190  goto errorout;
191  }
192  }
193 
194  IrpContext->Irp->IoStatus.Status = Status;
195 
196  FFSCompleteRequest(IrpContext->Irp, FALSE, IO_NO_INCREMENT);
197  }
198 
199 errorout:
200 
201  FFSFreeIrpContext(IrpContext);
202  }
203  else
204  {
206  }
207 
208  return Status;
209 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
_In_ PIRP Irp
Definition: csq.h:116
#define IoIsErrorUserInduced(Status)
Definition: iofuncs.h:2769
LONG NTSTATUS
Definition: precomp.h:26
__drv_mustHoldCriticalRegion VOID FFSFreeIrpContext(IN PFFS_IRP_CONTEXT IrpContext)
Definition: memory.c:179
#define FFSCompleteRequest(Irp, bPrint, PriorityBoost)
Definition: ffsdrv.h:1049
Definition: ffsdrv.h:283
PDEVICE_OBJECT NTAPI IoGetDeviceToVerify(IN PETHREAD Thread)
Definition: util.c:336
#define FFSBreakPoint()
Definition: ffsdrv.h:43
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define STATUS_PENDING
Definition: ntstatus.h:82
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
Definition: iotypes.h:166
#define IO_NO_INCREMENT
Definition: iotypes.h:565
VOID NTAPI IoRaiseHardError(IN PIRP Irp, IN PVPB Vpb, IN PDEVICE_OBJECT RealDeviceObject)
Definition: error.c:656
IoMarkIrpPending(Irp)
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1664
VOID NTAPI IoSetDeviceToVerify(IN PETHREAD Thread, IN PDEVICE_OBJECT DeviceObject)
Definition: util.c:304

Referenced by FFSBuildRequest(), FFSDeQueueCloseRequest(), and FFSDeQueueRequest().

Variable Documentation

◆ FFSGlobal

PFFS_GLOBAL FFSGlobal

Definition at line 22 of file init.c.