- Fix calling property handler in IKsFilter_DispatchDeviceIoControl
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Mon, 24 Aug 2009 12:21:20 +0000 (12:21 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Mon, 24 Aug 2009 12:21:20 +0000 (12:21 +0000)
- Found by [[Amine Khaldi]]
- Implement handling of KSPROPERTY_TYPE_BASICSUPPORT

svn path=/trunk/; revision=42910

reactos/drivers/ksfilter/ks/filter.c
reactos/drivers/ksfilter/ks/ksfunc.h
reactos/drivers/ksfilter/ks/property.c

index 1ad54d1..edc91ac 100644 (file)
@@ -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))
-    {
-        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 property handler supported by ks */
+    Status = KspPropertyHandler(Irp, 2, FilterPropertySet, NULL, sizeof(KSPROPERTY_ITEM));
+
+    if (Status == STATUS_NOT_FOUND)
     {
-        /* 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;
index 4e2e33c..76f38b5 100644 (file)
@@ -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
index 6b3ee96..f7cba22 100644 (file)
@@ -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);