[KS]
[reactos.git] / reactos / drivers / ksfilter / ks / property.c
index 7d6a29b..72f6089 100644 (file)
@@ -30,6 +30,8 @@ FindPropertyHandler(
     OUT PKSPROPERTY_ITEM *PropertyItem)
 {
     ULONG Index, ItemIndex;
+    PULONG Flags;
+    PKSPROPERTY_DESCRIPTION Description;
 
     for(Index = 0; Index < PropertySetCount; Index++)
     {
@@ -39,46 +41,16 @@ FindPropertyHandler(
         {
             for(ItemIndex = 0; ItemIndex < PropertySet[Index].PropertiesCount; ItemIndex++)
             {
-                if (PropertySet[Index].PropertyItem[ItemIndex].PropertyId == Property->Id)
-                {
-                    if (PropertySet[Index].PropertyItem[ItemIndex].MinProperty > InputBufferLength)
-                    {
-                        /* too small input buffer */
-                        IoStatus->Information = PropertySet[Index].PropertyItem[ItemIndex].MinProperty;
-                        return STATUS_INVALID_PARAMETER;
-                    }
-
-                    if (PropertySet[Index].PropertyItem[ItemIndex].MinData > OutputBufferLength)
-                    {
-                        /* too small output buffer */
-                        IoStatus->Information = PropertySet[Index].PropertyItem[ItemIndex].MinData;
-                        return STATUS_MORE_ENTRIES;
-                    }
-
-                    /* store property set */
-                    *Set = (PKSPROPERTY_SET)&PropertySet[Index];
-                    *PropertyItem = (PKSPROPERTY_ITEM)&PropertySet[Index].PropertyItem[ItemIndex];
-
-                    if (Property->Flags & KSPROPERTY_TYPE_SET)
-                    {
-                        /* store property handler */
-                        *PropertyHandler = PropertySet[Index].PropertyItem[ItemIndex].SetPropertyHandler;
-                        return STATUS_SUCCESS;
-                    }
 
-                    if (Property->Flags & KSPROPERTY_TYPE_GET)
-                    {
-                        /* store property handler */
-                        *PropertyHandler = PropertySet[Index].PropertyItem[ItemIndex].GetPropertyHandler;
-                        return STATUS_SUCCESS;
-                    }
+                /* store property set */
+                *Set = (PKSPROPERTY_SET)&PropertySet[Index];
+                *PropertyItem = (PKSPROPERTY_ITEM)&PropertySet[Index].PropertyItem[ItemIndex];
 
 
+                if (PropertySet[Index].PropertyItem[ItemIndex].PropertyId == Property->Id)
+                {
                     if (Property->Flags & KSPROPERTY_TYPE_BASICSUPPORT)
                     {
-                        PULONG Flags;
-                        PKSPROPERTY_DESCRIPTION Description;
-
                         if (sizeof(ULONG) > OutputBufferLength)
                         {
                             /* too small buffer */
@@ -123,6 +95,37 @@ FindPropertyHandler(
                         }
                         return STATUS_SUCCESS;
                     }
+
+                    if (PropertySet[Index].PropertyItem[ItemIndex].MinProperty > InputBufferLength)
+                    {
+                        /* too small input buffer */
+                        IoStatus->Information = PropertySet[Index].PropertyItem[ItemIndex].MinProperty;
+                        return STATUS_INVALID_PARAMETER;
+                    }
+
+                    if (PropertySet[Index].PropertyItem[ItemIndex].MinData > OutputBufferLength)
+                    {
+                        /* too small output buffer */
+                        IoStatus->Information = PropertySet[Index].PropertyItem[ItemIndex].MinData;
+                        return STATUS_MORE_ENTRIES;
+                    }
+
+
+                    if (Property->Flags & KSPROPERTY_TYPE_SET)
+                    {
+                        /* store property handler */
+                        *PropertyHandler = PropertySet[Index].PropertyItem[ItemIndex].SetPropertyHandler;
+                        return STATUS_SUCCESS;
+                    }
+
+                    if (Property->Flags & KSPROPERTY_TYPE_GET)
+                    {
+                        /* store property handler */
+                        *PropertyHandler = PropertySet[Index].PropertyItem[ItemIndex].GetPropertyHandler;
+                        return STATUS_SUCCESS;
+                    }
+
+
                 }
             }
         }
@@ -300,7 +303,7 @@ KspPropertyHandler(
             if (Allocator)
             {
                 /* allocate the requested amount */
-                Status = Allocator(Irp, Irp->IoStatus.Information, FALSE);
+                Status = Allocator(Irp, (ULONG)Irp->IoStatus.Information, FALSE);
 
                 /* check if the block was allocated */
                 if (!NT_SUCCESS(Status))
@@ -364,15 +367,16 @@ KsPropertyHandler(
 /*
     @implemented
 */
+_IRQL_requires_max_(PASSIVE_LEVEL)
 KSDDKAPI
 NTSTATUS
 NTAPI
 KsPropertyHandlerWithAllocator(
-    IN  PIRP Irp,
-    IN  ULONG PropertySetsCount,
-    IN  PKSPROPERTY_SET PropertySet,
-    IN  PFNKSALLOCATOR Allocator OPTIONAL,
-    IN  ULONG PropertyItemSize OPTIONAL)
+    _In_ PIRP Irp,
+    _In_ ULONG PropertySetsCount,
+    _In_reads_(PropertySetsCount) const KSPROPERTY_SET* PropertySet,
+    _In_opt_ PFNKSALLOCATOR Allocator,
+    _In_opt_ ULONG PropertyItemSize)
 {
     return KspPropertyHandler(Irp, PropertySetsCount, PropertySet, Allocator, PropertyItemSize);
 }