ReactOS  0.4.13-dev-235-g7373cb3
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)
 
NTSTATUS KspForwardIrpSynchronous (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
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
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:997
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T _In_ POOL_TYPE PoolType
Definition: fltkernel.h:1444

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(), PinWaveCyclicDataFormat(), PinWavePciDataFormat(), 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
_In_ CCHAR PriorityBoost
Definition: iofuncs.h:763
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_PENDING
Definition: ntstatus.h:82
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)

◆ FindMatchingCreateItem()

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

Definition at line 1750 of file irp.c.

1754 {
1756  PCREATE_ITEM_ENTRY CreateItemEntry;
1757  UNICODE_STRING RefString;
1758  LPWSTR pStr;
1759  ULONG Count;
1760 
1761  /* Copy the input string */
1762  RefString = *String;
1763 
1764  /* Check if the string starts with a backslash */
1765  if (String->Buffer[0] == L'\\')
1766  {
1767  /* Skip backslash */
1768  RefString.Buffer++;
1769  RefString.Length -= sizeof(WCHAR);
1770  }
1771  else
1772  {
1773  /* get terminator */
1774  pStr = String->Buffer;
1775  Count = String->Length / sizeof(WCHAR);
1776  while ((Count > 0) && (*pStr != L'\\'))
1777  {
1778  pStr++;
1779  Count--;
1780  }
1781 
1782  /* sanity check */
1783  ASSERT(Count != 0);
1784 
1785  // request is for pin / node / allocator
1786  RefString.Length = (USHORT)((PCHAR)pStr - (PCHAR)String->Buffer);
1787  }
1788 
1789  /* point to first entry */
1790  Entry = ListHead->Flink;
1791 
1792  /* loop all device items */
1793  while (Entry != ListHead)
1794  {
1795  /* get create item entry */
1796  CreateItemEntry = (PCREATE_ITEM_ENTRY)CONTAINING_RECORD(Entry,
1798  Entry);
1799 
1800  ASSERT(CreateItemEntry->CreateItem);
1801 
1802  if(CreateItemEntry->CreateItem->Flags & KSCREATE_ITEM_WILDCARD)
1803  {
1804  /* create item is default */
1805  *OutCreateItem = CreateItemEntry;
1806  return STATUS_SUCCESS;
1807  }
1808 
1809  if (!CreateItemEntry->CreateItem->Create)
1810  {
1811  /* skip free create item */
1812  Entry = Entry->Flink;
1813  continue;
1814  }
1815 
1816  DPRINT("CreateItem %S Length %u Request %wZ %u\n",
1817  CreateItemEntry->CreateItem->ObjectClass.Buffer,
1818  CreateItemEntry->CreateItem->ObjectClass.Length,
1819  &RefString,
1820  RefString.Length);
1821 
1822  if (CreateItemEntry->CreateItem->ObjectClass.Length > RefString.Length)
1823  {
1824  /* create item doesnt match in length */
1825  Entry = Entry->Flink;
1826  continue;
1827  }
1828 
1829  /* now check if the object class is the same */
1830  if (!RtlCompareUnicodeString(&CreateItemEntry->CreateItem->ObjectClass,
1831  &RefString,
1832  TRUE))
1833  {
1834  /* found matching create item */
1835  *OutCreateItem = CreateItemEntry;
1836  return STATUS_SUCCESS;
1837  }
1838  /* iterate to next */
1839  Entry = Entry->Flink;
1840  }
1841 
1842  return STATUS_NOT_FOUND;
1843 }
signed char * PCHAR
Definition: retypes.h:7
#define TRUE
Definition: types.h:120
struct _Entry Entry
Definition: kefuncs.h:640
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
static WCHAR String[]
Definition: stringtable.c:55
Definition: kstypes.h:45
PKSOBJECT_CREATE_ITEM CreateItem
Definition: kstypes.h:48
void DPRINT(...)
Definition: polytest.cpp:61
struct CREATE_ITEM_ENTRY * PCREATE_ITEM_ENTRY
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define PCHAR
Definition: match.c:90
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define STATUS_NOT_FOUND
Definition: shellext.h:67
__wchar_t WCHAR
Definition: xmlstorage.h:180
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
Definition: typedefs.h:117
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184
return STATUS_SUCCESS
Definition: btrfs.c:2745
base of all file and directory entries
Definition: entries.h:82

Referenced by IKsDevice_Create(), and KspCreate().

◆ FreeItem()

VOID FreeItem ( IN PVOID  Item)

Definition at line 43 of file misc.c.

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

Referenced by _KsEdit(), AllocEventData(), CloseStreamRoutine(), 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(), PinSetStateWorkerRoutine(), PinWaveCyclicDataFormat(), PinWavePciDataFormat(), 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 591 of file device.c.

594 {
595  PCREATE_ITEM_ENTRY CreateItemEntry;
596  PIO_STACK_LOCATION IoStack;
597  PDEVICE_EXTENSION DeviceExtension;
598  PKSIDEVICE_HEADER DeviceHeader;
599  PKSIOBJECT_HEADER ObjectHeader;
601 
602  DPRINT("IKsDevice_Create\n");
603  /* get current stack location */
605  /* get device extension */
606  DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
607  /* get device header */
608  DeviceHeader = DeviceExtension->DeviceHeader;
609 
610  if (IoStack->FileObject->FileName.Buffer == NULL)
611  {
612  // ReactOS PnPMgr still sucks
613  ASSERT(IoStack->FileObject->FileName.Length == 0);
614  Irp->IoStatus.Status = STATUS_SUCCESS;
616  DPRINT1("ReactOS PnP hack\n");
617  return STATUS_SUCCESS;
618  }
619 
620  /* acquire list lock */
621  IKsDevice_fnAcquireDevice((IKsDevice*)&DeviceHeader->BasicHeader.OuterUnknown);
622 
623  /* sanity check */
624  ASSERT(IoStack->FileObject);
625 
626  /* check if the request is relative */
627  if (IoStack->FileObject->RelatedFileObject != NULL)
628  {
629  /* request is to instantiate a pin / node / clock / allocator */
630  ObjectHeader = (PKSIOBJECT_HEADER)IoStack->FileObject->RelatedFileObject->FsContext2;
631 
632  /* sanity check */
633  ASSERT(ObjectHeader);
634 
635  /* find a matching a create item */
636  Status = FindMatchingCreateItem(&ObjectHeader->ItemList,
637  &IoStack->FileObject->FileName,
638  &CreateItemEntry);
639  }
640  else
641  {
642  /* request to create a filter */
643  Status = FindMatchingCreateItem(&DeviceHeader->ItemList,
644  &IoStack->FileObject->FileName,
645  &CreateItemEntry);
646  }
647 
648  if (NT_SUCCESS(Status))
649  {
650  /* set object create item */
651  KSCREATE_ITEM_IRP_STORAGE(Irp) = CreateItemEntry->CreateItem;
652 
653  /* call create function */
654  Status = CreateItemEntry->CreateItem->Create(DeviceObject, Irp);
655 
656  if (NT_SUCCESS(Status))
657  {
658  /* increment create item reference count */
659  InterlockedIncrement(&CreateItemEntry->ReferenceCount);
660  }
661  }
662 
663  /* release list lock */
664  IKsDevice_fnReleaseDevice((IKsDevice*)&DeviceHeader->BasicHeader.OuterUnknown);
665 
666  /* done */
667  return Status;
668 
669 
670 }
_In_ PIRP Irp
Definition: csq.h:116
struct KSIOBJECT_HEADER * PKSIOBJECT_HEADER
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI IKsDevice_fnReleaseDevice(IN IKsDevice *iface)
Definition: device.c:119
PUNKNOWN OuterUnknown
Definition: kstypes.h:62
Definition: kstypes.h:45
PKSOBJECT_CREATE_ITEM CreateItem
Definition: kstypes.h:48
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
NTSTATUS NTAPI IKsDevice_fnAcquireDevice(IN IKsDevice *iface)
Definition: device.c:109
void DPRINT(...)
Definition: polytest.cpp:61
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
KSBASIC_HEADER BasicHeader
Definition: kstypes.h:87
LIST_ENTRY ItemList
Definition: kstypes.h:26
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
#define InterlockedIncrement
Definition: armddk.h:53
LONG ReferenceCount
Definition: kstypes.h:50
NTSTATUS FindMatchingCreateItem(PLIST_ENTRY ListHead, PUNICODE_STRING String, OUT PCREATE_ITEM_ENTRY *OutCreateItem)
Definition: irp.c:1750
#define DPRINT1
Definition: precomp.h:8
LIST_ENTRY ItemList
Definition: kstypes.h:94
#define IO_NO_INCREMENT
Definition: iotypes.h:565
return STATUS_SUCCESS
Definition: btrfs.c:2745
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION

Referenced by KsDispatchIrp(), and KsInitializeDriver().

◆ IKsDevice_Pnp()

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

Definition at line 406 of file device.c.

409 {
410  PIO_STACK_LOCATION IoStack;
411  PDEVICE_EXTENSION DeviceExtension;
412  PKSIDEVICE_HEADER DeviceHeader;
413  PKSDEVICE_DISPATCH Dispatch = NULL;
415 
416  /* get current stack location */
418 
419  /* get device extension */
420  DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
421  /* get device header */
422  DeviceHeader = DeviceExtension->DeviceHeader;
423 
424  /* do we have a device descriptor */
425  if (DeviceHeader->KsDevice.Descriptor && DeviceHeader->KsDevice.Descriptor->Dispatch)
426  {
427  /* does the device want pnp notifications */
428  Dispatch = (PKSDEVICE_DISPATCH)DeviceHeader->KsDevice.Descriptor->Dispatch;
429  }
430 
431  switch (IoStack->MinorFunction)
432  {
433  case IRP_MN_START_DEVICE:
434  {
436  }
437 
439  {
441  /* check for pnp notification support */
442  if (Dispatch)
443  {
444  /* check for query stop support */
445  if (Dispatch->QueryStop)
446  {
447  /* call driver's query stop */
448  Status = Dispatch->QueryStop(&DeviceHeader->KsDevice, Irp);
450  }
451  }
452 
453  if (!NT_SUCCESS(Status))
454  {
455  DPRINT1("Driver: query stop failed %x\n", Status);
456  Irp->IoStatus.Status = Status;
458  return Status;
459  }
460 
461  /* pass the irp down the driver stack */
463 
464  DPRINT("Next Device: Status %x\n", Status);
465 
466  Irp->IoStatus.Status = Status;
468  return Status;
469  }
470 
472  {
473  /* Clean up */
474  if (Dispatch)
475  {
476  /* check for remove support */
477  if (Dispatch->Remove)
478  {
479  /* call driver's stop routine */
480  Dispatch->Remove(&DeviceHeader->KsDevice, Irp);
481  }
482  }
483 
484  /* pass the irp down the driver stack */
486 
487  DPRINT("Next Device: Status %x\n", Status);
488 
489  /* FIXME delete device resources */
490 
491 
492  Irp->IoStatus.Status = Status;
494  return Status;
495  }
497  {
499  /* check for pnp notification support */
500  if (Dispatch)
501  {
502  /* check for query interface support */
503  if (Dispatch->QueryInterface)
504  {
505  /* call driver's query interface */
506  Status = Dispatch->QueryInterface(&DeviceHeader->KsDevice, Irp);
508  }
509  }
510 
511  if (NT_SUCCESS(Status))
512  {
513  /* driver supports a private interface */
514  DPRINT1("IRP_MN_QUERY_INTERFACE Device supports interface\n");
515  Irp->IoStatus.Status = Status;
517  return Status;
518  }
519 
520  /* pass the irp down the driver stack */
522 
523  DPRINT1("IRP_MN_QUERY_INTERFACE Next Device: Status %x\n", Status);
524  Irp->IoStatus.Status = Status;
526  return Status;
527  }
529  {
530  /* pass the irp down the driver stack */
532 
533  DPRINT("IRP_MN_QUERY_DEVICE_RELATIONS Next Device: Status %x\n", Status);
534 
535  //Irp->IoStatus.Status = Status;
537  return Status;
538  }
540  {
541  /* pass the irp down the driver stack */
542  //Status = KspForwardIrpSynchronous(DeviceObject, Irp);
543  Status = Irp->IoStatus.Status;
544  DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS Next Device: Status %x\n", Status);
545 
546  //Irp->IoStatus.Status = Status;
548  return Status;
549  }
551  {
552  /* pass the irp down the driver stack */
554 
555  DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS Next Device: Status %x\n", Status);
556 
557  Irp->IoStatus.Status = Status;
559  return Status;
560  }
561  default:
562  DPRINT1("unhandled function %u\n", IoStack->MinorFunction);
563  /* pass the irp down the driver stack */
565 
566  Irp->IoStatus.Status = Status;
568  return Status;
569  }
570 }
#define IRP_MN_REMOVE_DEVICE
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI IKsDevice_PnpStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: device.c:276
KSDEVICE KsDevice
Definition: kstypes.h:88
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define IRP_MN_QUERY_STOP_DEVICE
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define IRP_MN_START_DEVICE
#define IRP_MN_QUERY_INTERFACE
NTSTATUS NTAPI CompleteRequest(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: dispatch.c:19
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH * Dispatch
Definition: wsk.h:182
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define DPRINT1
Definition: precomp.h:8
#define IO_NO_INCREMENT
Definition: iotypes.h:565
NTSTATUS KspForwardIrpSynchronous(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: misc.c:65
return STATUS_SUCCESS
Definition: btrfs.c:2745
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION

Referenced by KsDispatchIrp(), and KsInitializeDriver().

◆ IKsDevice_Power()

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

Definition at line 574 of file device.c.

577 {
579 
580  /* TODO */
581 
582  Irp->IoStatus.Status = STATUS_SUCCESS;
583  Irp->IoStatus.Information = 0;
585 
586  return STATUS_SUCCESS;
587 }
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS NTAPI CompleteRequest(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: dispatch.c:19
#define IO_NO_INCREMENT
Definition: iotypes.h:565
#define UNIMPLEMENTED
Definition: debug.h:114
return STATUS_SUCCESS
Definition: btrfs.c:2745

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 }
struct KSBASIC_HEADER * PKSBASIC_HEADER
PKSPIN NTAPI KsPinGetNextSiblingPin(IN PKSPIN Pin)
Definition: pin.c:1086
uint32_t ULONG_PTR
Definition: typedefs.h:63
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
smooth NULL
Definition: ftsmooth.c:416
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
PKSPIN Pin
Definition: kstypes.h:74
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:415
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
union KSBASIC_HEADER::@954 Next

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 }
struct KSBASIC_HEADER * PKSBASIC_HEADER
PKSPIN NTAPI KsPinGetNextSiblingPin(IN PKSPIN Pin)
Definition: pin.c:1086
uint32_t ULONG_PTR
Definition: typedefs.h:63
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
smooth NULL
Definition: ftsmooth.c:416
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
PKSPIN Pin
Definition: kstypes.h:74
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:415
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
union KSBASIC_HEADER::@954 Next

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");
56  return STATUS_UNSUCCESSFUL;
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 
70  if (Status != STATUS_PENDING)
71  {
72  Irp->IoStatus.Information = 0;
73  Irp->IoStatus.Status = Status;
75  }
76 
77  return Status;
78 }
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
void DPRINT(...)
Definition: polytest.cpp:61
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define STATUS_PENDING
Definition: ntstatus.h:82
NTSTATUS NTAPI CompleteRequest(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: dispatch.c:19
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSTATUS NTAPI KspCreateFilter(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN IKsFilterFactory *iface)
Definition: filter.c:1636
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define DPRINT1
Definition: precomp.h:8
#define IO_NO_INCREMENT
Definition: iotypes.h:565

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 STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct _Entry Entry
Definition: kefuncs.h:640
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
#define InsertTailList(ListHead, Entry)
Definition: kstypes.h:45
Entry(ENTRY_TYPE etype)
Definition: entries.cpp:35
smooth NULL
Definition: ftsmooth.c:416
static const UCHAR Index[8]
Definition: usbohci.c:18
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2745
base of all file and directory entries
Definition: entries.h:82

Referenced by KsAllocateDeviceHeader(), and KsAllocateObjectHeader().

◆ KspCopyCreateRequest()

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

Definition at line 101 of file misc.c.

106 {
107  PIO_STACK_LOCATION IoStack;
108  SIZE_T ObjectLength, ParametersLength;
109  PVOID Buffer;
110 
111  /* get current irp stack */
113 
114  /* get object class length */
115  ObjectLength = (wcslen(ObjectClass) + 1) * sizeof(WCHAR);
116 
117  /* check for minium length requirement */
118  if (ObjectLength + *Size > IoStack->FileObject->FileName.MaximumLength)
119  return STATUS_UNSUCCESSFUL;
120 
121  /* extract parameters length */
122  ParametersLength = IoStack->FileObject->FileName.MaximumLength - ObjectLength;
123 
124  /* allocate buffer */
125  Buffer = AllocateItem(NonPagedPool, ParametersLength);
126  if (!Buffer)
128 
129  /* copy parameters */
130  RtlMoveMemory(Buffer, &IoStack->FileObject->FileName.Buffer[ObjectLength / sizeof(WCHAR)], ParametersLength);
131 
132  /* store result */
133  *Result = Buffer;
134  *Size = (ULONG)ParametersLength;
135 
136  return STATUS_SUCCESS;
137 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
_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
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
ULONG_PTR SIZE_T
Definition: typedefs.h:78
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2745
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

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 {
1641  IKsFilterImpl * This;
1642  IKsDevice *KsDevice;
1643  PKSFILTERFACTORY Factory;
1644  PIO_STACK_LOCATION IoStack;
1645  PDEVICE_EXTENSION DeviceExtension;
1646  NTSTATUS Status;
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 */
1703  IoStack = IoGetCurrentIrpStackLocation(Irp);
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 
1793  if (!NT_SUCCESS(Status) && Status != STATUS_PENDING)
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 }
NTSTATUS IKsFilter_CopyFilterDescriptor(IKsFilterImpl *This, const KSFILTER_DESCRIPTOR *FilterDescriptor)
Definition: filter.c:1299
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
#define KSSTRING_Pin
Definition: ks.h:48
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI IKsFilter_DispatchCreateNode(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: filter.c:1501
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
static IKsControlVtbl vt_IKsControl
Definition: filter.c:374
void * PVOID
Definition: retypes.h:9
VOID NTAPI IKsFilter_FilterCentricWorker(IN PVOID Ctx)
Definition: filter.c:1622
NTSTATUS NTAPI IKsFilter_DispatchCreatePin(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: filter.c:1432
#define ExInitializeWorkItem(Item, Routine, Context)
Definition: exfuncs.h:265
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
NTSTATUS IKsFilter_CreateDescriptors(IKsFilterImpl *This, KSFILTER_DESCRIPTOR *FilterDescriptor)
Definition: filter.c:1163
KSDDKAPI NTSTATUS NTAPI KsRegisterCountedWorker(IN WORK_QUEUE_TYPE WorkQueueType, IN PWORK_QUEUE_ITEM CountedWorkItem, OUT PKSWORKER *Worker)
Definition: worker.c:166
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
Definition: mutex.c:67
static IKsProcessingObjectVtbl vt_IKsProcessingObject
Definition: filter.c:264
Status
Definition: gdiplustypes.h:24
static IKsFilterVtbl vt_IKsFilter
Definition: filter.c:642
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
VOID IKsFilter_AttachFilterToFilterFactory(IKsFilterImpl *This, PKSFILTERFACTORY FilterFactory)
Definition: filter.c:1513
static KSDISPATCH_TABLE DispatchTable
Definition: filter.c:1147
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KSSTRING_TopologyNode
Definition: ks.h:52
#define DPRINT1
Definition: precomp.h:8
KSDDKAPI VOID NTAPI KsUnregisterWorker(IN PKSWORKER Worker)
Definition: worker.c:128
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
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION

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 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_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:182
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
static IKsFilterFactoryVtbl vt_IKsFilterFactoryVtbl
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
return STATUS_SUCCESS
Definition: btrfs.c:2745
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

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,
62  FILE_OPEN,
63  0,
64  NULL,
65  0,
67  NULL,
69 
70  /* free request buffer */
71  FreeItem(Name.Buffer);
72  return Status;
73 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
ObjectType
Definition: metafile.c:80
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define IO_FORCE_ACCESS_CHECK
Definition: iotypes.h:507
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
_In_ PKSNODE_CREATE _In_ ACCESS_MASK _Out_ PHANDLE NodeHandle
Definition: ks.h:4575
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define OBJ_OPENIF
Definition: winternl.h:229
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
#define IO_NO_PARAMETER_CHECKING
Definition: iotypes.h:508
struct NameRec_ * Name
Definition: cdprocs.h:464
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
#define FILE_OPEN
Definition: from_kernel.h:54
unsigned short USHORT
Definition: pedump.c:61
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
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:3009
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

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;
2297  NTSTATUS Status;
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 */
2383  IoStack = IoGetCurrentIrpStackLocation(Irp);
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 */
2485  DataFormat = (PKSDATAFORMAT)(Connect + 1);
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 */
2501  KsFreeObjectBag((KSOBJECT_BAG)This->Pin.Bag);
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);
2541  KsFreeObjectBag((KSOBJECT_BAG)This->Pin.Bag);
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 */
2576  KsFreeObjectBag((KSOBJECT_BAG)This->Pin.Bag);
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);
2597  KsFreeObjectBag((KSOBJECT_BAG)This->Pin.Bag);
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 
2635  if (!NT_SUCCESS(Status) && Status != STATUS_PENDING)
2636  {
2637  /* failed to create pin, release resources */
2638  IKsFilter_RemovePin(Filter->lpVtbl->GetStruct(Filter), &This->Pin);
2639  KsFreeObjectBag((KSOBJECT_BAG)This->Pin.Bag);
2640  KsFreeObjectHeader((KSOBJECT_HEADER)This->ObjectHeader);
2641  FreeItem(This);
2642 
2643  /* return failure code */
2644  return Status;
2645  }
2646 
2647  return Status;
2648 }
struct KSBASIC_HEADER * PKSBASIC_HEADER
static PWSTR GuidString
Definition: apphelp.c:91
KSPIN_INTERFACE Interface
Definition: ks.h:2630
#define KSSTRING_Allocator
Definition: ks.h:50
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
KSPIN_MEDIUM Medium
Definition: ks.h:2631
_In_ PKSPIN_CONNECT Connect
Definition: ks.h:4565
NTSTATUS NTAPI IKsPin_DispatchCreateClock(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pin.c:2175
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
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
_In_ PIRP Irp
Definition: csq.h:116
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
Definition: pin.c:31
KSPROPERTY_SET PinPropertySet[]
Definition: pin.c:95
REFERENCE_TIME AvgTimePerFrame
Definition: bdamedia.h:340
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
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
BDA_TRANSPORT_INFO BdaTransportInfo
Definition: bdamedia.h:345
VOID NTAPI IKsPin_PinCentricWorker(IN PVOID Parameter)
Definition: pin.c:1818
KSDDKAPI VOID NTAPI KsFreeObjectHeader(IN PVOID Header)
Definition: api.c:720
#define KSSTRING_Clock
Definition: ks.h:49
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
uint32_t ULONG_PTR
Definition: typedefs.h:63
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
ULONG PinId
Definition: ks.h:2632
static IKsPinVtbl vt_IKsPin
Definition: pin.c:691
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
PRKMUTEX ControlMutex
Definition: kstypes.h:58
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
void * PVOID
Definition: retypes.h:9
const GUID KSDATAFORMAT_SUBTYPE_BDA_MPEG2_TRANSPORT
Definition: connectivity.c:28
static KSDISPATCH_TABLE PinDispatchTable
Definition: pin.c:2268
NTSTATUS NTAPI IKsPin_DispatchCreateAllocator(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pin.c:2162
#define ExInitializeWorkItem(Item, Routine, Context)
Definition: exfuncs.h:265
VOID IKsFilter_RemovePin(PKSFILTER Filter, PKSPIN Pin)
Definition: filter.c:1378
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
static const UCHAR Index[8]
Definition: usbohci.c:18
KSDDKAPI NTSTATUS NTAPI KsRegisterCountedWorker(IN WORK_QUEUE_TYPE WorkQueueType, IN PWORK_QUEUE_ITEM CountedWorkItem, OUT PKSWORKER *Worker)
Definition: worker.c:166
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID IKsFilter_AddPin(PKSFILTER Filter, PKSPIN Pin)
Definition: filter.c:1337
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
Definition: mutex.c:67
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
static IKsReferenceClockVtbl vt_ReferenceClock
Definition: pin.c:911
struct tagKS_DATARANGE_BDA_TRANSPORT * PKS_DATARANGE_BDA_TRANSPORT
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
ULONG ulcbPhyiscalFrameAlignment
Definition: bdamedia.h:339
#define KSSTRING_TopologyNode
Definition: ks.h:52
NTSTATUS NTAPI IKsPin_DispatchCreateNode(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pin.c:2257
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
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
KSPRIORITY Priority
Definition: ks.h:2634
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION
KSDDKAPI VOID NTAPI KsFreeObjectBag(IN KSOBJECT_BAG ObjectBag)
Definition: bag.c:308
KSDATAFORMAT * PKSDATAFORMAT
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

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;
99  KSEVENT Event;
100  PKSEVENT_ITEM EventItem, FoundEventItem;
101  PKSEVENTDATA EventData;
102  const KSEVENT_SET *FoundEventSet;
103  PKSEVENT_ENTRY EventEntry;
104  ULONG Index, SubIndex, Size;
105  PVOID Object;
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 */
115  return STATUS_NOT_SUPPORTED;
116  }
117 
118  if (Irp->RequestorMode == UserMode)
119  {
120  _SEH2_TRY
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 }
static PWSTR GuidString
Definition: apphelp.c:91
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
ULONG NotificationType
Definition: ks.h:1763
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
PKSEVENT_ENTRY EventEntry
Definition: kstypes.h:138
#define SEMAPHORE_MODIFY_STATE
Definition: winbase.h:161
POBJECT_TYPE ExEventObjectType
Definition: event.c:22
static BOOL Set
Definition: pageheap.c:10
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
_SEH2_TRY
Definition: create.c:4250
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
BOOLEAN KspSynchronizedEventRoutine(IN KSEVENTS_LOCKTYPE EventsFlags, IN PVOID EventsLock, IN PKSEVENT_SYNCHRONIZED_ROUTINE SynchronizedRoutine, IN PKSEVENT_CTX Ctx)
Definition: event.c:15
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:496
LONG Adjustment
Definition: ks.h:1772
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:434
struct _KSEVENT_ENTRY KSEVENT_ENTRY
Definition: ks.h:2131
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
static GUID * Guid
Definition: apphelp.c:93
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define KSEVENTF_SEMAPHORE_HANDLE
Definition: ks.h:1809
#define UlongToPtr(u)
Definition: config.h:106
struct KSEVENTDATA::@2881::@2884 SemaphoreHandle
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define KSEVENT_TYPE_SETSUPPORT
Definition: ks.h:1822
static const UCHAR Index[8]
Definition: usbohci.c:18
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
static IUnknown Object
Definition: main.c:512
struct KSEVENTDATA::@2881::@2883 EventHandle
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned char UCHAR
Definition: xmlstorage.h:181
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define GUID_NULL
Definition: ks.h:106
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define STATUS_MORE_ENTRIES
Definition: udferr_usr.h:124
Status
Definition: gdiplustypes.h:24
#define STATUS_PROPSET_NOT_FOUND
Definition: ntstatus.h:678
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
struct _GUID GUID
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
_SEH2_END
Definition: create.c:4424
KSDDKAPI VOID NTAPI KsDiscardEvent(IN PKSEVENT_ENTRY EventEntry)
Definition: event.c:523
HANDLE Event
Definition: ks.h:1766
BOOLEAN NTAPI SyncAddEvent(PKSEVENT_CTX Context)
Definition: event.c:79
#define KSEVENTF_EVENT_HANDLE
Definition: ks.h:1808
#define DPRINT1
Definition: precomp.h:8
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
#define EVENT_MODIFY_STATE
Definition: winbase.h:163
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
struct _KSEVENT_ENTRY * PKSEVENT_ENTRY
Definition: ks.h:2131
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
HANDLE Semaphore
Definition: ks.h:1770
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
return STATUS_SUCCESS
Definition: btrfs.c:2745
PLIST_ENTRY List
Definition: kstypes.h:136
POBJECT_TYPE ExSemaphoreObjectType
Definition: sem.c:22
GUID * LPGUID
Definition: guiddef.h:76

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

◆ KspForwardIrpSynchronous()

NTSTATUS KspForwardIrpSynchronous ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 65 of file misc.c.

68 {
69  KEVENT Event;
71  PDEVICE_EXTENSION DeviceExtension;
72  PKSIDEVICE_HEADER DeviceHeader;
73 
75 
76  /* get device extension */
78  /* get device header */
79  DeviceHeader = DeviceExtension->DeviceHeader;
80 
81  /* initialize the notification event */
83 
85 
87 
88  /* now call the driver */
89  Status = IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
90  /* did the request complete yet */
91  if (Status == STATUS_PENDING)
92  {
93  /* not yet, lets wait a bit */
95  Status = Irp->IoStatus.Status;
96  }
97  return Status;
98 }
#define TRUE
Definition: types.h:120
_In_ PIRP Irp
Definition: csq.h:116
#define ASSERT_IRQL_EQUAL(x)
Definition: debug.h:43
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
KSDEVICE KsDevice
Definition: kstypes.h:88
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2820
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:434
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_PENDING
Definition: ntstatus.h:82
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI KspForwardIrpSynchronousCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: misc.c:51
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION

Referenced by IKsDevice_Pnp(), and IKsDevice_PnpStartDevice().

◆ 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 */
54  FreeItem(Entry);
55  }
56 
57  return STATUS_SUCCESS;
58 }
struct _Entry Entry
Definition: kefuncs.h:640
UNICODE_STRING SymbolicLink
Definition: kstypes.h:124
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
Definition: kstypes.h:121
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
Definition: typedefs.h:117
struct SYMBOLIC_LINK_ENTRY * PSYMBOLIC_LINK_ENTRY
return STATUS_SUCCESS
Definition: btrfs.c:2745
base of all file and directory entries
Definition: entries.h:82

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 STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
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
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
GUID Set
Definition: dmksctrl.h:76
static BOOL Set
Definition: pageheap.c:10
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
static GUID * Guid
Definition: apphelp.c:93
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_INVALID_BUFFER_SIZE
Definition: ntstatus.h:636
ULONG Id
Definition: dmksctrl.h:77
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct KSIDENTIFIER * PKSMETHOD
static const UCHAR Index[8]
Definition: usbohci.c:18
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG Flags
Definition: dmksctrl.h:78
#define GUID_NULL
Definition: ks.h:106
#define STATUS_MORE_ENTRIES
Definition: udferr_usr.h:124
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
struct _GUID GUID
#define KSMETHOD_TYPE_SETSUPPORT
Definition: dmksctrl.h:40
unsigned int ULONG
Definition: retypes.h:1
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
return STATUS_SUCCESS
Definition: btrfs.c:2745
GUID * LPGUID
Definition: guiddef.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;
333  KSMULTIPLE_ITEM * Item;
334  PIO_STACK_LOCATION IoStack;
335  ULONG Size, Index;
336  PVOID Buffer;
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 
354  if (Property->Id != KSPROPERTY_PIN_CTYPES)
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 
428  Item = (KSMULTIPLE_ITEM*)Buffer;
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 
550  case KSPROPERTY_PIN_NAME:
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 }
ULONG Count
Definition: ks.h:2010
KSPIN_INTERFACE StandardPinInterface
Definition: connectivity.c:14
static PWSTR GuidString
Definition: apphelp.c:91
ULONG Size
Definition: ks.h:2009
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
KSDDKAPI NTSTATUS NTAPI KsHandleSizedListQuery(IN PIRP Irp, IN ULONG DataItemsCount, IN ULONG DataItemSize, IN const VOID *DataItems)
Definition: connectivity.c:774
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
NTSTATUS KspReadMediaCategory(IN LPGUID Category, PKEY_VALUE_PARTIAL_INFORMATION *OutInformation)
Definition: connectivity.c:232
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
uint32_t ULONG_PTR
Definition: typedefs.h:63
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
WORD wBitsPerSample
Definition: audioclient.idl:45
static GUID * Guid
Definition: apphelp.c:93
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
void DPRINT(...)
Definition: polytest.cpp:61
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
KSPIN_DATAFLOW
Definition: ks.h:1278
DWORD nSamplesPerSec
Definition: audioclient.idl:42
#define STATUS_NOT_FOUND
Definition: shellext.h:67
Definition: ks.h:672
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:415
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const UCHAR Index[8]
Definition: usbohci.c:18
WAVEFORMATEX WaveFormatEx
Definition: ksmedia.h:532
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
static const WCHAR L[]
Definition: oid.c:1250
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
struct _GUID GUID
struct KSDATAFORMAT_WAVEFORMATEX * PKSDATAFORMAT_WAVEFORMATEX
KSPIN_COMMUNICATION
Definition: ks.h:1283
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
#define STATUS_NO_MATCH
Definition: ntstatus.h:737
unsigned int * PULONG
Definition: retypes.h:1
#define DPRINT1
Definition: precomp.h:8
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
KSPIN_MEDIUM StandardPinMedium
Definition: connectivity.c:21
#define UNIMPLEMENTED
Definition: debug.h:114
WCHAR * LPWSTR
Definition: xmlstorage.h:184
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2745
GUID * LPGUID
Definition: guiddef.h:76
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

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 
289  _SEH2_TRY
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  }
314  _SEH2_TRY
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 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
#define KSPROPERTY_TYPE_SETSUPPORT
Definition: dmksctrl.h:44
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG _In_ ULONG OutputBufferLength
Definition: fltkernel.h:1374
#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
static BOOL Set
Definition: pageheap.c:10
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
_SEH2_TRY
Definition: create.c:4250
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
static GUID * Guid
Definition: apphelp.c:93
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_INVALID_BUFFER_SIZE
Definition: ntstatus.h:636
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
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
static const UCHAR Index[8]
Definition: usbohci.c:18
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:871
struct PropertyItem PropertyItem
#define GUID_NULL
Definition: ks.h:106
#define STATUS_MORE_ENTRIES
Definition: udferr_usr.h:124
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG InputBufferLength
Definition: fltkernel.h:1372
Status
Definition: gdiplustypes.h:24
_In_ DWORD Property
Definition: setupapi.h:1545
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
struct _GUID GUID
_SEH2_END
Definition: create.c:4424
#define IRP_INPUT_OPERATION
#define IRP_BUFFERED_IO
#define IRP_DEALLOCATE_BUFFER
unsigned int ULONG
Definition: retypes.h:1
struct KSIDENTIFIER * PKSPROPERTY
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
return STATUS_SUCCESS
Definition: btrfs.c:2745
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
GUID * LPGUID
Definition: guiddef.h:76

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 
261  RtlAppendUnicodeStringToString(&Path, &MediaPath);
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 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
static PWSTR GuidString
Definition: apphelp.c:91
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
USHORT MaximumLength
Definition: env_spec_w32.h:370
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static const WCHAR L[]
Definition: oid.c:1250
#define GENERIC_READ
Definition: compat.h:124
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
PRTL_UNICODE_STRING_BUFFER Path
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#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 {
68  ULONG Index;
70  PSYMBOLIC_LINK_ENTRY SymEntry;
71 
72  for(Index = 0; Index < CategoriesCount; Index++)
73  {
74  /* allocate a symbolic link entry */
75  SymEntry = AllocateItem(NonPagedPool, sizeof(SYMBOLIC_LINK_ENTRY));
76  /* check for success */
77  if (!SymEntry)
79 
80  /* now register device interface */
82  &Categories[Index],
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 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_opt_ PDEVICE_OBJECT _In_ ULONG _Outptr_result_nullonfailure_ _At_ * SymbolicLinkList(return==0, __drv_allocatesMem(Mem))) PZZWSTR *SymbolicLinkList
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
LIST_ENTRY Entry
Definition: kstypes.h:123
UNICODE_STRING SymbolicLink
Definition: kstypes.h:124
#define InsertTailList(ListHead, Entry)
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
const GUID Categories[]
Definition: splitter.c:208
_In_ CONST GUID _In_opt_ PUNICODE_STRING ReferenceString
Definition: iofuncs.h:1134
Definition: kstypes.h:121
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const UCHAR Index[8]
Definition: usbohci.c:18
CLSID DeviceInterfaceClass
Definition: kstypes.h:125
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
Definition: deviface.c:955
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2745

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 }
struct _Entry Entry
Definition: kefuncs.h:640
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:140
UNICODE_STRING SymbolicLink
Definition: kstypes.h:124
Definition: kstypes.h:121
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1311
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Definition: typedefs.h:117
struct SYMBOLIC_LINK_ENTRY * PSYMBOLIC_LINK_ENTRY
Status
Definition: gdiplustypes.h:24
return STATUS_SUCCESS
Definition: btrfs.c:2745
base of all file and directory entries
Definition: entries.h:82

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 }
struct _Entry Entry
Definition: kefuncs.h:640
LONG NTSTATUS
Definition: precomp.h:26
Definition: kstypes.h:45
PKSOBJECT_CREATE_ITEM CreateItem
Definition: kstypes.h:48
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
NTSTATUS NTAPI IKsFilterFactory_Create(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: filterfactory.c:42
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: typedefs.h:117
Status
Definition: gdiplustypes.h:24
KSDDKAPI NTSTATUS NTAPI KsFilterFactorySetDeviceClassesState(IN PKSFILTERFACTORY FilterFactory, IN BOOLEAN NewState)
return STATUS_SUCCESS
Definition: btrfs.c:2745
base of all file and directory entries
Definition: entries.h:82

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;
72  ULONG Index;
73  ULONG Count;
74  BOOLEAN Found;
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;
119  Interface = (PKSPIN_INTERFACE)Descriptor->Interfaces;
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 }
KSPIN_INTERFACE StandardPinInterface
Definition: connectivity.c:14
static PWSTR GuidString
Definition: apphelp.c:91
#define TRUE
Definition: types.h:120
KSPIN_INTERFACE Interface
Definition: ks.h:2630
KSPIN_MEDIUM Medium
Definition: ks.h:2631
_In_ PKSPIN_CONNECT Connect
Definition: ks.h:4565
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define KSSTRING_Pin
Definition: ks.h:48
LONG NTSTATUS
Definition: precomp.h:26
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
KSIDENTIFIER * PKSPIN_INTERFACE
Definition: ks.h:273
NTSTATUS KspCopyCreateRequest(IN PIRP Irp, IN LPWSTR ObjectClass, IN OUT PULONG Size, OUT PVOID *Result)
Definition: misc.c:101
GUID Set
Definition: dmksctrl.h:76
static BOOL Set
Definition: pageheap.c:10
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
uint32_t ULONG_PTR
Definition: typedefs.h:63
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
ULONG PinId
Definition: ks.h:2632
unsigned char BOOLEAN
void DPRINT(...)
Definition: polytest.cpp:61
return Found
Definition: dirsup.c:1270
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
ULONG Id
Definition: dmksctrl.h:77
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const UCHAR Index[8]
Definition: usbohci.c:18
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
KSIDENTIFIER * PKSPIN_MEDIUM
Definition: ks.h:274
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
#define STATUS_NO_MATCH
Definition: ntstatus.h:737
unsigned int ULONG
Definition: retypes.h:1
KSPIN_MEDIUM StandardPinMedium
Definition: connectivity.c:21
return STATUS_SUCCESS
Definition: btrfs.c:2745
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

Referenced by IKsFilter_DispatchCreatePin(), and KsValidateConnectRequest().