Game Development Community

Examples about how to use zips with T2D

by Adam Johnston · in Torque Game Builder · 01/19/2006 (1:02 pm) · 6 replies

I know there is a encryption resource for images and dso
What I need to know is where to find examples about using the
ZIP support of the engine (I found a Zipsubstream object in the game)
search directs me to TGE links I don't have access.

Thankyou.

#1
01/19/2006 (1:09 pm)
I know for a fact that .dso encryption should be pretty easy to do, though i dont belive any .dso decompilers are currently available, so i wouldnt worry about it.

that being said, if you step through the exec() code, you can see where the file is first loaded into a byte array and then parsed. your encryption/decryption mechanism would go right inbetween.

I havent spent any time looking into image/art encryption, though this eventually will be important to me. I am guessing that it can be done in a similar way to the exec() method i described, but if anyone has done this research already i would love to hear your findings.

-Jason
#2
01/19/2006 (2:07 pm)
By default, you should be able to simply zip up your sub-folders and it'll "just work." For example, using the spacescroller example, you can zip the contents of example\spacescroller\client\images as example\spacescroller\client\images.zip and it'll find and load it from there transparently.

Note that you need to zip them without the "images/" path included (don't right-click the images folder and tell it to zip it up into images.zip), the most straight forward way is to go into the images folder, select all the individual files, right-click and select 'Add to images.zip' from the Zip context menu, then move the images.zip up one level and get rid of/rename the original images folder.

There are a few things to keep in mind. First, in at least 1.0.2 I *think* I remember Melv saying something about some of the new T2D files (tilemaps and/or particle effects) not using the Torque resource manager, which means they wouldn't work this way (the resource manager is responsible for the automatic zip file support). In the same thread I believe Melv did say everything was going to be moved to use the resource manager, so this may no longer be an issue with 1.1.

Also, the encryption resource as-is seems to break zip file usage. If you implement png encryption for example, then try to put it into a zip file as described above, it won't properly decode it. I never looked deeply into why, it may be trivial to fix.

In regard to encryption on dso files, since you can view .dso's as text and glean a good bit of relevent information (variable and function names specifically) even a basic obfuscation would be useful.

The cryptostream resource (and the added info in this thread is easily applicable to graphics and dso's.
#3
01/19/2006 (3:12 pm)
Jason && Luke:

I tested "ziping" my level images and renaming the folder and torque loaded the
images from the zip file instead, so it's working in alpha2.
About zipping encrypted png are you correct, T2D died with:
Fatal-ISV: (\jtech\T2d\engine\dgl\bitmapPng.cc @ 80) Error reading PNG file:
 [00][00][00][00]: invalid chunk type
I was planning at first only encrypt some pngs and use zip files to "pack"
the rest of the files...

I'm concerned too with the main.cs file because I tested a simple hack against
a game of the show off forum (no name here) and it's quite trivial mount
your console window and dump sensitive functions like scoring and so...
Of course this is not a problem in a offline game, but could be troublesome
in an online game.

Thank you.
#4
01/19/2006 (3:47 pm)
If you use a .zip, is there any way to use an embedded password or the such for actual 'protection' instead of just storage?
#5
01/19/2006 (3:49 pm)
@Adam: fyi, if you are doing an online game, you should never trust what the client sends you. if your game isnt popular, then you dont have to worry about hackers, but the moment people actually like your game, you'll have people trying to hack it.

and they will hack it, so again, never trust what the client sends to the server...
#6
01/19/2006 (4:59 pm)
@Jason: yes, you are correct about security.
And there is a posibility to encript zips I found this resource
even I couldn't test because I read there was problems or so...
I would try whenever I get time *wonder when*
this is low priority for me now.