3

I've written a game in C/C++ which is soon ready to be released.

My question is: what would be a good way to make the resources (images/sound etc) inaccessible to the user?

It doesn't have to be a strong encryption, I just don't want the average player to browse the resource folders.

As of now the resources are not linked in the Visual Studio project, they are loaded from a path.

CharlesB
  • 86,532
  • 28
  • 194
  • 218
Orujimaru
  • 835
  • 2
  • 13
  • 18
  • 3
    You could compress the resources as a big constant string, and uncompress them during initialization. Alternatively, you could make your game free software http://www.fsf.org/ and take advantage of the work of the community on it. – Basile Starynkevitch Sep 17 '12 at 09:51
  • We used to separate pallate and data of image, and create image at run time. – MarsRover Sep 17 '12 at 10:06
  • On [GDSE](http://gamedev.stackexchange.com/) you can get more appropriate answers for game related questions. – ErikEsTT Sep 17 '12 at 11:01
  • How would you suggest I compress the resources as a string? Will the string be significally larger than the uncomressed resources combined? – Orujimaru Sep 17 '12 at 11:14

2 Answers2

4

It depends how badly you want to hide things from users; how much you're willing to invest versus the reward. Here are some ideas:

  1. Just change / remove the file extensions of your resource files. Most average users will be stopped already.
  2. Modify the files slightly to corrupt it by adding some extra bytes at the beginning which your app knows to skip. The extra bytes could be a misleading header or garbage.
  3. Store the resources in a container / archive format like ZIP or Blizzard's MPQ. Optionally with a password.
  4. Store them as resources in your executable binary. Users would need to use a resource editor / viewer to see them; most users won't even know they're there.
tenfour
  • 36,141
  • 15
  • 83
  • 142
3

A simple way to handle it would be to compress all the files into a password protected ZIP file that you unzip in memory (onto a memory based file system if you want to be fancy).

The obvious drawback is that you'll either need to keep everything in memory or do several calls to get the files you want at the moment.

EDIT: A quick search gave me this link to a Q&A relating to this: Simple way to unzip a .zip file using zlib

Warning

The hacker can still access these strings by detaching the application process with a debugger while the application is running.

Community
  • 1
  • 1
HonkyTonk
  • 1,961
  • 11
  • 11
  • This sounds like an reasonable solution, I only load resources in between levels so multiple calls that take time wouldn't be a problem. Could you point me in the direction of how to achieve this? Like a thread or tutorial. – Orujimaru Sep 17 '12 at 11:17
  • @Orujimaru I've added a link. – HonkyTonk Sep 17 '12 at 11:36