Hidden Source Files (perhaps difficult to explain in one line)

Started by
5 comments, last by Retlaf 17 years, 2 months ago
Hi, I'm new to these forums! This is my second semester of my first year of Software Engineering in University. The thing that interests me most is game development. Anyway, I've been messing around with OpenGL & C++ and it's been a blast. Now, I've come here with what might turn out to be a very simple question, but might not. I'm really not sure! What I want to know is how I can hide my source image files, music files, etc. so that the average user will not be able to view/edit them. Right now I basically import everything from a folder. But the user could just open up the folder and get a sneak peek at all the textures and music used for the hidden levels and everything! I would like to make these files hidden or encypted somehow. Is there an easy way to do this? I use Microsoft Visual Studio C++ 6.0 if that needs to be known. Edit: I forgot to mention that if this IS a difficult task, I'd be thrilled if you could send me in the right direciton towards learning how to do this. Thank a lot! ~Retlaf
Advertisement
Is including them as resources in the executable out of the question? If not that, have you considered a "virtual file system"?
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
You can put all your resources in a zip file (or some other, possibly your own, format) and extract it in-memory. This is what older quakes used to do anyway(.pak is just a .zip renamed, AFAIK. I don't know about the newer ones). There are libraries which can help with this, like physfs.

You could also build all the resources into your executable by using resources. I don't know much about this, I don't use resource files.

Note none of these will stop determined attempt to get to your data, but it will stop a casual look for these files.

Encryption would also work, but its not difficult to read the data once you decrypt it in memory so you can't stop the data being read altogether.
"Is including them as resources in the executable out of the question?"

No. I don't believe so, anyway. I've never tried it nor do I know how to go about doing it. I suppose it would depend if the file types I use would be compatible with this method. But I don't know anything about it... so I'd be very thankful if you could send me in the right direction for learning more about how to do this.
You can do that by adding them as resources. I don't remember how they work, but the last time I saw this being used was here: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=38
Basically, they will be placed inside your executable file.
Another way, especially if you don't want to load it all at the starting, is to make your own file format, or just encript existing ones.
EDIT: this was posted before you replied. Anyway, I really think you should try to learn how resources work - this will be the easier way to do what you want (however, I have never tried to use them in Visual Studio, so I can't really tell you how to do it).
There are a few ways I can thinl of off the top of my head, some easier than others, some more secure (nonthing is totaly secure)

1) Compile all the source files into a single file, you will need to write a bit of code to handle the loading of the indvidual resource from this file. This is how a lot of big games (eg Doom :) ) do it, ie the WAD file. Think of it as a "zip" file containing many other files, not always compressed. You could add some form of encryption to this.

2) Use a less common file format (if you were using directx you could use DDS which is less likely to be supported on a "user" machine.

3) Roll your own image and sound file types and your own loaders (can just be adding more header info at the start of the file to confuse regular editing software.

"1" is probably your best option but it is a bit of work.

There is prob. some libs out there to do it if you hunt for them.
Thanks for the info, everyone. This is exactly what I needed to start my learning spree.

This topic is closed to new replies.

Advertisement