/* Reads a file to a newly allocated buffer */
VOID* FileHandleReadToNewBuffer(IN EFI_FILE_HANDLE FileHandle, IN UINTN ReadSize)
/* Reads a file to a newly allocated buffer */
VOID* FileHandleReadToNewBuffer(IN EFI_FILE_HANDLE FileHandle, IN UINTN ReadSize)
{
  EFI_STATUS  Status;
  UINTN       ActualReadSize;
  VOID        *FileContents;
  ActualReadSize = ReadSize;
  FileContents   = AllocatePool (ReadSize);
  if (FileContents != NULL) {
    Status = FileHandleRead (
               FileHandle,
               &ReadSize,
               FileContents
               );
    if (EFI_ERROR (Status) || (ActualReadSize != ReadSize)) {
      FreePool (FileContents);
      return NULL;
    }
  }
  return FileContents;
}