/* Clears out all files from the Fv buffer in memory */
EFI_STATUS FvBufGetSize(IN VOID *Fv, OUT UINTN *Size)
/* Clears out all files from the Fv buffer in memory */
EFI_STATUS FvBufGetSize(IN VOID *Fv, OUT UINTN *Size)
{
  EFI_FIRMWARE_VOLUME_HEADER *hdr = (EFI_FIRMWARE_VOLUME_HEADER*)Fv;
  EFI_FV_BLOCK_MAP_ENTRY *blk = hdr->BlockMap;
  *Size = 0;
  while (blk->Length != 0 || blk->NumBlocks != 0) {
    *Size = *Size + (blk->Length * blk->NumBlocks);
    if (*Size >= 0x40000000) {
      return EFI_VOLUME_CORRUPTED;
    }
    blk++;
  }
  if (*Size == 0) {
    return EFI_VOLUME_CORRUPTED;
  }
  return EFI_SUCCESS;
}