/* Read then Measure and log an EFI variable, and extend the measurement result into a specific RTMR. */
EFI_STATUS ReadAndMeasureVariable(IN UINT32 MrIndex, IN TCG_EVENTTYPE EventType, IN CHAR16 *VarName, IN EFI_GUID *VendorGuid, OUT UINTN *VarSize, OUT VOID **VarData)
/* Read then Measure and log an EFI variable, and extend the measurement result into a specific RTMR. */
EFI_STATUS ReadAndMeasureVariable(IN UINT32 MrIndex, IN TCG_EVENTTYPE EventType, IN CHAR16 *VarName, IN EFI_GUID *VendorGuid, OUT UINTN *VarSize, OUT VOID **VarData)
{
  EFI_STATUS  Status;
  Status = GetVariable2 (VarName, VendorGuid, VarData, VarSize);
  if (EventType == EV_EFI_VARIABLE_DRIVER_CONFIG) {
    if (EFI_ERROR (Status)) {
      *VarData = NULL;
      *VarSize = 0;
    }
  } else {
    if (EFI_ERROR (Status)) {
      return EFI_NOT_FOUND;
    }
  }
  Status = MeasureVariable (
             MrIndex,
             EventType,
             VarName,
             VendorGuid,
             *VarData,
             *VarSize
             );
  return Status;
}