Game media x 2

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
TheApprentice
Posts: 15
Joined: Fri May 20, 2005 8:27 pm

Game media x 2

Post by TheApprentice »

Ok, I just started to explore Irrlicht and C++
I made a very simple FPS (without the shooting part :wink:) based on the tutorials. I compile my game but I have two questions:

1. The .exe file alone won't be any good since it needs the models and textures. If I have a folder with the .exe, should all other files just be put in the same directory? :? Please help me to get this clear.

2. Is there a way to encrypt the models and textures? That would be really usefull. Many sites allow you to use their models, but not if they can be redistrubuted but the end-user. How can I solve this? A free (even for commercial use) solution is the way to go with the budget I have (or should I say, don't have :)). Do you have any ideas? All suggestions are welcome.
JoeWright
Posts: 74
Joined: Mon Dec 08, 2003 3:51 pm

Post by JoeWright »

1) This depends on the path your using to load the media files (models and textures). If its simply "filename" then the same directory, if "media/filename" then in a sub directory called media, etc...

You also need to distribute the irrlicht.dll file in the same directory as the exe

2) You could write you own loading code/format. Maybe Niko might add this but I doubt it will be a priority unless there's much of a demand for it. I see your point though.

Joe
TheApprentice
Posts: 15
Joined: Fri May 20, 2005 8:27 pm

Post by TheApprentice »

JoeWright wrote:2) You could write you own loading code/format. Maybe Niko might add this but I doubt it will be a priority unless there's much of a demand for it. I see your point though.

Joe
Thanks a lot for being helpful, I appreciate it. Could you or someone else push me in the right direction n how to build a custom format? But it sounds hard and I don't have any prior experience in 3d programming, I need one that takes care of bitmaps, bones, animations... sigh... :cry: It doesn't have to be uber advances, but still do the job of protecting the media.

Another way could be something like a packer that encrypts all of your game (like "MoleBox" :?) but I'm pretty sure there is no free AND platform independent application for that.

Any other suggestions or hints? Have someone done this before?

IMO this is a extremely important feature, because even if you make all the artwork for your game yourself, you (or is it just me?) want to protect it. My project is pretty much halted until I can come up with a solution, that's how important it is...
JoeWright
Posts: 74
Joined: Mon Dec 08, 2003 3:51 pm

Post by JoeWright »

Irrlicht already supports zip files so I think the easiest thing to do would be to add encryption at that point.

Anyone got any ideas?

Joe
Guest

Post by Guest »

JoeWright wrote:Irrlicht already supports zip files so I think the easiest thing to do would be to add encryption at that point.

Anyone got any ideas?

Joe
I got that idea to, it would be great if it could work since any file format can be zipped. But is there a way to tell what password the zip-archive has? Someone is willing to try to code it?

"device->getFileSystem()->addZipFileArchive("../../media/map-20kdm2.pk3");"

(but with a password :?)
That would so rock :cry:

*goes back to thinking*
Guest

Post by Guest »

maybe another solution:

1. zip your media in a file called data.zip
2. rename it do data.gmf (or .whatever). its not important how the file extension is called, just something that is not known like .zip or .rar etc...
3. now load data.gmf as a zip file in irrlicht

thats a very little protection but users that dont have a clue about computers and just click on game.exe wont figure that out anyways :)
Armen138
Posts: 298
Joined: Mon Feb 23, 2004 3:38 am

Post by Armen138 »

irrlicht uses zlib for handling zip files, and i dont think zlib supports encrypted zip files...
if you're looking for me, start looking on irc, i'm probably there.
TheApprentice
Posts: 15
Joined: Fri May 20, 2005 8:27 pm

Post by TheApprentice »

GFXstyLER wrote:maybe another solution:

1. zip your media in a file called data.zip
2. rename it do data.gmf (or .whatever). its not important how the file extension is called, just something that is not known like .zip or .rar etc...
3. now load data.gmf as a zip file in irrlicht

thats a very little protection but users that dont have a clue about computers and just click on game.exe wont figure that out anyways :)
Haha, that is a bit too weak, I don't want to run into legal issues and say "Well, I changed the extension!" :roll: (By the way, Windows boot up screen is "protected"/hidden like that. Bitmap renamed to .sys. By lets be more secure than MS :wink:) There must be a way... perhaps to make a petition for adding this feature?I guess not, hmm...

Models are the most imprtant thing. The only thing that matters is that a regular modeling program should not be able to open the model. I think that you may not invent an entire file format, pleas consider this suggestion below and comment it:

What if you make a model, open it with a texteditor and inserts a line of nonsense... say at line 20, but remember what line! I tried to open the model, it crashed one modeler and the other one just gave me a error message. Could we tell irrlitch, or code it, to skip reading that line...?

Someone could still open the file in a text editor and edit it back if they know what they look for. But IMO, this is secure enough! A model I created in the .x format (I pretty much only use that format) is a bit over 800 poyls. In a text editor, that is a bit more than... 8400 lines of code! :shock: See this example:

3;120,490,494;,
3:321.542.222:,
3;493,490,120;,
3;129,128,115;,
3;495,129,115;,
3;496,497,498;,

The line that says "3:321.542.222:," (the second line) messes up the entire model! That is a line added by me with random numbers but with ; -> : and , -> . you see? I guess there are loads of different possibilites on how to sneak in code like this. Now...

A import command with a parameter that tells a line or two to skip, would be like heaven for me... :? What do you say? Only one for just the .x format and that would be good! With a parameter for the line to skip, it would pretty much be universial, and usable for different projects but no one can open your model with ease.
FlyHigh
Posts: 111
Joined: Wed Mar 23, 2005 12:05 am

Post by FlyHigh »

Save the zip file as normal, then XOR the header with some sequence, then hardcode the sequence into your game and XOR back to the original...

Its weak but now requires that users (hackers) will have to dissassemble the game and find the XOR sequence (although if it were a constant global variable it wouldn't take long) but still it now raises the bar a bit because only programmers can now decode the models not general users who tried renaming it. (its the first thing we all try isn't it?)

Of course, might as well rename all the files/zips as well as XOR'ing just to delay them a bit longer, if people can read your model in ASCII then your doomed from the start I'll just open it up in notepad and see where it went wrong and fix it
TheApprentice
Posts: 15
Joined: Fri May 20, 2005 8:27 pm

Post by TheApprentice »

FlyHigh wrote:Save the zip file as normal, then XOR the header with some sequence, then hardcode the sequence into your game and XOR back to the original...

Its weak but now requires that users (hackers) will have to dissassemble the game and find the XOR sequence (although if it were a constant global variable it wouldn't take long) but still it now raises the bar a bit because only programmers can now decode the models not general users who tried renaming it. (its the first thing we all try isn't it?)

Of course, might as well rename all the files/zips as well as XOR'ing just to delay them a bit longer, if people can read your model in ASCII then your doomed from the start I'll just open it up in notepad and see where it went wrong and fix it
Where and how do I do this? :oops: Is there a command for doing this in irrlitcht? I havn't heard "XOR" before. Is there possibly some code ready to do this so I could try? :? It's hard to program when you don't know what you want to do. I admit, I'm hoping for an "copy & paste" solution if you have one :P
hybrid

Post by hybrid »

Armen138 wrote:irrlicht uses zlib for handling zip files, and i dont think zlib supports encrypted zip files...
But zlib also does not offer zip-file handling, only the compress and uncompress algorithms for single files. Thus, Irrlich already contains lots of additional code to implement such things. I think it would be straight forward to add some crypto library to support arbitrary encryption by intercepting the IO streams. Maybe there is already some code available that does such things. Try googling for it.
TheApprentice
Posts: 15
Joined: Fri May 20, 2005 8:27 pm

Post by TheApprentice »

hybrid wrote:
Armen138 wrote:irrlicht uses zlib for handling zip files, and i dont think zlib supports encrypted zip files...
But zlib also does not offer zip-file handling, only the compress and uncompress algorithms for single files. Thus, Irrlich already contains lots of additional code to implement such things. I think it would be straight forward to add some crypto library to support arbitrary encryption by intercepting the IO streams. Maybe there is already some code available that does such things. Try googling for it.
Could this help? Because I don't know exactly what to look for:
http://www.eskimo.com/~weidai/cryptlib.html

I can't be the only one who want's to do this. A breif tutorial on how to set things up and import one mesh, secured with encryption or the XOR method, is to much to ask for? Please...? :cry: You'll get... a cookie :oops:
FlyHigh
Posts: 111
Joined: Wed Mar 23, 2005 12:05 am

Post by FlyHigh »

I'm sure you have heard of XOR ( 'exclusive or' ).

I would create a different zip loader based on the existing one with one difference; after opening the file for reading, XOR the sequence with the zip header that way only in memory is header decodable and on disc its a mess of random letters.

Code: Select all

void OpenZip(FILE *fp)
{
    char xorString[] = "Some Random Text Here";
    char header[zip_header_size];
    fread(fp,header,zip_header_size);
    int i = 0; int j = 0;
    for(; i < zip_header_size;i++,j++)
    {
         if(xorString[j] == 0) j = 0;
         else header[i] ^= xorString[j];
    }
    //header is now valid. providing it was encryted with the same XOR string
}
AssiDragon
Posts: 158
Joined: Wed Apr 28, 2004 11:03 am
Location: Hungary
Contact:

Post by AssiDragon »

One thing though, if your game is opensource than any encyrption idea is flawed. (As people can just check out what you use to encrypt your stuff).
Staring through eyes of hate we kill
Are we controlled, or is our own will...?
(Edguy)
hybrid

Post by hybrid »

Since Zip files have a common start it would be fairly easy to find the first bytes of the XOR secret. Thus it will be also easy to recover the complete secret by searching for that specific byte sequence. But if I recall correctly the zip crypto algorithm is not more secure, so all of these approaches are just better ways of hiding the information.
And how do you prevent your application from being altered? If you use Irrlicht and just change the reading function in known ways it is easy to add both your input function and an additional output function writing your "secret mesh" to an unencrypted file...
Post Reply