/* Get variable name or data to output buffer. */
VOID GetVariableNameOrData(IN VARIABLE_STORE_INFO *StoreInfo, IN UINT8 *NameOrData, IN UINTN Size, OUT UINT8 *Buffer)
/* Get variable name or data to output buffer. */
VOID GetVariableNameOrData(IN VARIABLE_STORE_INFO *StoreInfo, IN UINT8 *NameOrData, IN UINTN Size, OUT UINT8 *Buffer)
{
  EFI_PHYSICAL_ADDRESS  TargetAddress;
  EFI_PHYSICAL_ADDRESS  SpareAddress;
  UINTN                 PartialSize;
  if (StoreInfo->FtwLastWriteData != NULL) {
    TargetAddress = StoreInfo->FtwLastWriteData->TargetAddress;
    SpareAddress  = StoreInfo->FtwLastWriteData->SpareAddress;
    if (((UINTN)NameOrData < (UINTN)TargetAddress) && (((UINTN)NameOrData + Size) > (UINTN)TargetAddress)) {
      PartialSize = (UINTN)TargetAddress - (UINTN)NameOrData;
      CopyMem (Buffer, NameOrData, PartialSize);
      CopyMem (Buffer + PartialSize, (UINT8 *)(UINTN)SpareAddress, Size - PartialSize);
      return;
    }
  }
  CopyMem (Buffer, NameOrData, Size);
}