Thursday, October 11, 2018

anti cheat - Strategies to Defeat Memory Editors for Cheating - Desktop Games



I'm assuming we're talking about desktop games -- something the player downloads and runs on their local computer. Many are the memory editors that allow you to detect and freeze values, like your player's health.


How do you prevent cheating via memory-modifiation? What strategies are effective to combat this kind of cheating?


For reference, I know that players can: - Search for something by value or range - Search for something that changed value - Set memory values - Freeze memory values


I'm looking for some good ones. Two I use that are mediocre are:




  • Displaying values as a percentage instead of the number (eg. 46/50 = 92% health)

  • A low-level class that holds values in an array and moves them with each change. (For example, instead of an int, I have a class that's an array of ints, and whenever the value changes, I use a different, randomly-chosen array item to hold the value)


The game is offline, free and single-player.


Edit: for posterity, I solved this (in C#) and posted my solution here, on my blog.



Answer



Another possibility (for integer values) is to have a second member-variable which holds a bitwise complement of an existing variable.


So imagine you got health, you would also have healthComplement. Your implementation could look like this:


// setter sets value and complement
void setHealth(int value){

health = value;
healthComplement = ~value;
}

// getter checks if value was changed outside of the setter
int getHealth(){
if(value != ~healthComplement){
// launch some cheat-counter-measure, like crashing the game?
exit;
}

return health;
}

Somebody who wants to cheat would have to set health and healthComplement correctly, otherwise the game would crash.


I think it's kinda pointless to try to prevent stuff like this. People have successfully created hacks/cheats for much more complex stuff and it just needlessly obfuscates your code or makes your game perform worse.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...