What is stopping someone from copying
the game onto their computer, and
injecting functions and modules to
cheat?
Nothing.
Is there any fundamental way to
protect people from doing this sort of
thing by designing your game code in a
certain way?
Nope.