/* This service is a checker handler for the UEFI Runtime Service SetVariable() */
EFI_STATUS EFIAPI SetVariableCheckHandlerMor(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, IN VOID *Data)
/* This service is a checker handler for the UEFI Runtime Service SetVariable() */
EFI_STATUS EFIAPI SetVariableCheckHandlerMor(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, IN VOID *Data)
{
  UINTN       MorLockDataSize;
  BOOLEAN     MorLock;
  EFI_STATUS  Status;
  if (!IsAnyMorVariable (VariableName, VendorGuid)) {
    return EFI_SUCCESS;
  }
  MorLockDataSize = sizeof (MorLock);
  Status          = InternalGetVariable (
                      MEMORY_OVERWRITE_REQUEST_CONTROL_LOCK_NAME,
                      &gEfiMemoryOverwriteRequestControlLockGuid,
                      NULL,
                      &MorLockDataSize,
                      &MorLock
                      );
  if (!EFI_ERROR (Status) && MorLock) {
    return EFI_INVALID_PARAMETER;
  }
  if ((DataSize != sizeof (UINT8)) || (Data == NULL) || (Attributes == 0)) {
    return EFI_INVALID_PARAMETER;
  }
  if (IsMorLockVariable (VariableName, VendorGuid)) {
    if ((*(UINT8 *)Data != 1) && (*(UINT8 *)Data != 0)) {
      return EFI_INVALID_PARAMETER;
    }
  }
  return EFI_SUCCESS;
}