They are usually just coded in a trigger and either obfuscated (so that someone won't think to change it) or they try to hide it as much as possible. Here is one, with some explanations on the techniques:
http://www.wc3c.net/showthread.php?t=97922
I'm sure there are a lot of others too. The fog protection basically has units in places on the map that aren't normally viewable. If someone hacks it to enable visibility, it'll reveal that point. You can then check if the unit is visible to the players, and crash wc3 or w/e.