This only happens on Pokémon HeartGold/SoulSilver. This is why you have to save often, like what Ooka said. You might also want to try and find an Anti-Piracy patch to fix the problem once and for all, like what Blazichu said.
However, I'm pretty sure there is a way of bypassing the Anti Piracy without the patch or Action Replay code, that is if the developers of DeSmuME were able to do it. Just remember, with ROM Hacking... anything's possible. Nothing is impossible at all. ;)
EDIT: However, I know the crashing from the Anti-Piracy occurs in Pokémon Ranger: Guardian Signs, however you can prevent it from happening by changing the 3D settings often.