The demilich, an epic monster originally from the Epic Level Handbook for Dungeons and Dragons, Third Edition and nominally updated to Dungeons and Dragons 3.5 by the SRD and Conversion Book, has the extraordinary ability magic immunity which says
Demiliches are immune to all magical and supernatural effects, except as follows. A shatter spell affects a demilich as if it were a crystalline creature, but deals half the damage normally indicated. A dispel evil spell deals 3d6 points of damage (Fort save for half damage). Holy smite spells affect demiliches normally.
However, a demilich also has as spell-like abilities at will astral projection and harm, the latter noted as often used on itself to repair hp damage. Can the demilich, technically, even use these abilities on itself? Further, can a demilich cast its spells on itself?
Note: Split from a question about astral projection herehere. As the tags indicate, this question may require knowledge of how special abilities and magic function in both Dungeons and Dragons, Third Edition and Dungeons and Dragons 3.5.