/* If InputSection is NULL, then ASSERT(). If OutputBuffer is NULL, then ASSERT(). If ScratchBuffer is NULL and this decode operation requires a scratch buffer, then ASSERT(). If AuthenticationStatus is NULL, then ASSERT(). */
RETURN_STATUS EFIAPI ExtractGuidedSectionDecode(IN CONST VOID *InputSection, OUT VOID **OutputBuffer, IN VOID *ScratchBuffer OPTIONAL, OUT UINT32 *AuthenticationStatus)
/* If InputSection is NULL, then ASSERT(). If OutputBuffer is NULL, then ASSERT(). If ScratchBuffer is NULL and this decode operation requires a scratch buffer, then ASSERT(). If AuthenticationStatus is NULL, then ASSERT(). */
RETURN_STATUS EFIAPI ExtractGuidedSectionDecode(IN CONST VOID *InputSection, OUT VOID **OutputBuffer, IN VOID *ScratchBuffer OPTIONAL, OUT UINT32 *AuthenticationStatus)
{
  UINT32                                   Index;
  EFI_STATUS                               Status;
  PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO  *HandlerInfo;
  EFI_GUID                                 *SectionDefinitionGuid;
  ASSERT (InputSection != NULL);
  ASSERT (OutputBuffer != NULL);
  ASSERT (AuthenticationStatus != NULL);
  Status = PeiGetExtractGuidedSectionHandlerInfo (&HandlerInfo);
  if (EFI_ERROR (Status)) {
    return Status;
  }
  if (IS_SECTION2 (InputSection)) {
    SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *)InputSection)->SectionDefinitionGuid);
  } else {
    SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *)InputSection)->SectionDefinitionGuid);
  }
  ASSERT (HandlerInfo != NULL);
  for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index++) {
    if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, SectionDefinitionGuid)) {
      return HandlerInfo->ExtractDecodeHandlerTable[Index](
                                                           InputSection,
                                                           OutputBuffer,
                                                           ScratchBuffer,
                                                           AuthenticationStatus
                                                           );
    }
  }
  return RETURN_UNSUPPORTED;
}