- for (;;) {\r
- if (ChildIsType (SourceStream, CurrentChildNode, SearchType, SectionDefinitionGuid)) {\r
- //\r
- // The type matches, so check the instance count to see if it's the one we want\r
- //\r
- (*SectionInstance)--;\r
- if (*SectionInstance == 0) {\r
- //\r
- // Got it!\r
- //\r
- *FoundChild = CurrentChildNode;\r
- *FoundStream = SourceStream;\r
- *AuthenticationStatus = SourceStream->AuthenticationStatus;\r
- return EFI_SUCCESS;\r
- }\r
- }\r
- \r
- if (CurrentChildNode->EncapsulatedStreamHandle != NULL_STREAM_HANDLE) {\r
- //\r
- // If the current node is an encapsulating node, recurse into it...\r
- //\r
- Status = FindChildNode (\r
- (CORE_SECTION_STREAM_NODE *)CurrentChildNode->EncapsulatedStreamHandle,\r
- SearchType,\r
- SectionInstance,\r
- SectionDefinitionGuid,\r
- &RecursedChildNode,\r
- &RecursedFoundStream,\r
- AuthenticationStatus\r
- );\r
- //\r
- // If the status is not EFI_SUCCESS, just save the error code and continue\r
- // to find the request child node in the rest stream.\r
- //\r
- if (*SectionInstance == 0) {\r
- ASSERT_EFI_ERROR (Status);\r
- *FoundChild = RecursedChildNode;\r
- *FoundStream = RecursedFoundStream;\r
- return EFI_SUCCESS;\r
- } else {\r
- ErrorStatus = Status;\r
- }\r
- }\r
- \r
- if (!IsNodeAtEnd (&SourceStream->Children, &CurrentChildNode->Link)) {\r
- //\r
- // We haven't found the child node we're interested in yet, but there's\r
- // still more nodes that have already been parsed so get the next one\r
- // and continue searching..\r
- //\r
- CurrentChildNode = CHILD_SECTION_NODE_FROM_LINK (GetNextNode (&SourceStream->Children, &CurrentChildNode->Link));\r
- } else {\r
- //\r
- // We've exhausted children that have already been parsed, so see if\r
- // there's any more data and continue parsing out more children if there\r
- // is.\r
- //\r
- NextChildOffset = CurrentChildNode->OffsetInStream + CurrentChildNode->Size;\r
- //\r
- // Round up to 4 byte boundary\r
- //\r
- NextChildOffset += 3;\r
- NextChildOffset &= ~(UINTN)3;\r
- if (NextChildOffset <= SourceStream->StreamLength - sizeof (EFI_COMMON_SECTION_HEADER)) {\r
- //\r
- // There's an unparsed child remaining in the stream, so create a new child node\r
- //\r
- Status = CreateChildNode (SourceStream, NextChildOffset, &CurrentChildNode);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- } else {\r
- ASSERT (EFI_ERROR (ErrorStatus));\r
- return ErrorStatus;\r
- }\r