ReactOS 0.4.15-dev-5666-gc548b97
ksfunc.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TAG_KSDEVICE   'DESK'
 
#define TAG_KSOBJECT_TAG   'HOSK'
 

Functions

VOID CompleteRequest (PIRP Irp, CCHAR PriorityBoost)
 
NTSTATUS NTAPI KspCreateObjectType (IN HANDLE ParentHandle, IN LPWSTR ObjectType, PVOID CreateParameters, UINT CreateParametersSize, IN ACCESS_MASK DesiredAccess, OUT PHANDLE NodeHandle)
 
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)
 
NTSTATUS NTAPI IKsDevice_Create (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IKsDevice_Pnp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IKsDevice_Power (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI KspCreateFilter (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN IKsFilterFactory *iface)
 
NTSTATUS KspSetDeviceInterfacesState (IN PLIST_ENTRY ListHead, IN BOOL Enable)
 
NTSTATUS KspFreeDeviceInterfaces (IN PLIST_ENTRY ListHead)
 
NTSTATUS KspRegisterDeviceInterfaces (IN PDEVICE_OBJECT PhysicalDeviceObject, IN ULONG CategoriesCount, IN GUID const *Categories, IN PUNICODE_STRING ReferenceString, OUT PLIST_ENTRY SymbolicLinkList)
 
PVOID AllocateItem (IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
 
VOID FreeItem (IN PVOID Item)
 
KSDDKAPI NTSTATUS NTAPI KspPinPropertyHandler (IN PIRP Irp, IN PKSPROPERTY Property, IN OUT PVOID Data, IN ULONG DescriptorsCount, IN const KSPIN_DESCRIPTOR *Descriptors, IN ULONG DescriptorSize)
 
NTSTATUS FindMatchingCreateItem (PLIST_ENTRY ListHead, PUNICODE_STRING String, OUT PCREATE_ITEM_ENTRY *OutCreateItem)
 
NTSTATUS KspCopyCreateRequest (IN PIRP Irp, IN LPWSTR ObjectClass, IN OUT PULONG Size, OUT PVOID *Result)
 
NTSTATUS KspCreatePin (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PKSDEVICE KsDevice, IN IKsFilterFactory *FilterFactory, IN IKsFilter *Filter, IN PKSPIN_CONNECT Connect, IN KSPIN_DESCRIPTOR_EX *Descriptor)
 
NTSTATUS KspAddCreateItemToList (OUT PLIST_ENTRY ListHead, IN ULONG ItemsCount, IN PKSOBJECT_CREATE_ITEM ItemsList)
 
VOID KspFreeCreateItems (IN PLIST_ENTRY ListHead)
 
NTSTATUS KspPropertyHandler (IN PIRP Irp, IN ULONG PropertySetsCount, IN const KSPROPERTY_SET *PropertySet, IN PFNKSALLOCATOR Allocator OPTIONAL, IN ULONG PropertyItemSize OPTIONAL)
 
NTSTATUS NTAPI IKsFilterFactory_Create (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS KspSetFilterFactoriesState (IN PKSIDEVICE_HEADER DeviceHeader, IN BOOLEAN NewState)
 
NTSTATUS NTAPI KspMethodHandlerWithAllocator (IN PIRP Irp, IN ULONG MethodSetsCount, IN const KSMETHOD_SET *MethodSet, IN PFNKSALLOCATOR Allocator OPTIONAL, IN ULONG MethodItemSize OPTIONAL)
 
VOID IKsFilter_AddPin (PKSFILTER Filter, PKSPIN Pin)
 
VOID IKsFilter_RemovePin (PKSFILTER Filter, PKSPIN Pin)
 
NTSTATUS KspEnableEvent (IN PIRP Irp, IN ULONG EventSetsCount, IN const KSEVENT_SET *EventSet, IN OUT PLIST_ENTRY EventsList OPTIONAL, IN KSEVENTS_LOCKTYPE EventsFlags OPTIONAL, IN PVOID EventsLock OPTIONAL, IN PFNKSALLOCATOR Allocator OPTIONAL, IN ULONG EventItemSize OPTIONAL)
 
NTSTATUS KspValidateConnectRequest (IN PIRP Irp, IN ULONG DescriptorsCount, IN PVOID Descriptors, IN ULONG DescriptorSize, OUT PKSPIN_CONNECT *Connect)
 
NTSTATUS KspReadMediaCategory (IN LPGUID Category, PKEY_VALUE_PARTIAL_INFORMATION *OutInformation)
 

Macro Definition Documentation

◆ TAG_KSDEVICE

#define TAG_KSDEVICE   'DESK'

Definition at line 3 of file ksfunc.h.

◆ TAG_KSOBJECT_TAG

#define TAG_KSOBJECT_TAG   'HOSK'

Definition at line 4 of file ksfunc.h.

Function Documentation

◆ AllocateItem()

PVOID AllocateItem ( IN POOL_TYPE  PoolType,
IN SIZE_T  NumberOfBytes 
)

Definition at line 30 of file misc.c.

33{
35 if (!Item)
36 return Item;
37
39 return Item;
40}
#define TAG_KS
Definition: misc.c:14
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:1036

Referenced by _KsEdit(), Alloc(), AllocateInterfaceDescriptorsArray(), AllocEventData(), ComputeCompatibleFormat(), DispatchCreateSysAudio(), DispatchCreateSysAudioPin(), EventCallback(), FDO_CreateChildPdo(), FDO_DeviceRelations(), GetConnectRequest(), CPortPinWaveRT::HandleKsProperty(), HDA_FDOQueryBusRelations(), HDA_InitCodec(), HDA_PDOHandleQueryDeviceText(), HDA_PDOQueryBusInformation(), HDA_PDOQueryId(), IKsDevice_PnpStartDevice(), IKsFilter_CopyFilterDescriptor(), IKsFilter_CreateDescriptors(), IKsFilterFactory_fnInitialize(), InsertAudioDevice(), InstantiatePins(), KopAddDevice(), KopDispatchCreate(), KsAddItemToObjectBag(), KsAllocateDefaultClockEx(), KsAllocateDeviceHeader(), KsAllocateExtraData(), KsAllocateObjectBag(), KsAllocateObjectCreateItem(), KsAllocateObjectHeader(), KsCacheMedium(), KsCreateBusEnumObject(), KsCreateDefaultAllocatorEx(), KsCreateDefaultClock(), KsFilterFactoryUpdateCacheData(), KsGetBusEnumIdentifier(), KsGetImageNameAndResourceId(), KsInitializeDevice(), KsLoadResource(), KsMapModuleName(), KsMergeAutomationTables(), KspAddCreateItemToList(), KspBusQueryReferenceString(), KspCreateDeviceAssociation(), KspCreateDeviceReference(), KspCreateFilter(), KspCreateFilterFactory(), KspCreateObjectType(), KspCreatePDO(), KspCreatePin(), KspEnableEvent(), KspEnumerateBusRegistryKeys(), KspMergePropertySet(), KspPropertyHandler(), KspQueryBusInformation(), KspQueryBusRelations(), KspQueryId(), KspReadMediaCategory(), KspRegisterDeviceInterfaces(), KsProbeStreamIrp(), KspStartBusDevice(), KsRegisterWorker(), KsServiceBusEnumPnpRequest(), KsSetInformationFile(), KsStreamPointerClone(), NewDispatchObject(), PcAddAdapterDevice(), PcAddToPropertyTable(), PcCreateItemDispatch(), PcCreateSubdeviceDescriptor(), PcNewResourceList(), PcNewResourceSublist(), PcRegisterIoTimeout(), PcRegisterSubdevice(), PortClsPower(), PropertyItemDispatch(), QueryKeyValue(), RegisterConnection(), SysAudioAllocateDeviceHeader(), USBCCG_InitIdsWithInterfaceDescriptor(), USBCCGP_BuildConfigurationDescriptor(), USBCCGP_EnumWithAssociationDescriptor(), USBCCGP_EnumWithAudioLegacy(), USBCCGP_GetDescriptor(), USBCCGP_GetStringDescriptor(), USBCCGP_InitFunctionDescriptor(), USBCCGP_LegacyEnum(), USBCCGP_PdoAppendInterfaceNumber(), USBCCGP_PdoHandleDeviceRelations(), USBCCGP_PdoHandleQueryDeviceText(), USBCCGP_PdoHandleQueryId(), USBCCGP_PDOSelectConfiguration(), USBCCGP_ScanConfigurationDescriptor(), USBCCGP_SelectConfiguration(), USBCCGP_SelectInterface(), USBSTOR_AllocateIrpContext(), USBSTOR_FdoHandleDeviceRelations(), USBSTOR_GetDescriptor(), USBSTOR_GetEndpointStatus(), USBSTOR_PdoHandleDeviceRelations(), USBSTOR_PdoHandleQueryCompatibleId(), USBSTOR_PdoHandleQueryDeviceId(), USBSTOR_PdoHandleQueryDeviceText(), USBSTOR_PdoHandleQueryHardwareId(), USBSTOR_PdoHandleQueryInstanceId(), USBSTOR_ResetPipeWithHandle(), USBSTOR_SelectConfigurationAndInterface(), USBSTOR_SendCapacity(), USBSTOR_SendModeSense(), WdmAudControlOpenMixer(), WdmAudOpenSysaudio(), WdmAudOpenSysAudioDeviceInterfaces(), WdmAudOpenSysAudioDevices(), and WdmAudReadWrite().

◆ CompleteRequest()

VOID CompleteRequest ( PIRP  Irp,
CCHAR  PriorityBoost 
)

Definition at line 17 of file misc.c.

20{
21 DPRINT("Completing IRP %p Status %x\n", Irp, Irp->IoStatus.Status);
22
23 ASSERT(Irp->IoStatus.Status != STATUS_PENDING);
24
25
27}
_In_ PIRP Irp
Definition: csq.h:116
#define ASSERT(a)
Definition: mode.c:44
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_PENDING
Definition: ntstatus.h:82
#define DPRINT
Definition: sndvol32.h:71
_In_ WDFREQUEST _In_ NTSTATUS _In_ CCHAR PriorityBoost
Definition: wdfrequest.h:1016

◆ FindMatchingCreateItem()

NTSTATUS FindMatchingCreateItem ( PLIST_ENTRY  ListHead,
PUNICODE_STRING  String,
OUT PCREATE_ITEM_ENTRY OutCreateItem 
)

Definition at line 1762 of file irp.c.

1766{
1768 PCREATE_ITEM_ENTRY CreateItemEntry;
1770 LPWSTR pStr;
1771 ULONG Count;
1772
1773 /* Copy the input string */
1774 RefString = *String;
1775
1776 /* Check if the string starts with a backslash */
1777 if (String->Buffer[0] == L'\\')
1778 {
1779 /* Skip backslash */
1780 RefString.Buffer++;
1781 RefString.Length -= sizeof(WCHAR);
1782 }
1783 else
1784 {
1785 /* get terminator */
1786 pStr = String->Buffer;
1787 Count = String->Length / sizeof(WCHAR);
1788 while ((Count > 0) && (*pStr != L'\\'))
1789 {
1790 pStr++;
1791 Count--;
1792 }
1793
1794 /* sanity check */
1795 ASSERT(Count != 0);
1796
1797 // request is for pin / node / allocator
1798 RefString.Length = (USHORT)((PCHAR)pStr - (PCHAR)String->Buffer);
1799 }
1800
1801 /* point to first entry */
1802 Entry = ListHead->Flink;
1803
1804 /* loop all device items */
1805 while (Entry != ListHead)
1806 {
1807 /* get create item entry */
1808 CreateItemEntry = (PCREATE_ITEM_ENTRY)CONTAINING_RECORD(Entry,
1810 Entry);
1811
1812 ASSERT(CreateItemEntry->CreateItem);
1813
1814 if(CreateItemEntry->CreateItem->Flags & KSCREATE_ITEM_WILDCARD)
1815 {
1816 /* create item is default */
1817 *OutCreateItem = CreateItemEntry;
1818 return STATUS_SUCCESS;
1819 }
1820
1821 if (!CreateItemEntry->CreateItem->Create)
1822 {
1823 /* skip free create item */
1824 Entry = Entry->Flink;
1825 continue;
1826 }
1827
1828 DPRINT("CreateItem %S Length %u Request %wZ %u\n",
1829 CreateItemEntry->CreateItem->ObjectClass.Buffer,
1830 CreateItemEntry->CreateItem->ObjectClass.Length,
1831 &RefString,
1832 RefString.Length);
1833
1834 if (CreateItemEntry->CreateItem->ObjectClass.Length > RefString.Length)
1835 {
1836 /* create item doesnt match in length */
1837 Entry = Entry->Flink;
1838 continue;
1839 }
1840
1841 /* now check if the object class is the same */
1842 if (!RtlCompareUnicodeString(&CreateItemEntry->CreateItem->ObjectClass,
1843 &RefString,
1844 TRUE))
1845 {
1846 /* found matching create item */
1847 *OutCreateItem = CreateItemEntry;
1848 return STATUS_SUCCESS;
1849 }
1850 /* iterate to next */
1851 Entry = Entry->Flink;
1852 }
1853
1854 return STATUS_NOT_FOUND;
1855}
#define TRUE
Definition: types.h:120
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
__in WDFDEVICE __in CONST GUID __in_opt PCUNICODE_STRING RefString
struct CREATE_ITEM_ENTRY * PCREATE_ITEM_ENTRY
signed char * PCHAR
Definition: retypes.h:7
unsigned int ULONG
Definition: retypes.h:1
#define PCHAR
Definition: match.c:90
int Count
Definition: noreturn.cpp:7
#define L(x)
Definition: ntvdm.h:50
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_NOT_FOUND
Definition: shellext.h:72
Definition: kstypes.h:46
PKSOBJECT_CREATE_ITEM CreateItem
Definition: kstypes.h:48
base of all file and directory entries
Definition: entries.h:83
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by IKsDevice_Create(), and KspCreate().

◆ FreeItem()

VOID FreeItem ( IN PVOID  Item)

Definition at line 43 of file misc.c.

45{
47}
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by _KsEdit(), AllocEventData(), ComputeCompatibleFormat(), Dispatch_fnClose(), DispatchCreateSysAudioPin(), Enum(), Free(), FreeEventData(), CPortPinWaveRT::HandleKsProperty(), HDA_FDORemoveDevice(), HDA_InitCodec(), IKsAllocator_fnRelease(), IKsDevice_PnpPostStart(), IKsDevice_PnpStartDevice(), IKsFilter_CopyFilterDescriptor(), IKsFilter_CreateDescriptors(), IKsFilter_fnRelease(), IKsFilterFactory_fnRelease(), IKsPin_fnRelease(), InsertAudioDevice(), InstantiatePins(), IoCompletion(), KopAddDevice(), KopDispatchClose(), KopDispatchCreate(), KsAllocateExtraData(), KsAllocateObjectCreateItem(), KsAllocateObjectHeader(), KsCacheMedium(), KsCreateBusEnumObject(), KsCreateDefaultAllocatorEx(), KsCreateDefaultClock(), KsDiscardEvent(), KsDispatchSetSecurity(), KsFilterFactoryUpdateCacheData(), KsFreeDefaultClock(), KsFreeDeviceHeader(), KsFreeObjectBag(), KsFreeObjectHeader(), KsGetImageNameAndResourceId(), KsLoadResource(), KsMapModuleName(), KsMergeAutomationTables(), KspCreateDeviceAssociation(), KspCreateDeviceReference(), KspCreateFilter(), KspCreateObjectType(), KspCreatePin(), KspEnumerateBusRegistryKeys(), KspFreeCreateItems(), KspFreeDeviceInterfaces(), KspMergePropertySet(), KspPinPropertyHandler(), KspReadMediaCategory(), KspRegisterDeviceAssociation(), KspRegisterDeviceInterfaces(), KspRemoveDeviceAssociations(), KspValidateConnectRequest(), KsRegisterFilterWithNoKSPins(), KsRemoveItemFromObjectBag(), KsServiceBusEnumPnpRequest(), KsSetInformationFile(), KsStreamPointerClone(), KsStreamPointerDelete(), KsTopologyPropertyHandler(), KsUnregisterWorker(), KsValidateAllocatorCreateRequest(), KsValidateClockCreateRequest(), KsValidateTopologyNodeCreateRequest(), NewDispatchObject(), PcAddAdapterDevice(), PcAddToPropertyTable(), PcCompletePendingPropertyRequest(), PcCreateItemDispatch(), PcCreatePinDispatch(), PcCreateSubdeviceDescriptor(), PcNewResourceList(), PcRegisterIoTimeout(), PcUnregisterIoTimeout(), PDO_HandleInternalDeviceControl(), Pin_fnClose(), PropertyItemDispatch(), PwrCompletionFunction(), QueryKeyValue(), RegisterConnection(), USBCCGP_BuildConfigurationDescriptor(), USBCCGP_GetDescriptor(), USBCCGP_GetDescriptors(), USBCCGP_GetStringDescriptor(), USBCCGP_PDOSelectConfiguration(), USBCCGP_SelectInterface(), USBSTOR_AllocateIrpContext(), USBSTOR_CSWCompletionRoutine(), USBSTOR_GetDescriptor(), USBSTOR_GetDescriptors(), USBSTOR_GetEndpointStatus(), USBSTOR_HandleTransferError(), USBSTOR_ResetPipeWithHandle(), USBSTOR_SelectConfigurationAndInterface(), USBSTOR_SendModeSense(), USBSTOR_SendRequest(), WdmAudCleanup(), WdmAudControlOpenMixer(), WdmAudGetDeviceInterface(), WdmAudGetMixerEvent(), WdmAudOpenSysAudioDevices(), WdmAudReadWrite(), and CResourceList::~CResourceList().

◆ IKsDevice_Create()

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

Definition at line 566 of file device.c.

569{
570 PCREATE_ITEM_ENTRY CreateItemEntry;
571 PIO_STACK_LOCATION IoStack;
572 PDEVICE_EXTENSION DeviceExtension;
573 PKSIDEVICE_HEADER DeviceHeader;
574 PKSIOBJECT_HEADER ObjectHeader;
576
577 DPRINT("IKsDevice_Create\n");
578 /* get current stack location */
580 /* get device extension */
581 DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
582 /* get device header */
583 DeviceHeader = DeviceExtension->DeviceHeader;
584
585 if (IoStack->FileObject->FileName.Buffer == NULL)
586 {
587 // ReactOS PnPMgr still sucks
588 ASSERT(IoStack->FileObject->FileName.Length == 0);
589 Irp->IoStatus.Status = STATUS_SUCCESS;
591 DPRINT1("ReactOS PnP hack\n");
592 return STATUS_SUCCESS;
593 }
594
595 /* acquire list lock */
596 IKsDevice_fnAcquireDevice((IKsDevice*)&DeviceHeader->BasicHeader.OuterUnknown);
597
598 /* sanity check */
599 ASSERT(IoStack->FileObject);
600
601 /* check if the request is relative */
602 if (IoStack->FileObject->RelatedFileObject != NULL)
603 {
604 /* request is to instantiate a pin / node / clock / allocator */
605 ObjectHeader = (PKSIOBJECT_HEADER)IoStack->FileObject->RelatedFileObject->FsContext2;
606
607 /* sanity check */
608 ASSERT(ObjectHeader);
609
610 /* find a matching a create item */
611 Status = FindMatchingCreateItem(&ObjectHeader->ItemList,
612 &IoStack->FileObject->FileName,
613 &CreateItemEntry);
614 }
615 else
616 {
617 /* request to create a filter */
618 Status = FindMatchingCreateItem(&DeviceHeader->ItemList,
619 &IoStack->FileObject->FileName,
620 &CreateItemEntry);
621 }
622
623 if (NT_SUCCESS(Status))
624 {
625 /* set object create item */
626 KSCREATE_ITEM_IRP_STORAGE(Irp) = CreateItemEntry->CreateItem;
627
628 /* call create function */
629 Status = CreateItemEntry->CreateItem->Create(DeviceObject, Irp);
630
631 if (NT_SUCCESS(Status))
632 {
633 /* increment create item reference count */
634 InterlockedIncrement(&CreateItemEntry->ReferenceCount);
635 }
636 }
637
638 /* release list lock */
639 IKsDevice_fnReleaseDevice((IKsDevice*)&DeviceHeader->BasicHeader.OuterUnknown);
640
641 /* done */
642 return Status;
643
644
645}
#define InterlockedIncrement
Definition: armddk.h:53
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION
NTSTATUS NTAPI IKsDevice_fnReleaseDevice(IN IKsDevice *iface)
Definition: device.c:119
NTSTATUS NTAPI IKsDevice_fnAcquireDevice(IN IKsDevice *iface)
Definition: device.c:109
NTSTATUS FindMatchingCreateItem(PLIST_ENTRY ListHead, PUNICODE_STRING String, OUT PCREATE_ITEM_ENTRY *OutCreateItem)
Definition: irp.c:1762
Status
Definition: gdiplustypes.h:25
struct KSIOBJECT_HEADER * PKSIOBJECT_HEADER
if(dx< 0)
Definition: linetemp.h:194
LONG ReferenceCount
Definition: kstypes.h:50
PUNKNOWN OuterUnknown
Definition: kstypes.h:62
KSBASIC_HEADER BasicHeader
Definition: kstypes.h:87
LIST_ENTRY ItemList
Definition: kstypes.h:94
LIST_ENTRY ItemList
Definition: kstypes.h:26
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Referenced by KsDispatchIrp(), and KsInitializeDriver().

◆ IKsDevice_Pnp()

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

Definition at line 409 of file device.c.

412{
413 PIO_STACK_LOCATION IoStack;
414 PDEVICE_EXTENSION DeviceExtension;
415 PKSIDEVICE_HEADER DeviceHeader;
416 PKSDEVICE_DISPATCH Dispatch = NULL;
418
419 /* get current stack location */
421
422 /* get device extension */
423 DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
424 /* get device header */
425 DeviceHeader = DeviceExtension->DeviceHeader;
426
427 /* do we have a device descriptor */
428 if (DeviceHeader->KsDevice.Descriptor && DeviceHeader->KsDevice.Descriptor->Dispatch)
429 {
430 /* does the device want pnp notifications */
431 Dispatch = (PKSDEVICE_DISPATCH)DeviceHeader->KsDevice.Descriptor->Dispatch;
432 }
433
434 switch (IoStack->MinorFunction)
435 {
437 {
439 }
440
442 {
444 /* check for pnp notification support */
445 if (Dispatch)
446 {
447 /* check for query stop support */
448 if (Dispatch->QueryStop)
449 {
450 /* call driver's query stop */
451 Status = Dispatch->QueryStop(&DeviceHeader->KsDevice, Irp);
453 }
454 }
455
456 if (!NT_SUCCESS(Status))
457 {
458 DPRINT1("Driver: query stop failed %x\n", Status);
459 Irp->IoStatus.Status = Status;
461 return Status;
462 }
463
464 /* pass the irp down the driver stack */
466 return IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
467 }
468
470 {
471 /* Clean up */
472 if (Dispatch)
473 {
474 /* check for remove support */
475 if (Dispatch->Remove)
476 {
477 /* call driver's stop routine */
478 Dispatch->Remove(&DeviceHeader->KsDevice, Irp);
479 }
480 }
481
482 /* pass the irp down the driver stack */
484 Status = IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
485 /* FIXME delete device resources */
486 return Status;
487 }
489 {
491 /* check for pnp notification support */
492 if (Dispatch)
493 {
494 /* check for query interface support */
495 if (Dispatch->QueryInterface)
496 {
497 /* call driver's query interface */
498 Status = Dispatch->QueryInterface(&DeviceHeader->KsDevice, Irp);
500 }
501 }
502
503 if (NT_SUCCESS(Status))
504 {
505 /* driver supports a private interface */
506 DPRINT1("IRP_MN_QUERY_INTERFACE Device supports interface\n");
507 Irp->IoStatus.Status = Status;
509 return Status;
510 }
511
512 /* pass the irp down the driver stack */
514 return IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
515 }
517 {
518 /* pass the irp down the driver stack */
520 return IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
521 }
523 {
524 /* pass the irp down the driver stack */
525 //Status = KspForwardIrpSynchronous(DeviceObject, Irp);
526 Status = Irp->IoStatus.Status;
527 DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS Next Device: Status %x\n", Status);
528
529 //Irp->IoStatus.Status = Status;
531 return Status;
532 }
534 {
535 /* pass the irp down the driver stack */
537 return IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
538 }
539 default:
540 DPRINT1("unhandled function %u\n", IoStack->MinorFunction);
541 /* pass the irp down the driver stack */
543 return IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
544 }
545}
NTSTATUS NTAPI CompleteRequest(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: dispatch.c:19
NTSTATUS NTAPI IKsDevice_PnpStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: device.c:276
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IoCallDriver
Definition: irp.c:1225
KSDEVICE KsDevice
Definition: kstypes.h:88
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH * Dispatch
Definition: wsk.h:188
#define IRP_MN_QUERY_INTERFACE
#define IRP_MN_START_DEVICE
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IRP_MN_QUERY_STOP_DEVICE

Referenced by KsDispatchIrp(), and KsInitializeDriver().

◆ IKsDevice_Power()

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

Definition at line 549 of file device.c.

552{
554
555 /* TODO */
556
557 Irp->IoStatus.Status = STATUS_SUCCESS;
558 Irp->IoStatus.Information = 0;
560
561 return STATUS_SUCCESS;
562}
#define UNIMPLEMENTED
Definition: debug.h:115

Referenced by KsDispatchIrp(), and KsInitializeDriver().

◆ IKsFilter_AddPin()

VOID IKsFilter_AddPin ( PKSFILTER  Filter,
PKSPIN  Pin 
)

Definition at line 1337 of file filter.c.

1340{
1341 PKSPIN NextPin, CurPin;
1342 PKSBASIC_HEADER BasicHeader;
1344
1345 /* sanity check */
1346 ASSERT(Pin->Id < This->Filter.Descriptor->PinDescriptorsCount);
1347
1348 if (This->FirstPin[Pin->Id] == NULL)
1349 {
1350 /* welcome first pin */
1351 This->FirstPin[Pin->Id] = Pin;
1352 This->PinInstanceCount[Pin->Id]++;
1353 return;
1354 }
1355
1356 /* get first pin */
1357 CurPin = This->FirstPin[Pin->Id];
1358
1359 do
1360 {
1361 /* get next instantiated pin */
1362 NextPin = KsPinGetNextSiblingPin(CurPin);
1363 if (!NextPin)
1364 break;
1365
1366 NextPin = CurPin;
1367
1368 }while(NextPin != NULL);
1369
1370 /* get basic header */
1371 BasicHeader = (PKSBASIC_HEADER)((ULONG_PTR)CurPin - sizeof(KSBASIC_HEADER));
1372
1373 /* store pin */
1374 BasicHeader->Next.Pin = Pin;
1375}
PKSPIN NTAPI KsPinGetNextSiblingPin(IN PKSPIN Pin)
Definition: pin.c:1086
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:427
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
struct KSBASIC_HEADER * PKSBASIC_HEADER
PKSPIN Pin
Definition: kstypes.h:74
union KSBASIC_HEADER::@960 Next
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by KspCreatePin().

◆ IKsFilter_RemovePin()

VOID IKsFilter_RemovePin ( PKSFILTER  Filter,
PKSPIN  Pin 
)

Definition at line 1378 of file filter.c.

1381{
1382 PKSPIN NextPin, CurPin, LastPin;
1383 PKSBASIC_HEADER BasicHeader;
1385
1386 /* sanity check */
1387 ASSERT(Pin->Id < This->Filter.Descriptor->PinDescriptorsCount);
1388
1389 /* get first pin */
1390 CurPin = This->FirstPin[Pin->Id];
1391
1392 LastPin = NULL;
1393 do
1394 {
1395 /* get next instantiated pin */
1396 NextPin = KsPinGetNextSiblingPin(CurPin);
1397
1398 if (CurPin == Pin)
1399 {
1400 if (LastPin)
1401 {
1402 /* get basic header of last pin */
1403 BasicHeader = (PKSBASIC_HEADER)((ULONG_PTR)LastPin - sizeof(KSBASIC_HEADER));
1404
1405 BasicHeader->Next.Pin = NextPin;
1406 }
1407 else
1408 {
1409 /* erase last pin */
1410 This->FirstPin[Pin->Id] = NextPin;
1411 }
1412 /* decrement pin instance count */
1413 This->PinInstanceCount[Pin->Id]--;
1414 return;
1415 }
1416
1417 if (!NextPin)
1418 break;
1419
1420 LastPin = CurPin;
1421 NextPin = CurPin;
1422
1423 }while(NextPin != NULL);
1424
1425 /* pin not found */
1426 ASSERT(0);
1427}

Referenced by IKsPin_Close(), and KspCreatePin().

◆ 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}
NTSTATUS NTAPI KspCreateFilter(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN IKsFilterFactory *iface)
Definition: filter.c:1636

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

◆ KspAddCreateItemToList()

NTSTATUS KspAddCreateItemToList ( OUT PLIST_ENTRY  ListHead,
IN ULONG  ItemsCount,
IN PKSOBJECT_CREATE_ITEM  ItemsList 
)

Definition at line 458 of file api.c.

462{
463 ULONG Index;
465
466 /* add the items */
467 for(Index = 0; Index < ItemsCount; Index++)
468 {
469 /* allocate item */
471 if (!Entry)
472 {
473 /* no memory */
475 }
476
477 /* initialize entry */
478 InitializeListHead(&Entry->ObjectItemList);
479 Entry->CreateItem = &ItemsList[Index];
480 Entry->ReferenceCount = 0;
481 Entry->ItemFreeCallback = NULL;
482
483 InsertTailList(ListHead, &Entry->Entry);
484 }
485 return STATUS_SUCCESS;
486}
#define InsertTailList(ListHead, Entry)
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
Entry(ENTRY_TYPE etype)
Definition: entries.cpp:35
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by KsAllocateDeviceHeader(), and KsAllocateObjectHeader().

◆ KspCopyCreateRequest()

NTSTATUS KspCopyCreateRequest ( IN PIRP  Irp,
IN LPWSTR  ObjectClass,
IN OUT PULONG  Size,
OUT PVOID Result 
)

Definition at line 50 of file misc.c.

55{
56 PIO_STACK_LOCATION IoStack;
57 SIZE_T ObjectLength, ParametersLength;
59
60 /* get current irp stack */
62
63 /* get object class length */
64 ObjectLength = (wcslen(ObjectClass) + 1) * sizeof(WCHAR);
65
66 /* check for minium length requirement */
67 if (ObjectLength + *Size > IoStack->FileObject->FileName.MaximumLength)
69
70 /* extract parameters length */
71 ParametersLength = IoStack->FileObject->FileName.MaximumLength - ObjectLength;
72
73 /* allocate buffer */
74 Buffer = AllocateItem(NonPagedPool, ParametersLength);
75 if (!Buffer)
77
78 /* copy parameters */
79 RtlMoveMemory(Buffer, &IoStack->FileObject->FileName.Buffer[ObjectLength / sizeof(WCHAR)], ParametersLength);
80
81 /* store result */
82 *Result = Buffer;
83 *Size = (ULONG)ParametersLength;
84
85 return STATUS_SUCCESS;
86}
Definition: bufpool.h:45
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426

Referenced by KspValidateConnectRequest(), KsValidateAllocatorCreateRequest(), KsValidateClockCreateRequest(), and KsValidateTopologyNodeCreateRequest().

◆ KspCreateFilter()

NTSTATUS NTAPI KspCreateFilter ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN IKsFilterFactory *  iface 
)

Definition at line 1636 of file filter.c.

1640{
1642 IKsDevice *KsDevice;
1643 PKSFILTERFACTORY Factory;
1644 PIO_STACK_LOCATION IoStack;
1645 PDEVICE_EXTENSION DeviceExtension;
1647 PKSOBJECT_CREATE_ITEM CreateItem;
1648
1649 /* get device extension */
1650 DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
1651
1652 /* get the filter factory */
1653 Factory = iface->lpVtbl->GetStruct(iface);
1654
1655 if (!Factory || !Factory->FilterDescriptor)
1656 {
1657 /* Sorry it just will not work */
1658 return STATUS_UNSUCCESSFUL;
1659 }
1660
1661 if (Factory->FilterDescriptor->Flags & KSFILTER_FLAG_DENY_USERMODE_ACCESS)
1662 {
1663 if (Irp->RequestorMode == UserMode)
1664 {
1665 /* filter not accessible from user mode */
1666 DPRINT1("Access denied\n");
1667 return STATUS_UNSUCCESSFUL;
1668 }
1669 }
1670
1671 /* allocate filter instance */
1673 if (!This)
1674 {
1675 DPRINT1("KspCreateFilter OutOfMemory\n");
1677 }
1678
1679 /* initialize object bag */
1680 This->Filter.Bag = AllocateItem(NonPagedPool, sizeof(KSIOBJECT_BAG));
1681 if (!This->Filter.Bag)
1682 {
1683 /* no memory */
1684 FreeItem(This);
1685 DPRINT1("KspCreateFilter OutOfMemory\n");
1687 }
1688 KsDevice = (IKsDevice*)&DeviceExtension->DeviceHeader->BasicHeader.OuterUnknown;
1689 KsDevice->lpVtbl->InitializeObjectBag(KsDevice, (PKSIOBJECT_BAG)This->Filter.Bag, NULL);
1690
1691 /* copy filter descriptor */
1692 Status = IKsFilter_CopyFilterDescriptor(This, Factory->FilterDescriptor);
1693 if (!NT_SUCCESS(Status))
1694 {
1695 /* not enough memory */
1696 FreeItem(This->Filter.Bag);
1697 FreeItem(This);
1698 DPRINT("KspCreateFilter IKsFilter_CopyFilterDescriptor failed %lx\n", Status);
1700 }
1701
1702 /* get current irp stack */
1704
1705 /* allocate create items */
1706 CreateItem = AllocateItem(NonPagedPool, sizeof(KSOBJECT_CREATE_ITEM) * 2);
1707 if (!CreateItem)
1708 {
1709 /* no memory */
1710 FreeItem(This->Filter.Bag);
1711 FreeItem(This);
1712 DPRINT1("KspCreateFilter OutOfMemory\n");
1714 }
1715
1716 /* initialize pin create item */
1717 CreateItem[0].Create = IKsFilter_DispatchCreatePin;
1718 CreateItem[0].Context = (PVOID)This;
1719 CreateItem[0].Flags = KSCREATE_ITEM_FREEONSTOP;
1720 RtlInitUnicodeString(&CreateItem[0].ObjectClass, KSSTRING_Pin);
1721 /* initialize node create item */
1722 CreateItem[1].Create = IKsFilter_DispatchCreateNode;
1723 CreateItem[1].Context = (PVOID)This;
1724 CreateItem[1].Flags = KSCREATE_ITEM_FREEONSTOP;
1725 RtlInitUnicodeString(&CreateItem[1].ObjectClass, KSSTRING_TopologyNode);
1726
1727
1728 /* initialize filter instance */
1729 This->ref = 1;
1730 This->Header.OuterUnknown = (PUNKNOWN)&vt_IKsFilter;
1731 This->lpVtblKsControl = &vt_IKsControl;
1732 This->lpVtblKsProcessingObject = &vt_IKsProcessingObject;
1733
1734 This->Factory = Factory;
1735 This->FilterFactory = iface;
1736 This->FileObject = IoStack->FileObject;
1737 KeInitializeMutex(&This->ProcessingMutex, 0);
1738
1739 /* initialize basic header */
1740 This->Header.KsDevice = &DeviceExtension->DeviceHeader->KsDevice;
1741 This->Header.Parent.KsFilterFactory = iface->lpVtbl->GetStruct(iface);
1742 This->Header.Type = KsObjectTypeFilter;
1743 This->Header.ControlMutex = &This->ControlMutex;
1744 KeInitializeMutex(This->Header.ControlMutex, 0);
1745 InitializeListHead(&This->Header.EventList);
1746 KeInitializeSpinLock(&This->Header.EventListLock);
1747
1748 /* initialize and gate */
1749 KsGateInitializeAnd(&This->Gate, NULL);
1750
1751 /* FIXME initialize and gate based on pin flags */
1752
1753 /* initialize work item */
1754 ExInitializeWorkItem(&This->WorkItem, IKsFilter_FilterCentricWorker, (PVOID)This->lpVtblKsProcessingObject);
1755
1756 /* allocate counted work item */
1758 if (!NT_SUCCESS(Status))
1759 {
1760 /* what can go wrong, goes wrong */
1761 DPRINT1("KsRegisterCountedWorker failed with %lx\n", Status);
1762 FreeItem(This);
1763 FreeItem(CreateItem);
1764 return Status;
1765 }
1766
1767 /* allocate the stream descriptors */
1768 Status = IKsFilter_CreateDescriptors(This, (PKSFILTER_DESCRIPTOR)Factory->FilterDescriptor);
1769 if (!NT_SUCCESS(Status))
1770 {
1771 /* what can go wrong, goes wrong */
1772 DPRINT1("IKsFilter_CreateDescriptors failed with %lx\n", Status);
1773 KsUnregisterWorker(This->Worker);
1774 FreeItem(This);
1775 FreeItem(CreateItem);
1776 return Status;
1777 }
1778
1779
1780
1781 /* does the filter have a filter dispatch */
1782 if (Factory->FilterDescriptor->Dispatch)
1783 {
1784 /* does it have a create routine */
1785 if (Factory->FilterDescriptor->Dispatch->Create)
1786 {
1787 /* now let driver initialize the filter instance */
1788
1789 ASSERT(This->Header.KsDevice);
1790 ASSERT(This->Header.KsDevice->Started);
1791 Status = Factory->FilterDescriptor->Dispatch->Create(&This->Filter, Irp);
1792
1794 {
1795 /* driver failed to initialize */
1796 DPRINT1("Driver: Status %x\n", Status);
1797
1798 /* free filter instance */
1799 KsUnregisterWorker(This->Worker);
1800 FreeItem(This);
1801 FreeItem(CreateItem);
1802 return Status;
1803 }
1804 }
1805 }
1806
1807 /* now allocate the object header */
1808 Status = KsAllocateObjectHeader((PVOID*)&This->ObjectHeader, 2, CreateItem, Irp, &DispatchTable);
1809 if (!NT_SUCCESS(Status))
1810 {
1811 /* failed to allocate object header */
1812 DPRINT1("Failed to allocate object header %x\n", Status);
1813
1814 return Status;
1815 }
1816
1817 /* initialize object header extra fields */
1818 This->ObjectHeader->Type = KsObjectTypeFilter;
1819 This->ObjectHeader->Unknown = (PUNKNOWN)&This->Header.OuterUnknown;
1820 This->ObjectHeader->ObjectType = (PVOID)&This->Filter;
1821
1822 /* attach filter to filter factory */
1823 IKsFilter_AttachFilterToFilterFactory(This, This->Header.Parent.KsFilterFactory);
1824
1825 /* completed initialization */
1826 DPRINT1("KspCreateFilter done %lx KsDevice %p\n", Status, This->Header.KsDevice);
1827 return Status;
1828}
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
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 IKsFilter_CopyFilterDescriptor(IKsFilterImpl *This, const KSFILTER_DESCRIPTOR *FilterDescriptor)
Definition: filter.c:1299
static IKsFilterVtbl vt_IKsFilter
Definition: filter.c:642
static IKsControlVtbl vt_IKsControl
Definition: filter.c:374
NTSTATUS NTAPI IKsFilter_DispatchCreatePin(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: filter.c:1432
VOID IKsFilter_AttachFilterToFilterFactory(IKsFilterImpl *This, PKSFILTERFACTORY FilterFactory)
Definition: filter.c:1513
static IKsProcessingObjectVtbl vt_IKsProcessingObject
Definition: filter.c:264
NTSTATUS NTAPI IKsFilter_DispatchCreateNode(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: filter.c:1501
VOID NTAPI IKsFilter_FilterCentricWorker(IN PVOID Ctx)
Definition: filter.c:1622
NTSTATUS IKsFilter_CreateDescriptors(IKsFilterImpl *This, KSFILTER_DESCRIPTOR *FilterDescriptor)
Definition: filter.c:1163
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
#define KSSTRING_Pin
Definition: ks.h:48
#define KSSTRING_TopologyNode
Definition: ks.h:52
@ KsObjectTypeFilter
Definition: ks.h:1210
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
void * PVOID
Definition: retypes.h:9
#define UserMode
Definition: asm.h:35
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
Definition: mutex.c:67
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:248
KSDDKAPI VOID NTAPI KsUnregisterWorker(IN PKSWORKER Worker)
Definition: worker.c:128
KSDDKAPI NTSTATUS NTAPI KsRegisterCountedWorker(IN WORK_QUEUE_TYPE WorkQueueType, IN PWORK_QUEUE_ITEM CountedWorkItem, OUT PKSWORKER *Worker)
Definition: worker.c:166
#define ExInitializeWorkItem(Item, Routine, Context)
Definition: exfuncs.h:265
@ HyperCriticalWorkQueue
Definition: extypes.h:191

Referenced by IKsFilterFactory_Create().

◆ 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}
static IKsFilterFactoryVtbl vt_IKsFilterFactoryVtbl
_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

Referenced by KsCreateFilterFactory(), and KsInitializeDevice().

◆ KspCreateObjectType()

NTSTATUS NTAPI KspCreateObjectType ( IN HANDLE  ParentHandle,
IN LPWSTR  ObjectType,
PVOID  CreateParameters,
UINT  CreateParametersSize,
IN ACCESS_MASK  DesiredAccess,
OUT PHANDLE  NodeHandle 
)

Definition at line 16 of file topology.c.

23{
28
29 /* calculate request length */
30 Name.Length = 0;
31 Name.MaximumLength = (USHORT)(wcslen(ObjectType) * sizeof(WCHAR) + CreateParametersSize + 1 * sizeof(WCHAR));
32 Name.MaximumLength += sizeof(WCHAR);
33 /* acquire request buffer */
34 Name.Buffer = AllocateItem(NonPagedPool, Name.MaximumLength);
35 /* check for success */
36 if (!Name.Buffer)
37 {
38 /* insufficient resources */
40 }
41
42 /* build a request which looks like {ObjectClass}\CreateParameters
43 * For pins the parent is the reference string used in registration
44 * For clocks it is full path for pin\{ClockGuid}\ClockCreateParams
45 */
48 /* append create parameters */
49 RtlMoveMemory(Name.Buffer + (Name.Length / sizeof(WCHAR)), CreateParameters, CreateParametersSize);
50 Name.Length += CreateParametersSize;
51 Name.Buffer[Name.Length / 2] = L'\0';
52
54 /* create the instance */
59 NULL,
60 0,
61 0,
63 0,
64 NULL,
65 0,
67 NULL,
69
70 /* free request buffer */
71 FreeItem(Name.Buffer);
72 return Status;
73}
struct NameRec_ * Name
Definition: cdprocs.h:460
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
#define FILE_OPEN
Definition: from_kernel.h:54
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_OPENIF
Definition: winternl.h:229
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_In_ PKSNODE_CREATE _In_ ACCESS_MASK _Out_ PHANDLE NodeHandle
Definition: ks.h:4548
ObjectType
Definition: metafile.c:81
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSTATUS NTAPI IoCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG Disposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength, IN CREATE_FILE_TYPE CreateFileType, IN PVOID ExtraCreateParameters OPTIONAL, IN ULONG Options)
Definition: file.c:3010
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
#define IO_FORCE_ACCESS_CHECK
Definition: iotypes.h:540
#define IO_NO_PARAMETER_CHECKING
Definition: iotypes.h:541
@ CreateFileTypeNone
Definition: iotypes.h:535

Referenced by KsCreateAllocator(), KsCreateClock(), KsCreatePin(), and KsCreateTopologyNode().

◆ KspCreatePin()

NTSTATUS KspCreatePin ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PKSDEVICE  KsDevice,
IN IKsFilterFactory *  FilterFactory,
IN IKsFilter *  Filter,
IN PKSPIN_CONNECT  Connect,
IN KSPIN_DESCRIPTOR_EX *  Descriptor 
)

Definition at line 2283 of file pin.c.

2291{
2292 IKsPinImpl * This;
2293 PIO_STACK_LOCATION IoStack;
2294 IKsDevice * Device;
2295 PDEVICE_EXTENSION DeviceExtension;
2296 PKSOBJECT_CREATE_ITEM CreateItem;
2299 PKSBASIC_HEADER BasicHeader;
2300 ULONG Index;
2301 ULONG FrameSize = 0;
2302 ULONG NumFrames = 0;
2303 KSAUTOMATION_TABLE AutomationTable;
2304
2305 /* sanity checks */
2306 ASSERT(Descriptor->Dispatch);
2307
2308 DPRINT("KspCreatePin PinId %lu Flags %x\n", Connect->PinId, Descriptor->Flags);
2309
2310//Output Pin: KSPIN_FLAG_PROCESS_IN_RUN_STATE_ONLY
2311//Input Pin: KSPIN_FLAG_FIXED_FORMAT|KSPIN_FLAG_DO_NOT_USE_STANDARD_TRANSPORT|KSPIN_FLAG_FRAMES_NOT_REQUIRED_FOR_PROCESSING
2312
2313 DPRINT("KspCreatePin Dataflow %lu\n", Descriptor->PinDescriptor.DataFlow);
2314 DPRINT("KspCreatePin Communication %lu\n", Descriptor->PinDescriptor.Communication);
2315 if (Descriptor->AllocatorFraming)
2316 {
2317 DPRINT("KspCreatePin CountItems %lu\n", Descriptor->AllocatorFraming->CountItems);
2318 DPRINT("KspCreatePin PinFlags %lx\n", Descriptor->AllocatorFraming->PinFlags);
2319 DPRINT("KspCreatePin OutputCompression RatioNumerator %lu RatioDenominator %lu RatioConstantMargin %lu\n", Descriptor->AllocatorFraming->OutputCompression.RatioNumerator,
2320 Descriptor->AllocatorFraming->OutputCompression.RatioDenominator, Descriptor->AllocatorFraming->OutputCompression.RatioConstantMargin);
2321 DPRINT("KspCreatePin PinWeight %lx\n", Descriptor->AllocatorFraming->PinWeight);
2322
2323 for(Index = 0; Index < Descriptor->AllocatorFraming->CountItems; Index++)
2324 {
2325 DPRINT("KspCreatePin Index %lu MemoryFlags %lx\n", Index, Descriptor->AllocatorFraming->FramingItem[Index].MemoryFlags);
2326 DPRINT("KspCreatePin Index %lu BusFlags %lx\n", Index, Descriptor->AllocatorFraming->FramingItem[Index].BusFlags);
2327 DPRINT("KspCreatePin Index %lu Flags %lx\n", Index, Descriptor->AllocatorFraming->FramingItem[Index].Flags);
2328 DPRINT("KspCreatePin Index %lu Frames %lu\n", Index, Descriptor->AllocatorFraming->FramingItem[Index].Frames);
2329 DPRINT("KspCreatePin Index %lu FileAlignment %lx\n", Index, Descriptor->AllocatorFraming->FramingItem[Index].FileAlignment);
2330 DPRINT("KspCreatePin Index %lu MemoryTypeWeight %lx\n", Index, Descriptor->AllocatorFraming->FramingItem[Index].MemoryTypeWeight);
2331 DPRINT("KspCreatePin Index %lu PhysicalRange MinFrameSize %lu MaxFrameSize %lu Stepping %lu\n", Index, Descriptor->AllocatorFraming->FramingItem[Index].PhysicalRange.MinFrameSize,
2332 Descriptor->AllocatorFraming->FramingItem[Index].PhysicalRange.MaxFrameSize,
2333 Descriptor->AllocatorFraming->FramingItem[Index].PhysicalRange.Stepping);
2334
2335 DPRINT("KspCreatePin Index %lu FramingRange MinFrameSize %lu MaxFrameSize %lu Stepping %lu InPlaceWeight %lu NotInPlaceWeight %lu\n",
2336 Index,
2337 Descriptor->AllocatorFraming->FramingItem[Index].FramingRange.Range.MinFrameSize,
2338 Descriptor->AllocatorFraming->FramingItem[Index].FramingRange.Range.MaxFrameSize,
2339 Descriptor->AllocatorFraming->FramingItem[Index].FramingRange.Range.Stepping,
2340 Descriptor->AllocatorFraming->FramingItem[Index].FramingRange.InPlaceWeight,
2341 Descriptor->AllocatorFraming->FramingItem[Index].FramingRange.NotInPlaceWeight);
2342
2343 FrameSize = Descriptor->AllocatorFraming->FramingItem[Index].FramingRange.Range.MaxFrameSize;
2344 NumFrames = Descriptor->AllocatorFraming->FramingItem[Index].Frames;
2345 }
2346 }
2347
2348 for (Index = 0; Index < Descriptor->PinDescriptor.DataRangesCount; Index++)
2349 {
2351 /* convert the guid to string */
2352 RtlStringFromGUID(&Descriptor->PinDescriptor.DataRanges[Index]->MajorFormat, &GuidString);
2353 DPRINT("Index %lu MajorFormat %S\n", Index, GuidString.Buffer);
2354 RtlStringFromGUID(&Descriptor->PinDescriptor.DataRanges[Index]->SubFormat, &GuidString);
2355 DPRINT("Index %lu SubFormat %S\n", Index, GuidString.Buffer);
2356 RtlStringFromGUID(&Descriptor->PinDescriptor.DataRanges[Index]->Specifier, &GuidString);
2357 DPRINT("Index %lu Specifier %S\n", Index, GuidString.Buffer);
2358 RtlStringFromGUID(&Descriptor->PinDescriptor.DataRanges[Index]->Specifier, &GuidString);
2359 DPRINT("Index %lu FormatSize %lu Flags %lu SampleSize %lu Reserved %lu KSDATAFORMAT %lu\n", Index,
2360 Descriptor->PinDescriptor.DataRanges[Index]->FormatSize, Descriptor->PinDescriptor.DataRanges[Index]->Flags, Descriptor->PinDescriptor.DataRanges[Index]->SampleSize, Descriptor->PinDescriptor.DataRanges[Index]->Reserved, sizeof(KSDATAFORMAT));
2361
2362 if (IsEqualGUIDAligned(&Descriptor->PinDescriptor.DataRanges[Index]->SubFormat, &KSDATAFORMAT_SUBTYPE_BDA_MPEG2_TRANSPORT))
2363 {
2364#if !defined(NDEBUG)
2365 PKS_DATARANGE_BDA_TRANSPORT Transport = (PKS_DATARANGE_BDA_TRANSPORT)&Descriptor->PinDescriptor.DataRanges[Index];
2366 DPRINT("KSDATAFORMAT_SUBTYPE_BDA_MPEG2_TRANSPORT AvgTimePerFrame %I64u ulcbPhyiscalFrame %lu ulcbPhyiscalFrameAlignment %lu ulcbPhyiscalPacket %lu\n", Transport->BdaTransportInfo.AvgTimePerFrame, Transport->BdaTransportInfo.ulcbPhyiscalFrame,
2368#endif
2369 }
2370 }
2371 if (!FrameSize)
2372 {
2373 /* default to 50 * 188 (MPEG2 TS packet size) */
2374 FrameSize = 9400;
2375 }
2376
2377 if (!NumFrames)
2378 {
2379 NumFrames = 8;
2380 }
2381
2382 /* get current irp stack */
2384
2385 /* get device extension */
2386 DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
2387
2388 /* get ks device interface */
2389 Device = (IKsDevice*)&DeviceExtension->DeviceHeader->BasicHeader.OuterUnknown;
2390
2391 /* first allocate pin ctx */
2393 if (!This)
2394 {
2395 /* not enough memory */
2397 }
2398
2399 /* allocate create item */
2400 CreateItem = AllocateItem(NonPagedPool, sizeof(KSOBJECT_CREATE_ITEM) * 3);
2401 if (!CreateItem)
2402 {
2403 /* not enough memory */
2404 FreeItem(This);
2405 DPRINT("KspCreatePin OutOfMemory\n");
2407 }
2408
2409 /* initialize basic header */
2410 This->BasicHeader.KsDevice = KsDevice;
2411 This->BasicHeader.Type = KsObjectTypePin;
2412 This->BasicHeader.Parent.KsFilter = Filter->lpVtbl->GetStruct(Filter);
2413 This->BasicHeader.OuterUnknown = (PUNKNOWN)&vt_IKsPin;
2414 InitializeListHead(&This->BasicHeader.EventList);
2415 KeInitializeSpinLock(&This->BasicHeader.EventListLock);
2416
2417 ASSERT(This->BasicHeader.Parent.KsFilter);
2418
2419 BasicHeader = (PKSBASIC_HEADER)((ULONG_PTR)This->BasicHeader.Parent.KsFilter - sizeof(KSBASIC_HEADER));
2420
2421 This->BasicHeader.ControlMutex = BasicHeader->ControlMutex;
2422 ASSERT(This->BasicHeader.ControlMutex);
2423
2424 InitializeListHead(&This->BasicHeader.EventList);
2425 KeInitializeSpinLock(&This->BasicHeader.EventListLock);
2426
2427 /* initialize pin */
2428 This->FrameSize = FrameSize;
2429 This->NumFrames = NumFrames;
2430 This->lpVtblReferenceClock = &vt_ReferenceClock;
2431 This->ref = 1;
2432 This->FileObject = IoStack->FileObject;
2433 This->Filter = Filter;
2434 KeInitializeMutex(&This->ProcessingMutex, 0);
2435 InitializeListHead(&This->IrpList);
2436 KeInitializeSpinLock(&This->IrpListLock);
2437
2438 /* allocate object bag */
2439 This->Pin.Bag = AllocateItem(NonPagedPool, sizeof(KSIOBJECT_BAG));
2440 if (!This->Pin.Bag)
2441 {
2442 /* not enough memory */
2443 FreeItem(This);
2444 FreeItem(CreateItem);
2446 }
2447
2448 /* initialize object bag */
2449 Device->lpVtbl->InitializeObjectBag(Device, This->Pin.Bag, NULL);
2450
2451 /* allocate pin descriptor */
2452 This->Pin.Descriptor = AllocateItem(NonPagedPool, sizeof(KSPIN_DESCRIPTOR_EX));
2453 if (!This->Pin.Descriptor)
2454 {
2455 /* not enough memory */
2456 KsFreeObjectBag(This->Pin.Bag);
2457 FreeItem(This);
2458 FreeItem(CreateItem);
2460 }
2461
2462 /* copy pin descriptor */
2463 RtlMoveMemory((PVOID)This->Pin.Descriptor, Descriptor, sizeof(KSPIN_DESCRIPTOR_EX));
2464
2465 /* initialize automation table */
2466 RtlZeroMemory(&AutomationTable, sizeof(KSAUTOMATION_TABLE));
2467
2468 AutomationTable.PropertyItemSize = sizeof(KSPROPERTY_ITEM);
2469 AutomationTable.PropertySets = PinPropertySet;
2470 AutomationTable.PropertySetsCount = sizeof(PinPropertySet) / sizeof(KSPROPERTY_SET);
2471
2472 /* merge in pin property sets */
2473 Status = KsMergeAutomationTables((PKSAUTOMATION_TABLE*)&This->Pin.Descriptor->AutomationTable, (PKSAUTOMATION_TABLE)Descriptor->AutomationTable, &AutomationTable, This->Pin.Bag);
2474
2475 if (!NT_SUCCESS(Status))
2476 {
2477 /* not enough memory */
2478 KsFreeObjectBag(This->Pin.Bag);
2479 FreeItem(This);
2480 FreeItem(CreateItem);
2481 return Status;
2482 }
2483
2484 /* get format */
2486
2487 /* initialize pin descriptor */
2488 This->Pin.Context = NULL;
2489 This->Pin.Id = Connect->PinId;
2490 This->Pin.Communication = Descriptor->PinDescriptor.Communication;
2491 This->Pin.ConnectionIsExternal = FALSE; //FIXME
2492 RtlMoveMemory(&This->Pin.ConnectionInterface, &Connect->Interface, sizeof(KSPIN_INTERFACE));
2493 RtlMoveMemory(&This->Pin.ConnectionMedium, &Connect->Medium, sizeof(KSPIN_MEDIUM));
2494 RtlMoveMemory(&This->Pin.ConnectionPriority, &Connect->Priority, sizeof(KSPRIORITY));
2495
2496 /* allocate format */
2497 Status = _KsEdit(This->Pin.Bag, (PVOID*)&This->Pin.ConnectionFormat, DataFormat->FormatSize, DataFormat->FormatSize, 0);
2498 if (!NT_SUCCESS(Status))
2499 {
2500 /* failed to allocate format */
2502 FreeItem(This);
2503 FreeItem(CreateItem);
2505 }
2506
2507 /* copy format */
2508 RtlMoveMemory((PVOID)This->Pin.ConnectionFormat, DataFormat, DataFormat->FormatSize);
2509
2510 This->Pin.AttributeList = NULL; //FIXME
2511 This->Pin.StreamHeaderSize = sizeof(KSSTREAM_HEADER);
2512 This->Pin.DataFlow = Descriptor->PinDescriptor.DataFlow;
2513 This->Pin.DeviceState = KSSTATE_STOP;
2514 This->Pin.ResetState = KSRESET_END;
2515 This->Pin.ClientState = KSSTATE_STOP;
2516
2517 /* initialize allocator create item */
2518 CreateItem[0].Context = (PVOID)&This->Pin;
2519 CreateItem[0].Create = IKsPin_DispatchCreateAllocator;
2520 CreateItem[0].Flags = KSCREATE_ITEM_FREEONSTOP;
2521 RtlInitUnicodeString(&CreateItem[0].ObjectClass, KSSTRING_Allocator);
2522
2523 /* initialize clock create item */
2524 CreateItem[1].Context = (PVOID)&This->Pin;
2525 CreateItem[1].Create = IKsPin_DispatchCreateClock;
2526 CreateItem[1].Flags = KSCREATE_ITEM_FREEONSTOP;
2527 RtlInitUnicodeString(&CreateItem[1].ObjectClass, KSSTRING_Clock);
2528
2529 /* initialize topology node create item */
2530 CreateItem[2].Context = (PVOID)&This->Pin;
2531 CreateItem[2].Create = IKsPin_DispatchCreateNode;
2532 CreateItem[2].Flags = KSCREATE_ITEM_FREEONSTOP;
2533 RtlInitUnicodeString(&CreateItem[2].ObjectClass, KSSTRING_TopologyNode);
2534
2535 /* now allocate object header */
2536 Status = KsAllocateObjectHeader((KSOBJECT_HEADER*)&This->ObjectHeader, 3, CreateItem, Irp, &PinDispatchTable);
2537 if (!NT_SUCCESS(Status))
2538 {
2539 /* failed to create object header */
2540 DPRINT("KspCreatePin KsAllocateObjectHeader failed %lx\n", Status);
2542 FreeItem(This);
2543 FreeItem(CreateItem);
2544
2545 /* return failure code */
2546 return Status;
2547 }
2548
2549 /* add extra info to object header */
2550 This->ObjectHeader->Type = KsObjectTypePin;
2551 This->ObjectHeader->Unknown = (PUNKNOWN)&This->BasicHeader.OuterUnknown;
2552 This->ObjectHeader->ObjectType = (PVOID)&This->Pin;
2553
2554 if (!Descriptor->Dispatch || !Descriptor->Dispatch->Process)
2555 {
2556 /* the pin is part of filter-centric processing filter
2557 * add process pin to filter
2558 */
2559 This->ProcessPin.BytesAvailable = 0;
2560 This->ProcessPin.BytesUsed = 0;
2561 This->ProcessPin.CopySource = NULL;
2562 This->ProcessPin.Data = NULL;
2563 This->ProcessPin.DelegateBranch = NULL;
2564 This->ProcessPin.Flags = 0;
2565 This->ProcessPin.InPlaceCounterpart = NULL;
2566 This->ProcessPin.Pin = &This->Pin;
2567 This->ProcessPin.StreamPointer = (PKSSTREAM_POINTER)&This->LeadingEdgeStreamPointer.StreamPointer;
2568 This->ProcessPin.Terminate = FALSE;
2569
2570 Status = Filter->lpVtbl->AddProcessPin(Filter, &This->ProcessPin);
2571 DPRINT("KspCreatePin AddProcessPin %lx\n", Status);
2572
2573 if (!NT_SUCCESS(Status))
2574 {
2575 /* failed to add process pin */
2577 KsFreeObjectHeader(&This->ObjectHeader);
2578 FreeItem(This);
2579 FreeItem(CreateItem);
2580 /* return failure code */
2581 return Status;
2582 }
2583 }
2584 else if (Descriptor->Dispatch && Descriptor->Dispatch->Process)
2585 {
2586 /* pin centric processing filter */
2587
2588 /* initialize work item */
2590
2591 /* allocate counted work item */
2592 Status = KsRegisterCountedWorker(HyperCriticalWorkQueue, &This->PinWorkQueueItem, &This->PinWorker);
2593
2594 if (!NT_SUCCESS(Status))
2595 {
2596 DPRINT("Failed to register Worker %lx\n", Status);
2598 KsFreeObjectHeader(&This->ObjectHeader);
2599 FreeItem(This);
2600 FreeItem(CreateItem);
2601 return Status;
2602 }
2603
2604 if (This->Pin.Descriptor->PinDescriptor.DataFlow == KSPIN_DATAFLOW_IN)
2605 This->LeadingEdgeStreamPointer.StreamPointer.Offset = &This->LeadingEdgeStreamPointer.StreamPointer.OffsetIn;
2606 else
2607 This->LeadingEdgeStreamPointer.StreamPointer.Offset = &This->LeadingEdgeStreamPointer.StreamPointer.OffsetOut;
2608
2609
2610 KeInitializeEvent(&This->FrameComplete, NotificationEvent, FALSE);
2611
2612 }
2613
2614 /* FIXME add pin instance to filter instance */
2615 IKsFilter_AddPin(Filter->lpVtbl->GetStruct(Filter), &This->Pin);
2616
2617 if (Descriptor->Dispatch && Descriptor->Dispatch->SetDataFormat)
2618 {
2619 Status = Descriptor->Dispatch->SetDataFormat(&This->Pin, NULL, NULL, This->Pin.ConnectionFormat, NULL);
2620 DPRINT("KspCreatePin SetDataFormat %lx\n", Status);
2621 }
2622
2623
2624 /* does the driver have a pin dispatch */
2625 if (Descriptor->Dispatch && Descriptor->Dispatch->Create)
2626 {
2627 /* now inform the driver to create a new pin */
2628 Status = Descriptor->Dispatch->Create(&This->Pin, Irp);
2629 DPRINT("KspCreatePin DispatchCreate %lx\n", Status);
2630 }
2631
2632
2633 DPRINT("KspCreatePin Status %lx KsDevice %p\n", Status, KsDevice);
2634
2636 {
2637 /* failed to create pin, release resources */
2638 IKsFilter_RemovePin(Filter->lpVtbl->GetStruct(Filter), &This->Pin);
2640 KsFreeObjectHeader((KSOBJECT_HEADER)This->ObjectHeader);
2641 FreeItem(This);
2642
2643 /* return failure code */
2644 return Status;
2645 }
2646
2647 return Status;
2648}
KSDDKAPI VOID NTAPI KsFreeObjectBag(IN KSOBJECT_BAG ObjectBag)
Definition: bag.c:308
KSDDKAPI NTSTATUS NTAPI _KsEdit(IN KSOBJECT_BAG ObjectBag, IN OUT PVOID *PointerToPointerToItem, IN ULONG NewSize, IN ULONG OldSize, IN ULONG Tag)
Definition: bag.c:358
#define KSDATAFORMAT_SUBTYPE_BDA_MPEG2_TRANSPORT
Definition: bdamedia.h:365
struct tagKS_DATARANGE_BDA_TRANSPORT * PKS_DATARANGE_BDA_TRANSPORT
KSDATAFORMAT * PKSDATAFORMAT
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI KsMergeAutomationTables(OUT PKSAUTOMATION_TABLE *AutomationTableAB, IN PKSAUTOMATION_TABLE AutomationTableA OPTIONAL, IN PKSAUTOMATION_TABLE AutomationTableB OPTIONAL, IN KSOBJECT_BAG Bag OPTIONAL)
Definition: api.c:2303
KSDDKAPI VOID NTAPI KsFreeObjectHeader(IN PVOID Header)
Definition: api.c:720
VOID IKsFilter_AddPin(PKSFILTER Filter, PKSPIN Pin)
Definition: filter.c:1337
VOID IKsFilter_RemovePin(PKSFILTER Filter, PKSPIN Pin)
Definition: filter.c:1378
KSPROPERTY_SET PinPropertySet[]
Definition: pin.c:95
VOID NTAPI IKsPin_PinCentricWorker(IN PVOID Parameter)
Definition: pin.c:1818
static IKsReferenceClockVtbl vt_ReferenceClock
Definition: pin.c:911
static IKsPinVtbl vt_IKsPin
Definition: pin.c:691
NTSTATUS NTAPI IKsPin_DispatchCreateClock(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pin.c:2175
NTSTATUS NTAPI IKsPin_DispatchCreateAllocator(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pin.c:2162
NTSTATUS NTAPI IKsPin_DispatchCreateNode(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pin.c:2257
static KSDISPATCH_TABLE PinDispatchTable
Definition: pin.c:2268
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
#define KSSTRING_Allocator
Definition: ks.h:50
@ KSRESET_END
Definition: ks.h:1228
@ KsObjectTypePin
Definition: ks.h:1211
@ KSSTATE_STOP
Definition: ks.h:1215
@ KSPIN_DATAFLOW_IN
Definition: ks.h:1249
_In_ PKSPIN_CONNECT Connect
Definition: ks.h:4536
#define KSSTRING_Clock
Definition: ks.h:49
static PWSTR GuidString
Definition: apphelp.c:93
@ NotificationEvent
Definition: pin.c:32
PRKMUTEX ControlMutex
Definition: kstypes.h:58
ULONG PinId
Definition: ks.h:2603
KSPIN_MEDIUM Medium
Definition: ks.h:2602
KSPRIORITY Priority
Definition: ks.h:2605
KSPIN_INTERFACE Interface
Definition: ks.h:2601
REFERENCE_TIME AvgTimePerFrame
Definition: bdamedia.h:340
ULONG ulcbPhyiscalFrameAlignment
Definition: bdamedia.h:339
BDA_TRANSPORT_INFO BdaTransportInfo
Definition: bdamedia.h:345
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235

Referenced by IKsFilter_DispatchCreatePin().

◆ KspEnableEvent()

NTSTATUS KspEnableEvent ( IN PIRP  Irp,
IN ULONG  EventSetsCount,
IN const KSEVENT_SET *  EventSet,
IN OUT PLIST_ENTRY EventsList  OPTIONAL,
IN KSEVENTS_LOCKTYPE EventsFlags  OPTIONAL,
IN PVOID EventsLock  OPTIONAL,
IN PFNKSALLOCATOR Allocator  OPTIONAL,
IN ULONG EventItemSize  OPTIONAL 
)

Definition at line 87 of file event.c.

96{
97 PIO_STACK_LOCATION IoStack;
100 PKSEVENT_ITEM EventItem, FoundEventItem;
101 PKSEVENTDATA EventData;
102 const KSEVENT_SET *FoundEventSet;
103 PKSEVENT_ENTRY EventEntry;
104 ULONG Index, SubIndex, Size;
106 KSEVENT_CTX Ctx;
107 LPGUID Guid;
108
109 /* get current stack location */
111
112 if (IoStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(KSEVENT))
113 {
114 /* invalid parameter */
116 }
117
118 if (Irp->RequestorMode == UserMode)
119 {
121 {
122 ProbeForRead(IoStack->Parameters.DeviceIoControl.Type3InputBuffer, sizeof(KSEVENT), sizeof(UCHAR));
123 ProbeForRead(Irp->UserBuffer, IoStack->Parameters.DeviceIoControl.OutputBufferLength, sizeof(UCHAR));
124 RtlMoveMemory(&Event, IoStack->Parameters.DeviceIoControl.Type3InputBuffer, sizeof(KSEVENT));
126 }
128 {
129 /* Exception, get the error code */
131 }
132 _SEH2_END;
133
134 /* check for success */
135 if (!NT_SUCCESS(Status))
136 {
137 /* failed to probe parameters */
138 return Status;
139 }
140 }
141 else
142 {
143 /* copy event struct */
144 RtlMoveMemory(&Event, IoStack->Parameters.DeviceIoControl.Type3InputBuffer, sizeof(KSEVENT));
145 }
146
147 FoundEventItem = NULL;
148 FoundEventSet = NULL;
149
150
151 if (IsEqualGUIDAligned(&Event.Set, &GUID_NULL) && Event.Id == 0 && Event.Flags == KSEVENT_TYPE_SETSUPPORT)
152 {
153 // store output size
154 Irp->IoStatus.Information = sizeof(GUID) * EventSetsCount;
155 if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(GUID) * EventSetsCount)
156 {
157 // buffer too small
158 return STATUS_MORE_ENTRIES;
159 }
160
161 // get output buffer
162 Guid = (LPGUID)Irp->UserBuffer;
163
164 // copy property guids from property sets
165 for(Index = 0; Index < EventSetsCount; Index++)
166 {
167 RtlMoveMemory(&Guid[Index], EventSet[Index].Set, sizeof(GUID));
168 }
169 return STATUS_SUCCESS;
170 }
171
172 /* now try to find event set */
173 for(Index = 0; Index < EventSetsCount; Index++)
174 {
175 if (IsEqualGUIDAligned(&Event.Set, EventSet[Index].Set))
176 {
177 EventItem = (PKSEVENT_ITEM)EventSet[Index].EventItem;
178
179 /* sanity check */
180 ASSERT(EventSet[Index].EventsCount);
181 ASSERT(EventItem);
182
183 /* now find matching event id */
184 for(SubIndex = 0; SubIndex < EventSet[Index].EventsCount; SubIndex++)
185 {
186 if (EventItem[SubIndex].EventId == Event.Id)
187 {
188 /* found event item */
189 FoundEventItem = &EventItem[SubIndex];
190 FoundEventSet = &EventSet[Index];
191 break;
192 }
193 }
194
195 if (FoundEventSet)
196 break;
197 }
198 }
199
200 if (!FoundEventSet)
201 {
203
205
206 DPRINT("Guid %S Id %u Flags %x not found\n", GuidString.Buffer, Event.Id, Event.Flags);
209
210
211 }
212
213 if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < FoundEventItem->DataInput)
214 {
215 /* buffer too small */
216 DPRINT1("Got %u expected %u\n", IoStack->Parameters.DeviceIoControl.OutputBufferLength, FoundEventItem->DataInput);
217 return STATUS_SUCCESS;
218 }
219
220 if (!FoundEventItem->AddHandler && !EventsList)
221 {
222 /* no add handler and no list to add the new entry to */
224 }
225
226 /* get event data */
227 EventData = Irp->UserBuffer;
228
229 /* sanity check */
230 ASSERT(EventData);
231
232 if (Irp->RequestorMode == UserMode)
233 {
235 {
236 /* get semaphore object handle */
238
239 if (!NT_SUCCESS(Status))
240 {
241 /* invalid semaphore handle */
243 }
244 }
245 else if (EventData->NotificationType == KSEVENTF_EVENT_HANDLE)
246 {
247 /* get event object handle */
249
250 if (!NT_SUCCESS(Status))
251 {
252 /* invalid event handle */
254 }
255 }
256 else
257 {
258 /* user mode client can only pass an event or semaphore handle */
260 }
261 }
262 else
263 {
264 if (EventData->NotificationType != KSEVENTF_EVENT_OBJECT &&
265 EventData->NotificationType != KSEVENTF_SEMAPHORE_OBJECT &&
266 EventData->NotificationType != KSEVENTF_DPC &&
267 EventData->NotificationType != KSEVENTF_WORKITEM &&
268 EventData->NotificationType != KSEVENTF_KSWORKITEM)
269 {
270 /* invalid type requested */
272 }
273 }
274
275
276 /* calculate request size */
277 Size = sizeof(KSEVENT_ENTRY) + FoundEventItem->ExtraEntryData;
278
279 /* do we have an allocator */
280 if (Allocator)
281 {
282 /* allocate event entry */
283 Status = Allocator(Irp, Size, FALSE);
284
285 if (!NT_SUCCESS(Status))
286 {
287 /* failed */
288 return Status;
289 }
290
291 /* assume the caller put it there */
292 EventEntry = KSEVENT_ENTRY_IRP_STORAGE(Irp);
293
294 }
295 else
296 {
297 /* allocate it from nonpaged pool */
298 EventEntry = AllocateItem(NonPagedPool, Size);
299 }
300
301 if (!EventEntry)
302 {
303 /* not enough memory */
305 }
306
307 /* zero event entry */
308 RtlZeroMemory(EventEntry, Size);
309
310 /* initialize event entry */
311 EventEntry->EventData = EventData;
312 EventEntry->NotificationType = EventData->NotificationType;
313 EventEntry->EventItem = FoundEventItem;
314 EventEntry->EventSet = FoundEventSet;
315 EventEntry->FileObject = IoStack->FileObject;
316
317 switch(EventEntry->NotificationType)
318 {
320 EventEntry->Object = Object;
321 EventEntry->Reserved = 0;
322 break;
324 EventEntry->Object = Object;
325 EventEntry->SemaphoreAdjustment = EventData->SemaphoreHandle.Adjustment;
326 EventEntry->Reserved = 0;
327 break;
328 case KSEVENTF_EVENT_OBJECT:
329 EventEntry->Object = EventData->EventObject.Event;
330 EventEntry->Reserved = EventData->EventObject.Increment;
331 break;
332 case KSEVENTF_SEMAPHORE_OBJECT:
333 EventEntry->Object = EventData->SemaphoreObject.Semaphore;
334 EventEntry->SemaphoreAdjustment = EventData->SemaphoreObject.Adjustment;
335 EventEntry->Reserved = EventData->SemaphoreObject.Increment;
336 break;
337 case KSEVENTF_DPC:
338 EventEntry->Object = EventData->Dpc.Dpc;
339 EventData->Dpc.ReferenceCount = 0;
340 break;
341 case KSEVENTF_WORKITEM:
342 EventEntry->Object = EventData->WorkItem.WorkQueueItem;
343 EventEntry->BufferItem = (PKSBUFFER_ITEM)UlongToPtr(EventData->WorkItem.WorkQueueType);
344 break;
345 case KSEVENTF_KSWORKITEM:
346 EventEntry->Object = EventData->KsWorkItem.KsWorkerObject;
347 EventEntry->DpcItem = (PKSDPC_ITEM)EventData->KsWorkItem.WorkQueueItem;
348 break;
349 default:
350 /* should not happen */
351 ASSERT(0);
352 }
353
354 if (FoundEventItem->AddHandler)
355 {
356 /* now add the event */
357 Status = FoundEventItem->AddHandler(Irp, EventData, EventEntry);
358
359 if (!NT_SUCCESS(Status))
360 {
361 /* discard event entry */
362 KsDiscardEvent(EventEntry);
363 }
364 }
365 else
366 {
367 /* setup context */
368 Ctx.List = EventsList;
369 Ctx.EventEntry = EventEntry;
370
371 /* add the event */
372 (void)KspSynchronizedEventRoutine(EventsFlags, EventsLock, SyncAddEvent, &Ctx);
373
375 }
376
377 /* done */
378 return Status;
379}
BOOLEAN KspSynchronizedEventRoutine(IN KSEVENTS_LOCKTYPE EventsFlags, IN PVOID EventsLock, IN PKSEVENT_SYNCHRONIZED_ROUTINE SynchronizedRoutine, IN PKSEVENT_CTX Ctx)
Definition: event.c:15
BOOLEAN NTAPI SyncAddEvent(PKSEVENT_CTX Context)
Definition: event.c:79
KSDDKAPI VOID NTAPI KsDiscardEvent(IN PKSEVENT_ENTRY EventEntry)
Definition: event.c:523
#define UlongToPtr(u)
Definition: config.h:106
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define GUID_NULL
Definition: ks.h:106
struct _KSEVENT_ENTRY * PKSEVENT_ENTRY
Definition: ks.h:2101
#define KSEVENT_TYPE_SETSUPPORT
Definition: ks.h:1792
#define KSEVENTF_EVENT_HANDLE
Definition: ks.h:1778
struct _KSEVENT_ENTRY KSEVENT_ENTRY
Definition: ks.h:2101
#define KSEVENTF_SEMAPHORE_HANDLE
Definition: ks.h:1779
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
POBJECT_TYPE ExEventObjectType
Definition: event.c:18
#define STATUS_PROPSET_NOT_FOUND
Definition: ntstatus.h:692
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
static BOOL Set
Definition: pageheap.c:10
GUID * LPGUID
Definition: guiddef.h:81
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
POBJECT_TYPE ExSemaphoreObjectType
Definition: sem.c:22
HANDLE Semaphore
Definition: ks.h:1740
LONG Adjustment
Definition: ks.h:1742
ULONG NotificationType
Definition: ks.h:1733
struct KSEVENTDATA::@3000::@3003 SemaphoreHandle
struct KSEVENTDATA::@3000::@3002 EventHandle
HANDLE Event
Definition: ks.h:1736
PKSEVENT_ENTRY EventEntry
Definition: kstypes.h:138
PLIST_ENTRY List
Definition: kstypes.h:136
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_MORE_ENTRIES
Definition: udferr_usr.h:124
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:762
#define SEMAPHORE_MODIFY_STATE
Definition: winbase.h:161
#define EVENT_MODIFY_STATE
Definition: winbase.h:163
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by _IRQL_requires_max_(), IKsFilter_DispatchDeviceIoControl(), IKsPin_DispatchDeviceIoControl(), and KsEnableEvent().

◆ KspFreeCreateItems()

VOID KspFreeCreateItems ( IN PLIST_ENTRY  ListHead)

◆ KspFreeDeviceInterfaces()

NTSTATUS KspFreeDeviceInterfaces ( IN PLIST_ENTRY  ListHead)

Definition at line 37 of file deviceinterface.c.

39{
41 PSYMBOLIC_LINK_ENTRY SymEntry;
42
43 while(!IsListEmpty(ListHead))
44 {
45 /* remove first entry */
46 Entry = RemoveHeadList(ListHead);
47
48 /* fetch symbolic link entry */
50
51 /* free device interface string */
53 /* free entry item */
55 }
56
57 return STATUS_SUCCESS;
58}
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
struct SYMBOLIC_LINK_ENTRY * PSYMBOLIC_LINK_ENTRY
Definition: kstypes.h:122
UNICODE_STRING SymbolicLink
Definition: kstypes.h:124

Referenced by IKsFilterFactory_fnRelease().

◆ KspMethodHandlerWithAllocator()

NTSTATUS NTAPI KspMethodHandlerWithAllocator ( IN PIRP  Irp,
IN ULONG  MethodSetsCount,
IN const KSMETHOD_SET *  MethodSet,
IN PFNKSALLOCATOR Allocator  OPTIONAL,
IN ULONG MethodItemSize  OPTIONAL 
)

Definition at line 99 of file methods.c.

105{
106 PKSMETHOD Method;
107 PKSMETHOD_SET Set;
108 PIO_STACK_LOCATION IoStack;
110 PFNKSHANDLER MethodHandler = NULL;
111 ULONG Index;
112 LPGUID Guid;
113
114 /* get current irp stack */
116
117 /* check if inputbuffer at least holds KSMETHOD item */
118 if (IoStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(KSMETHOD))
119 {
120 /* invalid parameter */
121 Irp->IoStatus.Information = sizeof(KSPROPERTY);
123 }
124
125 /* FIXME probe the input / output buffer if from user mode */
126
127 /* get input property request */
128 Method = (PKSMETHOD)IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
129
130// DPRINT("KspMethodHandlerWithAllocator Irp %p PropertySetsCount %u PropertySet %p Allocator %p PropertyItemSize %u ExpectedPropertyItemSize %u\n", Irp, PropertySetsCount, PropertySet, Allocator, PropertyItemSize, sizeof(KSPROPERTY_ITEM));
131
132 /* sanity check */
133 ASSERT(MethodItemSize == 0 || MethodItemSize == sizeof(KSMETHOD_ITEM));
134
135 /* find the method handler */
136 Status = FindMethodHandler(&Irp->IoStatus, MethodSet, MethodSetsCount, Method, IoStack->Parameters.DeviceIoControl.InputBufferLength, IoStack->Parameters.DeviceIoControl.OutputBufferLength, Irp->UserBuffer, &MethodHandler, &Set);
137
138 if (NT_SUCCESS(Status) && MethodHandler)
139 {
140 /* call method handler */
141 KSMETHOD_SET_IRP_STORAGE(Irp) = Set;
142 Status = MethodHandler(Irp, Method, Irp->UserBuffer);
143
145 {
146 /* output buffer is too small */
147 if (Allocator)
148 {
149 /* allocate the requested amount */
150 Status = Allocator(Irp, (ULONG)Irp->IoStatus.Information, FALSE);
151
152 /* check if the block was allocated */
153 if (!NT_SUCCESS(Status))
154 {
155 /* no memory */
157 }
158
159 /* re-call method handler */
160 Status = MethodHandler(Irp, Method, Irp->UserBuffer);
161 }
162 }
163 }
164 else if (IsEqualGUIDAligned(&Method->Set, &GUID_NULL) && Method->Id == 0 && Method->Flags == KSMETHOD_TYPE_SETSUPPORT)
165 {
166 // store output size
167 Irp->IoStatus.Information = sizeof(GUID) * MethodSetsCount;
168 if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(GUID) * MethodSetsCount)
169 {
170 // buffer too small
171 return STATUS_MORE_ENTRIES;
172 }
173
174 // get output buffer
175 Guid = (LPGUID)Irp->UserBuffer;
176
177 // copy property guids from property sets
178 for(Index = 0; Index < MethodSetsCount; Index++)
179 {
180 RtlMoveMemory(&Guid[Index], MethodSet[Index].Set, sizeof(GUID));
181 }
182 return STATUS_SUCCESS;
183 }
184
185 /* done */
186 return Status;
187}
struct KSIDENTIFIER KSPROPERTY
#define KSMETHOD_TYPE_SETSUPPORT
Definition: dmksctrl.h:40
struct KSIDENTIFIER * PKSMETHOD
NTSTATUS FindMethodHandler(IN PIO_STATUS_BLOCK IoStatus, IN const KSMETHOD_SET *MethodSet, IN ULONG MethodSetCount, IN PKSMETHOD Method, IN ULONG InputBufferLength, IN ULONG OutputBufferLength, OUT PVOID OutputBuffer, OUT PFNKSHANDLER *MethodHandler, OUT PKSMETHOD_SET *Set)
Definition: methods.c:15
#define STATUS_INVALID_BUFFER_SIZE
Definition: ntstatus.h:650
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
ULONG Id
Definition: dmksctrl.h:77
ULONG Flags
Definition: dmksctrl.h:78
GUID Set
Definition: dmksctrl.h:76

Referenced by _IRQL_requires_max_(), IKsFilter_DispatchDeviceIoControl(), and IKsPin_DispatchDeviceIoControl().

◆ KspPinPropertyHandler()

KSDDKAPI NTSTATUS NTAPI KspPinPropertyHandler ( IN PIRP  Irp,
IN PKSPROPERTY  Property,
IN OUT PVOID  Data,
IN ULONG  DescriptorsCount,
IN const KSPIN_DESCRIPTOR *  Descriptors,
IN ULONG  DescriptorSize 
)

Definition at line 324 of file connectivity.c.

331{
332 KSP_PIN * Pin;
334 PIO_STACK_LOCATION IoStack;
337 PKSDATARANGE_AUDIO *WaveFormatOut;
338 PKSDATAFORMAT_WAVEFORMATEX WaveFormatIn;
340 const KSPIN_DESCRIPTOR *Descriptor;
342 ULONG Count;
343 const PKSDATARANGE* DataRanges;
344 LPGUID Guid;
345
347 Buffer = Data;
348
349 //DPRINT("KsPinPropertyHandler Irp %p Property %p Data %p DescriptorsCount %u Descriptor %p OutputLength %u Id %u\n", Irp, Property, Data, DescriptorsCount, Descriptor, IoStack->Parameters.DeviceIoControl.OutputBufferLength, Property->Id);
350
351 /* convert to PKSP_PIN */
352 Pin = (KSP_PIN*)Property;
353
355 {
356 if (Pin->PinId >= DescriptorsCount)
357 {
358 /* invalid parameter */
360 }
361 }
362 else
363 {
364 (*(PULONG)Buffer) = DescriptorsCount;
365 Irp->IoStatus.Information = sizeof(ULONG);
366 return STATUS_SUCCESS;
367 }
368
369
370 if (DescriptorSize == sizeof(KSPIN_DESCRIPTOR))
371 {
372 /* it is simple pin descriptor */
373 Descriptor = &Descriptors[Pin->PinId];
374 }
375 else
376 {
377 /* get offset to pin descriptor */
378 Descriptor = &(((PKSPIN_DESCRIPTOR_EX)((ULONG_PTR)Descriptors + Pin->PinId * DescriptorSize))->PinDescriptor);
379 }
380
381 switch(Property->Id)
382 {
384
385 Size = sizeof(KSPIN_DATAFLOW);
386 if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < Size)
387 {
388 Irp->IoStatus.Information = Size;
390 break;
391 }
392
393 *((KSPIN_DATAFLOW*)Buffer) = Descriptor->DataFlow;
394 Irp->IoStatus.Information = sizeof(KSPIN_DATAFLOW);
396 break;
397
400
401 Size = sizeof(KSMULTIPLE_ITEM);
402 DPRINT("Id %lu PinId %lu DataRangesCount %lu ConstrainedDataRangesCount %lu\n", Property->Id, Pin->PinId, Descriptor->DataRangesCount, Descriptor->ConstrainedDataRangesCount);
403
404 if (Property->Id == KSPROPERTY_PIN_DATARANGES || Descriptor->ConstrainedDataRangesCount == 0)
405 {
406 DataRanges = Descriptor->DataRanges;
407 Count = Descriptor->DataRangesCount;
408 }
409 else
410 {
411 DataRanges = Descriptor->ConstrainedDataRanges;
412 Count = Descriptor->ConstrainedDataRangesCount;
413 }
414
415 for (Index = 0; Index < Count; Index++)
416 {
417 Size += ((DataRanges[Index]->FormatSize + 0x7) & ~0x7);
418 }
419
420 if (IoStack->Parameters.DeviceIoControl.OutputBufferLength == 0)
421 {
422 /* buffer too small */
423 Irp->IoStatus.Information = Size;
425 break;
426 }
427
429
430 if (IoStack->Parameters.DeviceIoControl.OutputBufferLength == sizeof(ULONG))
431 {
432 /* store the result size */
433 Item->Size = Size;
434 Irp->IoStatus.Information = sizeof(ULONG);
436 break;
437 }
438
439 /* store descriptor size */
440 Item->Size = Size;
441 Item->Count = Count;
442
443 if (IoStack->Parameters.DeviceIoControl.OutputBufferLength == sizeof(KSMULTIPLE_ITEM))
444 {
445 Irp->IoStatus.Information = sizeof(KSMULTIPLE_ITEM);
447 break;
448 }
449
450 /* now copy all dataranges */
451 Data = (PUCHAR)(Item +1);
452
453 /* alignment assert */
454 ASSERT(((ULONG_PTR)Data & 0x7) == 0);
455
456 for (Index = 0; Index < Count; Index++)
457 {
459 /* convert the guid to string */
460 RtlStringFromGUID(&DataRanges[Index]->MajorFormat, &GuidString);
461 DPRINT("Index %lu MajorFormat %S\n", Index, GuidString.Buffer);
462 RtlStringFromGUID(&DataRanges[Index]->SubFormat, &GuidString);
463 DPRINT("Index %lu SubFormat %S\n", Index, GuidString.Buffer);
464 RtlStringFromGUID(&DataRanges[Index]->Specifier, &GuidString);
465 DPRINT("Index %lu Specifier %S\n", Index, GuidString.Buffer);
466 RtlStringFromGUID(&DataRanges[Index]->Specifier, &GuidString);
467 DPRINT("Index %lu FormatSize %lu Flags %lu SampleSize %lu Reserved %lu KSDATAFORMAT %lu\n", Index,
468 DataRanges[Index]->FormatSize, DataRanges[Index]->Flags, DataRanges[Index]->SampleSize, DataRanges[Index]->Reserved, sizeof(KSDATAFORMAT));
469
470 RtlMoveMemory(Data, DataRanges[Index], DataRanges[Index]->FormatSize);
471 Data = ((PUCHAR)Data + DataRanges[Index]->FormatSize);
472 /* alignment assert */
473 ASSERT(((ULONG_PTR)Data & 0x7) == 0);
474 Data = (PVOID)(((ULONG_PTR)Data + 0x7) & ~0x7);
475 }
476
478 Irp->IoStatus.Information = Size;
479 break;
481
482 if (Descriptor->Interfaces)
483 {
484 /* use mediums provided by driver */
485 return KsHandleSizedListQuery(Irp, Descriptor->InterfacesCount, sizeof(KSPIN_MEDIUM), Descriptor->Interfaces);
486 }
487 else
488 {
489 /* use standard medium */
491 }
492 break;
493
495
496 if (Descriptor->MediumsCount)
497 {
498 /* use mediums provided by driver */
499 return KsHandleSizedListQuery(Irp, Descriptor->MediumsCount, sizeof(KSPIN_MEDIUM), Descriptor->Mediums);
500 }
501 else
502 {
503 /* use standard medium */
505 }
506 break;
507
509
510 Size = sizeof(KSPIN_COMMUNICATION);
511 if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < Size)
512 {
513 Irp->IoStatus.Information = Size;
515 break;
516 }
517
518 *((KSPIN_COMMUNICATION*)Buffer) = Descriptor->Communication;
519
521 Irp->IoStatus.Information = Size;
522 break;
523
525
526 if (!Descriptor->Category)
527 {
528 /* no pin category */
529 return STATUS_NOT_FOUND;
530 }
531
532 /* check size */
533 Size = sizeof(GUID);
534 if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < Size)
535 {
536 /* buffer too small */
537 Irp->IoStatus.Information = Size;
539 break;
540 }
541
542 /* copy category guid */
543 RtlMoveMemory(Buffer, Descriptor->Category, sizeof(GUID));
544
545 /* save result */
547 Irp->IoStatus.Information = Size;
548 break;
549
551
552 if (Descriptor->Name)
553 {
554 /* use pin name */
555 Guid = (LPGUID)Descriptor->Name;
556 }
557 else
558 {
559 /* use pin category as fallback */
560 Guid = (LPGUID)Descriptor->Category;
561 }
562
563 if (!Guid)
564 {
565 /* no friendly name available */
566 return STATUS_NOT_FOUND;
567 }
568
569 /* read friendly name category name */
570 Status = KspReadMediaCategory(Guid, &KeyInfo);
571 if (!NT_SUCCESS(Status))
572 {
573 /* failed to read category */
574 Irp->IoStatus.Information = 0;
575 break;
576 }
577
578 /* store required length */
579 Irp->IoStatus.Information = KeyInfo->DataLength + sizeof(WCHAR);
580
581 /* check if buffer is too small */
582 if (KeyInfo->DataLength + sizeof(WCHAR) > IoStack->Parameters.DeviceIoControl.OutputBufferLength)
583 {
584 /* buffer too small */
586 FreeItem(KeyInfo);
587 break;
588 }
589
590 /* copy result */
591 RtlMoveMemory(Irp->AssociatedIrp.SystemBuffer, &KeyInfo->Data, KeyInfo->DataLength);
592
593 /* null terminate name */
594 ((LPWSTR)Irp->AssociatedIrp.SystemBuffer)[KeyInfo->DataLength / sizeof(WCHAR)] = L'\0';
595
596 /* free key info */
597 FreeItem(KeyInfo);
598 break;
600 Size = sizeof(KSDATAFORMAT);
601 if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < Size)
602 {
603 Irp->IoStatus.Information = Size;
605 break;
606 }
607 if (IoStack->Parameters.DeviceIoControl.OutputBufferLength != sizeof(KSDATAFORMAT_WAVEFORMATEX))
608 {
611 Irp->IoStatus.Information = 0;
612 break;
613 }
614
615 WaveFormatIn = (PKSDATAFORMAT_WAVEFORMATEX)Buffer;
616 if (!Descriptor->DataRanges || !Descriptor->DataRangesCount)
617 {
619 Irp->IoStatus.Information = 0;
620 break;
621 }
622 WaveFormatOut = (PKSDATARANGE_AUDIO*)Descriptor->DataRanges;
623 for(Index = 0; Index < Descriptor->DataRangesCount; Index++)
624 {
625 if (WaveFormatOut[Index]->DataRange.FormatSize != sizeof(KSDATARANGE_AUDIO))
626 {
628 continue;
629 }
630
631 if (WaveFormatOut[Index]->MinimumSampleFrequency > WaveFormatIn->WaveFormatEx.nSamplesPerSec ||
632 WaveFormatOut[Index]->MaximumSampleFrequency < WaveFormatIn->WaveFormatEx.nSamplesPerSec ||
633 WaveFormatOut[Index]->MinimumBitsPerSample > WaveFormatIn->WaveFormatEx.wBitsPerSample ||
634 WaveFormatOut[Index]->MaximumBitsPerSample < WaveFormatIn->WaveFormatEx.wBitsPerSample ||
635 WaveFormatOut[Index]->MaximumChannels < WaveFormatIn->WaveFormatEx.nChannels)
636 {
637 Irp->IoStatus.Status = STATUS_NO_MATCH;
638 Irp->IoStatus.Information = 0;
639 return STATUS_NO_MATCH;
640 }
641 else
642 {
643 Irp->IoStatus.Status = STATUS_SUCCESS;
644 Irp->IoStatus.Information = 0;
645 return STATUS_SUCCESS;
646 }
647 }
649 Irp->IoStatus.Information = 0;
650 break;
651 default:
652 DPRINT1("Unhandled property request %x\n", Property->Id);
654 Irp->IoStatus.Information = 0;
655 }
656
657 return Status;
658}
KSPIN_MEDIUM StandardPinMedium
Definition: connectivity.c:21
KSDDKAPI NTSTATUS NTAPI KsHandleSizedListQuery(IN PIRP Irp, IN ULONG DataItemsCount, IN ULONG DataItemSize, IN const VOID *DataItems)
Definition: connectivity.c:774
KSPIN_INTERFACE StandardPinInterface
Definition: connectivity.c:14
NTSTATUS KspReadMediaCategory(IN LPGUID Category, PKEY_VALUE_PARTIAL_INFORMATION *OutInformation)
Definition: connectivity.c:232
@ KSPROPERTY_PIN_COMMUNICATION
Definition: ks.h:632
@ KSPROPERTY_PIN_CATEGORY
Definition: ks.h:636
@ KSPROPERTY_PIN_MEDIUMS
Definition: ks.h:631
@ KSPROPERTY_PIN_NAME
Definition: ks.h:637
@ KSPROPERTY_PIN_PROPOSEDATAFORMAT
Definition: ks.h:639
@ KSPROPERTY_PIN_CONSTRAINEDDATARANGES
Definition: ks.h:638
@ KSPROPERTY_PIN_DATARANGES
Definition: ks.h:628
@ KSPROPERTY_PIN_CTYPES
Definition: ks.h:626
@ KSPROPERTY_PIN_DATAFLOW
Definition: ks.h:627
@ KSPROPERTY_PIN_INTERFACES
Definition: ks.h:630
KSPIN_DATAFLOW
Definition: ks.h:1248
KSPIN_COMMUNICATION
Definition: ks.h:1253
struct KSDATAFORMAT_WAVEFORMATEX * PKSDATAFORMAT_WAVEFORMATEX
unsigned int * PULONG
Definition: retypes.h:1
unsigned char * PUCHAR
Definition: retypes.h:3
#define STATUS_NO_MATCH
Definition: ntstatus.h:751
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
WAVEFORMATEX WaveFormatEx
Definition: ksmedia.h:632
Definition: ks.h:642
WORD wBitsPerSample
Definition: audioclient.idl:45
DWORD nSamplesPerSec
Definition: audioclient.idl:42
_In_ SIZE_T DescriptorSize
Definition: nls.c:40
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by FilterPinPropertyHandler(), and KsPinPropertyHandler().

◆ KspPropertyHandler()

NTSTATUS KspPropertyHandler ( IN PIRP  Irp,
IN ULONG  PropertySetsCount,
IN const KSPROPERTY_SET *  PropertySet,
IN PFNKSALLOCATOR Allocator  OPTIONAL,
IN ULONG PropertyItemSize  OPTIONAL 
)

Definition at line 138 of file property.c.

144{
146 PKSPROPERTY_ITEM PropertyItem;
147 PKSPROPERTY_SET Set;
148 PIO_STACK_LOCATION IoStack;
150 PFNKSHANDLER PropertyHandler = NULL;
152 LPGUID Guid;
153 //UNICODE_STRING GuidBuffer;
154
155 /* get current irp stack */
157
158 /* get parameters */
159 OutputBufferLength = (IoStack->Parameters.DeviceIoControl.OutputBufferLength + 7) & ~7;
160 InputBufferLength = IoStack->Parameters.DeviceIoControl.InputBufferLength;
161
162 /* check for invalid buffer length size */
163 if (OutputBufferLength < IoStack->Parameters.DeviceIoControl.OutputBufferLength)
164 {
165 /* unsigned overflow */
167 }
168
169 /* check for integer overflow */
170 if (InputBufferLength + OutputBufferLength < IoStack->Parameters.DeviceIoControl.OutputBufferLength)
171 {
172 /* overflow */
174 }
175
176 /* check if inputbuffer at least holds KSPROPERTY item */
177 if (IoStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(KSPROPERTY))
178 {
179 /* invalid parameter */
181 }
182
183 /* get total size */
185
186 /* get input property request */
187 Property = (PKSPROPERTY)IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
188
189 /* have the parameters been checked yet */
190 if (!Irp->AssociatedIrp.SystemBuffer)
191 {
192 /* is it from user mode */
193 if (Irp->RequestorMode == UserMode)
194 {
195 /* probe user buffer */
196 ProbeForRead(IoStack->Parameters.DeviceIoControl.Type3InputBuffer, InputBufferLength, 1);
197 }
198
199 /* do we have an allocator */
200 if ((Allocator) && (Property->Flags & (KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_SET)))
201 {
202 /* call allocator */
203 Status = Allocator(Irp, TotalSize, (Property->Flags & KSPROPERTY_TYPE_GET));
204
205 /* check for success */
206 if (!NT_SUCCESS(Status))
207 return Status;
208 }
209 else
210 {
211 /* allocate buffer */
212 Irp->AssociatedIrp.SystemBuffer = AllocateItem(NonPagedPool, TotalSize);
213
214 /* sanity check */
215 ASSERT(Irp->AssociatedIrp.SystemBuffer != NULL);
216
217 /* mark irp as buffered so that changes the stream headers are propagated back */
219 }
220
221 /* now copy the buffer */
222 RtlCopyMemory((PVOID)((ULONG_PTR)Irp->AssociatedIrp.SystemBuffer + OutputBufferLength), IoStack->Parameters.DeviceIoControl.Type3InputBuffer, InputBufferLength);
223
224 /* use new property buffer */
225 Property = (PKSPROPERTY)((ULONG_PTR)Irp->AssociatedIrp.SystemBuffer + OutputBufferLength);
226
227 /* is it a set operation */
228 if (Property->Flags & KSPROPERTY_TYPE_SET)
229 {
230 /* for set operations, the output parameters need to be copied */
231 if (Irp->RequestorMode == UserMode)
232 {
233 /* probe user parameter */
234 ProbeForRead(Irp->UserBuffer, IoStack->Parameters.DeviceIoControl.OutputBufferLength, 1);
235 }
236
237 /* copy parameters, needs un-aligned parameter length */
238 RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer, Irp->UserBuffer, IoStack->Parameters.DeviceIoControl.OutputBufferLength);
239 }
240
241 /* is there an output buffer */
242 if (IoStack->Parameters.DeviceIoControl.OutputBufferLength)
243 {
244 /* is it from user mode */
245 if (Irp->RequestorMode == UserMode)
246 {
247 /* probe buffer for writing */
248 ProbeForWrite(Irp->UserBuffer, IoStack->Parameters.DeviceIoControl.OutputBufferLength, 1);
249 }
250
251 if (!Allocator || !(Property->Flags & KSPROPERTY_TYPE_GET))
252 {
253 /* it is an input operation */
254 Irp->Flags |= IRP_INPUT_OPERATION;
255 }
256 }
257 }
258 else
259 {
260 /* use new property buffer */
261 Property = (PKSPROPERTY)((ULONG_PTR)Irp->AssociatedIrp.SystemBuffer + OutputBufferLength);
262 }
263
264 //RtlStringFromGUID(&Property->Set, &GuidBuffer);
265
266 //DPRINT("KspPropertyHandler Irp %p PropertySetsCount %u PropertySet %p Allocator %p PropertyItemSize %u ExpectedPropertyItemSize %u\n", Irp, PropertySetsCount, PropertySet, Allocator, PropertyItemSize, sizeof(KSPROPERTY_ITEM));
267 //DPRINT("PropertyId %lu PropertyFlags %x Guid %S\n", Property->Id, Property->Flags, GuidBuffer.Buffer);
268
269 //RtlFreeUnicodeString(&GuidBuffer);
270
271 /* sanity check */
272 ASSERT(PropertyItemSize == 0 || PropertyItemSize == sizeof(KSPROPERTY_ITEM));
273
274 /* find the property handler */
275 Status = FindPropertyHandler(&Irp->IoStatus, PropertySet, PropertySetsCount, Property, InputBufferLength, OutputBufferLength, Irp->AssociatedIrp.SystemBuffer, &PropertyHandler, &Set, &PropertyItem);
276
277 if (NT_SUCCESS(Status) && PropertyHandler)
278 {
279 /* store set */
280 KSPROPERTY_SET_IRP_STORAGE(Irp) = Set;
281
282 /* are any custom property item sizes used */
283 if (PropertyItemSize)
284 {
285 /* store custom property item */
286 KSPROPERTY_ITEM_IRP_STORAGE(Irp) = PropertyItem;
287 }
288
290 {
291 /* call property handler */
292 Status = PropertyHandler(Irp, Property, (OutputBufferLength > 0 ? Irp->AssociatedIrp.SystemBuffer : NULL));
293 }
295 {
297 }
298 _SEH2_END;
299
301 {
302 /* output buffer is too small */
303 if (Allocator)
304 {
305 /* allocate the requested amount */
306 Status = Allocator(Irp, (ULONG)Irp->IoStatus.Information, FALSE);
307
308 /* check if the block was allocated */
309 if (!NT_SUCCESS(Status))
310 {
311 /* no memory */
313 }
315 {
316 /* re-call property handler */
317 Status = PropertyHandler(Irp, Property, Irp->AssociatedIrp.SystemBuffer);
318 }
320 {
322 }
323 _SEH2_END;
324 }
325 }
326 }
328 {
329 // store output size
330 Irp->IoStatus.Information = sizeof(GUID) * PropertySetsCount;
331 if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(GUID) * PropertySetsCount)
332 {
333 // buffer too small
334 return STATUS_MORE_ENTRIES;
335 }
336
337 // get output buffer
338 Guid = (LPGUID)Irp->AssociatedIrp.SystemBuffer;
339
340 // copy property guids from property sets
341 for(Index = 0; Index < PropertySetsCount; Index++)
342 {
343 RtlMoveMemory(&Guid[Index], PropertySet[Index].Set, sizeof(GUID));
344 }
346 }
347
348 /* done */
349 return Status;
350}
NTSTATUS FindPropertyHandler(IN PIO_STATUS_BLOCK IoStatus, IN const KSPROPERTY_SET *PropertySet, IN ULONG PropertySetCount, IN PKSPROPERTY Property, IN ULONG InputBufferLength, IN ULONG OutputBufferLength, OUT PVOID OutputBuffer, OUT PFNKSHANDLER *PropertyHandler, OUT PKSPROPERTY_SET *Set, OUT PKSPROPERTY_ITEM *PropertyItem)
Definition: property.c:20
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
#define KSPROPERTY_TYPE_SETSUPPORT
Definition: dmksctrl.h:44
struct KSIDENTIFIER * PKSPROPERTY
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:162
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:320
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
Definition: wdfio.h:322
#define IRP_DEALLOCATE_BUFFER
#define IRP_INPUT_OPERATION
#define IRP_BUFFERED_IO

Referenced by _IRQL_requires_max_(), IKsFilter_DispatchDeviceIoControl(), IKsPin_DispatchDeviceIoControl(), and KsPropertyHandler().

◆ KspReadMediaCategory()

NTSTATUS KspReadMediaCategory ( IN LPGUID  Category,
PKEY_VALUE_PARTIAL_INFORMATION OutInformation 
)

Definition at line 232 of file connectivity.c.

235{
236 UNICODE_STRING MediaPath = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control\\MediaCategories\\");
241 HANDLE hKey;
242 ULONG Size;
244
245 /* convert the guid to string */
246 Status = RtlStringFromGUID(Category, &GuidString);
247 if (!NT_SUCCESS(Status))
248 return Status;
249
250 /* allocate buffer for the registry key */
251 Path.Length = 0;
252 Path.MaximumLength = MediaPath.MaximumLength + GuidString.MaximumLength;
253 Path.Buffer = AllocateItem(NonPagedPool, Path.MaximumLength);
254 if (!Path.Buffer)
255 {
256 /* not enough memory */
259 }
260
263
264 /* free guid string */
266
267 /* initialize object attributes */
269
270 /* open the key */
271 Status = ZwOpenKey(&hKey, GENERIC_READ, &ObjectAttributes);
272
273 DPRINT("ZwOpenKey() status 0x%08lx %wZ\n", Status, &Path);
274
275 /* free path buffer */
276 FreeItem(Path.Buffer);
277
278 /* check for success */
279 if (!NT_SUCCESS(Status))
280 {
281 DPRINT1("ZwOpenKey() failed with status 0x%08lx\n", Status);
282 return Status;
283 }
284
285 /* query the name size */
286 Status = ZwQueryValueKey(hKey, &Name, KeyValuePartialInformation, NULL, 0, &Size);
288 {
289 /* failed to query for name key */
290 ZwClose(hKey);
291 return Status;
292 }
293
294 /* allocate buffer to read key info */
296 if (!KeyInfo)
297 {
298 /* not enough memory */
299 ZwClose(hKey);
301 }
302
303 /* now read the info */
304 Status = ZwQueryValueKey(hKey, &Name, KeyValuePartialInformation, (PVOID)KeyInfo, Size, &Size);
305
306 /* close the key */
307 ZwClose(hKey);
308
309 if (!NT_SUCCESS(Status))
310 {
311 /* failed to read key */
312 FreeItem(KeyInfo);
313 return Status;
314 }
315
316 /* store key information */
317 *OutInformation = KeyInfo;
318 return Status;
319}
PRTL_UNICODE_STRING_BUFFER Path
#define GENERIC_READ
Definition: compat.h:135
FxAutoRegKey hKey
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
@ KeyValuePartialInformation
Definition: nt_native.h:1182
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by KspPinPropertyHandler(), and KsTopologyPropertyHandler().

◆ KspRegisterDeviceInterfaces()

NTSTATUS KspRegisterDeviceInterfaces ( IN PDEVICE_OBJECT  PhysicalDeviceObject,
IN ULONG  CategoriesCount,
IN GUID const Categories,
IN PUNICODE_STRING  ReferenceString,
OUT PLIST_ENTRY  SymbolicLinkList 
)

Definition at line 61 of file deviceinterface.c.

67{
70 PSYMBOLIC_LINK_ENTRY SymEntry;
71
72 for(Index = 0; Index < CategoriesCount; Index++)
73 {
74 /* allocate a symbolic link entry */
76 /* check for success */
77 if (!SymEntry)
79
80 /* now register device interface */
84 &SymEntry->SymbolicLink);
85
86 if (!NT_SUCCESS(Status))
87 {
88 DPRINT1("Failed to register device interface %x\n", Status);
89
90 /* free entry */
91 FreeItem(SymEntry);
92
93 /* return result */
94 return Status;
95 }
96
97 /* copy device class */
99
100 /* insert symbolic link entry */
102 }
103
104 /* return result */
105 return Status;
106}
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
Definition: deviface.c:955
const GUID Categories[]
Definition: splitter.c:208
LIST_ENTRY Entry
Definition: kstypes.h:123
CLSID DeviceInterfaceClass
Definition: kstypes.h:125
_Must_inspect_result_ _In_ WDFDEVICE _In_ CONST GUID _In_opt_ PCUNICODE_STRING ReferenceString
Definition: wdfdevice.h:3630
_In_opt_ PDEVICE_OBJECT _In_ ULONG _Outptr_result_nullonfailure_ _At_ * SymbolicLinkList(return==0, __drv_allocatesMem(Mem))) PZZWSTR *SymbolicLinkList

Referenced by IKsFilterFactory_fnInitialize().

◆ KspSetDeviceInterfacesState()

NTSTATUS KspSetDeviceInterfacesState ( IN PLIST_ENTRY  ListHead,
IN BOOL  Enable 
)

Definition at line 7 of file deviceinterface.c.

10{
13 PSYMBOLIC_LINK_ENTRY SymEntry;
14
15
16 Entry = ListHead->Flink;
17 while(Entry != ListHead)
18 {
19 /* fetch symbolic link entry */
21 /* set device interface state */
23
24 DPRINT("KspSetDeviceInterfacesState SymbolicLink '%S' Status %lx\n", SymEntry->SymbolicLink.Buffer, Status, Enable);
25
26 /* check for success */
27 if (!NT_SUCCESS(Status))
28 return Status;
29 /* get next entry */
30 Entry = Entry->Flink;
31 }
32 /* return result */
33 return Status;
34}
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:142
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1311

Referenced by IKsFilterFactory_fnRelease(), and IKsFilterFactory_fnSetDeviceClassesState().

◆ KspSetFilterFactoriesState()

NTSTATUS KspSetFilterFactoriesState ( IN PKSIDEVICE_HEADER  DeviceHeader,
IN BOOLEAN  NewState 
)

Definition at line 109 of file deviceinterface.c.

112{
113 PCREATE_ITEM_ENTRY CreateEntry;
116
117 /* grab first device interface */
118 Entry = DeviceHeader->ItemList.Flink;
119 while(Entry != &DeviceHeader->ItemList && Status == STATUS_SUCCESS)
120 {
121 /* grab create entry */
123
124 /* sanity check */
125 ASSERT(CreateEntry->CreateItem);
126
127 if (CreateEntry->CreateItem->Create == IKsFilterFactory_Create)
128 {
129 /* found our own filterfactory */
130 Status = KsFilterFactorySetDeviceClassesState((PKSFILTERFACTORY)CreateEntry->CreateItem->Context, NewState);
131 }
132
133 Entry = Entry->Flink;
134 }
135
136 /* store result */
137 return Status;
138}
NTSTATUS NTAPI IKsFilterFactory_Create(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: filterfactory.c:42
KSDDKAPI NTSTATUS NTAPI KsFilterFactorySetDeviceClassesState(IN PKSFILTERFACTORY FilterFactory, IN BOOLEAN NewState)

Referenced by IKsDevice_PnpPostStart(), and IKsDevice_PnpStartDevice().

◆ KspValidateConnectRequest()

NTSTATUS KspValidateConnectRequest ( IN PIRP  Irp,
IN ULONG  DescriptorsCount,
IN PVOID  Descriptors,
IN ULONG  DescriptorSize,
OUT PKSPIN_CONNECT Connect 
)

FIXME implement format checking

Definition at line 60 of file connectivity.c.

66{
67 PKSPIN_CONNECT ConnectDetails;
69 PKSPIN_MEDIUM Medium;
70 ULONG Size;
75 PKSPIN_DESCRIPTOR Descriptor;
76 UNICODE_STRING GuidString2;
77
78 /* did the caller miss the connect parameter */
79 if (!Connect)
81
82 /* set create param size */
83 Size = sizeof(KSPIN_CONNECT);
84
85 /* fetch create parameters */
88 &Size,
89 (PVOID*)&ConnectDetails);
90
91 /* check for success */
92 if (!NT_SUCCESS(Status))
93 return Status;
94
95 /* is pin id out of bounds */
96 if (ConnectDetails->PinId >= DescriptorsCount)
97 {
98 FreeItem(ConnectDetails);
100 }
101
102 if (DescriptorSize == sizeof(KSPIN_DESCRIPTOR))
103 {
104 /* standard pin descriptor */
105 Descriptor = (PKSPIN_DESCRIPTOR)((ULONG_PTR)Descriptors + sizeof(KSPIN_DESCRIPTOR) * ConnectDetails->PinId);
106 }
107 else
108 {
109 /* extended / variable pin descriptor */
110 Descriptor = &((PKSPIN_DESCRIPTOR_EX)((ULONG_PTR)Descriptors + DescriptorSize * ConnectDetails->PinId))->PinDescriptor;
111 }
112
113
114 /* does the pin have interface details filled in */
115 if (Descriptor->InterfacesCount && Descriptor->Interfaces)
116 {
117 /* use provided pin interface count */
118 Count = Descriptor->InterfacesCount;
120 }
121 else
122 {
123 /* use standard pin interface */
124 Count = 1;
126 }
127
128 /* now check the interface */
129 Found = FALSE;
130 Index = 0;
131 RtlStringFromGUID(&ConnectDetails->Interface.Set, &GuidString2);
132 do
133 {
136
137 DPRINT("Driver Interface %S Id %u\n", GuidString.Buffer, Interface[Index].Id);
138 DPRINT("Connect Interface %S Id %u\n", GuidString2.Buffer, ConnectDetails->Interface.Id);
139
141
142 if (IsEqualGUIDAligned(&Interface[Index].Set, &ConnectDetails->Interface.Set) &&
143 Interface[Index].Id == ConnectDetails->Interface.Id)
144 {
145 /* found a matching interface */
146 Found = TRUE;
147 break;
148 }
149 /* iterate to next interface */
150 Index++;
151 }while(Index < Count);
152 RtlFreeUnicodeString(&GuidString2);
153
154 if (!Found)
155 {
156 /* pin doesnt support this interface */
157 FreeItem(ConnectDetails);
158 return STATUS_NO_MATCH;
159 }
160
161 /* does the pin have medium details filled in */
162 if (Descriptor->MediumsCount && Descriptor->Mediums)
163 {
164 /* use provided pin interface count */
165 Count = Descriptor->MediumsCount;
166 Medium = (PKSPIN_MEDIUM)Descriptor->Mediums;
167 }
168 else
169 {
170 /* use standard pin interface */
171 Count = 1;
172 Medium = &StandardPinMedium;
173 }
174
175 /* now check the interface */
176 Found = FALSE;
177 Index = 0;
178 RtlStringFromGUID(&ConnectDetails->Medium.Set, &GuidString2);
179 do
180 {
183
184 DPRINT("Driver Medium %S Id %u\n", GuidString.Buffer, Medium[Index].Id);
185 DPRINT("Connect Medium %S Id %u\n", GuidString2.Buffer, ConnectDetails->Medium.Id);
186
188
189 if (IsEqualGUIDAligned(&Medium[Index].Set, &ConnectDetails->Medium.Set) &&
190 Medium[Index].Id == ConnectDetails->Medium.Id)
191 {
192 /* found a matching interface */
193 Found = TRUE;
194 break;
195 }
196
197 /* iterate to next medium */
198 Index++;
199 }while(Index < Count);
200 RtlFreeUnicodeString(&GuidString2);
201
202 if (!Found)
203 {
204 /* pin doesnt support this medium */
205 FreeItem(ConnectDetails);
206 return STATUS_NO_MATCH;
207 }
208
211
212 *Connect = ConnectDetails;
213 return STATUS_SUCCESS;
214}
unsigned char BOOLEAN
return Found
Definition: dirsup.c:1270
KSIDENTIFIER * PKSPIN_INTERFACE
Definition: ks.h:243
KSIDENTIFIER * PKSPIN_MEDIUM
Definition: ks.h:244
NTSTATUS KspCopyCreateRequest(IN PIRP Irp, IN LPWSTR ObjectClass, IN OUT PULONG Size, OUT PVOID *Result)
Definition: misc.c:50
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465

Referenced by IKsFilter_DispatchCreatePin(), and KsValidateConnectRequest().