ReactOS 0.4.16-dev-338-g34e76ad
dispatcher.cpp
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Kernel Streaming
4 * FILE: drivers/wdm/audio/backpln/portcls/dispatcher.c
5 * PURPOSE: portcls generic dispatcher
6 * PROGRAMMER: Johannes Anderwald
7 */
8
9#include "private.hpp"
10
11#define NDEBUG
12#include <debug.h>
13
18 PIRP Irp)
19{
20 PIO_STACK_LOCATION IoStack;
22
23 // get current irp stack
25
26 // get dispatch context
27 DispatchContext = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
28
29 // let IrpTarget handle request
30 return DispatchContext->Target->DeviceIoControl(DeviceObject, Irp);
31}
32
37 PIRP Irp)
38{
39 PIO_STACK_LOCATION IoStack;
41
42 // get current irp stack
44
45 // get dispatch context
46 DispatchContext = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
47
48 // let IrpTarget handle request
49 return DispatchContext->Target->Read(DeviceObject, Irp);
50}
51
56 PIRP Irp)
57{
58 PIO_STACK_LOCATION IoStack;
60
61 // get current irp stack
63
64 // get dispatch context
65 DispatchContext = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
66
67 // let IrpTarget handle request
68 return DispatchContext->Target->Write(DeviceObject, Irp);
69}
70
75 PIRP Irp)
76{
77 PIO_STACK_LOCATION IoStack;
79
80 // get current irp stack
82
83 // get dispatch context
84 DispatchContext = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
85
86 // let IrpTarget handle request
87 return DispatchContext->Target->Flush(DeviceObject, Irp);
88}
89
94 PIRP Irp)
95{
96 PIO_STACK_LOCATION IoStack;
99
100 // get current irp stack
102 // get dispatch context
103 DispatchContext = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
104
105 // let IrpTarget handle request
106 Status = DispatchContext->Target->Close(DeviceObject, Irp);
107
108 if (NT_SUCCESS(Status))
109 {
110 KsFreeObjectHeader(DispatchContext->ObjectHeader);
112 }
113 // done
114 return Status;
115}
116
118NTAPI
121 PIRP Irp)
122{
123 PIO_STACK_LOCATION IoStack;
125
126 // get current irp stack
128
129 // get dispatch context
130 DispatchContext = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
131
132 // let IrpTarget handle request
133 return DispatchContext->Target->QuerySecurity(DeviceObject, Irp);
134}
135
137NTAPI
140 PIRP Irp)
141{
142 PIO_STACK_LOCATION IoStack;
144
145 // get current irp stack
147
148 // get dispatch context
149 DispatchContext = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
150
151 // let IrpTarget handle request
152 return DispatchContext->Target->SetSecurity(DeviceObject, Irp);
153}
154
156NTAPI
167{
169
170 // get dispatch context
172
173 // let IrpTarget handle request
175}
176
178NTAPI
188{
190
191 // get dispatch context
193
194 // let IrpTarget handle request
196}
197
199NTAPI
209{
211
212 // get dispatch context
214 // let IrpTarget handle request
216}
217
218static KSDISPATCH_TABLE DispatchTable =
219{
230};
231
233NTAPI
235 IN PIRP Irp,
236 IN IIrpTarget * Target,
237 IN ULONG CreateItemCount,
238 IN PKSOBJECT_CREATE_ITEM CreateItem)
239{
241 KSOBJECT_HEADER ObjectHeader;
242 PIO_STACK_LOCATION IoStack;
244
245 // get current irp stack location
247
249 if (!DispatchContext)
251
252 // allocate object header
253 Status = KsAllocateObjectHeader(&ObjectHeader, CreateItemCount, CreateItem, Irp, &DispatchTable);
254
255 if (!NT_SUCCESS(Status))
256 {
257 // free dispatch context
259 // done
260 return Status;
261 }
262
263 // initialize dispatch context
264 DispatchContext->ObjectHeader = ObjectHeader;
265 DispatchContext->Target = Target;
266 DispatchContext->CreateItem = CreateItem;
267
268 // store dispatch context
269 IoStack->FileObject->FsContext = DispatchContext;
270
271 DPRINT("KsAllocateObjectHeader result %x Target %p Context %p\n", Status, Target, DispatchContext);
272 return Status;
273}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:160
Definition: bufpool.h:45
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS NTAPI Dispatch_fnDeviceIoControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatcher.cpp:16
NTSTATUS NTAPI Dispatch_fnRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatcher.cpp:35
NTSTATUS NTAPI Dispatch_fnClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatcher.cpp:92
NTSTATUS NTAPI Dispatch_fnFlush(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatcher.cpp:73
NTSTATUS NTAPI NewDispatchObject(IN PIRP Irp, IN IIrpTarget *Target, IN ULONG CreateItemCount, IN PKSOBJECT_CREATE_ITEM CreateItem)
Definition: dispatcher.cpp:234
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:200
NTSTATUS NTAPI Dispatch_fnSetSecurity(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatcher.cpp:138
NTSTATUS NTAPI Dispatch_fnQuerySecurity(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatcher.cpp:119
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:179
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:157
NTSTATUS NTAPI Dispatch_fnWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatcher.cpp:54
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
KSDDKAPI VOID NTAPI KsFreeObjectHeader(IN PVOID Header)
Definition: api.c:720
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 NonPagedPool
Definition: env_spec_w32.h:307
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG LockKey
Definition: fatprocs.h:2666
static CABITEM * CreateItem(LPCWSTR Path, UINT Attrib, UINT Size, UINT DateTime)
Definition: folder.cpp:69
Status
Definition: gdiplustypes.h:25
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:29
VOID FreeItem(IN PVOID Item)
Definition: misc.c:37
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
#define TAG_PORTCLASS
Definition: private.hpp:24
#define DPRINT
Definition: sndvol32.h:73
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ UCHAR _In_ UCHAR _In_ ULONG _In_ WDFCONTEXT _Inout_ PIRP _In_ WDFCONTEXT DispatchContext
Definition: wdfdevice.h:1708
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:325
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:320
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
Definition: wdfio.h:322
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:248
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
* PFILE_OBJECT
Definition: iotypes.h:1998