ReactOS  0.4.15-dev-492-ga1108f6
dispatch.c File Reference
#include "rfsd.h"
Include dependency graph for dispatch.c:

Go to the source code of this file.

Functions

NTSTATUS RfsdQueueRequest (IN PRFSD_IRP_CONTEXT IrpContext)
 
VOID NTAPI RfsdDeQueueRequest (IN PVOID Context)
 
__drv_mustHoldCriticalRegion NTSTATUS RfsdDispatchRequest (IN PRFSD_IRP_CONTEXT IrpContext)
 
NTSTATUS NTAPI RfsdBuildRequest (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 

Variables

PRFSD_GLOBAL RfsdGlobal
 

Function Documentation

◆ RfsdBuildRequest()

NTSTATUS NTAPI RfsdBuildRequest ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 176 of file dispatch.c.

177 {
178  BOOLEAN AtIrqlPassiveLevel = FALSE;
179  BOOLEAN IsTopLevelIrp = FALSE;
180  PRFSD_IRP_CONTEXT IrpContext = NULL;
182 
183  PAGED_CODE();
184 
185  _SEH2_TRY {
186 
187  _SEH2_TRY {
188 
189 #if DBG
191 #endif
192 
193  AtIrqlPassiveLevel = (KeGetCurrentIrql() == PASSIVE_LEVEL);
194 
195  if (AtIrqlPassiveLevel) {
196 
198  }
199 
200  if (!IoGetTopLevelIrp()) {
201 
202  IsTopLevelIrp = TRUE;
204  }
205 
206  IrpContext = RfsdAllocateIrpContext(DeviceObject, Irp);
207 
208  if (!IrpContext) {
209 
211  Irp->IoStatus.Status = Status;
212 
214 
215  } else {
216 
217  if ((IrpContext->MajorFunction == IRP_MJ_CREATE) &&
218  !AtIrqlPassiveLevel) {
219 
220  DbgBreak();
221  }
222 
223  Status = RfsdDispatchRequest(IrpContext);
224  }
226 
227  Status = RfsdExceptionHandler(IrpContext);
228  } _SEH2_END;
229 
230  } _SEH2_FINALLY {
231 
232  if (IsTopLevelIrp) {
234  }
235 
236  if (AtIrqlPassiveLevel) {
238  }
239  } _SEH2_END;
240 
241  return Status;
242 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
NTSTATUS RfsdExceptionHandler(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: except.c:103
#define TRUE
Definition: types.h:120
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
_SEH2_TRY
Definition: create.c:4226
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:11
NTSTATUS RfsdExceptionFilter(IN PRFSD_IRP_CONTEXT IrpContext, IN PEXCEPTION_POINTERS ExceptionPointer)
Definition: except.c:27
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
UCHAR MajorFunction
Definition: rfsd.h:764
VOID RfsdDbgPrintCall(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
__drv_mustHoldCriticalRegion NTSTATUS RfsdDispatchRequest(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: dispatch.c:97
PIRP NTAPI IoGetTopLevelIrp(VOID)
Definition: irp.c:1843
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
_SEH2_END
Definition: create.c:4400
_SEH2_FINALLY
Definition: create.c:4371
#define IO_NO_INCREMENT
Definition: iotypes.h:568
#define DbgBreak()
Definition: ext2fs.h:46
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
PRFSD_IRP_CONTEXT RfsdAllocateIrpContext(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: memory.c:48
#define RfsdCompleteRequest(Irp, bPrint, PriorityBoost)
Definition: rfsd.h:1072
#define PAGED_CODE()

◆ RfsdDeQueueRequest()

VOID NTAPI RfsdDeQueueRequest ( IN PVOID  Context)

Definition at line 56 of file dispatch.c.

57 {
58  PRFSD_IRP_CONTEXT IrpContext;
59 
60  PAGED_CODE();
61 
62  IrpContext = (PRFSD_IRP_CONTEXT) Context;
63 
64  ASSERT(IrpContext);
65 
66  ASSERT((IrpContext->Identifier.Type == RFSDICX) &&
67  (IrpContext->Identifier.Size == sizeof(RFSD_IRP_CONTEXT)));
68 
69  _SEH2_TRY {
70 
71  _SEH2_TRY {
72 
74 
75  if (!IrpContext->IsTopLevel) {
76 
78  }
79 
80  RfsdDispatchRequest(IrpContext);
81 
83 
84  RfsdExceptionHandler(IrpContext);
85  } _SEH2_END;
86 
87  } _SEH2_FINALLY {
88 
90 
92  } _SEH2_END;
93 }
NTSTATUS RfsdExceptionHandler(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: except.c:103
#define FsRtlEnterFileSystem
BOOLEAN IsTopLevel
Definition: rfsd.h:783
#define FsRtlExitFileSystem
_SEH2_TRY
Definition: create.c:4226
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:11
NTSTATUS RfsdExceptionFilter(IN PRFSD_IRP_CONTEXT IrpContext, IN PEXCEPTION_POINTERS ExceptionPointer)
Definition: except.c:27
smooth NULL
Definition: ftsmooth.c:416
RFSD_IDENTIFIER_TYPE Type
Definition: rfsd.h:336
Definition: rfsd.h:326
__drv_mustHoldCriticalRegion NTSTATUS RfsdDispatchRequest(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: dispatch.c:97
RFSD_IDENTIFIER Identifier
Definition: rfsd.h:755
#define FSRTL_FSP_TOP_LEVEL_IRP
Definition: fsrtltypes.h:59
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
struct _RFSD_IRP_CONTEXT * PRFSD_IRP_CONTEXT
_SEH2_END
Definition: create.c:4400
_SEH2_FINALLY
Definition: create.c:4371
ULONG Size
Definition: rfsd.h:337
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define PAGED_CODE()

Referenced by RfsdQueueRequest().

◆ RfsdDispatchRequest()

__drv_mustHoldCriticalRegion NTSTATUS RfsdDispatchRequest ( IN PRFSD_IRP_CONTEXT  IrpContext)

Definition at line 97 of file dispatch.c.

98 {
99  PAGED_CODE();
100 
101  ASSERT(IrpContext);
102 
103  ASSERT((IrpContext->Identifier.Type == RFSDICX) &&
104  (IrpContext->Identifier.Size == sizeof(RFSD_IRP_CONTEXT)));
105 
106  switch (IrpContext->MajorFunction) {
107 
108  case IRP_MJ_CREATE:
109  return RfsdCreate(IrpContext);
110 
111  case IRP_MJ_CLOSE:
112  return RfsdClose(IrpContext);
113 
114  case IRP_MJ_READ:
115  return RfsdRead(IrpContext);
116 
117 #if !RFSD_READ_ONLY
118  case IRP_MJ_WRITE:
119  return RfsdWrite(IrpContext);
120 #endif // !RFSD_READ_ONLY
121 
123  return RfsdFlush(IrpContext);
124 
126  return RfsdQueryInformation(IrpContext);
127 
129  return RfsdSetInformation(IrpContext);
130 
132  return RfsdQueryVolumeInformation(IrpContext);
133 
134 #if !RFSD_READ_ONLY
136  return RfsdSetVolumeInformation(IrpContext);
137 #endif // !RFSD_READ_ONLY
138 
140  return RfsdDirectoryControl(IrpContext);
141 
143  return RfsdFileSystemControl(IrpContext);
144 
146  return RfsdDeviceControl(IrpContext);
147 
148  case IRP_MJ_LOCK_CONTROL:
149  return RfsdLockControl(IrpContext);
150 
151  case IRP_MJ_CLEANUP:
152  return RfsdCleanup(IrpContext);
153 
154  case IRP_MJ_SHUTDOWN:
155  return RfsdShutDown(IrpContext);
156 
157 #if (_WIN32_WINNT >= 0x0500)
158  case IRP_MJ_PNP:
159  return RfsdPnp(IrpContext);
160 #endif //(_WIN32_WINNT >= 0x0500)
161  default:
162  {
164 
165  RfsdPrint((DBG_ERROR, "RfsdDispatchRequest: Unexpected major function: %xh\n",
166  IrpContext->MajorFunction));
167 
168  RfsdCompleteIrpContext(IrpContext, DefaultRC);
169 
170  return DefaultRC;
171  }
172  }
173 }
NTSTATUS RfsdCompleteIrpContext(IN PRFSD_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: memory.c:160
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define IRP_MJ_FLUSH_BUFFERS
NTSTATUS RfsdClose(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: close.c:29
#define IRP_MJ_SHUTDOWN
NTSTATUS RfsdSetVolumeInformation(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: volinfo.c:312
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
LONG NTSTATUS
Definition: precomp.h:26
#define IRP_MJ_SET_VOLUME_INFORMATION
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
NTSTATUS RfsdSetInformation(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: fileinfo.c:457
NTSTATUS RfsdRead(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: read.c:894
NTSTATUS RfsdQueryVolumeInformation(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: volinfo.c:30
Definition: rfsd.h:326
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
NTSTATUS RfsdShutDown(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: shutdown.c:27
__drv_mustHoldCriticalRegion NTSTATUS RfsdPnp(IN PRFSD_IRP_CONTEXT IrpContext)
NTSTATUS RfsdDirectoryControl(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: dirctl.c:784
#define IRP_MJ_FILE_SYSTEM_CONTROL
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define RfsdPrint(arg)
Definition: rfsd.h:1069
NTSTATUS RfsdCreate(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: create.c:1153
#define DBG_ERROR
Definition: ffsdrv.h:1031
NTSTATUS RfsdFlush(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: flush.c:153
NTSTATUS RfsdDeviceControl(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: devctl.c:236
NTSTATUS RfsdCleanup(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: cleanup.c:27
#define IRP_MJ_LOCK_CONTROL
Definition: rdpdr.c:53
#define IRP_MJ_READ
Definition: rdpdr.c:46
NTSTATUS RfsdQueryInformation(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: fileinfo.c:35
#define IRP_MJ_CLEANUP
NTSTATUS RfsdFileSystemControl(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: fsctl.c:1233
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
NTSTATUS RfsdWrite(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: write.c:1358
NTSTATUS RfsdLockControl(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: lockctl.c:26
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define PAGED_CODE()

Referenced by RfsdBuildRequest(), and RfsdDeQueueRequest().

◆ RfsdQueueRequest()

NTSTATUS RfsdQueueRequest ( IN PRFSD_IRP_CONTEXT  IrpContext)

Definition at line 29 of file dispatch.c.

30 {
31  PAGED_CODE();
32 
33  ASSERT(IrpContext);
34 
35  ASSERT((IrpContext->Identifier.Type == RFSDICX) &&
36  (IrpContext->Identifier.Size == sizeof(RFSD_IRP_CONTEXT)));
37 
38  // IsSynchronous means we can block (so we don't requeue it)
39  IrpContext->IsSynchronous = TRUE;
40 
41  SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_REQUEUED);
42 
43  IoMarkIrpPending(IrpContext->Irp);
44 
46  &IrpContext->WorkQueueItem,
48  IrpContext );
49 
50  ExQueueWorkItem(&IrpContext->WorkQueueItem, CriticalWorkQueue);
51 
52  return STATUS_PENDING;
53 }
#define TRUE
Definition: types.h:120
VOID NTAPI ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
Definition: work.c:717
Definition: rfsd.h:326
#define ExInitializeWorkItem(Item, Routine, Context)
Definition: exfuncs.h:265
#define STATUS_PENDING
Definition: ntstatus.h:82
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define IRP_CONTEXT_FLAG_REQUEUED
Definition: ext2fs.h:1085
IoMarkIrpPending(Irp)
VOID NTAPI RfsdDeQueueRequest(IN PVOID Context)
Definition: dispatch.c:56
#define PAGED_CODE()

Referenced by RfsdCleanup(), RfsdDeferWrite(), RfsdQueryDirectory(), RfsdQueryInformation(), RfsdQueryVolumeInformation(), RfsdReadFile(), RfsdReadVolume(), RfsdSetInformation(), RfsdSetVolumeInformation(), RfsdShutDown(), RfsdWriteFile(), and RfsdWriteVolume().

Variable Documentation

◆ RfsdGlobal

PRFSD_GLOBAL RfsdGlobal

Definition at line 17 of file init.c.