Background
I\'ve had problems for quite a while now with players cheating in my android game. For a strict single-player game this wouldn\'t be a big is
You should store a hash (eg crc32 or md5) of the health etc. everytime you update the value, do a hash check on the currently set value. In this case, the cheaters would have to write a seperate app that handles the hashes. Possible, but this will stop the script-kiddy cheaters soon enough.
To prevent memory cheating you can do one of the following:
try{
ApplicationInfo info = getPackageManager().
getApplicationInfo("com.cih.gamecih", 0 );
return true;
} catch( PackageManager.NameNotFoundException e ){
return false;
}
If this function returns true, don't even let the hacker enter Multiplayer mode, and prompt him to uninstall it.
I have a thought on this, since I sometimes use GameCIH myself. You could have a rolling 10-entry transaction log that self-checks on every new transaction.
What you would do (since GameCIH can only deal with one variable at a time) is have two variables that are checked against each other.
If the negative of the summation value doesn't match the original plus the 10 logged transactions, return an error.
You would just have to change how your stat mods are handled - if even one of them still tries to modify the original value directly, your game would return that it's been incorrectly changed.
You can store life in X number of variables and the real value will be the sum of them (always calculated dynamically). You randomly choose which one to update. On top of that You can add some consistency check and it becomes extremely hard for cheater to realise what and how to change it.
The consistency check could be a simple rule that 1st, 2nd and 3rd variables are in growing order for example and the 4th is the smallest. It will take someone good while to figure this out with this tool.
Yoy can also get more creative and mix in some encryption etc (the way you mentioned) on top of that. Then it becomes second to impossible unless someone has your code.
EDIT: Add 100 random variables that change all the time with random names (or positions in the array, to make it easier) and then good luck for cheaters looking for the right ones. And make it all dynamic so every time they have to crack it again.
Could you just check for root access on game launch? Then deny opening app or deny multiplayer mode on rooted devices? Provide a small check at the opening load screen only when app is initialized, maybe have app request super user then if user grants it try to do a harmless function not allowed without superuser then a code to check if said function was successfully then undo change and pop a message box indicating user should leave root mode try again.
Alternately this check could be applied upon entering multiplayer mode.
Also you could just run multiplayer mode from a server and single player from device and let single players hex edit freely.