ReactOS  0.4.14-dev-297-g23e575c
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 YDEBUG
14 #include <debug.h>
15 
17 NTAPI
20  PIRP Irp)
21 {
23  DbgBreakPoint();
24 
25  Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
26  Irp->IoStatus.Information = 0;
28  return STATUS_UNSUCCESSFUL;
29 }
30 
32 NTAPI
35  PIRP Irp)
36 {
38 
39  Irp->IoStatus.Status = STATUS_SUCCESS;
40  Irp->IoStatus.Information = 0;
42  return STATUS_SUCCESS;
43 }
44 
45 static KSDISPATCH_TABLE DispatchTable =
46 {
55  KsDispatchFastWriteFailure,
56  KsDispatchFastWriteFailure,
57 };
58 
60 NTAPI
63  IN PIRP Irp)
64 {
66 
67  DPRINT("DispatchCreateKMix entered\n");
68 
69  /* create the pin */
70  Status = CreatePin(Irp);
71 
72  /* save result */
73  Irp->IoStatus.Status = Status;
74  /* complete the request */
76  /* done */
77  return Status;
78 }
79 
81 NTAPI
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 
100 NTAPI
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 
177 NTSTATUS
178 NTAPI
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 }
202 
#define IN
Definition: typedefs.h:38
NTSTATUS NTAPI DispatchCreateKMixPin(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: filter.c:61
#define KSSTRING_Allocator
Definition: ks.h:50
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
KSDDKAPI NTSTATUS NTAPI KsReferenceSoftwareBusObject(IN KSDEVICE_HEADER Header)
Definition: device.c:805
KSDDKAPI VOID NTAPI KsDereferenceSoftwareBusObject(IN KSDEVICE_HEADER Header)
Definition: device.c:876
KSDDKAPI NTSTATUS NTAPI KsAllocateDeviceHeader(OUT KSDEVICE_HEADER *OutHeader, IN ULONG ItemsCount, IN PKSOBJECT_CREATE_ITEM ItemsList OPTIONAL)
Definition: api.c:522
_In_ PIRP Irp
Definition: csq.h:116
KSDDKAPI NTSTATUS NTAPI KsCreateDefaultAllocator(IN PIRP Irp)
Definition: allocators.c:384
#define KSSTRING_Pin
Definition: ks.h:48
LONG NTSTATUS
Definition: precomp.h:26
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:1218
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
void DbgBreakPoint()
Definition: mach.c:553
#define KSSTRING_Filter
Definition: ks.h:47
static KSDISPATCH_TABLE DispatchTable
Definition: filter.c:45
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
struct KMIXER_DEVICE_EXT * PKMIXER_DEVICE_EXT
PVOID DeviceExtension
Definition: env_spec_w32.h:418
NTSTATUS NTAPI Dispatch_fnDeviceIoControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: filter.c:18
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS NTAPI Dispatch_fnClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: filter.c:33
NTSTATUS NTAPI DispatchCreateKMixAllocator(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: filter.c:82
NTSTATUS NTAPI DispatchCreateKMix(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: filter.c:101
KSDDKAPI NTSTATUS NTAPI KsDispatchInvalidDeviceRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1156
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS CreatePin(IN PIRP Irp)
Definition: pin.c:699
NTSTATUS NTAPI KMixAllocateDeviceHeader(IN PKMIXER_DEVICE_EXT DeviceExtension)
Definition: filter.c:179
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
static const WCHAR L[]
Definition: oid.c:1250
KSDEVICE_HEADER KsDeviceHeader
Definition: kmixer.h:9
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
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 IO_NO_INCREMENT
Definition: iotypes.h:566
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNIMPLEMENTED
Definition: debug.h:114
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define ExFreePool(addr)
Definition: env_spec_w32.h:352