DISCLAIMER: I am not trying to prevent all hacking. I am simple trying to make it a bit harder for beginners who watched 1 or 2 Cheat Engine tutorials to hack my game. I am aware it is impossible to prevent hacking client-side, that is NOT what I am trying to do. I am simply trying to make it a little bit harder, so someone cannot install Cheat Engine, watch a 5 minute tutorial and completely hack my game.

How do I protect a simple int value, for example my character's health, from being found and/or altered in memory scanners like Cheat Engine very easily.

Even if the solution just makes it take 5 minutes instead of 1 minute to alter my variable, that is exactly what I'm looking for!

It's ok if they can hack my game after watching 2-3 more tutorials on Cheat Engine. I just don't want every random to be able to hack my game.

Obviously better protection would be appreciated, yes I still understand that there is no way to stop client-side hacking completely, that is ok.

My question is similar but not the same as: How to prevent memory hacks? That is not C# and it doesn't explain what the code does or how it works. I've tried it and it doesn't seem to work at all, or maybe I'm just missing something. From what I tested, it just reverses the number, which is just as easy to find with Cheat Engine as a plain number. Also, what is stopping someone from just looking at the _mask value itself? That would still be stored in memory not? Making this whole exercise just completely pointless?

  • 1
    \$\begingroup\$ This question is similar to: How to prevent memory hacks?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. \$\endgroup\$
    – Pikalek
    Commented Jul 8 at 15:05
  • \$\begingroup\$ Another easy to use do things are obfuscators. There are a few on the asset store, they make it way harder to read clean decompiled code (which is not needed for memory hacks but makes it easier to find the correct addresses). \$\endgroup\$
    – Zibelas
    Commented Jul 8 at 15:27
  • 1
    \$\begingroup\$ What kind of game are you making? The techniques you use to make memory hacking more difficult might be different in a real-time game than in a turn-based game. Also, note that being able to slow down beginners isn't much help once more experienced hackers start writing beginner-friendly tutorials (or creating custom tools) for your specific game. \$\endgroup\$
    – Kevin
    Commented Jul 8 at 19:27
  • \$\begingroup\$ Why do you want to do this? In a single player game, I see little reason to prevent cheating. If your game is multiplayer, then that is a very important piece of information that changes everything and should be included in your question. \$\endgroup\$
    – Philipp
    Commented Jul 9 at 8:21
  • \$\begingroup\$ "That is not C#" — I wrote that answer, and yes it is. "doesn't explain what the code does" — I do explain. If you have follow-up questions or things you'd like clarified, please feel free to post a comment on that answer. The answer does assume familiarity with core C# operators like bitwise XOR / complement, which are not "reversing the number", but you can find that documented online if you're curious. \$\endgroup\$
    – DMGregory
    Commented Jul 10 at 10:44


You must log in to answer this question.

Browse other questions tagged .