Sign in to follow this  
Eric Bizet

Make file unreadable by an external program

Recommended Posts

Eric Bizet    117
Hi,
 
As mentionned in the title, I want to make my resources files (text, images and audio) of my game unreadable from external programs like Word, Photoshop or VLC Media Player...
 
I don't want to make an encryption/decryption algorithm that requires to create a output file (because it could be read easily) or something stored in the memory (don't want to take to much pc resources you see ?). I just want to make them directly readable in SFML through a c++ algorithm, i'm not looking for an extremely complicated process.
 
I saw how resources files were crypted for Terraria (XNB Files) and if you could tell how it works it would be great ^^
 
Thanks for your replies

Share this post


Link to post
Share on other sites
SmkViper    5396
Encryption will also slow down your game loader - not much of an issue in a small project, but for a large game it's definitely noticeable. Released games are more concerned about loading something fast then encrypting it - it just so happens that the kinds of things you do to make something load fast, like archiving them, using a custom format, or preprocessing also make them difficult to read by standard programs.

Share this post


Link to post
Share on other sites
Eric Bizet    117

Thank for your replies

 

 

I find it highly unlikely that Terraria encrypts its files. According to 30 seconds of Googling, it just appears to be a custom format, most likely to make loading and streaming easier. That's not encryption and any user with a bit of technical background can get access to the data even if the specification is not public for easier modding.

If you want to prevent casual opening/modifications of your resources give them a non-standard extension (like .myimage instead of .png). That should prevent opening them by simple double-click in Windows. Of course even a user with a minimum of technical understanding can still just drag the file into Gimp.
Alternatively just store multiple files inside some archive format. I would advise against encryption. It will most likely cause you more problems getting it right than a skilled user to grab the decryption keys from your own executable.

 

I had also the same idea about the custom file extension but that is not enough

 

Encryption will also slow down your game loader - not much of an issue in a small project, but for a large game it's definitely noticeable. Released games are more concerned about loading something fast then encrypting it - it just so happens that the kinds of things you do to make something load fast, like archiving them, using a custom format, or preprocessing also make them difficult to read by standard programs.

 

Ok so i give up the encryption method

 

XNBs are simply files that are generated by the XNA Content Pipeline. They are not encrypted in any way, you can write yourself a viewer without much trouble using XNA or Monogame.

The easiest way that I can think of to "protect" your assets would be to store them in one or multiple archive (7z, zip, ...) and use a custom extension. Then, you change the the archive header so that the files cannot be opened without knowing how to reconstruct the original header.

Somehow I wonder what kind of assets you have that no one must be able to see them. biggrin.png

 

But zipping file will not make them slower to read ?

Share this post


Link to post
Share on other sites
Chris_F    3030


I had also the same idea about the custom file extension but that is not enough

 

Why not? What are you trying to prevent?

 

The reality check is that no matter how much effort you put into it, people will be able to undo whatever it is you come up with, so you might as well not waste much of your time with it. I'm sure it could be better spent improving other, more important aspects of your game.

Share this post


Link to post
Share on other sites
Jan2go    2057

But zipping file will not make them slower to read ?


As Sean already said, the decompression will be faster than the IO most of the time. If for some reason you are slowed down by the decompression you can always take a compression algorithm that favors speed over compression ratio (e.g. LZ4).

Share this post


Link to post
Share on other sites
BedderDanu    292

For what it's worth, Microsoft uses regular old zipped XML files for it's office documents (.???x files, like .docx). If you convert them from docx to zip, you can extract the XML and see what makes them up.

 

Almost everyone has no idea they are multi-file zip archives, and opening them takes almost no time, even for large files.

 

So if you name them "Tank.content"; which is really Tank.zip; which is an archive that contains Tank.obj, Tank.png, and Tank.wav; then you have already deterred most everyone from opening them up and seeing what's inside.

Share this post


Link to post
Share on other sites

You can obfuscate, bitshift, encrypt, hide the keys, decrypt in a custom VM and download secondary keys from a remote server all you want.

As soon, as the game has loaded, literally all I need to do is Alt-Tab out to Pix/gDebugger/ApiTrace/... select the texture and click "Save As...".

It simply doesn't matter what you do to your content, as long as you pass it into an API call somewhere down the line, that will always be the weak spot.

 

Quote this one again for truth.  If people want to steal your assets they will steal your assets.  There is nothing you can do to prevent that.  If multi billion dollar companies are using plain old zip (which is probably more for file size on disk and not encryption) then why are you worrying about this so much?  Spend your time on something more important.

Share this post


Link to post
Share on other sites
Eric Bizet    117

I'm looking for a simple process to make my files unaccessible from random people a look at as they wish. Just to discourage dumb people to do it you see ?

 

I think a would try compression with a minimum compression ratio, thank you guys for your precise answers.

 

 

As soon, as the game has loaded, literally all I need to do is Alt-Tab out to Pix/gDebugger/ApiTrace/... select the texture and click "Save As...".

 

 

I'm did not understand this line, could you tell me more about it please ? If you agree ^^

Edited by Reakbyz

Share this post


Link to post
Share on other sites
Jan2go    2057

As soon, as the game has loaded, literally all I need to do is Alt-Tab out to Pix/gDebugger/ApiTrace/... select the texture and click "Save As...".

I'm did not understand this line, could you tell me more about it please ? If you agree ^^


Tools like Pix (for DirectX) or gDEBugger/CodeXL (for OpenGL) are used for graphics debugging. Among others things, they can show you all textures that are loaded by the program that you are debugging.
jcuz8u63.jpg
Even if these tools may not necessarily provide an export functionality, it's still not that hard to save your textures.

Share this post


Link to post
Share on other sites
Ohforf sake    2052

I'm did not understand this line, could you tell me more about it please ? If you agree ^^


Pix, gDebugger etc. are tools for debugging graphical problems. They allow you to record an entire frame (or multiple frames) and look at what's going on, step by step. They also allow you to "inspect" all the resources, including vertex buffers, index buffers and textures. And they usually also include the nice feature, that you can export/save them from the trace. So just by uploading your textures into the rendering API, you pass it to Pix/gDebugger and they expose methods for saving it back to disk.

Pretty much the same applies for all APIs, even if the tools might not be as easily available. If for example you pass a soundeffect to your audio library, which happens to be a DLL, a programmer can write a wrapper around that DLL which intercepts the data. 
 

Dumb people won't try.  Smart people will look at the files no matter what you do.


This! Most people aren't really that interested in UV unwrapped textures. But those that are, and like to look at them at a regular basis, also know how to use Pix/gDebugger to do so.

Besides, everyone who plays the game will (hopefully) look at the textures anyway, inside the game. What "damage" do you expect to arise from people also looking at them outside the game?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this