ReactOS 0.4.16-dev-306-g647d351
filter.c File Reference
#include "stream.h"
Include dependency graph for filter.c:

Go to the source code of this file.

Functions

NTSTATUS NTAPI StreamClassCreatePin (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI FilterDispatch_fnDeviceIoControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI FilterDispatch_fnClose (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
VOID RegisterDeviceInterfaces (IN PSTREAM_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS InitializeFilterWithKs (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI StreamClassCreateFilter (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 

Variables

static KSDISPATCH_TABLE DispatchTable
 

Function Documentation

◆ FilterDispatch_fnClose()

NTSTATUS NTAPI FilterDispatch_fnClose ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 45 of file filter.c.

48{
50 PSTREAM_DEVICE_EXTENSION DeviceExtension;
51 HW_STREAM_REQUEST_BLOCK_EXT RequestBlock;
52
53 /* Get device extension */
55
57 {
58 /* driver supports only one instance */
59 if (DeviceExtension->InstanceCount)
60 {
61 /* there is already one instance open */
63 }
64 }
65 else
66 {
67 /* driver supports more than one filter instance */
68 RtlZeroMemory(&RequestBlock, sizeof(HW_STREAM_REQUEST_BLOCK_EXT));
69
70 /* set up request block */
72 RequestBlock.Block.HwDeviceExtension = DeviceExtension->DeviceExtension;
73 RequestBlock.Block.Irp = Irp;
75
76 /*FIXME SYNCHRONIZATION */
77
78 /* Send the request */
79 DeviceExtension->DriverExtension->Data.HwReceivePacket((PHW_STREAM_REQUEST_BLOCK)&RequestBlock);
80 if (RequestBlock.Block.Status == STATUS_PENDING)
81 {
82 /* Wait for the request */
83 KeWaitForSingleObject(&RequestBlock.Event, Executive, KernelMode, FALSE, NULL);
84 }
85 }
86
87 /* Increment total instance count */
88 InterlockedDecrement(&DeviceExtension->InstanceCount);
89
90 Irp->IoStatus.Status = Status;
91 Irp->IoStatus.Information = 0;
93 return Status;
94}
#define InterlockedDecrement
Definition: armddk.h:52
LONG NTSTATUS
Definition: precomp.h:26
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_PENDING
Definition: d3dkmdt.h:43
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
struct STREAM_DEVICE_EXTENSION * PSTREAM_DEVICE_EXTENSION
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
Status
Definition: gdiplustypes.h:25
if(dx< 0)
Definition: linetemp.h:194
#define KernelMode
Definition: asm.h:34
@ SynchronizationEvent
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_SUCCESS
Definition: shellext.h:65
@ SRB_CLOSE_DEVICE_INSTANCE
Definition: strmini.h:195
HW_STREAM_REQUEST_BLOCK Block
Definition: stream.h:54
HW_INITIALIZATION_DATA Data
Definition: stream.h:14
PSTREAM_CLASS_DRIVER_EXTENSION DriverExtension
Definition: stream.h:45
PHW_RECEIVE_DEVICE_SRB HwReceivePacket
Definition: strmini.h:356
ULONG FilterInstanceExtensionSize
Definition: strmini.h:362
SRB_COMMAND Command
Definition: strmini.h:224
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define IO_NO_INCREMENT
Definition: iotypes.h:598
@ Executive
Definition: ketypes.h:415

◆ FilterDispatch_fnDeviceIoControl()

NTSTATUS NTAPI FilterDispatch_fnDeviceIoControl ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 30 of file filter.c.

33{
34 DPRINT1("FilterDispatch Called\n");
35
36 Irp->IoStatus.Status = STATUS_SUCCESS;
37 Irp->IoStatus.Information = 0;
39 return STATUS_SUCCESS;
40}
#define DPRINT1
Definition: precomp.h:8

◆ InitializeFilterWithKs()

NTSTATUS InitializeFilterWithKs ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 150 of file filter.c.

153{
155 PSTREAM_DEVICE_EXTENSION DeviceExtension;
156 KSOBJECT_HEADER ObjectHeader;
157 PKSOBJECT_CREATE_ITEM CreateItem;
158 PIO_STACK_LOCATION IoStack;
159 HW_STREAM_REQUEST_BLOCK_EXT RequestBlock;
160 PVOID HwInstanceExtension = NULL;
161
162 /* Get device extension */
164
166 {
167 /* driver supports only one instance */
168 if (DeviceExtension->InstanceCount)
169 {
170 /* there is already one instance open */
171 return STATUS_UNSUCCESSFUL;
172 }
173 }
174 else
175 {
176 /* driver supports more than one filter instance */
177 RtlZeroMemory(&RequestBlock, sizeof(HW_STREAM_REQUEST_BLOCK_EXT));
178
179 /* allocate instance extension */
180 HwInstanceExtension = ExAllocatePool(NonPagedPool, DeviceExtension->DriverExtension->Data.FilterInstanceExtensionSize);
181 if (!HwInstanceExtension)
182 {
183 /* Not enough memory */
185 }
186
187 /* Zero instance extension */
188 RtlZeroMemory(HwInstanceExtension, DeviceExtension->DriverExtension->Data.FilterInstanceExtensionSize);
189
190 /* set up request block */
192 RequestBlock.Block.HwDeviceExtension = DeviceExtension->DeviceExtension;
193 RequestBlock.Block.Irp = Irp;
194 RequestBlock.Block.HwInstanceExtension = HwInstanceExtension;
196
197 /*FIXME SYNCHRONIZATION */
198
199 /* Send the request */
200 DeviceExtension->DriverExtension->Data.HwReceivePacket((PHW_STREAM_REQUEST_BLOCK)&RequestBlock);
201 if (RequestBlock.Block.Status == STATUS_PENDING)
202 {
203 /* Wait for the request */
204 KeWaitForSingleObject(&RequestBlock.Event, Executive, KernelMode, FALSE, NULL);
205 }
206 /* Check for success */
207 if (!NT_SUCCESS(RequestBlock.Block.Status))
208 {
209 /* Resource is not available */
210 ExFreePool(HwInstanceExtension);
211 return RequestBlock.Block.Status;
212 }
213 }
214
215 /* Allocate create item */
216 CreateItem = ExAllocatePool(NonPagedPool, sizeof(KSOBJECT_CREATE_ITEM));
217 if (!CreateItem)
218 {
219 /* not enough memory */
221 }
222
223 /* Zero create item */
224 RtlZeroMemory(CreateItem, sizeof(KSOBJECT_CREATE_ITEM));
225 /* Initialize createitem */
226 RtlInitUnicodeString(&CreateItem->ObjectClass, KSSTRING_Pin);
227 CreateItem->Create = StreamClassCreatePin;
228
229 /* Get current irp stack location */
231 /* Create Ks streaming object header */
232 Status = KsAllocateObjectHeader(&ObjectHeader, 1, CreateItem, Irp, &DispatchTable);
233 if (!NT_SUCCESS(Status))
234 {
235 /* Failed to create header */
236 ExFreePool(CreateItem);
237 if (HwInstanceExtension)
238 {
239 /* free instance buffer */
240 ExFreePool(HwInstanceExtension);
241 }
242 return Status;
243 }
244
245 /* Store instance buffer in file object context */
246 IoStack->FileObject->FsContext2 = HwInstanceExtension;
247
248 /* Increment total instance count */
249 InterlockedIncrement(&DeviceExtension->InstanceCount);
250
251 /* Register device stream interfaces */
252 RegisterDeviceInterfaces(DeviceExtension);
253
254 /* Return result */
255 return Status;
256
257}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define InterlockedIncrement
Definition: armddk.h:53
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
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
NTSTATUS NTAPI StreamClassCreatePin(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: filter.c:15
VOID RegisterDeviceInterfaces(IN PSTREAM_DEVICE_EXTENSION DeviceExtension)
Definition: filter.c:111
#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
#define KSSTRING_Pin
Definition: ks.h:48
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
@ SRB_OPEN_DEVICE_INSTANCE
Definition: strmini.h:194
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:248

Referenced by StreamClassCreateFilter().

◆ RegisterDeviceInterfaces()

VOID RegisterDeviceInterfaces ( IN PSTREAM_DEVICE_EXTENSION  DeviceExtension)

Definition at line 111 of file filter.c.

113{
114 ULONG Index;
115 PHW_STREAM_INFORMATION StreamInformation;
118
119 /* Sanity check */
120 ASSERT(DeviceExtension->StreamDescriptor);
121 ASSERT(DeviceExtension->StreamDescriptorSize);
122
123 /* Loop all stream descriptors and register device interfaces */
124 StreamInformation = (PHW_STREAM_INFORMATION)&DeviceExtension->StreamDescriptor->StreamInfo;
125
126 for(Index = 0; DeviceExtension->StreamDescriptor->StreamHeader.NumberOfStreams; Index++)
127 {
128 if (StreamInformation->Category)
129 {
130 /* Register device interface */
131 Status = IoRegisterDeviceInterface(DeviceExtension->PhysicalDeviceObject,
132 StreamInformation->Category,
133 NULL, /* see CORE-4218 and r42457 */
134 &SymbolicLink);
135
136 if (NT_SUCCESS(Status))
137 {
138 /* Activate device interface */
140 /* Release Symbolic Link */
142 }
143 }
144 StreamInformation = (PHW_STREAM_INFORMATION) (ULONG_PTR)StreamInformation + DeviceExtension->StreamDescriptor->StreamHeader.SizeOfHwStreamInformation;
145 }
146
147}
#define TRUE
Definition: types.h:120
static const WCHAR SymbolicLink[]
Definition: interface.c:31
#define ASSERT(a)
Definition: mode.c:44
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
Definition: deviface.c:955
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1311
struct _HW_STREAM_INFORMATION * PHW_STREAM_INFORMATION
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by InitializeFilterWithKs().

◆ StreamClassCreateFilter()

NTSTATUS NTAPI StreamClassCreateFilter ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 261 of file filter.c.

264{
266 DPRINT1("StreamClassCreateFilter Called\n");
267
268 /* Init filter */
270
271 Irp->IoStatus.Status = Status;
272 Irp->IoStatus.Information = 0;
274 return Status;
275}
NTSTATUS InitializeFilterWithKs(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: filter.c:150

Referenced by StreamClassAddDevice().

◆ StreamClassCreatePin()

NTSTATUS NTAPI StreamClassCreatePin ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 15 of file filter.c.

18{
20
21 Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
22 Irp->IoStatus.Information = 0;
25}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42

Referenced by InitializeFilterWithKs().

Variable Documentation

◆ DispatchTable

KSDISPATCH_TABLE DispatchTable
static
Initial value:
=
{
}
KSDDKAPI NTSTATUS NTAPI KsDispatchInvalidDeviceRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1189
NTSTATUS NTAPI FilterDispatch_fnClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: filter.c:45
NTSTATUS NTAPI FilterDispatch_fnDeviceIoControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: filter.c:30

Definition at line 96 of file filter.c.