+ // allocate topology descriptor
+ Descriptor->Topology = (PKSTOPOLOGY)AllocateItem(NonPagedPool, sizeof(KSTOPOLOGY), TAG_PORTCLASS);
+ if (!Descriptor->Topology)
+ goto cleanup;
+
+ // are there any connections
+ if (FilterDescription->ConnectionCount)
+ {
+ // allocate connection descriptor
+ Descriptor->Topology->TopologyConnections = (PKSTOPOLOGY_CONNECTION)AllocateItem(NonPagedPool, sizeof(KSTOPOLOGY_CONNECTION) * FilterDescription->ConnectionCount, TAG_PORTCLASS);
+ if (!Descriptor->Topology->TopologyConnections)
+ goto cleanup;
+
+ // copy connection descriptor
+ RtlMoveMemory((PVOID)Descriptor->Topology->TopologyConnections, FilterDescription->Connections, FilterDescription->ConnectionCount * sizeof(PCCONNECTION_DESCRIPTOR));
+
+ // store connection count
+ Descriptor->Topology->TopologyConnectionsCount = FilterDescription->ConnectionCount;
+ }
+
+ // does the filter have nodes
+ if (FilterDescription->NodeCount)
+ {
+ // allocate topology node types array
+ Descriptor->Topology->TopologyNodes = (const GUID *)AllocateItem(NonPagedPool, sizeof(GUID) * FilterDescription->NodeCount, TAG_PORTCLASS);
+ if (!Descriptor->Topology->TopologyNodes)
+ goto cleanup;
+
+ // allocate topology node names array
+ Descriptor->Topology->TopologyNodesNames = (const GUID *)AllocateItem(NonPagedPool, sizeof(GUID) * FilterDescription->NodeCount, TAG_PORTCLASS);
+ if (!Descriptor->Topology->TopologyNodesNames)
+ goto cleanup;
+
+ // grab first entry
+ NodeDescriptor = (PPCNODE_DESCRIPTOR)FilterDescription->Nodes;
+
+ // iterate all nodes and copy node types / names and node properties
+ for(Index = 0; Index < FilterDescription->NodeCount; Index++)
+ {
+ // does it have a type
+ if (NodeDescriptor->Type)
+ {
+ // copy node type
+ RtlMoveMemory((PVOID)&Descriptor->Topology->TopologyNodes[Index], NodeDescriptor->Type, sizeof(GUID));
+ }
+
+ // does it have a node name
+ if (NodeDescriptor->Name)
+ {
+ // copy node name
+ RtlMoveMemory((PVOID)&Descriptor->Topology->TopologyNodesNames[Index], NodeDescriptor->Name, sizeof(GUID));
+ }
+
+ // check if has an automation table
+ if (NodeDescriptor->AutomationTable)
+ {
+ // grab first entry
+ PropertyItem = (PPCPROPERTY_ITEM)NodeDescriptor->AutomationTable->Properties;
+
+ // copy all node properties into the global property set
+ for(SubIndex = 0; SubIndex < NodeDescriptor->AutomationTable->PropertyCount; SubIndex++)
+ {
+ // add to property set
+ Status = PcAddToPropertyTable(Descriptor, PropertyItem, TRUE);
+
+ // check for success
+ if (Status != STATUS_SUCCESS)
+ {
+ // failed
+ goto cleanup;
+ }
+
+ // move to next property item
+ PropertyItem = (PPCPROPERTY_ITEM)((ULONG_PTR)PropertyItem + NodeDescriptor->AutomationTable->PropertyItemSize);
+ }
+ }
+
+ // move to next descriptor
+ NodeDescriptor = (PPCNODE_DESCRIPTOR)((ULONG_PTR)NodeDescriptor + FilterDescription->NodeSize);
+ }
+
+ // now store the topology node count
+ Descriptor->Topology->TopologyNodesCount = FilterDescription->NodeCount;
+ }
+
+ // store descriptor