PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Save data in resource on the fly?

Hey there,

Is it possible to save data (high scores) in a resource?

I have currently got data being saved in normal external files (using CreateFile, ReadFile), but i assume these files could be edited and the scores changed.

What is the best way to store this kind of data?

Thanks :P

Tone.
I store the files the same way for Dr. Pocket. I considered writing them to the registry, too, but decided on the more convenient route. As far as I know, there's no way to add them to the resource, since you'd be changing the executable at runtime. (I wonder if it would say the file's in use...)

If you're just keeping one/a few high scores, and you don't want the user to be able to change it/them easily, I'd suggest keeping it/them in the registry. The user would have to download a registry editor and be savvy enough to use it to cheat.

-John
Thanks for the reply :)

The reason I want to stop people from editing their score is because I am considering having a high score submission system, this will show the best scores on a website. Obviousley I don't want people to be able to fudge the scores on the device, as this would make the online high score list useless.

I've never dealt with the registry before (when programming), I'll check this out and see if I can get it to work. I think I am just moving past the c++ noob stage to the c++ advanced noob stage :P .

Tone.
why not calculate some sort of huge checksum... That way, even if they do cheat and change their score, your system would detect it.
You could store the file's creation date in the registry, and if the user changes the file, you'd be able to detect the change. I doubt more than 1% of PDA users download a regeditor and know how to use it.
Even if you were storing the high scores as resources in the game exe, it would take about 2 minutes to hack them. Ever tried ResHack? It's an absolutely excellent resource editor, i sometimes use it to customize application menus to my liking :D
Sometimes you can even remove nag screens from application just by removing the dialog resource :P (i'm not saying this is a good use of the program though ;) )

So, skip the store-in-exe idea and simply use some kind of checksum system. It can probably still be hacked but will not be worth the effort anymore if you do it right :)
IF you can open the executable for editing (if as you suggest it's not in-use), all you really need to do is create a String resource of a couple of bytes, and then after you compile your program, open it in a hex editor and get the byte offset the string starts at.

Then, just treat it as a binary stream and make your changes. Pretty simple, if it's not in-use.

If you really want to go that route, what you could do is shell out to another program as you exit, and let that program check that the main program is closed, then do the editing. Should be quick enough to not be noticeable to a user.

But I'm with everyone else who said use the registry. Just encode the score in some relatively trivial way and store it there. Should be tamper-proof enough that way.