ReactOS  0.4.15-dev-3173-g40ee59d
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;
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);
118  }
119  // done
120  return Status;
121 }
_In_ UCHAR _In_ UCHAR _In_ ULONG _In_ WDFCONTEXT _Inout_ PIRP _In_ WDFCONTEXT DispatchContext
Definition: wdfdevice.h:1697
#define TAG_PORTCLASS
Definition: private.hpp:24
LONG NTSTATUS
Definition: precomp.h:26
KSDDKAPI VOID NTAPI KsFreeObjectHeader(IN PVOID Header)
Definition: api.c:720
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
_In_ PIRP Irp
Definition: csq.h:116
Status
Definition: gdiplustypes.h:24
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
PFILE_OBJECT FileObject
Definition: iotypes.h:3169

◆ 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;
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_ UCHAR _In_ UCHAR _In_ ULONG _In_ WDFCONTEXT _Inout_ PIRP _In_ WDFCONTEXT DispatchContext
Definition: wdfdevice.h:1697
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
PFILE_OBJECT FileObject
Definition: iotypes.h:3169

◆ 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 {
176 
177  // get dispatch context
179 
180  // let IrpTarget handle request
182 }
_In_ UCHAR _In_ UCHAR _In_ ULONG _In_ WDFCONTEXT _Inout_ PIRP _In_ WDFCONTEXT DispatchContext
Definition: wdfdevice.h:1697
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:167
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
Definition: wdfio.h:318
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:318
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:859
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:949
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:318
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:155

◆ 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 {
198 
199  // get dispatch context
201 
202  // let IrpTarget handle request
204 }
_In_ UCHAR _In_ UCHAR _In_ ULONG _In_ WDFCONTEXT _Inout_ PIRP _In_ WDFCONTEXT DispatchContext
Definition: wdfdevice.h:1697
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:167
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
Definition: bufpool.h:45
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG LockKey
Definition: fatprocs.h:2662
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:159
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:155

◆ 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 {
219 
220  // get dispatch context
222  // let IrpTarget handle request
224 }
_In_ UCHAR _In_ UCHAR _In_ ULONG _In_ WDFCONTEXT _Inout_ PIRP _In_ WDFCONTEXT DispatchContext
Definition: wdfdevice.h:1697
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:167
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
Definition: bufpool.h:45
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG LockKey
Definition: fatprocs.h:2662
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:159
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:155

◆ 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;
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_ UCHAR _In_ UCHAR _In_ ULONG _In_ WDFCONTEXT _Inout_ PIRP _In_ WDFCONTEXT DispatchContext
Definition: wdfdevice.h:1697
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
PFILE_OBJECT FileObject
Definition: iotypes.h:3169

◆ 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;
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_ UCHAR _In_ UCHAR _In_ ULONG _In_ WDFCONTEXT _Inout_ PIRP _In_ WDFCONTEXT DispatchContext
Definition: wdfdevice.h:1697
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
PFILE_OBJECT FileObject
Definition: iotypes.h:3169

◆ 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;
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_ UCHAR _In_ UCHAR _In_ ULONG _In_ WDFCONTEXT _Inout_ PIRP _In_ WDFCONTEXT DispatchContext
Definition: wdfdevice.h:1697
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
PFILE_OBJECT FileObject
Definition: iotypes.h:3169

◆ 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;
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_ UCHAR _In_ UCHAR _In_ ULONG _In_ WDFCONTEXT _Inout_ PIRP _In_ WDFCONTEXT DispatchContext
Definition: wdfdevice.h:1697
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
PFILE_OBJECT FileObject
Definition: iotypes.h:3169

◆ 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;
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_ UCHAR _In_ UCHAR _In_ ULONG _In_ WDFCONTEXT _Inout_ PIRP _In_ WDFCONTEXT DispatchContext
Definition: wdfdevice.h:1697
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
PFILE_OBJECT FileObject
Definition: iotypes.h:3169

◆ 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;
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
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 }
_In_ UCHAR _In_ UCHAR _In_ ULONG _In_ WDFCONTEXT _Inout_ PIRP _In_ WDFCONTEXT DispatchContext
Definition: wdfdevice.h:1697
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#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
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
_In_ PIRP Irp
Definition: csq.h:116
Status
Definition: gdiplustypes.h:24
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
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
#define DPRINT
Definition: sndvol32.h:71
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:245

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.