ReactOS  0.4.14-dev-115-g4576127
dispatcher.cpp File Reference
#include "private.hpp"
#include <debug.h>
Include dependency graph for dispatcher.cpp:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI Dispatch_fnDeviceIoControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI Dispatch_fnRead (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI Dispatch_fnWrite (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI Dispatch_fnFlush (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI Dispatch_fnClose (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI Dispatch_fnQuerySecurity (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI Dispatch_fnSetSecurity (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
BOOLEAN NTAPI Dispatch_fnFastDeviceIoControl (PFILE_OBJECT FileObject, BOOLEAN Wait, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength, ULONG IoControlCode, PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject)
 
BOOLEAN NTAPI Dispatch_fnFastRead (PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, ULONG Length, BOOLEAN Wait, ULONG LockKey, PVOID Buffer, PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject)
 
BOOLEAN NTAPI Dispatch_fnFastWrite (PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, ULONG Length, BOOLEAN Wait, ULONG LockKey, PVOID Buffer, PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject)
 
NTSTATUS NTAPI NewDispatchObject (IN PIRP Irp, IN IIrpTarget *Target, IN ULONG CreateItemCount, IN PKSOBJECT_CREATE_ITEM CreateItem)
 

Variables

static KSDISPATCH_TABLE DispatchTable
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file dispatcher.cpp.

Function Documentation

◆ Dispatch_fnClose()

NTSTATUS NTAPI Dispatch_fnClose ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 98 of file dispatcher.cpp.

101 {
102  PIO_STACK_LOCATION IoStack;
103  PDISPATCH_CONTEXT DispatchContext;
105 
106  // get current irp stack
108  // get dispatch context
109  DispatchContext = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
110 
111  // let IrpTarget handle request
112  Status = DispatchContext->Target->Close(DeviceObject, Irp);
113 
114  if (NT_SUCCESS(Status))
115  {
116  KsFreeObjectHeader(DispatchContext->ObjectHeader);
117  FreeItem(DispatchContext, TAG_PORTCLASS);
118  }
119  // done
120  return Status;
121 }
_In_ PIRP Irp
Definition: csq.h:116
#define TAG_PORTCLASS
Definition: private.hpp:24
LONG NTSTATUS
Definition: precomp.h:26
KSDDKAPI VOID NTAPI KsFreeObjectHeader(IN PVOID Header)
Definition: api.c:720
IIrpTarget * Target
Definition: private.hpp:438
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
KSOBJECT_HEADER ObjectHeader
Definition: private.hpp:437

◆ Dispatch_fnDeviceIoControl()

NTSTATUS NTAPI Dispatch_fnDeviceIoControl ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 19 of file dispatcher.cpp.

22 {
23  PIO_STACK_LOCATION IoStack;
24  PDISPATCH_CONTEXT DispatchContext;
25 
26  // get current irp stack
28 
29  // get dispatch context
30  DispatchContext = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
31 
32  // let IrpTarget handle request
33  return DispatchContext->Target->DeviceIoControl(DeviceObject, Irp);
34 }
_In_ PIRP Irp
Definition: csq.h:116
IIrpTarget * Target
Definition: private.hpp:438
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813

◆ Dispatch_fnFastDeviceIoControl()

BOOLEAN NTAPI Dispatch_fnFastDeviceIoControl ( PFILE_OBJECT  FileObject,
BOOLEAN  Wait,
PVOID  InputBuffer,
ULONG  InputBufferLength,
PVOID  OutputBuffer,
ULONG  OutputBufferLength,
ULONG  IoControlCode,
PIO_STATUS_BLOCK  IoStatus,
PDEVICE_OBJECT  DeviceObject 
)

Definition at line 164 of file dispatcher.cpp.

174 {
175  PDISPATCH_CONTEXT DispatchContext;
176 
177  // get dispatch context
178  DispatchContext = (PDISPATCH_CONTEXT)FileObject->FsContext;
179 
180  // let IrpTarget handle request
182 }
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG IoControlCode
Definition: fltkernel.h:1383
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG _In_ ULONG OutputBufferLength
Definition: fltkernel.h:1374
CHAR InputBuffer[80]
Definition: conmgr.c:33
IIrpTarget * Target
Definition: private.hpp:438
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG InputBufferLength
Definition: fltkernel.h:1372
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
IN BOOLEAN Wait
Definition: fatprocs.h:1529

◆ Dispatch_fnFastRead()

BOOLEAN NTAPI Dispatch_fnFastRead ( PFILE_OBJECT  FileObject,
PLARGE_INTEGER  FileOffset,
ULONG  Length,
BOOLEAN  Wait,
ULONG  LockKey,
PVOID  Buffer,
PIO_STATUS_BLOCK  IoStatus,
PDEVICE_OBJECT  DeviceObject 
)

Definition at line 187 of file dispatcher.cpp.

196 {
197  PDISPATCH_CONTEXT DispatchContext;
198 
199  // get dispatch context
200  DispatchContext = (PDISPATCH_CONTEXT)FileObject->FsContext;
201 
202  // let IrpTarget handle request
203  return DispatchContext->Target->FastRead(FileObject, FileOffset, Length, Wait, LockKey, Buffer, IoStatus, DeviceObject);
204 }
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
IIrpTarget * Target
Definition: private.hpp:438
Definition: bufpool.h:45
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG LockKey
Definition: fatprocs.h:2650
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
IN BOOLEAN Wait
Definition: fatprocs.h:1529

◆ Dispatch_fnFastWrite()

BOOLEAN NTAPI Dispatch_fnFastWrite ( PFILE_OBJECT  FileObject,
PLARGE_INTEGER  FileOffset,
ULONG  Length,
BOOLEAN  Wait,
ULONG  LockKey,
PVOID  Buffer,
PIO_STATUS_BLOCK  IoStatus,
PDEVICE_OBJECT  DeviceObject 
)

Definition at line 208 of file dispatcher.cpp.

217 {
218  PDISPATCH_CONTEXT DispatchContext;
219 
220  // get dispatch context
221  DispatchContext = (PDISPATCH_CONTEXT)FileObject->FsContext;
222  // let IrpTarget handle request
223  return DispatchContext->Target->FastWrite(FileObject, FileOffset, Length, Wait, LockKey, Buffer, IoStatus, DeviceObject);
224 }
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
IIrpTarget * Target
Definition: private.hpp:438
Definition: bufpool.h:45
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG LockKey
Definition: fatprocs.h:2650
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
IN BOOLEAN Wait
Definition: fatprocs.h:1529

◆ Dispatch_fnFlush()

NTSTATUS NTAPI Dispatch_fnFlush ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 78 of file dispatcher.cpp.

81 {
82  PIO_STACK_LOCATION IoStack;
83  PDISPATCH_CONTEXT DispatchContext;
84 
85  // get current irp stack
87 
88  // get dispatch context
89  DispatchContext = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
90 
91 
92  // let IrpTarget handle request
93  return DispatchContext->Target->Flush(DeviceObject, Irp);
94 }
_In_ PIRP Irp
Definition: csq.h:116
IIrpTarget * Target
Definition: private.hpp:438
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813

◆ Dispatch_fnQuerySecurity()

NTSTATUS NTAPI Dispatch_fnQuerySecurity ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 125 of file dispatcher.cpp.

128 {
129  PIO_STACK_LOCATION IoStack;
130  PDISPATCH_CONTEXT DispatchContext;
131 
132  // get current irp stack
134 
135  // get dispatch context
136  DispatchContext = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
137 
138 
139  // let IrpTarget handle request
140  return DispatchContext->Target->QuerySecurity(DeviceObject, Irp);
141 }
_In_ PIRP Irp
Definition: csq.h:116
IIrpTarget * Target
Definition: private.hpp:438
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813

◆ Dispatch_fnRead()

NTSTATUS NTAPI Dispatch_fnRead ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 38 of file dispatcher.cpp.

41 {
42  PIO_STACK_LOCATION IoStack;
43  PDISPATCH_CONTEXT DispatchContext;
44 
45  // get current irp stack
47 
48  // get dispatch context
49  DispatchContext = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
50 
51 
52  // let IrpTarget handle request
53  return DispatchContext->Target->Read(DeviceObject, Irp);
54 }
_In_ PIRP Irp
Definition: csq.h:116
IIrpTarget * Target
Definition: private.hpp:438
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813

◆ Dispatch_fnSetSecurity()

NTSTATUS NTAPI Dispatch_fnSetSecurity ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 145 of file dispatcher.cpp.

148 {
149  PIO_STACK_LOCATION IoStack;
150  PDISPATCH_CONTEXT DispatchContext;
151 
152  // get current irp stack
154 
155  // get dispatch context
156  DispatchContext = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
157 
158  // let IrpTarget handle request
159  return DispatchContext->Target->SetSecurity(DeviceObject, Irp);
160 }
_In_ PIRP Irp
Definition: csq.h:116
IIrpTarget * Target
Definition: private.hpp:438
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813

◆ Dispatch_fnWrite()

NTSTATUS NTAPI Dispatch_fnWrite ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 58 of file dispatcher.cpp.

61 {
62  PIO_STACK_LOCATION IoStack;
63  PDISPATCH_CONTEXT DispatchContext;
64 
65  // get current irp stack
67 
68  // get dispatch context
69  DispatchContext = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
70 
71 
72  // let IrpTarget handle request
73  return DispatchContext->Target->Write(DeviceObject, Irp);
74 }
_In_ PIRP Irp
Definition: csq.h:116
IIrpTarget * Target
Definition: private.hpp:438
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813

◆ NewDispatchObject()

NTSTATUS NTAPI NewDispatchObject ( IN PIRP  Irp,
IN IIrpTarget *  Target,
IN ULONG  CreateItemCount,
IN PKSOBJECT_CREATE_ITEM  CreateItem 
)

Definition at line 242 of file dispatcher.cpp.

247 {
249  KSOBJECT_HEADER ObjectHeader;
250  PIO_STACK_LOCATION IoStack;
251  PDISPATCH_CONTEXT DispatchContext;
252 
253  // get current irp stack location
255 
257  if (!DispatchContext)
259 
260  // allocate object header
261  Status = KsAllocateObjectHeader(&ObjectHeader, CreateItemCount, CreateItem, Irp, &DispatchTable);
262 
263  if (!NT_SUCCESS(Status))
264  {
265  // free dispatch context
266  FreeItem(DispatchContext, TAG_PORTCLASS);
267  // done
268  return Status;
269  }
270 
271  // initialize dispatch context
272  DispatchContext->ObjectHeader = ObjectHeader;
273  DispatchContext->Target = Target;
274  DispatchContext->CreateItem = CreateItem;
275 
276  // store dispatch context
277  IoStack->FileObject->FsContext = DispatchContext;
278 
279  DPRINT("KsAllocateObjectHeader result %x Target %p Context %p\n", Status, Target, DispatchContext);
280  return Status;
281 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
#define TAG_PORTCLASS
Definition: private.hpp:24
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
static KSDISPATCH_TABLE DispatchTable
Definition: dispatcher.cpp:226
IIrpTarget * Target
Definition: private.hpp:438
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
void DPRINT(...)
Definition: polytest.cpp:61
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1068
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:2813
KSDDKAPI NTSTATUS NTAPI KsAllocateObjectHeader(OUT KSOBJECT_HEADER *Header, IN ULONG ItemsCount, IN PKSOBJECT_CREATE_ITEM ItemsList OPTIONAL, IN PIRP Irp, IN KSDISPATCH_TABLE *Table)
Definition: api.c:610
KSOBJECT_HEADER ObjectHeader
Definition: private.hpp:437
PKSOBJECT_CREATE_ITEM CreateItem
Definition: private.hpp:439

Referenced by PcCreateItemDispatch(), and PcCreatePinDispatch().

Variable Documentation

◆ DispatchTable

KSDISPATCH_TABLE DispatchTable
static
Initial value:
=
{
}
NTSTATUS NTAPI Dispatch_fnRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatcher.cpp:38
NTSTATUS NTAPI Dispatch_fnFlush(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatcher.cpp:78
NTSTATUS NTAPI Dispatch_fnDeviceIoControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatcher.cpp:19
NTSTATUS NTAPI Dispatch_fnWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatcher.cpp:58
NTSTATUS NTAPI Dispatch_fnClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatcher.cpp:98
NTSTATUS NTAPI Dispatch_fnSetSecurity(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatcher.cpp:145
BOOLEAN NTAPI Dispatch_fnFastDeviceIoControl(PFILE_OBJECT FileObject, BOOLEAN Wait, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength, ULONG IoControlCode, PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject)
Definition: dispatcher.cpp:164
BOOLEAN NTAPI Dispatch_fnFastWrite(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, ULONG Length, BOOLEAN Wait, ULONG LockKey, PVOID Buffer, PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject)
Definition: dispatcher.cpp:208
BOOLEAN NTAPI Dispatch_fnFastRead(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, ULONG Length, BOOLEAN Wait, ULONG LockKey, PVOID Buffer, PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject)
Definition: dispatcher.cpp:187
NTSTATUS NTAPI Dispatch_fnQuerySecurity(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatcher.cpp:125

Definition at line 226 of file dispatcher.cpp.

Referenced by NewDispatchObject().