ReactOS 0.4.16-dev-336-gb667d82
connectivity.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for connectivity.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

KSDDKAPI NTSTATUS NTAPI KsCreatePin (IN HANDLE FilterHandle, IN PKSPIN_CONNECT Connect, IN ACCESS_MASK DesiredAccess, OUT PHANDLE ConnectionHandle)
 
NTSTATUS KspValidateConnectRequest (IN PIRP Irp, IN ULONG DescriptorsCount, IN PVOID Descriptors, IN ULONG DescriptorSize, OUT PKSPIN_CONNECT *Connect)
 
KSDDKAPI NTSTATUS NTAPI KsValidateConnectRequest (IN PIRP Irp, IN ULONG DescriptorsCount, IN KSPIN_DESCRIPTOR *Descriptor, OUT PKSPIN_CONNECT *Connect)
 
NTSTATUS KspReadMediaCategory (IN LPGUID Category, PKEY_VALUE_PARTIAL_INFORMATION *OutInformation)
 
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)
 
KSDDKAPI NTSTATUS NTAPI KsPinPropertyHandler (IN PIRP Irp, IN PKSPROPERTY Property, IN OUT PVOID Data, IN ULONG DescriptorsCount, IN const KSPIN_DESCRIPTOR *Descriptor)
 
KSDDKAPI NTSTATUS NTAPI KsPinDataIntersectionEx (IN PIRP Irp, IN PKSP_PIN Pin, OUT PVOID Data, IN ULONG DescriptorsCount, IN const KSPIN_DESCRIPTOR *Descriptor, IN ULONG DescriptorSize, IN PFNKSINTERSECTHANDLEREX IntersectHandler OPTIONAL, IN PVOID HandlerContext OPTIONAL)
 
KSDDKAPI NTSTATUS NTAPI KsPinDataIntersection (IN PIRP Irp, IN PKSP_PIN Pin, OUT PVOID Data, IN ULONG DescriptorsCount, IN const KSPIN_DESCRIPTOR *Descriptor, IN PFNKSINTERSECTHANDLER IntersectHandler)
 
KSDDKAPI NTSTATUS NTAPI KsHandleSizedListQuery (IN PIRP Irp, IN ULONG DataItemsCount, IN ULONG DataItemSize, IN const VOID *DataItems)
 

Variables

KSPIN_INTERFACE StandardPinInterface
 
KSPIN_MEDIUM StandardPinMedium
 
const GUID KSDATAFORMAT_SUBTYPE_BDA_MPEG2_TRANSPORT = {0xf4aeb342, 0x0329, 0x4fdd, {0xa8, 0xfd, 0x4a, 0xff, 0x49, 0x26, 0xc9, 0x78}}
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file connectivity.c.

Function Documentation

◆ KsCreatePin()

KSDDKAPI NTSTATUS NTAPI KsCreatePin ( IN HANDLE  FilterHandle,
IN PKSPIN_CONNECT  Connect,
IN ACCESS_MASK  DesiredAccess,
OUT PHANDLE  ConnectionHandle 
)

Definition at line 36 of file connectivity.c.

41{
42 UINT ConnectSize = sizeof(KSPIN_CONNECT);
43
45 if (Format->DataFormat.FormatSize == sizeof(KSDATAFORMAT) ||
46 Format->DataFormat.FormatSize == sizeof(KSDATAFORMAT) + sizeof(WAVEFORMATEX) + Format->WaveFormatEx.cbSize)
47 {
48 ConnectSize += Format->DataFormat.FormatSize;
49 }
50
51 return KspCreateObjectType(FilterHandle,
54 ConnectSize,
57}
#define KSSTRING_Pin
Definition: ks.h:48
_In_ PKSPIN_CONNECT Connect
Definition: ks.h:4536
_In_ PKSPIN_CONNECT _In_ ACCESS_MASK _Out_ PHANDLE ConnectionHandle
Definition: ks.h:4538
NTSTATUS NTAPI KspCreateObjectType(IN HANDLE ParentHandle, IN LPWSTR ObjectType, PVOID CreateParameters, UINT CreateParametersSize, IN ACCESS_MASK DesiredAccess, OUT PHANDLE NodeHandle)
Definition: topology.c:16
struct KSDATAFORMAT_WAVEFORMATEX * PKSDATAFORMAT_WAVEFORMATEX
unsigned int UINT
Definition: ndis.h:50
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658

◆ KsHandleSizedListQuery()

KSDDKAPI NTSTATUS NTAPI KsHandleSizedListQuery ( IN PIRP  Irp,
IN ULONG  DataItemsCount,
IN ULONG  DataItemSize,
IN const VOID DataItems 
)

Definition at line 774 of file connectivity.c.

779{
780 ULONG Size;
781 PIO_STACK_LOCATION IoStack;
783
784 /* get current irp stack location */
786
787 /* calculate size */
788 Size = DataItemSize * DataItemsCount + sizeof(KSMULTIPLE_ITEM);
789
790 /* get multiple item */
791 Item = (PKSMULTIPLE_ITEM)Irp->AssociatedIrp.SystemBuffer;
792
793 if (IoStack->Parameters.DeviceIoControl.OutputBufferLength == 0)
794 {
795 /* buffer too small */
796 Irp->IoStatus.Information = Size;
797
799 }
800
801 if (IoStack->Parameters.DeviceIoControl.OutputBufferLength == sizeof(ULONG))
802 {
803 /* store just the size */
804 Item->Size = Size;
805 Irp->IoStatus.Information = sizeof(ULONG);
806
807 return STATUS_SUCCESS;
808 }
809
810
811 if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(KSMULTIPLE_ITEM))
812 {
813 /* buffer too small */
815 }
816
817 Item->Count = DataItemsCount;
818 Item->Size = DataItemSize;
819
820 if (IoStack->Parameters.DeviceIoControl.OutputBufferLength == sizeof(KSMULTIPLE_ITEM))
821 {
822 /* buffer can only hold the length descriptor */
823 Irp->IoStatus.Information = sizeof(KSMULTIPLE_ITEM);
824 return STATUS_SUCCESS;
825 }
826
827 if (IoStack->Parameters.DeviceIoControl.OutputBufferLength >= Size)
828 {
829 /* copy items */
830 RtlMoveMemory((PVOID)(Item + 1), DataItems, DataItemSize * DataItemsCount);
831 /* store result */
832 Irp->IoStatus.Information = Size;
833 /* done */
834 return STATUS_SUCCESS;
835 }
836 else
837 {
838 /* buffer too small */
840 }
841}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
_In_ PIRP Irp
Definition: csq.h:116
struct KSMULTIPLE_ITEM * PKSMULTIPLE_ITEM
if(dx< 0)
Definition: linetemp.h:194
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
union _IO_STACK_LOCATION::@1581 Parameters
struct _IO_STACK_LOCATION::@1581::@1582 DeviceIoControl
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Referenced by KspPinPropertyHandler(), and KsTopologyPropertyHandler().

◆ KsPinDataIntersection()

KSDDKAPI NTSTATUS NTAPI KsPinDataIntersection ( IN PIRP  Irp,
IN PKSP_PIN  Pin,
OUT PVOID  Data,
IN ULONG  DescriptorsCount,
IN const KSPIN_DESCRIPTOR *  Descriptor,
IN PFNKSINTERSECTHANDLER  IntersectHandler 
)

Definition at line 700 of file connectivity.c.

707{
709 KSDATARANGE * DataRange;
710 PIO_STACK_LOCATION IoStack;
711 ULONG Size;
712 ULONG Index;
714
715 /* get current irp stack location */
717
718 /* calculate minimum data size */
719 Size = sizeof(KSP_PIN) + sizeof(KSMULTIPLE_ITEM) + sizeof(KSDATARANGE);
720 if (IoStack->Parameters.DeviceIoControl.InputBufferLength < Size)
721 {
722 /* buffer too small */
723 Irp->IoStatus.Information = Size;
724 Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
726 }
727 /* is pin id out of bounds */
728 if (Pin->PinId >= DescriptorsCount)
729 {
730 /* it is */
731 Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
732 Irp->IoStatus.Information = 0;
734 }
735
736 /* get start item */
737 Item = (KSMULTIPLE_ITEM*)(Pin + 1);
738 /* get first data range */
739 DataRange = (KSDATARANGE*)(Item + 1);
740 /* iterate through all data ranges */
741 for(Index = 0; Index < Item->Count; Index++, DataRange++)
742 {
743 /* call intersect handler */
744 Status = IntersectHandler(Irp, Pin, DataRange, Data);
745 if (NT_SUCCESS(Status))
746 {
747 if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < DataRange->FormatSize)
748 {
749 /* buffer is too small */
750 Irp->IoStatus.Information = DataRange->FormatSize;
751 Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
753 }
754 RtlMoveMemory(Irp->UserBuffer, DataRange, sizeof(KSDATARANGE));
755 Irp->IoStatus.Information = sizeof(KSDATARANGE);
756 Irp->IoStatus.Status = STATUS_SUCCESS;
757 return STATUS_SUCCESS;
758 }
759
760 }
761
762 Irp->IoStatus.Information = 0;
763 Irp->IoStatus.Status = STATUS_NO_MATCH;
764 return STATUS_NO_MATCH;
765}
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:428
Status
Definition: gdiplustypes.h:25
union KSDATAFORMAT KSDATARANGE
#define STATUS_NO_MATCH
Definition: ntstatus.h:751
Definition: ks.h:642
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ WDFCOLLECTION _In_ ULONG Index

◆ KsPinDataIntersectionEx()

KSDDKAPI NTSTATUS NTAPI KsPinDataIntersectionEx ( IN PIRP  Irp,
IN PKSP_PIN  Pin,
OUT PVOID  Data,
IN ULONG  DescriptorsCount,
IN const KSPIN_DESCRIPTOR *  Descriptor,
IN ULONG  DescriptorSize,
IN PFNKSINTERSECTHANDLEREX IntersectHandler  OPTIONAL,
IN PVOID HandlerContext  OPTIONAL 
)

Definition at line 680 of file connectivity.c.

689{
691 return STATUS_UNSUCCESSFUL;
692}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

◆ KsPinPropertyHandler()

KSDDKAPI NTSTATUS NTAPI KsPinPropertyHandler ( IN PIRP  Irp,
IN PKSPROPERTY  Property,
IN OUT PVOID  Data,
IN ULONG  DescriptorsCount,
IN const KSPIN_DESCRIPTOR *  Descriptor 
)

Definition at line 666 of file connectivity.c.

672{
673 return KspPinPropertyHandler(Irp, Property, Data, DescriptorsCount, Descriptor, sizeof(KSPIN_DESCRIPTOR));
674}
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: connectivity.c:324
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342

Referenced by PinPropertyHandler().

◆ KspPinPropertyHandler()

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

Definition at line 324 of file connectivity.c.

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

Referenced by FilterPinPropertyHandler(), and KsPinPropertyHandler().

◆ KspReadMediaCategory()

NTSTATUS KspReadMediaCategory ( IN LPGUID  Category,
PKEY_VALUE_PARTIAL_INFORMATION OutInformation 
)

Definition at line 232 of file connectivity.c.

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

Referenced by KspPinPropertyHandler(), and KsTopologyPropertyHandler().

◆ KspValidateConnectRequest()

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

FIXME implement format checking

Definition at line 60 of file connectivity.c.

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

Referenced by IKsFilter_DispatchCreatePin(), and KsValidateConnectRequest().

◆ KsValidateConnectRequest()

KSDDKAPI NTSTATUS NTAPI KsValidateConnectRequest ( IN PIRP  Irp,
IN ULONG  DescriptorsCount,
IN KSPIN_DESCRIPTOR *  Descriptor,
OUT PKSPIN_CONNECT Connect 
)

Definition at line 222 of file connectivity.c.

227{
228 return KspValidateConnectRequest(Irp, DescriptorsCount, Descriptor, sizeof(KSPIN_DESCRIPTOR), Connect);
229}
NTSTATUS KspValidateConnectRequest(IN PIRP Irp, IN ULONG DescriptorsCount, IN PVOID Descriptors, IN ULONG DescriptorSize, OUT PKSPIN_CONNECT *Connect)
Definition: connectivity.c:60

Referenced by PcValidateConnectRequest().

Variable Documentation

◆ KSDATAFORMAT_SUBTYPE_BDA_MPEG2_TRANSPORT

const GUID KSDATAFORMAT_SUBTYPE_BDA_MPEG2_TRANSPORT = {0xf4aeb342, 0x0329, 0x4fdd, {0xa8, 0xfd, 0x4a, 0xff, 0x49, 0x26, 0xc9, 0x78}}

Definition at line 28 of file connectivity.c.

◆ StandardPinInterface

KSPIN_INTERFACE StandardPinInterface
Initial value:
=
{
0
}
#define STATIC_KSINTERFACESETID_Standard
Definition: ks.h:277
@ KSINTERFACE_STANDARD_STREAMING
Definition: ks.h:283

Definition at line 14 of file connectivity.c.

Referenced by KspPinPropertyHandler(), and KspValidateConnectRequest().

◆ StandardPinMedium

KSPIN_MEDIUM StandardPinMedium
Initial value:
=
{
0
}
#define KSMEDIUM_TYPE_ANYINSTANCE
Definition: ks.h:301
#define STATIC_KSMEDIUMSETID_Standard
Definition: ks.h:303

Definition at line 21 of file connectivity.c.

Referenced by KspPinPropertyHandler(), and KspValidateConnectRequest().