/* This routine is called to get boot option by OptionNumber. */
EFI_STATUS GetBootOptionByNumber(IN UINT16 Number, OUT EFI_BOOT_MANAGER_LOAD_OPTION **OptionBuf)
/* This routine is called to get boot option by OptionNumber. */
EFI_STATUS GetBootOptionByNumber(IN UINT16 Number, OUT EFI_BOOT_MANAGER_LOAD_OPTION **OptionBuf)
{
  EFI_STATUS                    Status;
  CHAR16                        BootOptionName[20];
  EFI_BOOT_MANAGER_LOAD_OPTION  BootOption;
  UnicodeSPrint (BootOptionName, sizeof (BootOptionName), L"Boot%04x", Number);
  ZeroMem (&BootOption, sizeof (EFI_BOOT_MANAGER_LOAD_OPTION));
  Status = EfiBootManagerVariableToLoadOption (BootOptionName, &BootOption);
  if (!EFI_ERROR (Status)) {
    *OptionBuf = AllocatePool (sizeof (EFI_BOOT_MANAGER_LOAD_OPTION));
    if (*OptionBuf != NULL) {
      CopyMem (*OptionBuf, &BootOption, sizeof (EFI_BOOT_MANAGER_LOAD_OPTION));
      Status = EFI_SUCCESS;
    } else {
      Status = EFI_OUT_OF_RESOURCES;
    }
  }
  return Status;
}