This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Anti Cheat system?

Anti Cheat system?
by on (#59465)
I'm just Curious.
I wonder if it's possible to make anti cheat system,for emulator's save states...
My though is that to use SRAM.
-Game starts:SRAM is saved with flag 0 as TRUE.
-If player collide a enamy/bullet/spikes/water/or whatever then flag 0 is set to FALSE
-After a level end SRAM compare state of flag 0.If both is TRUE then game continues.
If Flag 0 state is FALSE then Game Shows message"Sorry,no cheating"And game restarts.
Is something like this is possible?Or maybe i'm missing something :roll:

by on (#59467)
Perhaps it's the foreigner-speak, but I don't completely understand what you're explaining here. What attack are you trying to thwart? A ROM attack like Game Genie? A RAM attack like Pro Action Replay? Or simple rewinding?

by on (#59468)
I don't think this is possible. Emulators save state does just that, save the state, including SRAM (only some early SNES emulators didn't save SRAM I think, because most games actually used it only for saving, but I'm not too sure).
You could potentially find a flaw in one particular emulator's format that will make save-state detectable (especially in early/inacurate emulators), but you won't be able to do something that detects all savestates for all emulators.

What you describe would always give a "sorry no cheating" screen if the player does get any hit which sounds like nonsense to me.

by on (#59469)
Umm..sorry looks like my english is poor...
I want to prevent save stating.
You know...save states...
So i guess it's like RAM attack(Save states is loading RAM...i guess)

by on (#59470)
Your mechanism can only work against emulators with buggy save states. A correct one cannot be detected because it restores everything perfectly. Imagine that the universe had a save state made, and then run forward a year, and then the state restored just now. Would you be able to tell?

Your best approach is to put emulator detection and refuse to run unless it's an actual NES.

by on (#59471)
No,no that's is not a option :lol: '
So,ok It will work only wtih buggy emulators.
But,anyways...anyone know how to Save an LOAD SRAM?
I plan to make unlockable extra character after beating game once.SO SRAM would be useful :)
Unfotrunelly wiki don't have information about it :cry:

by on (#59472)
Make an online game using chykn's adapter. An emulator can't save the state of a remote server.

by on (#59473)
Umm...sorry,but I don't understand...What do you mean by "make online game"?? :shock:

by on (#59474)
Develop a video game that will not function without a connection to a server through the Internet. I gave you a link to a topic describing a device through which an NES, through a PC proxy, can connect to the Internet.

by on (#59475)
Umm,but...why in the world...
I don't need that.
I just wanted to know how to save and load SRAM on emulator.

by on (#59477)
Denine wrote:
I just wanted to know how to save and load SRAM on emulator.

You don't have to do anything special. Whatever data you write to the SRAM area ($6000-$7FFF) will remain there, as long as the cart has a battery (or your ROM is defined as having a battery, in case of emulation). Some mappers do have registers to lock and unlock SRAM though (to prevent corruption by undesired writes), so check the documentation of the mapper you are using to see if you have to unlock the SRAM before using it (and lock it while you're not using it).

by on (#59479)
It's pretty simple, you just use it like normal memory - except that you don't normally clear it when the cart is reset. You put a signature byte/word in SRAM (like $55AA) when you first initialize it. Then on later resets, you don't initialize it if the signature is there.

by on (#59485)
You can defend against modification type cheats (RAM or ROM poking), but not against savestates.

To defend against RAM cheats, you could always maintain an 8-bit checksum of all your memory. Every time you write somewhere, also update the checksum. This is an 8-bit subtraction with the old value, followed by an 8-bit addition of the new value. This will also make your game slow as hell, and any hacker who cares about cheating can disable the mechanism as well. But this will defeat "cheat finders" built into emulators. Of course, you need to validate the checksum as well, and that's also slow.

To defend against ROM cheats, do a checksum of various places in the ROM. Check if they match. Have more than three different functions to validate the checksum, each with its own checksum information. This way the hackers need to get rid of many different checking routines, instead of just one. This won't stop people from cracking the game, but it would stop a Game Genie.

Not a damn thing you can do about savestates though, except make the game more deterministic, and less reliant on random numbers generated on the spot. So rather than asking for a random number, you would separate each thing that needs random numbers into its own "pile of cards", and "draw cards" from there each time you need a new random number. Or just separate RNG seeds for every type of thing.

by on (#59486)
Hard code the game into an open source emulator and disable the save states. Even then though, if the emulator saves the sram to a separate file, you're screwed.

by on (#59487)
As long as the open source emulator is under a permissive license, not a copyleft license, you can have it digitally sign the SRAM file like more recent game consoles do with their saved games.

by on (#59488)
I think you should just concede that some people will cheat through the game. It's unavoidable without extreme measures. Measures that take time away from actually developing something worth while. Many pirate famicom games suck yet have all sorts of protections. They should have spent more time working on creating something worth stealing.