[KS]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Thu, 1 Apr 2010 03:14:45 +0000 (03:14 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Thu, 1 Apr 2010 03:14:45 +0000 (03:14 +0000)
- Fix a bad cast in KsGetDevice which led to a crash
- Store IKsFilter in create item storage which is needed later by the pin property handler
- There is no need to copy the existing pin factories, just add pin factories which are added dynamically
- Handle possible null values for node types & names
- Put allocated objects into object bags which can be released later automatically
- Fix access IKsFilterFactory interface in IKsFilterFactory_Create
- graphedt can now 'open' tv tuner and enumerate pins / communication / interface. Code required for devenum not yet commited

svn path=/trunk/; revision=46634

reactos/drivers/ksfilter/ks/api.c
reactos/drivers/ksfilter/ks/deviceinterface.c
reactos/drivers/ksfilter/ks/driver.c
reactos/drivers/ksfilter/ks/filter.c
reactos/drivers/ksfilter/ks/filterfactory.c
reactos/drivers/ksfilter/ks/pin.c

index af9fd81..ef83f9d 100644 (file)
@@ -1621,7 +1621,10 @@ KsAcquireDevice(
     IN PKSDEVICE Device)
 {
     IKsDevice *KsDevice;
-    PKSIDEVICE_HEADER DeviceHeader = (PKSIDEVICE_HEADER)CONTAINING_RECORD(Device, KSIDEVICE_HEADER, KsDevice);
+    PKSIDEVICE_HEADER DeviceHeader;
+
+
+    DeviceHeader = (PKSIDEVICE_HEADER)CONTAINING_RECORD(Device, KSIDEVICE_HEADER, KsDevice);
 
     /* get device interface*/
     KsDevice = (IKsDevice*)&DeviceHeader->lpVtblIKsDevice;
index b1e74cd..cd0ffe2 100644 (file)
@@ -18,7 +18,7 @@ KspSetDeviceInterfacesState(
         /* set device interface state */
         Status = IoSetDeviceInterfaceState(&SymEntry->SymbolicLink, Enable);
 
-        DPRINT("KspSetDeviceInterfacesState SymbolicLink %S Status %lx\n", SymEntry->SymbolicLink.Buffer, Status, Enable);
+        DPRINT("KspSetDeviceInterfacesState SymbolicLink '%S' Status %lx\n", SymEntry->SymbolicLink.Buffer, Status, Enable);
 
         /* check for success */
         if (!NT_SUCCESS(Status))
index f6ace30..409977d 100644 (file)
@@ -37,11 +37,12 @@ NTAPI
 KsGetDevice(
     IN PVOID Object)
 {
-    PKSBASIC_HEADER BasicHeader = (PKSBASIC_HEADER)(ULONG_PTR)Object - sizeof(KSBASIC_HEADER);
+    PKSBASIC_HEADER BasicHeader = (PKSBASIC_HEADER)((ULONG_PTR)Object - sizeof(KSBASIC_HEADER));
 
-    DPRINT("KsGetDevice %p\n", Object);
+    DPRINT("KsGetDevice %p BasicHeader %p Type %x\n", Object, BasicHeader, BasicHeader->Type);
 
     ASSERT(BasicHeader->Type == KsObjectTypeFilterFactory || BasicHeader->Type == KsObjectTypeFilter || BasicHeader->Type == BasicHeader->Type);
+    ASSERT(BasicHeader->KsDevice);
 
     return BasicHeader->KsDevice;
 }
index 7a8e5b2..1341f53 100644 (file)
@@ -21,6 +21,7 @@ typedef struct
 
     PKSIOBJECT_HEADER ObjectHeader;
     KSTOPOLOGY Topology;
+    KSPIN_DESCRIPTOR_EX * PinDescriptorsEx;
     KSPIN_DESCRIPTOR * PinDescriptors;
     ULONG PinDescriptorCount;
     PKSFILTERFACTORY Factory;
@@ -695,7 +696,6 @@ KspPinPropertyHandler(
             UNIMPLEMENTED
             Status = STATUS_UNSUCCESSFUL;
     }
-
     return Status;
 }
 
@@ -736,6 +736,7 @@ IKsFilter_DispatchDeviceIoControl(
     }
 
     /* call property handler supported by ks */
+    KSPROPERTY_ITEM_IRP_STORAGE(Irp) = (KSPROPERTY_ITEM*)This;
     Status = KspPropertyHandler(Irp, 2, FilterPropertySet, NULL, sizeof(KSPROPERTY_ITEM));
 
     if (Status == STATUS_NOT_FOUND)
@@ -785,41 +786,12 @@ IKsFilter_CreateDescriptors(
     ULONG Index = 0;
 
     /* initialize pin descriptors */
-    if (FilterDescriptor->PinDescriptorsCount)
-    {
-        /* allocate pin instance count array */
-        This->PinInstanceCount = AllocateItem(NonPagedPool, sizeof(ULONG) * FilterDescriptor->PinDescriptorsCount);
-        if(!This->PinDescriptors)
-        {
-            return STATUS_INSUFFICIENT_RESOURCES;
-        }
-
-        /* allocate first pin array */
-        This->FirstPin = AllocateItem(NonPagedPool, sizeof(PKSPIN) * FilterDescriptor->PinDescriptorsCount);
-        if(!This->FirstPin)
-        {
-            FreeItem(This->PinDescriptors);
-            return STATUS_INSUFFICIENT_RESOURCES;
-        }
-
-
-        /* allocate pin descriptor array */
-        This->PinDescriptors = AllocateItem(NonPagedPool, sizeof(KSPIN_DESCRIPTOR) * FilterDescriptor->PinDescriptorsCount);
-        if(!This->PinDescriptors)
-        {
-            FreeItem(This->PinInstanceCount);
-            return STATUS_INSUFFICIENT_RESOURCES;
-        }
-
-        /* set pin count */
-        This->PinDescriptorCount = FilterDescriptor->PinDescriptorsCount;
-        /* now copy those pin descriptors over */
-        for(Index = 0; Index < FilterDescriptor->PinDescriptorsCount; Index++)
-        {
-            /* copy one pin per time */
-            RtlMoveMemory(&This->PinDescriptors[Index], &FilterDescriptor->PinDescriptors[Index].PinDescriptor, sizeof(KSPIN_DESCRIPTOR));
-        }
-    }
+    This->PinInstanceCount = NULL;
+    This->FirstPin = NULL;
+    This->PinInstanceCount = NULL;
+    This->PinDescriptors = NULL;
+    This->PinDescriptorsEx = NULL;
+    This->PinDescriptorCount = 0;
 
     /* initialize topology descriptor */
     This->Topology.CategoriesCount = FilterDescriptor->CategoriesCount;
@@ -828,30 +800,45 @@ IKsFilter_CreateDescriptors(
     This->Topology.TopologyConnectionsCount = FilterDescriptor->ConnectionsCount;
     This->Topology.TopologyConnections = FilterDescriptor->Connections;
 
-    if (This->Topology.TopologyNodesCount > 0)
+    if (FilterDescriptor->NodeDescriptorsCount)
     {
-        This->Topology.TopologyNodes = AllocateItem(NonPagedPool, sizeof(GUID) * This->Topology.TopologyNodesCount);
+        /* sanity check */
+        ASSERT(FilterDescriptor->NodeDescriptors);
+
+        /* FIXME handle variable sized node descriptors */
+        ASSERT(FilterDescriptor->NodeDescriptorSize == sizeof(KSNODE_DESCRIPTOR));
+
+        This->Topology.TopologyNodes = AllocateItem(NonPagedPool, sizeof(GUID) * FilterDescriptor->NodeDescriptorsCount);
         /* allocate topology node types array */
         if (!This->Topology.TopologyNodes)
+        {
+            DPRINT("IKsFilter_CreateDescriptors OutOfMemory TopologyNodesCount %lu\n", FilterDescriptor->NodeDescriptorsCount);
             return STATUS_INSUFFICIENT_RESOURCES;
+        }
 
-        This->Topology.TopologyNodesNames = AllocateItem(NonPagedPool, sizeof(GUID) * This->Topology.TopologyNodesCount);
+        This->Topology.TopologyNodesNames = AllocateItem(NonPagedPool, sizeof(GUID) * FilterDescriptor->NodeDescriptorsCount);
         /* allocate topology names array */
         if (!This->Topology.TopologyNodesNames)
         {
             FreeItem((PVOID)This->Topology.TopologyNodes);
+            DPRINT("IKsFilter_CreateDescriptors OutOfMemory TopologyNodesCount %lu\n", FilterDescriptor->NodeDescriptorsCount);
             return STATUS_INSUFFICIENT_RESOURCES;
         }
 
-        for(Index = 0; Index < This->Topology.TopologyNodesCount; Index++)
+        DPRINT("NodeDescriptorCount %lu\n", FilterDescriptor->NodeDescriptorsCount);
+        for(Index = 0; Index < FilterDescriptor->NodeDescriptorsCount; Index++)
         {
+            DPRINT("Index %lu Type %p Name %p\n", Index, FilterDescriptor->NodeDescriptors[Index].Type, FilterDescriptor->NodeDescriptors[Index].Name);
+
             /* copy topology type */
-            RtlMoveMemory((PVOID)&This->Topology.TopologyNodes[Index], FilterDescriptor->NodeDescriptors[Index].Type, sizeof(GUID));
+            if (FilterDescriptor->NodeDescriptors[Index].Type)
+                RtlMoveMemory((PVOID)&This->Topology.TopologyNodes[Index], FilterDescriptor->NodeDescriptors[Index].Type, sizeof(GUID));
+
             /* copy topology name */
-            RtlMoveMemory((PVOID)&This->Topology.TopologyNodesNames[Index], FilterDescriptor->NodeDescriptors[Index].Name, sizeof(GUID));
+            if (FilterDescriptor->NodeDescriptors[Index].Name)
+                RtlMoveMemory((PVOID)&This->Topology.TopologyNodesNames[Index], FilterDescriptor->NodeDescriptors[Index].Name, sizeof(GUID));
         }
     }
-
     /* done! */
     return STATUS_SUCCESS;
 }
@@ -861,72 +848,24 @@ IKsFilter_CopyFilterDescriptor(
     IKsFilterImpl * This,
     const KSFILTER_DESCRIPTOR* FilterDescriptor)
 {
-    This->Filter.Descriptor = (const KSFILTER_DESCRIPTOR*)AllocateItem(NonPagedPool, sizeof(KSFILTER_DESCRIPTOR));
+    NTSTATUS Status;
+
+    This->Filter.Descriptor = AllocateItem(NonPagedPool, sizeof(KSFILTER_DESCRIPTOR));
     if (!This->Filter.Descriptor)
         return STATUS_INSUFFICIENT_RESOURCES;
 
-    /* copy all fields */
-    RtlMoveMemory((PVOID)This->Filter.Descriptor, FilterDescriptor, sizeof(KSFILTER_DESCRIPTOR));
-
-
-    /* perform deep copy of pin descriptors */
-    if (FilterDescriptor->PinDescriptorsCount)
-    {
-        KSPIN_DESCRIPTOR_EX * PinDescriptors = (KSPIN_DESCRIPTOR_EX *)AllocateItem(NonPagedPool, FilterDescriptor->PinDescriptorSize * FilterDescriptor->PinDescriptorsCount);
-
-
-        if (!PinDescriptors)
-        {
-            FreeItem((PVOID)This->Filter.Descriptor);
-            return STATUS_INSUFFICIENT_RESOURCES;
-        }
-        RtlMoveMemory((PVOID)PinDescriptors, FilterDescriptor->PinDescriptors, FilterDescriptor->PinDescriptorSize * FilterDescriptor->PinDescriptorsCount);
-
-        /* brain-dead gcc hack */
-        RtlMoveMemory((PVOID)&This->Filter.Descriptor->PinDescriptors, PinDescriptors, sizeof(PKSPIN_DESCRIPTOR_EX));
-
-    }
-
-    /* perform deep copy of node descriptors */
-    if (FilterDescriptor->NodeDescriptorsCount)
+    Status = KsAddItemToObjectBag(This->Filter.Bag, (PVOID)This->Filter.Descriptor, NULL);
+    if (!NT_SUCCESS(Status))
     {
-        KSNODE_DESCRIPTOR* NodeDescriptor = AllocateItem(NonPagedPool, FilterDescriptor->NodeDescriptorsCount * FilterDescriptor->NodeDescriptorSize);
-        if (!NodeDescriptor)
-        {
-            if (This->Filter.Descriptor->PinDescriptors)
-                FreeItem((PVOID)This->Filter.Descriptor->PinDescriptors);
-            FreeItem((PVOID)This->Filter.Descriptor);
-            return STATUS_INSUFFICIENT_RESOURCES;
-        }
-        RtlMoveMemory((PVOID)NodeDescriptor, FilterDescriptor->NodeDescriptors, FilterDescriptor->NodeDescriptorsCount * FilterDescriptor->NodeDescriptorSize);
-
-        /* brain-dead gcc hack */
-        RtlMoveMemory((PVOID)&This->Filter.Descriptor->NodeDescriptors, NodeDescriptor, sizeof(PKSNODE_DESCRIPTOR));
+        FreeItem((PVOID)This->Filter.Descriptor);
+        This->Filter.Descriptor = NULL;
+        return STATUS_INSUFFICIENT_RESOURCES;
     }
 
-    /* perform deep copy of connections descriptors */
-    if (FilterDescriptor->NodeDescriptorsCount)
-    {
-        KSTOPOLOGY_CONNECTION* Connections = AllocateItem(NonPagedPool, sizeof(KSTOPOLOGY_CONNECTION) * FilterDescriptor->ConnectionsCount);
-        if (!Connections)
-        {
-            if (This->Filter.Descriptor->PinDescriptors)
-                FreeItem((PVOID)This->Filter.Descriptor->PinDescriptors);
-
-            if (This->Filter.Descriptor->NodeDescriptors)
-                FreeItem((PVOID)This->Filter.Descriptor->PinDescriptors);
-
-            FreeItem((PVOID)This->Filter.Descriptor);
-            return STATUS_INSUFFICIENT_RESOURCES;
-        }
-
-        RtlMoveMemory((PVOID)Connections, FilterDescriptor->Connections, sizeof(KSTOPOLOGY_CONNECTION) * FilterDescriptor->ConnectionsCount);
-
-        /* brain-dead gcc hack */
-        RtlMoveMemory((PVOID)&This->Filter.Descriptor->Connections, Connections, sizeof(PKSTOPOLOGY_CONNECTION));
-    }
+    /* copy filter descriptor fields */
+    RtlMoveMemory((PVOID)This->Filter.Descriptor, FilterDescriptor, sizeof(KSFILTER_DESCRIPTOR));
 
-    return STATUS_SUCCESS;
+    return Status;
 }
 
 
@@ -1118,37 +1057,47 @@ KspCreateFilter(
     }
 
     /* allocate filter instance */
-    This = AllocateItem(NonPagedPool, sizeof(IKsFilterFactory));
+    This = AllocateItem(NonPagedPool, sizeof(IKsFilterImpl));
     if (!This)
+    {
+        DPRINT("KspCreateFilter OutOfMemory\n");
         return STATUS_INSUFFICIENT_RESOURCES;
+    }
+
+    /* initialize object bag */
+    This->Filter.Bag = AllocateItem(NonPagedPool, sizeof(KSIOBJECT_BAG));
+    if (!This->Filter.Bag)
+    {
+        /* no memory */
+        FreeItem(This);
+        DPRINT("KspCreateFilter OutOfMemory\n");
+        return STATUS_INSUFFICIENT_RESOURCES;
+    }
+    KsDevice = (IKsDevice*)&DeviceExtension->DeviceHeader->lpVtblIKsDevice;
+    KsDevice->lpVtbl->InitializeObjectBag(KsDevice, (PKSIOBJECT_BAG)This->Filter.Bag, NULL);
 
     /* copy filter descriptor */
     Status = IKsFilter_CopyFilterDescriptor(This, Factory->FilterDescriptor);
     if (!NT_SUCCESS(Status))
     {
         /* not enough memory */
+        FreeItem(This->Filter.Bag);
         FreeItem(This);
+        DPRINT("KspCreateFilter IKsFilter_CopyFilterDescriptor failed %lx\n", Status);
         return STATUS_INSUFFICIENT_RESOURCES;
     }
 
     /* get current irp stack */
     IoStack = IoGetCurrentIrpStackLocation(Irp);
 
-    /* initialize object bag */
-    This->Filter.Bag = AllocateItem(NonPagedPool, sizeof(KSIOBJECT_BAG));
-    if (!This->Filter.Bag)
-    {
-        /* no memory */
-        FreeItem(This);
-        return STATUS_INSUFFICIENT_RESOURCES;
-    }
-
     /* allocate create items */
     CreateItem = AllocateItem(NonPagedPool, sizeof(KSOBJECT_CREATE_ITEM) * 2);
     if (!CreateItem)
     {
         /* no memory */
+        FreeItem(This->Filter.Bag);
         FreeItem(This);
+        DPRINT("KspCreateFilter OutOfMemory\n");
         return STATUS_INSUFFICIENT_RESOURCES;
     }
 
@@ -1164,9 +1113,6 @@ KspCreateFilter(
     RtlInitUnicodeString(&CreateItem[1].ObjectClass, KSSTRING_TopologyNode);
 
 
-    KsDevice = (IKsDevice*)&DeviceExtension->DeviceHeader->lpVtblIKsDevice;
-    KsDevice->lpVtbl->InitializeObjectBag(KsDevice, (PKSIOBJECT_BAG)This->Filter.Bag, NULL);
-
     /* initialize filter instance */
     This->ref = 1;
     This->lpVtbl = &vt_IKsFilter;
@@ -1192,6 +1138,7 @@ KspCreateFilter(
         /* what can go wrong, goes wrong */
         FreeItem(This);
         FreeItem(CreateItem);
+        DPRINT("IKsFilter_CreateDescriptors failed with %lx\n", Status);
         return Status;
     }
 
@@ -1202,6 +1149,8 @@ KspCreateFilter(
         if (Factory->FilterDescriptor->Dispatch->Create)
         {
             /* now let driver initialize the filter instance */
+            DPRINT("Before instantiating filter Filter %p This %p KSBASIC_HEADER %u\n", &This->Filter, This, sizeof(KSBASIC_HEADER));
+            ASSERT(This->Header.KsDevice);
             Status = Factory->FilterDescriptor->Dispatch->Create(&This->Filter, Irp);
 
             if (!NT_SUCCESS(Status) && Status != STATUS_PENDING)
@@ -1236,6 +1185,7 @@ KspCreateFilter(
     IKsFilter_AttachFilterToFilterFactory(This, This->Header.Parent.KsFilterFactory);
 
     /* completed initialization */
+    DPRINT("KspCreateFilter done %lx\n", Status);
     return Status;
 }
 
@@ -1355,77 +1305,57 @@ KsFilterCreatePinFactory (
     OUT PULONG PinID)
 {
     ULONG Count;
-    ULONG *PinInstanceCount;
-    KSPIN_DESCRIPTOR_EX * PinDescriptorsEx;
-    KSPIN_DESCRIPTOR * PinDescriptors;
-    PKSPIN *FirstPin;
+    NTSTATUS Status;
     IKsFilterImpl * This = (IKsFilterImpl*)CONTAINING_RECORD(Filter, IKsFilterImpl, Filter);
 
-    /* calculate existing count */
+    DPRINT("KsFilterCreatePinFactory\n");
+
+    /* calculate new count */
     Count = This->PinDescriptorCount + 1;
 
-    /* allocate pin descriptors array */
-    PinDescriptorsEx = AllocateItem(NonPagedPool, max(This->Filter.Descriptor->PinDescriptorSize, sizeof(KSPIN_DESCRIPTOR_EX)) * Count);
-    if (!PinDescriptorsEx)
-        return STATUS_INSUFFICIENT_RESOURCES;
+    /* sanity check */
+    ASSERT(This->Filter.Descriptor->PinDescriptorSize == sizeof(KSPIN_DESCRIPTOR_EX));
 
-    /* allocate pin instance count array */
-    PinInstanceCount = AllocateItem(NonPagedPool, sizeof(ULONG) * Count);
-    if (!PinInstanceCount)
+    /* allocate pin descriptors ex array */
+    Status = _KsEdit(This->Filter.Bag, (PVOID*)&This->PinDescriptorsEx, Count * sizeof(KSPIN_DESCRIPTOR_EX), This->PinDescriptorCount * sizeof(KSPIN_DESCRIPTOR_EX), 0);
+    if (!NT_SUCCESS(Status))
     {
-        /* not enough memory */
-        FreeItem(PinDescriptorsEx);
-        return STATUS_INSUFFICIENT_RESOURCES;
+        /* failed */
+        DPRINT("KsFilterCreatePinFactory _KsEdit failed with %lx\n", Status);
+        return Status;
     }
 
-    /* allocate pin descriptor array for pin property handling */
-    PinDescriptors = AllocateItem(NonPagedPool, sizeof(KSPIN_DESCRIPTOR) * Count);
-    if (!PinDescriptors)
+    /* allocate pin descriptors array */
+    Status = _KsEdit(This->Filter.Bag, (PVOID*)&This->PinDescriptors, Count * sizeof(KSPIN_DESCRIPTOR), This->PinDescriptorCount * sizeof(KSPIN_DESCRIPTOR), 0);
+    if (!NT_SUCCESS(Status))
     {
-        /* not enough memory */
-        FreeItem(PinDescriptorsEx);
-        FreeItem(PinInstanceCount);
-        return STATUS_INSUFFICIENT_RESOURCES;
+        /* failed */
+        DPRINT("KsFilterCreatePinFactory _KsEdit failed with %lx\n", Status);
+        return Status;
     }
 
-    /* allocate first pin array */
-    FirstPin = AllocateItem(NonPagedPool, sizeof(PKSPIN) * Count);
-    if (!FirstPin)
+
+    /* allocate pin instance count array */
+    Status = _KsEdit(This->Filter.Bag,(PVOID*)&This->PinInstanceCount, sizeof(ULONG) * Count, sizeof(ULONG) * This->PinDescriptorCount, 0);
+    if (!NT_SUCCESS(Status))
     {
-        /* not enough memory */
-        FreeItem(PinDescriptorsEx);
-        FreeItem(PinInstanceCount);
-        FreeItem(PinDescriptors);
-        return STATUS_INSUFFICIENT_RESOURCES;
+        /* failed */
+        DPRINT("KsFilterCreatePinFactory _KsEdit failed with %lx\n", Status);
+        return Status;
     }
 
-    /* now copy all fields */
-    if (Count > 1)
+    /* allocate first pin array */
+    Status = _KsEdit(This->Filter.Bag,(PVOID*)&This->FirstPin, sizeof(PKSPIN) * Count, sizeof(PKSPIN) * This->PinDescriptorCount, 0);
+    if (!NT_SUCCESS(Status))
     {
-        /* copy old descriptors */
-        RtlMoveMemory(PinDescriptorsEx, This->Filter.Descriptor->PinDescriptors, max(This->Filter.Descriptor->PinDescriptorSize, sizeof(KSPIN_DESCRIPTOR_EX)) * This->PinDescriptorCount);
-        RtlMoveMemory(PinInstanceCount, This->PinInstanceCount, This->PinDescriptorCount * sizeof(ULONG));
-        RtlMoveMemory(PinDescriptors, This->PinDescriptors, sizeof(KSPIN_DESCRIPTOR) * This->PinDescriptorCount);
-        RtlMoveMemory(FirstPin, This->FirstPin, sizeof(PKSPIN) * This->PinDescriptorCount);
-
-        /* now free old descriptors */
-        FreeItem(This->PinInstanceCount);
-        FreeItem((PVOID)This->Filter.Descriptor->PinDescriptors);
-        FreeItem(This->PinDescriptors);
-        FreeItem(This->FirstPin);
+        /* failed */
+        DPRINT("KsFilterCreatePinFactory _KsEdit failed with %lx\n", Status);
+        return Status;
     }
 
     /* add new pin factory */
-    RtlMoveMemory((PVOID)((ULONG_PTR)PinDescriptorsEx + max(This->Filter.Descriptor->PinDescriptorSize, sizeof(KSPIN_DESCRIPTOR_EX)) * This->PinDescriptorCount), InPinDescriptor, sizeof(KSPIN_DESCRIPTOR));
-    RtlMoveMemory((PVOID)(PinDescriptors + This->PinDescriptorCount), &InPinDescriptor->PinDescriptor, sizeof(KSPIN_DESCRIPTOR));
-
-    /* replace old descriptor by using a gcc-compliant hack */
-    RtlMoveMemory((PVOID)&This->Filter.Descriptor->PinDescriptors, PinDescriptorsEx, sizeof(KSPIN_DESCRIPTOR_EX*));
-    RtlMoveMemory((PVOID)&This->Filter.Descriptor->PinDescriptorsCount, &Count, sizeof(ULONG));
-
-    This->PinDescriptors = PinDescriptors;
-    This->PinInstanceCount = PinInstanceCount;
-    This->FirstPin = FirstPin;
+    RtlMoveMemory(&This->PinDescriptorsEx[This->PinDescriptorCount], InPinDescriptor, sizeof(KSPIN_DESCRIPTOR_EX));
+    RtlMoveMemory(&This->PinDescriptors[This->PinDescriptorCount], &InPinDescriptor->PinDescriptor, sizeof(KSPIN_DESCRIPTOR));
 
     /* store new pin id */
     *PinID = This->PinDescriptorCount;
@@ -1433,6 +1363,8 @@ KsFilterCreatePinFactory (
     /* increment pin descriptor count */
     This->PinDescriptorCount++;
 
+
+    DPRINT("KsFilterCreatePinFactory done\n");
     return STATUS_SUCCESS;
 
 }
index dc48f3c..a16b290 100644 (file)
@@ -41,6 +41,7 @@ IKsFilterFactory_Create(
     IN PIRP Irp)
 {
     PKSOBJECT_CREATE_ITEM CreateItem;
+    IKsFilterFactoryImpl * Factory;
     IKsFilterFactory * iface;
     NTSTATUS Status;
 
@@ -53,7 +54,10 @@ IKsFilterFactory_Create(
     }
 
     /* get filter factory interface */
-    iface = (IKsFilterFactory*)CONTAINING_RECORD(CreateItem->Context, IKsFilterFactoryImpl, FilterFactory);
+    Factory = (IKsFilterFactoryImpl*)CONTAINING_RECORD(CreateItem->Context, IKsFilterFactoryImpl, FilterFactory);
+
+    /* get interface */
+    iface = (IKsFilterFactory*)&Factory->lpVtbl;
 
     /* create a filter instance */
     Status = KspCreateFilter(DeviceObject, Irp, iface);
@@ -253,6 +257,8 @@ IKsFilterFactory_fnInitialize(
         FreeString = TRUE;
     }
 
+    DPRINT("IKsFilterFactory_fnInitialize CategoriesCount %u ReferenceString '%S'\n", Descriptor->CategoriesCount,ReferenceString.Buffer);
+
     /* now register the device interface */
     Status = KspRegisterDeviceInterfaces(DeviceExtension->DeviceHeader->KsDevice.PhysicalDeviceObject,
                                          Descriptor->CategoriesCount,
@@ -365,6 +371,10 @@ KspCreateFilterFactory(
     }
 
     /* return result */
+    DPRINT("KsCreateFilterFactory %x\n", Status);
+    /* sanity check */
+    ASSERT(Status == STATUS_SUCCESS);
+
     return Status;
 }
 
index 431fb26..3b4e0b8 100644 (file)
@@ -339,6 +339,7 @@ KsPinAttemptProcessing(
     IN PKSPIN  Pin,
     IN BOOLEAN  Asynchronous)
 {
+    DPRINT("KsPinAttemptProcessing\n");
     UNIMPLEMENTED
 }
 
@@ -456,6 +457,7 @@ NTAPI
     OUT PIKSREFERENCECLOCK*  Interface)
 {
     UNIMPLEMENTED
+    DPRINT("KsPinGetReferenceClockInterface Pin %p Interface %p\n", Pin, Interface);
     return STATUS_UNSUCCESSFUL;
 }
 
@@ -547,6 +549,8 @@ KsGetPinFromIrp(
     PKSIOBJECT_HEADER ObjectHeader;
     PIO_STACK_LOCATION IoStack = IoGetCurrentIrpStackLocation(Irp);
 
+    DPRINT("KsGetPinFromIrp\n");
+
     /* get object header */
     ObjectHeader = (PKSIOBJECT_HEADER)IoStack->FileObject->FsContext2;
     /* return object type */
@@ -624,6 +628,7 @@ KsPinGetLeadingEdgeStreamPointer(
     IN KSSTREAM_POINTER_STATE State)
 {
     UNIMPLEMENTED
+    DPRINT("KsPinGetLeadingEdgeStreamPointer Pin %p State %x\n", Pin, State);
     return NULL;
 }
 
@@ -679,6 +684,7 @@ KsStreamPointerUnlock(
     IN BOOLEAN Eject)
 {
     UNIMPLEMENTED
+    DPRINT("KsStreamPointerUnlock\n");
 }
 
 /*
@@ -693,6 +699,8 @@ KsStreamPointerAdvanceOffsetsAndUnlock(
     IN ULONG OutUsed,
     IN BOOLEAN Eject)
 {
+    DPRINT("KsStreamPointerAdvanceOffsets\n");
+
     UNIMPLEMENTED
 }
 
@@ -709,6 +717,8 @@ KsStreamPointerDelete(
     PKSISTREAM_POINTER Cur, Last;
     PKSISTREAM_POINTER Pointer = (PKSISTREAM_POINTER)StreamPointer;
 
+    DPRINT("KsStreamPointerDelete\n");
+
     This = (IKsPinImpl*)CONTAINING_RECORD(Pointer->StreamPointer.Pin, IKsPinImpl, Pin);
 
     /* point to first stream pointer */
@@ -755,6 +765,7 @@ KsStreamPointerClone(
     OUT PKSSTREAM_POINTER* CloneStreamPointer)
 {
     UNIMPLEMENTED
+    DPRINT("KsStreamPointerClone\n");
     return STATUS_NOT_IMPLEMENTED;
 }
 
@@ -864,7 +875,11 @@ NTAPI
 KsPinGetFirstCloneStreamPointer(
     IN PKSPIN Pin)
 {
-    IKsPinImpl * This = (IKsPinImpl*)CONTAINING_RECORD(Pin, IKsPinImpl, Pin);
+    IKsPinImpl * This;
+
+    DPRINT("KsPinGetFirstCloneStreamPointer %p\n", Pin);
+
+    This = (IKsPinImpl*)CONTAINING_RECORD(Pin, IKsPinImpl, Pin);
     /* return first cloned stream pointer */
     return &This->ClonedStreamPointer->StreamPointer;
 }
@@ -880,6 +895,8 @@ KsStreamPointerGetNextClone(
 {
     PKSISTREAM_POINTER Pointer = (PKSISTREAM_POINTER)StreamPointer;
 
+    DPRINT("KsStreamPointerGetNextClone\n");
+
     /* is there a another cloned stream pointer */
     if (!Pointer->Next)
         return NULL;