I used to work for a company called Freeloader.
They bought the publishing rites for games that were about a year old and gave them away for free making their money from advertising.
My job was to buy a copy of the game.
Remove the copy protection
Remove the DVD \ CD check so it could be digital only
Break the game into 10 or more downloadable modules, each of which must run and be playable
Get the download size for each module down to less than 10 G
Insert advertising into the game
Insert freeloader code into the game
Removing copy protection took between five minutes and five days.
Interestingly the people who bought in a commercial copy protection system produced games that were easier to hack
My tools were a copy of win32dasm, a tool that recorded file IO, and a hex editor
I developed my own tools to make the job easier as I went along, but they were just on the asset side of things… Making sure assets (textures,meshes, audio) were available when they were needed.
The hardest game I ever worked on was “Hidden And Dangerous.”
The coder on this game took copy protection very seriously and used a neat trick to make it very difficult to hack.
In the game initialisation he gradually built up the asset loading path on the stack. So you call a function that sets up the sound system and it leaves the drive letter in the stack. Then you call a routine to set up the renderer and it adds part of the asset path to the stack, and so on until the full asset path is available on the stack… All of these actions were nicely hidden, it didn’t have a string “c:\” anywhere in the game.
That was the one that took me 5 days to hack. The only one.
The ones that used encrypted executables were trivial. The basic problem is that the CPU cannot run encrypted code, so it must be decoded before execution and that process is easy to detect and you just grab the decrypted code and save it to disk then write your own loader
In short if you are trying to protect you code , then either invest more time and effort in that task than writing your game, or don’t use standard languages, or forget about it.
Besides , what do you think is so valuable about your code ?
There are only so many ways of doing things on computers and most are well defined and the subject of tutorials , scientific papers , open source projects, …
Instead of worrying about code security, worry about a great design, a great user interface, a great user experience.
Make your product so damn good that everyone will buy it within a week or it’s release and there is no market for the pirates. By the time they have hacked it , everyone has bought it and you are on the way to a tax haven with bags of lovely cash