/* This routine either returns all the payload of a EFI_FV_FILETYPE_RAW file, or finds the EFI_SECTION_RAW section within the file and returns its data. */
EFI_STATUS FvBufGetFileRawData(IN VOID *FfsFile, OUT VOID **RawData, OUT UINTN *RawDataSize)
/* This routine either returns all the payload of a EFI_FV_FILETYPE_RAW file, or finds the EFI_SECTION_RAW section within the file and returns its data. */
EFI_STATUS FvBufGetFileRawData(IN VOID *FfsFile, OUT VOID **RawData, OUT UINTN *RawDataSize)
{
  EFI_STATUS Status;
  EFI_FFS_FILE_HEADER* File;
  EFI_RAW_SECTION* Section;
  File = (EFI_FFS_FILE_HEADER*)FfsFile;
  if (File->Type == EFI_FV_FILETYPE_RAW) {
    *RawData = (VOID*)((UINT8 *)File + FvBufGetFfsHeaderSize (File));
    *RawDataSize = FvBufGetFfsFileSize (File) - FvBufGetFfsHeaderSize (File);
    return EFI_SUCCESS;
  }
  Status = FvBufFindSectionByType (File, EFI_SECTION_RAW, (VOID **)&Section);
  if (EFI_ERROR (Status)) {
    return Status;
  }
  *RawData = (VOID*)((UINT8 *)Section + FvBufGetSecHdrLen(Section));
  *RawDataSize =
    FvBufGetSecFileLen (Section) - FvBufGetSecHdrLen(Section);
  return EFI_SUCCESS;
}