ReactOS  0.4.14-dev-583-g2a1ba2c
dispatch.c File Reference
#include "ntifs.h"
#include "ffsdrv.h"
Include dependency graph for dispatch.c:

Go to the source code of this file.

Functions

NTSTATUS FFSQueueRequest (IN PFFS_IRP_CONTEXT IrpContext)
 
VOID NTAPI FFSDeQueueRequest (IN PVOID Context)
 
NTSTATUS FFSDispatchRequest (IN PFFS_IRP_CONTEXT IrpContext)
 
NTSTATUS NTAPI FFSBuildRequest (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 

Variables

PFFS_GLOBAL FFSGlobal
 

Function Documentation

◆ FFSBuildRequest()

NTSTATUS NTAPI FFSBuildRequest ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 181 of file dispatch.c.

184 {
185  BOOLEAN AtIrqlPassiveLevel = FALSE;
186  BOOLEAN IsTopLevelIrp = FALSE;
187  PFFS_IRP_CONTEXT IrpContext = NULL;
189 
190  PAGED_CODE();
191 
192  _SEH2_TRY
193  {
194  _SEH2_TRY
195  {
196 #if DBG
198 #endif
199 
200  AtIrqlPassiveLevel = (KeGetCurrentIrql() == PASSIVE_LEVEL);
201 
202  if (AtIrqlPassiveLevel)
203  {
205  }
206 
207  if (!IoGetTopLevelIrp())
208  {
209  IsTopLevelIrp = TRUE;
211  }
212 
213  IrpContext = FFSAllocateIrpContext(DeviceObject, Irp);
214 
215  if (!IrpContext)
216  {
218  Irp->IoStatus.Status = Status;
219 
221  }
222  else
223  {
224  if ((IrpContext->MajorFunction == IRP_MJ_CREATE) &&
225  !AtIrqlPassiveLevel)
226  {
227  FFSBreakPoint();
228  }
229 
230  Status = FFSDispatchRequest(IrpContext);
231  }
232  }
234  {
235  Status = FFSExceptionHandler(IrpContext);
236  } _SEH2_END;
237  }
239  {
240  if (IsTopLevelIrp)
241  {
243  }
244 
245  if (AtIrqlPassiveLevel)
246  {
248  }
249  } _SEH2_END;
250 
251  return Status;
252 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define TRUE
Definition: types.h:120
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSTATUS FFSExceptionHandler(IN PFFS_IRP_CONTEXT IrpContext)
Definition: except.c:117
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
_In_ PIRP Irp
Definition: csq.h:116
UCHAR MajorFunction
Definition: ffsdrv.h:731
LONG NTSTATUS
Definition: precomp.h:26
#define FFSCompleteRequest(Irp, bPrint, PriorityBoost)
Definition: ffsdrv.h:1049
VOID FFSDbgPrintCall(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
#define FFSBreakPoint()
Definition: ffsdrv.h:43
NTSTATUS FFSDispatchRequest(IN PFFS_IRP_CONTEXT IrpContext)
Definition: dispatch.c:104
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:11
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
__drv_mustHoldCriticalRegion PFFS_IRP_CONTEXT FFSAllocateIrpContext(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: memory.c:52
NTSTATUS FFSExceptionFilter(IN PFFS_IRP_CONTEXT IrpContext, IN PEXCEPTION_POINTERS ExceptionPointer)
Definition: except.c:31
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:1560
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

Referenced by DriverEntry().

◆ FFSDeQueueRequest()

VOID NTAPI FFSDeQueueRequest ( IN PVOID  Context)

Definition at line 62 of file dispatch.c.

64 {
65  PFFS_IRP_CONTEXT IrpContext;
66 
67  PAGED_CODE();
68 
69  IrpContext = (PFFS_IRP_CONTEXT) Context;
70 
71  ASSERT(IrpContext);
72 
73  ASSERT((IrpContext->Identifier.Type == FFSICX) &&
74  (IrpContext->Identifier.Size == sizeof(FFS_IRP_CONTEXT)));
75 
76  _SEH2_TRY
77  {
78  _SEH2_TRY
79  {
81 
82  if (!IrpContext->IsTopLevel)
83  {
85  }
86 
87  FFSDispatchRequest(IrpContext);
88  }
90  {
91  FFSExceptionHandler(IrpContext);
92  } _SEH2_END;
93  }
95  {
97 
99  } _SEH2_END;
100 }
NTSTATUS FFSExceptionHandler(IN PFFS_IRP_CONTEXT IrpContext)
Definition: except.c:117
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
Definition: ffsdrv.h:283
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
NTSTATUS FFSDispatchRequest(IN PFFS_IRP_CONTEXT IrpContext)
Definition: dispatch.c:104
BOOLEAN IsTopLevel
Definition: ffsdrv.h:750
struct _FFS_IRP_CONTEXT * PFFS_IRP_CONTEXT
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:11
smooth NULL
Definition: ftsmooth.c:416
FFS_IDENTIFIER_TYPE Type
Definition: ffsdrv.h:294
ULONG Size
Definition: ffsdrv.h:295
NTSTATUS FFSExceptionFilter(IN PFFS_IRP_CONTEXT IrpContext, IN PEXCEPTION_POINTERS ExceptionPointer)
Definition: except.c:31
#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
_SEH2_END
Definition: create.c:4424
FFS_IDENTIFIER Identifier
Definition: ffsdrv.h:722
_SEH2_FINALLY
Definition: create.c:4395
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

Referenced by FFSQueueRequest().

◆ FFSDispatchRequest()

NTSTATUS FFSDispatchRequest ( IN PFFS_IRP_CONTEXT  IrpContext)

Definition at line 104 of file dispatch.c.

106 {
107  PAGED_CODE();
108 
109  ASSERT(IrpContext);
110 
111  ASSERT((IrpContext->Identifier.Type == FFSICX) &&
112  (IrpContext->Identifier.Size == sizeof(FFS_IRP_CONTEXT)));
113 
114  switch (IrpContext->MajorFunction)
115  {
116  case IRP_MJ_CREATE:
117  return FFSCreate(IrpContext);
118 
119  case IRP_MJ_CLOSE:
120  return FFSClose(IrpContext);
121 
122  case IRP_MJ_READ:
123  return FFSRead(IrpContext);
124 
125 #if !FFS_READ_ONLY
126  case IRP_MJ_WRITE:
127  return FFSWrite(IrpContext);
128 #endif // !FFS_READ_ONLY
129 
131  return FFSFlush(IrpContext);
132 
134  return FFSQueryInformation(IrpContext);
135 
137  return FFSSetInformation(IrpContext);
138 
140  return FFSQueryVolumeInformation(IrpContext);
141 
142 #if !FFS_READ_ONLY
144  return FFSSetVolumeInformation(IrpContext);
145 #endif // !FFS_READ_ONLY
146 
148  return FFSDirectoryControl(IrpContext);
149 
151  return FFSFileSystemControl(IrpContext);
152 
154  return FFSDeviceControl(IrpContext);
155 
156  case IRP_MJ_LOCK_CONTROL:
157  return FFSLockControl(IrpContext);
158 
159  case IRP_MJ_CLEANUP:
160  return FFSCleanup(IrpContext);
161 
162  case IRP_MJ_SHUTDOWN:
163  return FFSShutDown(IrpContext);
164 
165 #if (_WIN32_WINNT >= 0x0500)
166  case IRP_MJ_PNP:
167  return FFSPnp(IrpContext);
168 #endif //(_WIN32_WINNT >= 0x0500)
169  default:
170  FFSPrint((DBG_ERROR, "FFSDispatchRequest: Unexpected major function: %xh\n",
171  IrpContext->MajorFunction));
172 
174 
176  }
177 }
__drv_mustHoldCriticalRegion NTSTATUS FFSWrite(IN PFFS_IRP_CONTEXT IrpContext)
Definition: write.c:1487
__drv_mustHoldCriticalRegion NTSTATUS FFSQueryVolumeInformation(IN PFFS_IRP_CONTEXT IrpContext)
Definition: volinfo.c:32
__drv_mustHoldCriticalRegion NTSTATUS FFSSetVolumeInformation(IN PFFS_IRP_CONTEXT IrpContext)
Definition: volinfo.c:349
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define IRP_MJ_FLUSH_BUFFERS
#define IRP_MJ_SHUTDOWN
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
#define IRP_MJ_SET_VOLUME_INFORMATION
Definition: ffsdrv.h:283
#define PAGED_CODE()
Definition: video.h:57
__drv_mustHoldCriticalRegion NTSTATUS FFSPnp(IN PFFS_IRP_CONTEXT IrpContext)
__drv_mustHoldCriticalRegion NTSTATUS FFSQueryInformation(IN PFFS_IRP_CONTEXT IrpContext)
Definition: fileinfo.c:37
__drv_mustHoldCriticalRegion NTSTATUS FFSCreate(IN PFFS_IRP_CONTEXT IrpContext)
Definition: create.c:1835
__drv_mustHoldCriticalRegion NTSTATUS FFSFileSystemControl(IN PFFS_IRP_CONTEXT IrpContext)
Definition: fsctl.c:1645
__drv_mustHoldCriticalRegion NTSTATUS FFSShutDown(IN PFFS_IRP_CONTEXT IrpContext)
Definition: shutdown.c:31
__drv_mustHoldCriticalRegion NTSTATUS FFSDeviceControl(IN PFFS_IRP_CONTEXT IrpContext)
Definition: devctl.c:263
__drv_mustHoldCriticalRegion NTSTATUS FFSLockControl(IN PFFS_IRP_CONTEXT IrpContext)
Definition: lock.c:30
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
#define IRP_MJ_FILE_SYSTEM_CONTROL
__drv_mustHoldCriticalRegion NTSTATUS FFSSetInformation(IN PFFS_IRP_CONTEXT IrpContext)
Definition: fileinfo.c:551
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_DRIVER_INTERNAL_ERROR
Definition: udferr_usr.h:177
__drv_mustHoldCriticalRegion NTSTATUS FFSCompleteIrpContext(IN PFFS_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:53
__drv_mustHoldCriticalRegion NTSTATUS FFSClose(IN PFFS_IRP_CONTEXT IrpContext)
Definition: close.c:32
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
__drv_mustHoldCriticalRegion NTSTATUS FFSRead(IN PFFS_IRP_CONTEXT IrpContext)
Definition: read.c:1068
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
#define IRP_MJ_LOCK_CONTROL
Definition: rdpdr.c:53
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_CLEANUP
__drv_mustHoldCriticalRegion NTSTATUS FFSCleanup(IN PFFS_IRP_CONTEXT IrpContext)
Definition: cleanup.c:30
#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
__drv_mustHoldCriticalRegion NTSTATUS FFSDirectoryControl(IN PFFS_IRP_CONTEXT IrpContext)
Definition: dirctl.c:1243
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
__drv_mustHoldCriticalRegion NTSTATUS FFSFlush(IN PFFS_IRP_CONTEXT IrpContext)
Definition: flush.c:169

Referenced by FFSBuildRequest(), and FFSDeQueueRequest().

◆ FFSQueueRequest()

NTSTATUS FFSQueueRequest ( IN PFFS_IRP_CONTEXT  IrpContext)

Definition at line 33 of file dispatch.c.

35 {
36  PAGED_CODE();
37 
38  ASSERT(IrpContext);
39 
40  ASSERT((IrpContext->Identifier.Type == FFSICX) &&
41  (IrpContext->Identifier.Size == sizeof(FFS_IRP_CONTEXT)));
42 
43  // IsSynchronous means we can block (so we don't requeue it)
44  IrpContext->IsSynchronous = TRUE;
45 
46  SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_REQUEUED);
47 
48  IoMarkIrpPending(IrpContext->Irp);
49 
51  &IrpContext->WorkQueueItem,
53  IrpContext);
54 
55  ExQueueWorkItem(&IrpContext->WorkQueueItem, CriticalWorkQueue);
56 
57  return STATUS_PENDING;
58 }
#define TRUE
Definition: types.h:120
VOID NTAPI ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
Definition: work.c:717
Definition: ffsdrv.h:283
#define PAGED_CODE()
Definition: video.h:57
VOID NTAPI FFSDeQueueRequest(IN PVOID Context)
Definition: dispatch.c:62
#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)

Referenced by FFSCleanup(), FFSDeferWrite(), FFSQueryDirectory(), FFSQueryInformation(), FFSQueryVolumeInformation(), FFSReadFile(), FFSReadVolume(), FFSSetInformation(), FFSSetVolumeInformation(), FFSShutDown(), FFSWriteFile(), and FFSWriteVolume().

Variable Documentation

◆ FFSGlobal

PFFS_GLOBAL FFSGlobal

Definition at line 22 of file init.c.