ReactOS 0.4.16-dev-297-gc569aee
filterfactory.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for filterfactory.c:

Go to the source code of this file.

Classes

struct  IKsFilterFactoryImpl
 

Macros

#define NDEBUG
 

Functions

VOID NTAPI IKsFilterFactory_ItemFreeCb (IN PKSOBJECT_CREATE_ITEM CreateItem)
 
NTSTATUS NTAPI IKsFilterFactory_Create (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IKsFilterFactory_fnQueryInterface (IKsFilterFactory *iface, IN REFIID refiid, OUT PVOID *Output)
 
ULONG NTAPI IKsFilterFactory_fnAddRef (IKsFilterFactory *iface)
 
ULONG NTAPI IKsFilterFactory_fnRelease (IKsFilterFactory *iface)
 
KSFILTERFACTORY *NTAPI IKsFilterFactory_fnGetStruct (IKsFilterFactory *iface)
 
NTSTATUS NTAPI IKsFilterFactory_fnSetDeviceClassesState (IKsFilterFactory *iface, IN BOOLEAN Enable)
 
VOID IKsFilterFactory_AttachFilterFactoryToDeviceHeader (IKsFilterFactoryImpl *This, PKSIDEVICE_HEADER DeviceHeader)
 
NTSTATUS NTAPI IKsFilterFactory_fnInitialize (IKsFilterFactory *iface, IN PDEVICE_OBJECT DeviceObject, IN const KSFILTER_DESCRIPTOR *Descriptor, IN PWSTR RefString OPTIONAL, IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL, IN ULONG CreateItemFlags, IN PFNKSFILTERFACTORYPOWER SleepCallback OPTIONAL, IN PFNKSFILTERFACTORYPOWER WakeCallback OPTIONAL, OUT PKSFILTERFACTORY *FilterFactory OPTIONAL)
 
NTSTATUS NTAPI KspCreateFilterFactory (IN PDEVICE_OBJECT DeviceObject, IN const KSFILTER_DESCRIPTOR *Descriptor, IN PWSTR RefString OPTIONAL, IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL, IN ULONG CreateItemFlags, IN PFNKSFILTERFACTORYPOWER SleepCallback OPTIONAL, IN PFNKSFILTERFACTORYPOWER WakeCallback OPTIONAL, OUT PKSFILTERFACTORY *FilterFactory OPTIONAL)
 
KSDDKAPI NTSTATUS NTAPI KsCreateFilterFactory (IN PDEVICE_OBJECT DeviceObject, IN const KSFILTER_DESCRIPTOR *Descriptor, IN PWSTR RefString OPTIONAL, IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL, IN ULONG CreateItemFlags, IN PFNKSFILTERFACTORYPOWER SleepCallback OPTIONAL, IN PFNKSFILTERFACTORYPOWER WakeCallback OPTIONAL, OUT PKSFILTERFACTORY *FilterFactory OPTIONAL)
 
KSDDKAPI NTSTATUS NTAPI KsFilterFactorySetDeviceClassesState (IN PKSFILTERFACTORY FilterFactory, IN BOOLEAN NewState)
 
KSDDKAPI PUNICODE_STRING NTAPI KsFilterFactoryGetSymbolicLink (IN PKSFILTERFACTORY FilterFactory)
 
KSDDKAPI NTSTATUS NTAPI KsFilterFactoryAddCreateItem (IN PKSFILTERFACTORY FilterFactory, IN PWSTR RefString, IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL, IN ULONG CreateItemFlags)
 
ULONG KspCacheAddData (PKSPCACHE_DESCRIPTOR Descriptor, LPCVOID Data, ULONG Length)
 
KSDDKAPI NTSTATUS NTAPI KsFilterFactoryUpdateCacheData (IN PKSFILTERFACTORY FilterFactory, IN const KSFILTER_DESCRIPTOR *FilterDescriptor OPTIONAL)
 

Variables

static IKsFilterFactoryVtbl vt_IKsFilterFactoryVtbl
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file filterfactory.c.

Function Documentation

◆ IKsFilterFactory_AttachFilterFactoryToDeviceHeader()

VOID IKsFilterFactory_AttachFilterFactoryToDeviceHeader ( IKsFilterFactoryImpl This,
PKSIDEVICE_HEADER  DeviceHeader 
)

Definition at line 173 of file filterfactory.c.

176{
177 PKSBASIC_HEADER BasicHeader;
178 PKSFILTERFACTORY FilterFactory;
179
180 if (DeviceHeader->BasicHeader.FirstChild.FilterFactory == NULL)
181 {
182 /* first attached filter factory */
183 DeviceHeader->BasicHeader.FirstChild.FilterFactory = &This->FilterFactory;
184 return;
185 }
186
187 /* set to first entry */
188 FilterFactory = DeviceHeader->BasicHeader.FirstChild.FilterFactory;
189
190 do
191 {
192 /* get basic header */
193 BasicHeader = (PKSBASIC_HEADER)((ULONG_PTR)FilterFactory - sizeof(KSBASIC_HEADER));
194 /* sanity check */
195 ASSERT(BasicHeader->Type == KsObjectTypeFilterFactory);
196
197 if (BasicHeader->Next.FilterFactory)
198 {
199 /* iterate to next filter factory */
200 FilterFactory = BasicHeader->Next.FilterFactory;
201 }
202 else
203 {
204 /* found last entry */
205 break;
206 }
207 }while(FilterFactory);
208
209 /* attach filter factory */
210 BasicHeader->Next.FilterFactory = &This->FilterFactory;
211}
#define NULL
Definition: types.h:112
@ KsObjectTypeFilterFactory
Definition: ks.h:1209
struct KSBASIC_HEADER * PKSBASIC_HEADER
#define ASSERT(a)
Definition: mode.c:44
union KSBASIC_HEADER::@984 FirstChild
KSOBJECTTYPE Type
Definition: kstypes.h:56
union KSBASIC_HEADER::@983 Next
PKSFILTERFACTORY FilterFactory
Definition: kstypes.h:72
KSBASIC_HEADER BasicHeader
Definition: kstypes.h:87
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by IKsFilterFactory_fnInitialize().

◆ IKsFilterFactory_Create()

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

Definition at line 42 of file filterfactory.c.

45{
46 PKSOBJECT_CREATE_ITEM CreateItem;
48 IKsFilterFactory * iface;
50
51 /* access the create item */
52 CreateItem = KSCREATE_ITEM_IRP_STORAGE(Irp);
53 if (!CreateItem)
54 {
55 DPRINT1("IKsFilterFactory_Create no CreateItem\n");
57 }
58
59 /* get filter factory interface */
60 Factory = (IKsFilterFactoryImpl*)CONTAINING_RECORD(CreateItem->Context, IKsFilterFactoryImpl, FilterFactory);
61
62 /* get interface */
63 iface = (IKsFilterFactory*)&Factory->Header.OuterUnknown;
64
65 /* create a filter instance */
67
68 DPRINT("KspCreateFilter Status %x\n", Status);
69
71 {
72 Irp->IoStatus.Information = 0;
73 Irp->IoStatus.Status = Status;
75 }
76
77 return Status;
78}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_PENDING
Definition: d3dkmdt.h:43
NTSTATUS NTAPI CompleteRequest(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: dispatch.c:19
NTSTATUS NTAPI KspCreateFilter(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN IKsFilterFactory *iface)
Definition: filter.c:1636
Status
Definition: gdiplustypes.h:25
#define DPRINT
Definition: sndvol32.h:73
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Referenced by IKsFilterFactory_fnInitialize(), KsFilterFactoryAddCreateItem(), and KspSetFilterFactoriesState().

◆ IKsFilterFactory_fnAddRef()

ULONG NTAPI IKsFilterFactory_fnAddRef ( IKsFilterFactory *  iface)

Definition at line 117 of file filterfactory.c.

119{
121
122 return InterlockedIncrement(&This->ref);
123}
#define InterlockedIncrement
Definition: armddk.h:53
Definition: Header.h:9

◆ IKsFilterFactory_fnGetStruct()

KSFILTERFACTORY *NTAPI IKsFilterFactory_fnGetStruct ( IKsFilterFactory *  iface)

Definition at line 153 of file filterfactory.c.

155{
157
158 return &This->FilterFactory;
159}

◆ IKsFilterFactory_fnInitialize()

NTSTATUS NTAPI IKsFilterFactory_fnInitialize ( IKsFilterFactory *  iface,
IN PDEVICE_OBJECT  DeviceObject,
IN const KSFILTER_DESCRIPTOR *  Descriptor,
IN PWSTR RefString  OPTIONAL,
IN PSECURITY_DESCRIPTOR SecurityDescriptor  OPTIONAL,
IN ULONG  CreateItemFlags,
IN PFNKSFILTERFACTORYPOWER SleepCallback  OPTIONAL,
IN PFNKSFILTERFACTORYPOWER WakeCallback  OPTIONAL,
OUT PKSFILTERFACTORY *FilterFactory  OPTIONAL 
)

Definition at line 215 of file filterfactory.c.

225{
228 PDEVICE_EXTENSION DeviceExtension;
229 KSOBJECT_CREATE_ITEM CreateItem;
230 BOOL FreeString = FALSE;
231 IKsDevice * KsDevice;
232
234
235 /* get device extension */
236 DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
237
238 /* initialize filterfactory */
239 This->SleepCallback = SleepCallback;
240 This->WakeCallback = WakeCallback;
241 This->Header.KsDevice = &DeviceExtension->DeviceHeader->KsDevice;
242 This->Header.Type = KsObjectTypeFilterFactory;
243 This->Header.Parent.KsDevice = &DeviceExtension->DeviceHeader->KsDevice;
244 This->DeviceHeader = DeviceExtension->DeviceHeader;
245
246 /* copy descriptor */
247 This->FilterFactory.FilterDescriptor = AllocateItem(NonPagedPool, sizeof(KSFILTER_DESCRIPTOR));
248 if (!This->FilterFactory.FilterDescriptor)
249 {
250 DPRINT1("Out of memory\n");
252 }
253 RtlMoveMemory((PVOID)This->FilterFactory.FilterDescriptor, (PVOID)Descriptor, sizeof(KSFILTER_DESCRIPTOR));
254
255 /* initialize filter factory control mutex */
256 This->Header.ControlMutex = &This->ControlMutex;
257 KeInitializeMutex(This->Header.ControlMutex, 0);
258
259 /* unused fields */
260 InitializeListHead(&This->Header.EventList);
261 KeInitializeSpinLock(&This->Header.EventListLock);
262
263 InitializeListHead(&This->SymbolicLinkList);
264
265 /* does the device use a reference string */
266 if (RefString || !Descriptor->ReferenceGuid)
267 {
268 /* use device reference string */
270 }
271 else
272 {
273 /* create reference string from descriptor guid */
275
276 /* check for success */
277 if (!NT_SUCCESS(Status))
278 {
279 /* omg, we failed */
280 return Status;
281 }
282
283 FreeString = TRUE;
284 }
285
286 DPRINT("IKsFilterFactory_fnInitialize CategoriesCount %u ReferenceString '%S'\n", Descriptor->CategoriesCount,ReferenceString.Buffer);
287
288 /* now register the device interface */
289 Status = KspRegisterDeviceInterfaces(DeviceExtension->DeviceHeader->KsDevice.PhysicalDeviceObject,
290 Descriptor->CategoriesCount,
291 Descriptor->Categories,
293 &This->SymbolicLinkList);
294 /* check for success */
295 if (!NT_SUCCESS(Status))
296 {
297 DPRINT1("KspRegisterDeviceInterfaces failed with %x\n", Status);
298
299 if (FreeString)
300 {
301 /* free unicode string */
303 }
304
305 return Status;
306 }
307
308 /* now setup the create item */
309 CreateItem.SecurityDescriptor = SecurityDescriptor;
310 CreateItem.Flags = CreateItemFlags;
311 CreateItem.Create = IKsFilterFactory_Create;
312 CreateItem.Context = (PVOID)&This->FilterFactory;
313 RtlInitUnicodeString(&CreateItem.ObjectClass, ReferenceString.Buffer);
314
315 /* insert create item to device header */
316 Status = KsAllocateObjectCreateItem((KSDEVICE_HEADER)DeviceExtension->DeviceHeader, &CreateItem, TRUE, IKsFilterFactory_ItemFreeCb);
317
318 if (FreeString)
319 {
320 /* free unicode string */
322 }
323
324 /* create a object bag for the filter factory */
325 This->FilterFactory.Bag = AllocateItem(NonPagedPool, sizeof(KSIOBJECT_BAG));
326 if (This->FilterFactory.Bag)
327 {
328 /* initialize object bag */
329 KsDevice = (IKsDevice*)&DeviceExtension->DeviceHeader->BasicHeader.OuterUnknown;
330 KsDevice->lpVtbl->InitializeObjectBag(KsDevice, (PKSIOBJECT_BAG)This->FilterFactory.Bag, NULL);
331 }
332
333 if (FilterFactory)
334 {
335 /* return filterfactory */
336 *FilterFactory = &This->FilterFactory;
337 }
338
339 /* attach filterfactory to device header */
340 IKsFilterFactory_AttachFilterFactoryToDeviceHeader(This, DeviceExtension->DeviceHeader);
341
342 /* return result */
343 return Status;
344}
NTSTATUS KspRegisterDeviceInterfaces(IN PDEVICE_OBJECT PhysicalDeviceObject, IN ULONG CategoriesCount, IN GUID const *Categories, IN PUNICODE_STRING ReferenceString, OUT PLIST_ENTRY SymbolicLinkList)
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION
KSDDKAPI NTSTATUS NTAPI KsAllocateObjectCreateItem(IN KSDEVICE_HEADER DevHeader, IN PKSOBJECT_CREATE_ITEM CreateItem, IN BOOLEAN AllocateEntry, IN PFNKSITEMFREECALLBACK ItemFreeCallback OPTIONAL)
Definition: api.c:886
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSTATUS NTAPI IKsFilterFactory_Create(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: filterfactory.c:42
VOID NTAPI IKsFilterFactory_ItemFreeCb(IN PKSOBJECT_CREATE_ITEM CreateItem)
Definition: filterfactory.c:31
VOID IKsFilterFactory_AttachFilterFactoryToDeviceHeader(IKsFilterFactoryImpl *This, PKSIDEVICE_HEADER DeviceHeader)
__in WDFDEVICE __in CONST GUID __in_opt PCUNICODE_STRING RefString
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:29
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
Definition: mutex.c:67
void * PVOID
Definition: typedefs.h:50
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDEVICE _In_ CONST GUID _In_opt_ PCUNICODE_STRING ReferenceString
Definition: wdfdevice.h:3630
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH _In_opt_ PEPROCESS _In_opt_ PETHREAD _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
Definition: wsk.h:191

◆ IKsFilterFactory_fnQueryInterface()

NTSTATUS NTAPI IKsFilterFactory_fnQueryInterface ( IKsFilterFactory *  iface,
IN REFIID  refiid,
OUT PVOID Output 
)

Definition at line 83 of file filterfactory.c.

87{
89
91
92 if (IsEqualGUIDAligned(refiid, &IID_IUnknown))
93 {
94 *Output = &This->Header.OuterUnknown;
96 return STATUS_SUCCESS;
97 }
98
99 if (This->Header.ClientAggregate)
100 {
101 /* using client aggregate */
102 Status = This->Header.ClientAggregate->lpVtbl->QueryInterface(This->Header.ClientAggregate, refiid, Output);
103
104 if (NT_SUCCESS(Status))
105 {
106 /* client aggregate supports interface */
107 return Status;
108 }
109 }
110
111 DPRINT("IKsFilterFactory_fnQueryInterface no interface\n");
113}
const GUID IID_IUnknown
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
long __cdecl _InterlockedIncrement(_Interlocked_operand_ long volatile *_Addend)
@ Output
Definition: arc.h:85
#define STATUS_SUCCESS
Definition: shellext.h:65
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235

◆ IKsFilterFactory_fnRelease()

ULONG NTAPI IKsFilterFactory_fnRelease ( IKsFilterFactory *  iface)

Definition at line 127 of file filterfactory.c.

129{
131
133
134 if (This->ref == 0)
135 {
136 if (!IsListEmpty(&This->SymbolicLinkList))
137 {
138 /* disable device interfaces */
139 KspSetDeviceInterfacesState(&This->SymbolicLinkList, FALSE);
140 /* free device interface strings */
141 KspFreeDeviceInterfaces(&This->SymbolicLinkList);
142 }
143
144 FreeItem(This);
145 return 0;
146 }
147 /* Return new reference count */
148 return This->ref;
149}
#define InterlockedDecrement
Definition: armddk.h:52
NTSTATUS KspSetDeviceInterfacesState(IN PLIST_ENTRY ListHead, IN BOOL Enable)
NTSTATUS KspFreeDeviceInterfaces(IN PLIST_ENTRY ListHead)
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
VOID FreeItem(IN PVOID Item)
Definition: misc.c:37

◆ IKsFilterFactory_fnSetDeviceClassesState()

NTSTATUS NTAPI IKsFilterFactory_fnSetDeviceClassesState ( IKsFilterFactory *  iface,
IN BOOLEAN  Enable 
)

Definition at line 163 of file filterfactory.c.

166{
168
169 return KspSetDeviceInterfacesState(&This->SymbolicLinkList, Enable);
170}
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:142

◆ IKsFilterFactory_ItemFreeCb()

VOID NTAPI IKsFilterFactory_ItemFreeCb ( IN PKSOBJECT_CREATE_ITEM  CreateItem)

Definition at line 31 of file filterfactory.c.

33{
34 /* callback when create item is freed in the device header */
35 IKsFilterFactory * iface = (IKsFilterFactory*)CONTAINING_RECORD(CreateItem->Context, IKsFilterFactoryImpl, FilterFactory);
36
37 iface->lpVtbl->Release(iface);
38}

Referenced by IKsFilterFactory_fnInitialize(), and KsFilterFactoryAddCreateItem().

◆ KsCreateFilterFactory()

KSDDKAPI NTSTATUS NTAPI KsCreateFilterFactory ( IN PDEVICE_OBJECT  DeviceObject,
IN const KSFILTER_DESCRIPTOR *  Descriptor,
IN PWSTR RefString  OPTIONAL,
IN PSECURITY_DESCRIPTOR SecurityDescriptor  OPTIONAL,
IN ULONG  CreateItemFlags,
IN PFNKSFILTERFACTORYPOWER SleepCallback  OPTIONAL,
IN PFNKSFILTERFACTORYPOWER WakeCallback  OPTIONAL,
OUT PKSFILTERFACTORY *FilterFactory  OPTIONAL 
)

Definition at line 413 of file filterfactory.c.

422{
423 return KspCreateFilterFactory(DeviceObject, Descriptor, RefString, SecurityDescriptor, CreateItemFlags, SleepCallback, WakeCallback, FilterFactory);
424
425}
NTSTATUS NTAPI KspCreateFilterFactory(IN PDEVICE_OBJECT DeviceObject, IN const KSFILTER_DESCRIPTOR *Descriptor, IN PWSTR RefString OPTIONAL, IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL, IN ULONG CreateItemFlags, IN PFNKSFILTERFACTORYPOWER SleepCallback OPTIONAL, IN PFNKSFILTERFACTORYPOWER WakeCallback OPTIONAL, OUT PKSFILTERFACTORY *FilterFactory OPTIONAL)

Referenced by BdaCreateFilterFactoryEx(), and USBAudioCreateFilterContext().

◆ KsFilterFactoryAddCreateItem()

KSDDKAPI NTSTATUS NTAPI KsFilterFactoryAddCreateItem ( IN PKSFILTERFACTORY  FilterFactory,
IN PWSTR  RefString,
IN PSECURITY_DESCRIPTOR SecurityDescriptor  OPTIONAL,
IN ULONG  CreateItemFlags 
)

Definition at line 476 of file filterfactory.c.

481{
482 KSOBJECT_CREATE_ITEM CreateItem;
483
485
486 /* initialize create item */
487 CreateItem.Context = (PVOID)&Factory->FilterFactory;
488 CreateItem.Create = IKsFilterFactory_Create;
489 CreateItem.Flags = CreateItemFlags;
490 CreateItem.SecurityDescriptor = SecurityDescriptor;
491 RtlInitUnicodeString(&CreateItem.ObjectClass, RefString);
492
493 /* insert create item to device header */
495}

◆ KsFilterFactoryGetSymbolicLink()

KSDDKAPI PUNICODE_STRING NTAPI KsFilterFactoryGetSymbolicLink ( IN PKSFILTERFACTORY  FilterFactory)

Definition at line 451 of file filterfactory.c.

453{
454 PSYMBOLIC_LINK_ENTRY LinkEntry;
456
457 if (IsListEmpty(&Factory->SymbolicLinkList))
458 {
459 /* device has not registered any interfaces */
460 return NULL;
461 }
462
463 /* get first entry */
464 LinkEntry = (PSYMBOLIC_LINK_ENTRY)CONTAINING_RECORD(Factory->SymbolicLinkList.Flink, SYMBOLIC_LINK_ENTRY, Entry);
465
466 /* return first link */
467 return &LinkEntry->SymbolicLink;
468}
struct SYMBOLIC_LINK_ENTRY * PSYMBOLIC_LINK_ENTRY
base of all file and directory entries
Definition: entries.h:83
Definition: kstypes.h:122
UNICODE_STRING SymbolicLink
Definition: kstypes.h:124

◆ KsFilterFactorySetDeviceClassesState()

KSDDKAPI NTSTATUS NTAPI KsFilterFactorySetDeviceClassesState ( IN PKSFILTERFACTORY  FilterFactory,
IN BOOLEAN  NewState 
)

Definition at line 433 of file filterfactory.c.

436{
437 IKsFilterFactory * Factory;
439
440 Factory = (IKsFilterFactory*)&This->Header.OuterUnknown;
441 return Factory->lpVtbl->SetDeviceClassesState(Factory, NewState);
442}

Referenced by KspSetFilterFactoriesState().

◆ KsFilterFactoryUpdateCacheData()

KSDDKAPI NTSTATUS NTAPI KsFilterFactoryUpdateCacheData ( IN PKSFILTERFACTORY  FilterFactory,
IN const KSFILTER_DESCRIPTOR *FilterDescriptor  OPTIONAL 
)

Definition at line 541 of file filterfactory.c.

544{
546 PKSPCACHE_FILTER_HEADER FilterHeader;
548 PKSPCACHE_PIN_HEADER PinHeader;
549 ULONG Index, SubIndex;
551 PSYMBOLIC_LINK_ENTRY SymEntry;
553 HANDLE hKey;
555
557
558 DPRINT("KsFilterFactoryUpdateCacheData %p\n", FilterDescriptor);
559
560 if (!FilterDescriptor)
561 FilterDescriptor = Factory->FilterFactory.FilterDescriptor;
562
564
565 /* initialize cache descriptor */
567
568 /* calculate filter data size */
569 Descriptor.FilterLength = sizeof(KSPCACHE_FILTER_HEADER);
570
571 /* FIXME support variable size pin descriptors */
572 ASSERT(FilterDescriptor->PinDescriptorSize == sizeof(KSPIN_DESCRIPTOR_EX));
573
574 for(Index = 0; Index < FilterDescriptor->PinDescriptorsCount; Index++)
575 {
576 /* add filter descriptor */
577 Descriptor.FilterLength += sizeof(KSPCACHE_PIN_HEADER);
578
579 if (FilterDescriptor->PinDescriptors[Index].PinDescriptor.Category)
580 {
581 /* add extra ULONG for offset to category */
582 Descriptor.FilterLength += sizeof(ULONG);
583
584 /* add size for clsid */
585 Descriptor.DataLength += sizeof(CLSID);
586 }
587
588 /* add space for formats */
589 Descriptor.FilterLength += FilterDescriptor->PinDescriptors[Index].PinDescriptor.DataRangesCount * sizeof(KSPCACHE_DATARANGE);
590
591 /* add space for MajorFormat / MinorFormat */
592 Descriptor.DataLength += FilterDescriptor->PinDescriptors[Index].PinDescriptor.DataRangesCount * sizeof(CLSID) * 2;
593
594 /* add space for mediums */
595 Descriptor.FilterLength += FilterDescriptor->PinDescriptors[Index].PinDescriptor.MediumsCount * sizeof(ULONG);
596
597 /* add space for the data */
598 Descriptor.DataLength += FilterDescriptor->PinDescriptors[Index].PinDescriptor.MediumsCount * sizeof(KSPCACHE_MEDIUM);
599 }
600
601 /* now allocate the space */
602 Descriptor.FilterData = (PUCHAR)AllocateItem(NonPagedPool, Descriptor.DataLength + Descriptor.FilterLength);
603 if (!Descriptor.FilterData)
604 {
605 /* no memory */
607 }
608
609 /* initialize data cache */
610 Descriptor.DataCache = (PUCHAR)((ULONG_PTR)Descriptor.FilterData + Descriptor.FilterLength);
611
612 /* setup filter header */
613 FilterHeader = (PKSPCACHE_FILTER_HEADER)Descriptor.FilterData;
614
615 FilterHeader->dwVersion = 2;
616 FilterHeader->dwMerit = MERIT_DO_NOT_USE;
617 FilterHeader->dwUnused = 0;
618 FilterHeader->dwPins = FilterDescriptor->PinDescriptorsCount;
619
620 Descriptor.FilterOffset = sizeof(KSPCACHE_FILTER_HEADER);
621
622 /* write pin headers */
623 for(Index = 0; Index < FilterDescriptor->PinDescriptorsCount; Index++)
624 {
625 /* get offset to pin */
626 PinHeader = (PKSPCACHE_PIN_HEADER)((ULONG_PTR)Descriptor.FilterData + Descriptor.FilterOffset);
627
628 /* write pin header */
629 PinHeader->Signature = 0x33697030 + Index;
630 PinHeader->Flags = 0;
631 PinHeader->Instances = FilterDescriptor->PinDescriptors[Index].InstancesPossible;
632 if (PinHeader->Instances > 1)
633 PinHeader->Flags |= REG_PINFLAG_B_MANY;
634
635
636 PinHeader->MediaTypes = FilterDescriptor->PinDescriptors[Index].PinDescriptor.DataRangesCount;
637 PinHeader->Mediums = FilterDescriptor->PinDescriptors[Index].PinDescriptor.MediumsCount;
638 PinHeader->Category = (FilterDescriptor->PinDescriptors[Index].PinDescriptor.Category ? TRUE : FALSE);
639
640 Descriptor.FilterOffset += sizeof(KSPCACHE_PIN_HEADER);
641
642 if (PinHeader->Category)
643 {
644 /* get category offset */
645 PULONG Category = (PULONG)(PinHeader + 1);
646
647 /* write category offset */
648 *Category = KspCacheAddData(&Descriptor, FilterDescriptor->PinDescriptors[Index].PinDescriptor.Category, sizeof(CLSID));
649
650 /* adjust offset */
651 Descriptor.FilterOffset += sizeof(ULONG);
652 }
653
654 /* add dataranges */
655 for(SubIndex = 0; SubIndex < FilterDescriptor->PinDescriptors[Index].PinDescriptor.DataRangesCount; SubIndex++)
656 {
657 /* get datarange offset */
658 PKSPCACHE_DATARANGE DataRange = (PKSPCACHE_DATARANGE)((ULONG_PTR)Descriptor.FilterData + Descriptor.FilterOffset);
659
660 /* initialize data range */
661 DataRange->Signature = 0x33797430 + SubIndex;
662 DataRange->dwUnused = 0;
663 DataRange->OffsetMajor = KspCacheAddData(&Descriptor, &FilterDescriptor->PinDescriptors[Index].PinDescriptor.DataRanges[SubIndex]->MajorFormat, sizeof(CLSID));
664 DataRange->OffsetMinor = KspCacheAddData(&Descriptor, &FilterDescriptor->PinDescriptors[Index].PinDescriptor.DataRanges[SubIndex]->SubFormat, sizeof(CLSID));
665
666 /* adjust offset */
667 Descriptor.FilterOffset += sizeof(KSPCACHE_DATARANGE);
668 }
669
670 /* add mediums */
671 for(SubIndex = 0; SubIndex < FilterDescriptor->PinDescriptors[Index].PinDescriptor.MediumsCount; SubIndex++)
672 {
673 KSPCACHE_MEDIUM Medium;
674 PULONG MediumOffset;
675
676 /* get pin medium offset */
677 MediumOffset = (PULONG)((ULONG_PTR)Descriptor.FilterData + Descriptor.FilterOffset);
678
679 /* copy medium guid */
680 RtlMoveMemory(&Medium.Medium, &FilterDescriptor->PinDescriptors[Index].PinDescriptor.Mediums[SubIndex].Set, sizeof(GUID));
681 Medium.dw1 = FilterDescriptor->PinDescriptors[Index].PinDescriptor.Mediums[SubIndex].Id; /* FIXME verify */
682 Medium.dw2 = 0;
683
684 *MediumOffset = KspCacheAddData(&Descriptor, &Medium, sizeof(KSPCACHE_MEDIUM));
685
686 /* adjust offset */
687 Descriptor.FilterOffset += sizeof(ULONG);
688 }
689 }
690
691 /* sanity checks */
692 ASSERT(Descriptor.FilterOffset == Descriptor.FilterLength);
693 ASSERT(Descriptor.DataOffset <= Descriptor.DataLength);
694
695
696 /* now go through all entries and update 'FilterData' key */
697 for(Index = 0; Index < FilterDescriptor->CategoriesCount; Index++)
698 {
699 /* get first entry */
700 Entry = Factory->SymbolicLinkList.Flink;
701
702 /* set status to not found */
703 Found = FALSE;
704 /* loop list until the the current category is found */
705 while(Entry != &Factory->SymbolicLinkList)
706 {
707 /* fetch symbolic link entry */
709
710 if (IsEqualGUIDAligned(&SymEntry->DeviceInterfaceClass, &FilterDescriptor->Categories[Index]))
711 {
712 /* found category */
713 Found = TRUE;
714 break;
715 }
716
717 /* move to next entry */
718 Entry = Entry->Flink;
719 }
720
721 if (!Found)
722 {
723 /* filter category is not present */
725 break;
726 }
727
728 /* now open device interface */
730 if (!NT_SUCCESS(Status))
731 {
732 /* failed to open interface key */
733 break;
734 }
735
736 /* update filterdata key */
737 Status = ZwSetValueKey(hKey, &FilterData, 0, REG_BINARY, Descriptor.FilterData, Descriptor.FilterLength + Descriptor.DataOffset);
738
739 /* close filterdata key */
740 ZwClose(hKey);
741
742 if (!NT_SUCCESS(Status))
743 {
744 /* failed to set key value */
745 break;
746 }
747 }
748 /* free filter data */
749 FreeItem(Descriptor.FilterData);
750
751 /* done */
752 return Status;
753}
unsigned char BOOLEAN
return Found
Definition: dirsup.c:1270
#define REG_PINFLAG_B_MANY
Definition: precomp.h:17
#define MERIT_DO_NOT_USE
Definition: precomp.h:18
ULONG KspCacheAddData(PKSPCACHE_DESCRIPTOR Descriptor, LPCVOID Data, ULONG Length)
FxAutoRegKey hKey
struct KSPCACHE_PIN_HEADER * PKSPCACHE_PIN_HEADER
struct KSPCACHE_FILTER_HEADER * PKSPCACHE_FILTER_HEADER
struct KSPCACHE_DATARANGE * PKSPCACHE_DATARANGE
IID CLSID
Definition: mstsclib_i.c:62
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define REG_BINARY
Definition: nt_native.h:1496
#define KEY_WRITE
Definition: nt_native.h:1031
NTSTATUS NTAPI IoOpenDeviceInterfaceRegistryKey(IN PUNICODE_STRING SymbolicLinkName, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DeviceInterfaceKey)
Definition: deviface.c:241
#define L(x)
Definition: ntvdm.h:50
const KSFILTER_DESCRIPTOR FilterDescriptor
Definition: splitter.c:229
CLSID Medium
Definition: kstypes.h:277
CLSID DeviceInterfaceClass
Definition: kstypes.h:125
Definition: typedefs.h:120
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
uint32_t * PULONG
Definition: typedefs.h:59
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ WDFCOLLECTION _In_ ULONG Index
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR _In_ ULONGLONG _In_ ULONGLONG _In_opt_ PEVENT_FILTER_DESCRIPTOR FilterData
Definition: wmitypes.h:59

Referenced by BdaFilterFactoryUpdateCacheData().

◆ KspCacheAddData()

ULONG KspCacheAddData ( PKSPCACHE_DESCRIPTOR  Descriptor,
LPCVOID  Data,
ULONG  Length 
)

Definition at line 498 of file filterfactory.c.

502{
503 ULONG Index;
504
505 for(Index = 0; Index < Descriptor->DataOffset; Index++)
506 {
507 if (RtlCompareMemory(Descriptor->DataCache, Data, Length) == Length)
508 {
509 if (Index + Length > Descriptor->DataOffset)
510 {
511 /* adjust used space */
512 Descriptor->DataOffset = Index + Length;
513 /* return absolute offset */
514 return Descriptor->DataLength + Index;
515 }
516 }
517 }
518
519 /* sanity check */
520 ASSERT(Descriptor->DataOffset + Length < Descriptor->DataLength);
521
522 /* copy to data blob */
523 RtlMoveMemory((Descriptor->DataCache + Descriptor->DataOffset), Data, Length);
524
525 /* backup offset */
526 Index = Descriptor->DataOffset;
527
528 /* adjust used space */
529 Descriptor->DataOffset += Length;
530
531 /* return absolute offset */
532 return Descriptor->DataLength + Index;
533}
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1444
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102

Referenced by KsFilterFactoryUpdateCacheData().

◆ KspCreateFilterFactory()

NTSTATUS NTAPI KspCreateFilterFactory ( IN PDEVICE_OBJECT  DeviceObject,
IN const KSFILTER_DESCRIPTOR *  Descriptor,
IN PWSTR RefString  OPTIONAL,
IN PSECURITY_DESCRIPTOR SecurityDescriptor  OPTIONAL,
IN ULONG  CreateItemFlags,
IN PFNKSFILTERFACTORYPOWER SleepCallback  OPTIONAL,
IN PFNKSFILTERFACTORYPOWER WakeCallback  OPTIONAL,
OUT PKSFILTERFACTORY *FilterFactory  OPTIONAL 
)

Definition at line 359 of file filterfactory.c.

368{
370 IKsFilterFactory * Filter;
372
373 DPRINT("KsCreateFilterFactory\n");
374
375 /* Lets allocate a filterfactory */
377 if (!This)
378 {
379 /* not enough memory */
381 }
382
383 /* initialize struct */
384 This->ref = 1;
385 This->Header.OuterUnknown = (PUNKNOWN)&vt_IKsFilterFactoryVtbl;
386
387 /* map to com object */
388 Filter = (IKsFilterFactory*)&This->Header.OuterUnknown;
389
390 /* initialize filter */
391 Status = Filter->lpVtbl->Initialize(Filter, DeviceObject, Descriptor, RefString, SecurityDescriptor, CreateItemFlags, SleepCallback, WakeCallback, FilterFactory);
392 /* did we succeed */
393 if (!NT_SUCCESS(Status))
394 {
395 /* destroy filterfactory */
396 Filter->lpVtbl->Release(Filter);
397 }
398
399 /* return result */
400 DPRINT("KsCreateFilterFactory %x\n", Status);
401 /* sanity check */
403
404 return Status;
405}
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
static IKsFilterFactoryVtbl vt_IKsFilterFactoryVtbl
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801

Referenced by KsCreateFilterFactory(), and KsInitializeDevice().

Variable Documentation

◆ vt_IKsFilterFactoryVtbl

IKsFilterFactoryVtbl vt_IKsFilterFactoryVtbl
static
Initial value:
=
{
}
NTSTATUS NTAPI IKsFilterFactory_fnSetDeviceClassesState(IKsFilterFactory *iface, IN BOOLEAN Enable)
KSFILTERFACTORY *NTAPI IKsFilterFactory_fnGetStruct(IKsFilterFactory *iface)
NTSTATUS NTAPI IKsFilterFactory_fnInitialize(IKsFilterFactory *iface, IN PDEVICE_OBJECT DeviceObject, IN const KSFILTER_DESCRIPTOR *Descriptor, IN PWSTR RefString OPTIONAL, IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL, IN ULONG CreateItemFlags, IN PFNKSFILTERFACTORYPOWER SleepCallback OPTIONAL, IN PFNKSFILTERFACTORYPOWER WakeCallback OPTIONAL, OUT PKSFILTERFACTORY *FilterFactory OPTIONAL)
NTSTATUS NTAPI IKsFilterFactory_fnQueryInterface(IKsFilterFactory *iface, IN REFIID refiid, OUT PVOID *Output)
Definition: filterfactory.c:83
ULONG NTAPI IKsFilterFactory_fnRelease(IKsFilterFactory *iface)
ULONG NTAPI IKsFilterFactory_fnAddRef(IKsFilterFactory *iface)

Definition at line 346 of file filterfactory.c.

Referenced by KspCreateFilterFactory().