It's all about acoustic coupling, i.e., enough volume from your speaker to shake the guitar and vibrate the guitar strings, which excites the pickup which sends that note to the amp, which amplifies it and spews it into the air back to the guitar, which shakes the strings....
The only parts that are difficult about it are knowing your guitar and its pickups well enough to know which is the most resonant, and to know what difference from the speaker will affect your guitar.
Holding a note for 30 seconds is easy, but doing it at will with any note is a different situation. Carlos Santana, after sound check, wanders the stage and marks the spots he can stand that will guarantee his trademark sustain. It's not luck, it's knowing the equipment.
It's not that Gary Moore happened upon some magic thing, it's that he did what others do, he figured out the distances.