+ ULONG Key = 0;
+ ULONG Mask = 0;
+ PCONFIGURATION_COMPONENT_DATA Sibling;
+ PCONFIGURATION_COMPONENT_DATA ReturnEntry;
+
+ /* If we did get a key, then use it instead */
+ if (ComponentKey)
+ {
+ Key = *ComponentKey;
+ Mask = -1;
+ }
+
+ /* Loop the Components until we find a a match */
+ while (Child)
+ {
+ /* Check if we are starting somewhere already */
+ if (*NextLink)
+ {
+ /* If we've found the place where we started, clear and continue */
+ if (Child == *NextLink) *NextLink = NULL;
+ }
+ else
+ {
+ /* Try to get a match */
+ if (Child->Component.Class == Class &&
+ Child->Component.Type == Type &&
+ (Child->Component.Key & Mask) == Key)
+ {
+ /* Match found */
+ return Child;
+ }
+ }
+
+ /* Now we've also got to lookup the siblings */
+ Sibling = Child->Sibling;
+ while (Sibling)
+ {
+ /* Check if we are starting somewhere already */
+ if (*NextLink)
+ {
+ /* If we've found the place where we started, clear and continue */
+ if (Sibling == *NextLink) *NextLink = NULL;
+ }
+ else
+ {
+ /* Try to get a match */
+ if (Sibling->Component.Class == Class &&
+ Sibling->Component.Type == Type &&
+ (Sibling->Component.Key & Mask) == Key)
+ {
+ /* Match found */
+ return Sibling;
+ }
+ }
+
+ /* We've got to check if the Sibling has a Child as well */
+ if (Sibling->Child)
+ {
+ /* We're just going to call ourselves again */
+ if ((ReturnEntry = KeFindConfigurationNextEntry(Sibling->Child,
+ Class,
+ Type,
+ ComponentKey,
+ NextLink)))
+ {
+ return ReturnEntry;
+ }
+ }
+
+ /* Next Sibling */
+ Sibling = Sibling->Sibling;
+ }
+
+ /* Next Child */
+ Child = Child->Child;
+ }
+
+ /* If we got here, nothign was found */
+ return NULL;