Perfect gerund
The perfect gerund refers to a time before that of the verb in the main clause. However, it is only used if the time of the action expressed by the gerund is not obvious from the context:
He denied being married. (the simple gerund being refers to the same time as denied: He denied that he was married.)
He denied having been married. (the perfect gerund having been refers to a time before denied: He denied that he had been married.)
If it is clear that an earlier time is meant, we use the simple gerund:
He denied stealing the car. (He denied that he had stolen the car.)
Passive gerunds
Passive forms are also possible:
I hate being lied to. (passive simple gerund: I hate it when people lie to me.)
He complained of having been unjustly accused. (passive perfect gerund: He complained that they had unjustly accused him.)