/* Read an image into a buffer friom a source. */
EFI_STATUS HBufferImageRead(IN CONST CHAR16 *FileName, IN CONST CHAR16 *DiskName, IN UINTN DiskOffset, IN UINTN DiskSize, IN UINTN MemOffset, IN UINTN MemSize, IN EDIT_FILE_TYPE BufferType, IN BOOLEAN Recover)
/* Read an image into a buffer friom a source. */
EFI_STATUS HBufferImageRead(IN CONST CHAR16 *FileName, IN CONST CHAR16 *DiskName, IN UINTN DiskOffset, IN UINTN DiskSize, IN UINTN MemOffset, IN UINTN MemSize, IN EDIT_FILE_TYPE BufferType, IN BOOLEAN Recover)
{
  EFI_STATUS      Status;
  EDIT_FILE_TYPE  BufferTypeBackup;
  Status                  = EFI_SUCCESS;
  HBufferImage.BufferType = BufferType;
  BufferTypeBackup = HBufferImage.BufferType;
  switch (BufferType) {
    case FileTypeFileBuffer:
      Status = HFileImageRead (FileName, Recover);
      break;
    case FileTypeDiskBuffer:
      Status = HDiskImageRead (DiskName, DiskOffset, DiskSize, Recover);
      break;
    case FileTypeMemBuffer:
      Status = HMemImageRead (MemOffset, MemSize, Recover);
      break;
    default:
      Status = EFI_NOT_FOUND;
      break;
  }
  if (EFI_ERROR (Status)) {
    HBufferImage.BufferType = BufferTypeBackup;
  }
  return Status;
}