Archived

This topic is now archived and is closed to further replies.

d3ciph3r

Protecting Configuration Files

Recommended Posts

I''m writing a game engine that uses special configuration files to load textures and animations, meaning that this makes it easy for my animator to change the settings of various animation properties. This is a good thing for development, but when it will be ready for release, I don''t want users to be able to (easily)change these settings. Should I encrypt the files, write the configurations files in binary, or anything like that? How would I impliment this? Thanx, d3ciph3r

Share this post


Link to post
Share on other sites
Depending on how complex those configuration files are you might also consider writing a small compiler for them to translate them to a binary format. This way, changing the configuration would require reverse-engineering the file format and the "easy" part in changing the config would be done for.

Implementing this should not be too hard since it sounds like you already had code im place to translate the settings to data structures. Just dump those structures and you''re done.

Of course, there is about no way to keep the truly persistent hacker from changing the configuration, so it depends on how high you want to set the threshhold.

Share this post


Link to post
Share on other sites
Personally i would just write the files in binary.

At the end of developemnt just write a quick program to read the files in and then write them out in binary (+B) then just change your exe to open the files for binary reading. This will stop 99.99% of users from messing with them.

Share this post


Link to post
Share on other sites
Do you know any tutorials for writing and reading binary files?

I googled this and couldn''t find anything very clear. Some experiments with write() and read) didn''t turn out so well either.

Thnx

Share this post


Link to post
Share on other sites
Converting to some sort of bytecode format would probably work pretty well.

You need to ask yourself, tho: why do you want to do this? A dedicated person with a debugger will be able to cheat at any single-player game quite easily, while a multiplayer game should implement robust anti-cheating measures in its design and on the server. Does it really matter to you if someone cheats in a single-player game?


Don''t listen to me. I''ve had too much coffee.

Share this post


Link to post
Share on other sites
if you are using fopen then you sinply add a ''b'' or ''+b'' (i can''t remember which) to the param list to indicate that you want to open the file for binary reading. Its all in MSDN. Obviously this wouldn''t stop a hacker from changing them but i think that you are most likely bothered about the casual user from changing them.

Put it this way if the files contain anything other than straight text then it would take anyone (including a hacker) at least a half day to start making sense of a binary file that they didn''t know the format of.

Share this post


Link to post
Share on other sites
Opening the file in banary mode doesn''t change anything but the encoding of the newline. Every better editor will be able to show you the text.
For me, in a binary file numerical values are stored in banary form rather than in ASCII. This is somewhat harder to manipulate and saves memory.

Share this post


Link to post
Share on other sites
I don''t know of any editor that can read binary text files, which ones can?

Either way no editor could read a binary file of your own format and it is very easy to mainpulate. See fscanf.

Share this post


Link to post
Share on other sites
If you simply don''t want the average user screwing with your files, you could use some patheticaly simple encryption to make a perfectly normal ASCII file illegible (e.g. add 23 to the ascii code of each byte...)

Simplicity is good

Share this post


Link to post
Share on other sites