/* This opens a file, reads it into memory and returns a memory file object. */
EFI_STATUS GetMemoryFile(IN CHAR8 *InputFileName, OUT EFI_HANDLE *OutputMemoryFile)
/* This opens a file, reads it into memory and returns a memory file object. */
EFI_STATUS GetMemoryFile(IN CHAR8 *InputFileName, OUT EFI_HANDLE *OutputMemoryFile)
{
  EFI_STATUS  Status;
  CHAR8       *InputFileImage;
  UINT32      BytesRead;
  MEMORY_FILE *NewMemoryFile;
  Status = GetFileImage (InputFileName, &InputFileImage, &BytesRead);
  if (EFI_ERROR (Status)) {
    return Status;
  }
  NewMemoryFile = malloc (sizeof (*NewMemoryFile));
  if (NewMemoryFile == NULL) {
    free (InputFileImage);
    return EFI_OUT_OF_RESOURCES;
  }
  NewMemoryFile->FileImage           = InputFileImage;
  NewMemoryFile->CurrentFilePointer  = InputFileImage;
  NewMemoryFile->Eof                 = InputFileImage + BytesRead;
  *OutputMemoryFile = (EFI_HANDLE)NewMemoryFile;
  CheckMemoryFileState (*OutputMemoryFile);
  return EFI_SUCCESS;
}