ReactOS 0.4.15-dev-7994-gb388cb6
filter.c
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/filters/kmixer/filter.c
5 * PURPOSE: Filter File Context Header header
6 * PROGRAMMER: Johannes Anderwald
7 */
8
9#include "kmixer.h"
10
11#include <swenum.h>
12
13// #define NDEBUG
14#include <debug.h>
15
20 PIRP Irp)
21{
24
25 Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
26 Irp->IoStatus.Information = 0;
29}
30
35 PIRP Irp)
36{
38
39 Irp->IoStatus.Status = STATUS_SUCCESS;
40 Irp->IoStatus.Information = 0;
42 return STATUS_SUCCESS;
43}
44
45static KSDISPATCH_TABLE DispatchTable =
46{
55 KsDispatchFastWriteFailure,
56 KsDispatchFastWriteFailure,
57};
58
63 IN PIRP Irp)
64{
66
67 DPRINT("DispatchCreateKMix entered\n");
68
69 /* create the pin */
71
72 /* save result */
73 Irp->IoStatus.Status = Status;
74 /* complete the request */
76 /* done */
77 return Status;
78}
79
84 IN PIRP Irp)
85{
87
88 /* create the allocator */
90
91 /* save result */
92 Irp->IoStatus.Status = Status;
93 /* complete the request */
95 /* done */
96 return Status;
97}
98
100NTAPI
103 IN PIRP Irp)
104{
106 KSOBJECT_HEADER ObjectHeader;
107 PKSOBJECT_CREATE_ITEM CreateItem;
108 PKMIXER_DEVICE_EXT DeviceExtension;
109
110 DPRINT("DispatchCreateKMix entered\n");
111
112 /* check if the request was from usermode */
113 if (Irp->RequestorMode == UserMode)
114 {
115 /* deny access from usermode */
116 Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
117 Irp->IoStatus.Information = 0;
120 }
121
122 /* get device extension */
123 DeviceExtension = (PKMIXER_DEVICE_EXT)DeviceObject->DeviceExtension;
124
125#if 0
126 /* reference the software bus object */
128
129 if (!NT_SUCCESS(Status))
130 {
131 /* failed to reference bus object */
132 Irp->IoStatus.Status = Status;
133 Irp->IoStatus.Information = 0;
135 return Status;
136 }
137#endif
138
139 /* allocate create item */
140 CreateItem = ExAllocatePool(NonPagedPool, sizeof(KSOBJECT_CREATE_ITEM) * 2);
141 if (!CreateItem)
142 {
143 /* not enough memory */
144 Irp->IoStatus.Information = 0;
145 Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
148 }
149
150 /* zero create struct */
151 RtlZeroMemory(CreateItem, sizeof(KSOBJECT_CREATE_ITEM) * 2);
152
153 /* initialize pin create item */
154 CreateItem[0].Create = DispatchCreateKMixPin;
155 RtlInitUnicodeString(&CreateItem[0].ObjectClass, KSSTRING_Pin);
156 CreateItem[1].Create = DispatchCreateKMixAllocator;
157 RtlInitUnicodeString(&CreateItem[1].ObjectClass, KSSTRING_Allocator);
158
159 /* allocate object header */
160 Status = KsAllocateObjectHeader(&ObjectHeader, 2, CreateItem, Irp, &DispatchTable);
161
162 if (!NT_SUCCESS(Status))
163 {
164 /* failed to allocate object header */
165 ExFreePool(CreateItem);
167 }
168
169 DPRINT("KsAllocateObjectHeader result %x\n", Status);
170 /* complete the irp */
171 Irp->IoStatus.Information = 0;
172 Irp->IoStatus.Status = Status;
174 return Status;
175}
176
178NTAPI
180 IN PKMIXER_DEVICE_EXT DeviceExtension)
181{
183 PKSOBJECT_CREATE_ITEM CreateItem;
184
185 /* allocate create item */
186 CreateItem = ExAllocatePool(NonPagedPool, sizeof(KSOBJECT_CREATE_ITEM) * 2);
187 if (!CreateItem)
189
190 /* initialize create item struct */
191 RtlZeroMemory(CreateItem, sizeof(KSOBJECT_CREATE_ITEM) * 2);
192 CreateItem[0].Create = DispatchCreateKMix;
193 RtlInitUnicodeString(&CreateItem[0].ObjectClass, L"GLOBAL");
194 CreateItem[1].Create = DispatchCreateKMix;
195 RtlInitUnicodeString(&CreateItem[1].ObjectClass, KSSTRING_Filter);
196
197 Status = KsAllocateDeviceHeader(&DeviceExtension->KsDeviceHeader,
198 2,
199 CreateItem);
200 return Status;
201}
KSDDKAPI NTSTATUS NTAPI KsCreateDefaultAllocator(IN PIRP Irp)
Definition: allocators.c:384
LONG NTSTATUS
Definition: precomp.h:26
#define UNIMPLEMENTED
Definition: debug.h:115
_In_ PIRP Irp
Definition: csq.h:116
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
KSDDKAPI NTSTATUS NTAPI KsAllocateDeviceHeader(OUT KSDEVICE_HEADER *OutHeader, IN ULONG ItemsCount, IN PKSOBJECT_CREATE_ITEM ItemsList OPTIONAL)
Definition: api.c:522
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
KSDDKAPI NTSTATUS NTAPI KsReferenceSoftwareBusObject(IN KSDEVICE_HEADER Header)
Definition: device.c:780
KSDDKAPI VOID NTAPI KsDereferenceSoftwareBusObject(IN KSDEVICE_HEADER Header)
Definition: device.c:851
KSDDKAPI NTSTATUS NTAPI KsDispatchInvalidDeviceRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1189
KSDDKAPI BOOLEAN NTAPI KsDispatchFastIoDeviceControlFailure(IN PFILE_OBJECT FileObject, IN BOOLEAN Wait, IN PVOID InputBuffer OPTIONAL, IN ULONG InputBufferLength, OUT PVOID OutputBuffer OPTIONAL, IN ULONG OutputBufferLength, IN ULONG IoControlCode, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: irp.c:1251
NTSTATUS NTAPI Dispatch_fnDeviceIoControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: filter.c:18
NTSTATUS NTAPI DispatchCreateKMixAllocator(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: filter.c:82
NTSTATUS NTAPI Dispatch_fnClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: filter.c:33
NTSTATUS NTAPI DispatchCreateKMix(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: filter.c:101
NTSTATUS NTAPI DispatchCreateKMixPin(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: filter.c:61
NTSTATUS NTAPI KMixAllocateDeviceHeader(IN PKMIXER_DEVICE_EXT DeviceExtension)
Definition: filter.c:179
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define NonPagedPool
Definition: env_spec_w32.h:307
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
Status
Definition: gdiplustypes.h:25
NTSYSAPI void WINAPI DbgBreakPoint(void)
struct KMIXER_DEVICE_EXT * PKMIXER_DEVICE_EXT
NTSTATUS CreatePin(IN PIRP Irp)
Definition: pin.c:699
#define KSSTRING_Allocator
Definition: ks.h:50
#define KSSTRING_Pin
Definition: ks.h:48
#define KSSTRING_Filter
Definition: ks.h:47
#define UserMode
Definition: asm.h:35
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define IoCompleteRequest
Definition: irp.c:1240
#define L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
KSDEVICE_HEADER KsDeviceHeader
Definition: kmixer.h:9
#define NTAPI
Definition: typedefs.h:36
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:248
#define IO_NO_INCREMENT
Definition: iotypes.h:598