From 63b3ed6d1ea316dbd89ca4118df346fff83f0fc7 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Mon, 24 Aug 2009 12:21:20 +0000 Subject: [PATCH] - Fix calling property handler in IKsFilter_DispatchDeviceIoControl - Found by [[Amine Khaldi]] - Implement handling of KSPROPERTY_TYPE_BASICSUPPORT svn path=/trunk/; revision=42910 --- reactos/drivers/ksfilter/ks/filter.c | 31 ++++++++++------- reactos/drivers/ksfilter/ks/ksfunc.h | 9 +++++ reactos/drivers/ksfilter/ks/property.c | 48 ++++++++++++++++++++++++-- 3 files changed, 72 insertions(+), 16 deletions(-) diff --git a/reactos/drivers/ksfilter/ks/filter.c b/reactos/drivers/ksfilter/ks/filter.c index 1ad54d1de88..edc91ac7876 100644 --- a/reactos/drivers/ksfilter/ks/filter.c +++ b/reactos/drivers/ksfilter/ks/filter.c @@ -706,10 +706,10 @@ IKsFilter_DispatchDeviceIoControl( IN PIRP Irp) { PIO_STACK_LOCATION IoStack; - PFNKSHANDLER PropertyHandler = NULL; IKsFilter * Filter; IKsFilterImpl * This; NTSTATUS Status; + PKSFILTER FilterInstance; /* obtain filter from object header */ Status = IKsFilter_GetFilterFromIrp(Irp, &Filter); @@ -735,19 +735,24 @@ IKsFilter_DispatchDeviceIoControl( return STATUS_NOT_IMPLEMENTED; } - /* find a supported property handler */ - Status = KsPropertyHandler(Irp, 2, FilterPropertySet); - if (NT_SUCCESS(Status)) + /* call property handler supported by ks */ + Status = KspPropertyHandler(Irp, 2, FilterPropertySet, NULL, sizeof(KSPROPERTY_ITEM)); + + if (Status == STATUS_NOT_FOUND) { - KSPROPERTY_ITEM_IRP_STORAGE(Irp) = (PVOID)This; - DPRINT("Calling property handler %p\n", PropertyHandler); - Status = PropertyHandler(Irp, IoStack->Parameters.DeviceIoControl.Type3InputBuffer, Irp->UserBuffer); - } - else - { - /* call driver's property handler */ - UNIMPLEMENTED - Status = STATUS_NOT_IMPLEMENTED; + /* get filter instance */ + FilterInstance = Filter->lpVtbl->GetStruct(Filter); + + /* check if the driver supports property sets */ + if (FilterInstance->Descriptor->AutomationTable && FilterInstance->Descriptor->AutomationTable->PropertySetsCount) + { + /* call driver's filter property handler */ + Status = KspPropertyHandler(Irp, + FilterInstance->Descriptor->AutomationTable->PropertySetsCount, + FilterInstance->Descriptor->AutomationTable->PropertySets, + NULL, + FilterInstance->Descriptor->AutomationTable->PropertyItemSize); + } } Irp->IoStatus.Status = Status; diff --git a/reactos/drivers/ksfilter/ks/ksfunc.h b/reactos/drivers/ksfilter/ks/ksfunc.h index 4e2e33cf344..76f38b5ed28 100644 --- a/reactos/drivers/ksfilter/ks/ksfunc.h +++ b/reactos/drivers/ksfilter/ks/ksfunc.h @@ -139,4 +139,13 @@ 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); + + #endif diff --git a/reactos/drivers/ksfilter/ks/property.c b/reactos/drivers/ksfilter/ks/property.c index 6b3ee967bee..f7cba22d390 100644 --- a/reactos/drivers/ksfilter/ks/property.c +++ b/reactos/drivers/ksfilter/ks/property.c @@ -17,9 +17,11 @@ FindPropertyHandler( IN PKSPROPERTY Property, IN ULONG InputBufferLength, IN ULONG OutputBufferLength, + OUT PVOID OutputBuffer, OUT PFNKSHANDLER *PropertyHandler) { ULONG Index, ItemIndex; + //PULONG Flags; for(Index = 0; Index < PropertySetCount; Index++) { @@ -42,6 +44,46 @@ FindPropertyHandler( IoStatus->Information = PropertySet[Index].PropertyItem[ItemIndex].MinData; return STATUS_BUFFER_TOO_SMALL; } +#if 0 + if (Property->Flags & KSPROPERTY_TYPE_BASICSUPPORT) + { + if (sizeof(ULONG) > OutputBufferLength) + { + /* too small buffer */ + return STATUS_INVALID_PARAMETER; + } + + /* get output buffer */ + Flags = (PULONG)OutputBuffer; + + /* clear flags */ + *Flags = KSPROPERTY_TYPE_BASICSUPPORT; + + if (PropertySet[Index].PropertyItem[ItemIndex].GetSupported) + *Flags |= KSPROPERTY_TYPE_GET; + + if (PropertySet[Index].PropertyItem[ItemIndex].SetSupported) + *Flags |= KSPROPERTY_TYPE_SET; + + IoStatus->Information = sizeof(ULONG); + + if (OutputBufferLength >= sizeof(KSPROPERTY_DESCRIPTION)) + { + /* get output buffer */ + Description = (PKSPROPERTY_DESCRIPTION)OutputBuffer; + + /* store result */ + Description->DescriptionSize = sizeof(KSPROPERTY_DESCRIPTION); + Description->PropTypeSet.Set = KSPROPTYPESETID_General; + Description->PropTypeSet.Id = 0; + Description->PropTypeSet.Flags = 0; + Description->MembersListCount = 0; + Description->Reserved = 0; + + IoStatus->Information = sizeof(KSPROPERTY_DESCRIPTION); + } + } +#endif if (Property->Flags & KSPROPERTY_TYPE_SET) *PropertyHandler = PropertySet[Index].PropertyItem[ItemIndex].SetPropertyHandler; @@ -69,7 +111,7 @@ KspPropertyHandler( PKSPROPERTY Property; PIO_STACK_LOCATION IoStack; NTSTATUS Status; - PFNKSHANDLER PropertyHandler; + PFNKSHANDLER PropertyHandler = NULL; /* get current irp stack */ IoStack = IoGetCurrentIrpStackLocation(Irp); @@ -97,9 +139,9 @@ KspPropertyHandler( } /* find the property handler */ - Status = FindPropertyHandler(&Irp->IoStatus, PropertySet, PropertySetsCount, Property, IoStack->Parameters.DeviceIoControl.InputBufferLength, IoStack->Parameters.DeviceIoControl.OutputBufferLength, &PropertyHandler); + Status = FindPropertyHandler(&Irp->IoStatus, PropertySet, PropertySetsCount, Property, IoStack->Parameters.DeviceIoControl.InputBufferLength, IoStack->Parameters.DeviceIoControl.OutputBufferLength, Irp->UserBuffer, &PropertyHandler); - if (NT_SUCCESS(Status)) + if (NT_SUCCESS(Status) && PropertyHandler) { /* call property handler */ Status = PropertyHandler(Irp, Property, Irp->UserBuffer);