Trad123-
Obviously, one who forms a covert contrary intention NOT to do what the Church does, does not intend to do what the Church does, even if he feigns having a proper intention by walking through a sacramental rite.
Herve references this in his commentary on Leo XIII regarding “wicked ministers,” which he surmises will be rare (see post #305 in the bolded font):
“For indeed, if there be any such, they are extremely rarely found, who have such malice that while they perform the sacrament with serious exterior, they internally withhold the intention; and in such a case, the truth of the opinion of Catharinus would profit little, since a minister as perverse as this could most likely secretly falsify the matter and form of the sacrament.”