In X-2: X-Men United, Xavier is being controlled by Jason's illusions and made to try to kill all the mutants. However, Jason is not affected by Xavier's attack. Being a mutant, shouldn't he have been since Charles carried out a global attack on the mutants? Is it because he was inside Cerebro with Charles? Does this also explain why Charles isn't affected by his own attack?
Cerebro is shielded, or more accurately, Cerebro is a focusing artifact and cannot target inside its self.
If I recall correctly, it is explicitly stated in the movie that, if you are inside the chamber, you are immune to the effects.
Operation-wise, Cerebro is a device that amplifies the brainwaves of the user. For a telepath, it gives the user ability to rapidly read the minds of individuals around the globe from which the user can identify mutants and / or humans. From the movie reference, it is clear that professor Xavier literally connects to the minds of individuals - ..can see their feelings, their hopes, their fears. And after connecting to them he can manipulate them as well, if required.
In X-2, William Stryker instructed his son Jason to make sure that Prof. X kills all the mutants using the Cerebro. Jason created the illusion of a small girl and controlled professors mind through it. The professor then uses Cerebro to individually Lock-On all the mutants. As evident by the constant ranting of Jason's illusion "...find them, find them all..." when Prof was locking on to the individuals.
Hence, when he was being manipulated by Jason, it was very natural for Jason to instruct him to lock on all mutants, except himself (Jason is not doing a kamikaze mission) and Charles (cause, Jason needs to ensure the job is done first, killing Charles is a secondary objective to Col.Stryker). Thus he and Charles are unaffected by Cerebro.
The Cerebro device has no shielding as such for the user or anyone inside it. And in actual description from the movie and comics canons, it is highly dangerous for the user if the user is not a highly trained individual. For the amount of psychic input can overwhelm the user causing insanity, coma, or even brain damage.
Because the girl in the illusion with Charles is Jason. He tells Charles: "Find all the mutants".
Charles doesn't need to focus on the little girl (who is actually Jason), as he knows where she is, and he is not going to look for himself either. He just targets everyone else.