ReactOS  0.4.13-dev-464-g6b95727
except.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: GNU GENERAL PUBLIC LICENSE VERSION 2
3  * PROJECT: ReiserFs file system driver for Windows NT/2000/XP/Vista.
4  * FILE: except.c
5  * PURPOSE:
6  * PROGRAMMER: Mark Piper, Matt Wu, Bo BrantÚn.
7  * HOMEPAGE:
8  * UPDATE HISTORY:
9  */
10 
11 /* INCLUDES *****************************************************************/
12 
13 #include "rfsd.h"
14 
15 /* GLOBALS ***************************************************************/
16 
18 
19 /* DEFINITIONS *************************************************************/
20 
21 #ifdef ALLOC_PRAGMA
22 //#pragma alloc_text(PAGE, RfsdExceptionFilter)
23 //#pragma alloc_text(PAGE, RfsdExceptionHandler)
24 #endif
25 
28  IN PRFSD_IRP_CONTEXT IrpContext,
29  IN PEXCEPTION_POINTERS ExceptionPointer)
30 {
32  PEXCEPTION_RECORD ExceptRecord;
33 
34  ExceptRecord = ExceptionPointer->ExceptionRecord;
35 
36  ExceptionCode = ExceptRecord->ExceptionCode;
37 
38  DbgBreak();
39 
40  //
41  // Check IrpContext is valid or not
42  //
43 
44  if (IrpContext) {
45  if ((IrpContext->Identifier.Type != RFSDICX) ||
46  (IrpContext->Identifier.Size != sizeof(RFSD_IRP_CONTEXT))) {
47  IrpContext = NULL;
48  }
49  } else {
52  } else {
54  (ULONG_PTR)ExceptionPointer->ContextRecord,
55  (ULONG_PTR)ExceptRecord->ExceptionAddress );
56  }
57  }
58 
59  //
60  // For the purposes of processing this exception, let's mark this
61  // request as being able to wait, and neither write through nor on
62  // removable media if we aren't posting it.
63  //
64 
65  if (IrpContext)
66  { SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT); }
67 
69  //
70  // If the exception is expected execute our handler
71  //
72 
73  RfsdPrint((DBG_ERROR, "RfsdExceptionFilter: Catching exception %xh\n",
74  ExceptionCode));
75 
77 
78  if (IrpContext) {
79  IrpContext->ExceptionInProgress = TRUE;
80  IrpContext->ExceptionCode = ExceptionCode;
81  }
82 
83  } else {
84 
85  //
86  // Continue search for an higher level exception handler
87  //
88 
89  RfsdPrint((DBG_ERROR, "RfsdExceptionFilter: Passing on exception %#x\n",
90  ExceptionCode));
91 
93 
94  if (IrpContext) {
95  RfsdFreeIrpContext(IrpContext);
96  }
97  }
98 
99  return Status;
100 }
101 
102 NTSTATUS
104 {
106 
107  if (IrpContext) {
108  if ( (IrpContext->Identifier.Type != RFSDICX) ||
109  (IrpContext->Identifier.Size != sizeof(RFSD_IRP_CONTEXT))) {
110  DbgBreak();
111  return STATUS_UNSUCCESSFUL;
112  }
113 
114  Status = IrpContext->ExceptionCode;
115 
116  if (IrpContext->Irp) {
117 
118  //
119  // Check if this error is a result of user actions
120  //
121 
122  PIRP Irp = IrpContext->Irp;
123 
124 
126 
127  //
128  // Now we will generate a pop-up to user
129  //
130 
131  PDEVICE_OBJECT RealDevice;
132  PVPB Vpb = NULL;
134 
137  }
138 
139  //
140  // Get the initial thread
141  //
142 
143  Thread = Irp->Tail.Overlay.Thread;
144  RealDevice = IoGetDeviceToVerify( Thread );
145 
146  if (RealDevice == NULL) {
147  //
148  // Get current thread
149  //
150 
152  RealDevice = IoGetDeviceToVerify( Thread );
153 
154  ASSERT( RealDevice != NULL );
155  }
156 
157  if (RealDevice != NULL) {
158 
159  //
160  // Now we pop-up the error dialog ...
161  //
162 
164  IoRaiseHardError( Irp, Vpb, RealDevice );
165 
167 
169  goto errorout;
170  }
171  }
172 
173  IrpContext->Irp->IoStatus.Status = Status;
174 
175  RfsdCompleteRequest(IrpContext->Irp, FALSE, IO_NO_INCREMENT);
176  }
177 
178 errorout:
179 
180  RfsdFreeIrpContext(IrpContext);
181 
182  } else {
183 
185  }
186 
187  return Status;
188 }
_Inout_ PIRP _In_ NTSTATUS ExceptionCode
Definition: cdprocs.h:1782
PRFSD_GLOBAL RfsdGlobal
Definition: init.c:17
#define IN
Definition: typedefs.h:38
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
#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
VOID RfsdFreeIrpContext(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: memory.c:192
PDEVICE_OBJECT NTAPI IoGetDeviceToVerify(IN PETHREAD Thread)
Definition: util.c:336
PVOID ExceptionAddress
Definition: compat.h:199
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
Definition: rfsd.h:326
_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
#define RfsdPrint(arg)
Definition: rfsd.h:1069
#define DBG_ERROR
Definition: ffsdrv.h:1031
Status
Definition: gdiplustypes.h:24
struct _EXCEPTION_RECORD * ExceptionRecord
Definition: compat.h:198
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
#define RfsdBugCheck(A, B, C, D)
Definition: rfsd.h:232
NTSTATUS RfsdExceptionFilter(IN PRFSD_IRP_CONTEXT IrpContext, IN PEXCEPTION_POINTERS ExceptionPointer)
Definition: except.c:27
Definition: iotypes.h:166
#define IO_NO_INCREMENT
Definition: iotypes.h:565
#define DbgBreak()
Definition: ext2fs.h:46
VOID NTAPI IoRaiseHardError(IN PIRP Irp, IN PVPB Vpb, IN PDEVICE_OBJECT RealDeviceObject)
Definition: error.c:656
IoMarkIrpPending(Irp)
#define RFSD_BUGCHK_EXCEPT
Definition: rfsd.h:215
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
#define RfsdCompleteRequest(Irp, bPrint, PriorityBoost)
Definition: rfsd.h:1072
NTSTATUS RfsdExceptionHandler(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: except.c:103