Sign in to follow this  
personwholives

reading data from archives

Recommended Posts

I am currently working on a game engine type thing and i wanted to use an archive format of some type to group things together within the game. For example, it would contain texture groupings for a certain environment or whatever. I'm not entirely sure what all i'm going to do with it, but basically i need a method that will allow me to read individual files from the archive (compressed or not) and then use them as a chunk of memory with things like D3DXCreateTextureFromFileInMemory(). Any ideas would be appreciated. Thanks in advance. personwholives

Share this post


Link to post
Share on other sites
I would suggest using zlib - www.zlib.org.
this allows compressed and uncompressed, cross platform, access to the contents of .zip files (and the current??? game industry standard .pk3 files, which are just .zips with a different file extension).
I use it extensively in my projects, sometimes for compression, or just for packaging files into one file, and i have found it fast and reliable, although the learning curve can be a bit steep for new users (try googling for tutorials).

Hey, I just had a neat idea, why didn't I think of this before, to prevent modification of resources across multiple platforms, just store them in an encrypted zip, have to try it out and see if it works.

Anyway, give zlib a try,

SwiftCoder

Share this post


Link to post
Share on other sites
First off, I would like to thank you for pointing out something that I've been googling for for months.
Second, though,
Quote:
Original post by swiftcoder
Hey, I just had a neat idea, why didn't I think of this before, to prevent modification of resources across multiple platforms, just store them in an encrypted zip, have to try it out and see if it works.


Unfortunatly, encrypted zip files only prevent reading, not adding or replacing of data (according to Winzip's documentation). So while it would prevent them from looking at the files (which will prevent them from actually figuring out how the file is structured, so it's more difficult to create their own), it will not prevent them from adding data to the files in an unencrypted form.
Now of course, this added data will not be encrypted, so if you can require it to be encrypted (haven't looked closely at the library yet), then it could be an effective prevention routine--assuming that the cost of decrypting the data when you load it isn't significant.
Although other problems include the user using a debugger to watch the memory, giving them access to unencrypted data, or using a hex editor to find in your program the key to unlock the encrypted data (you're going to have to store it someplace you know!)

Share this post


Link to post
Share on other sites
Quote:
Original post by personwholives
thanks guys, as usual, someone here has an answer for me.


I wrote my own archive type, which is basically just a bunch of BMP or TGA images in a file, which is better because you cannot edit it at first like standalone images and it also looks more nice with big data files. I plan to add a function to load them as RLE compressed later. It contains a file header which describes the offsets etc. of the files contained within.
I suggest you to make own format, maybe it won't smaller than many others, but it's certainly more fun, believe me!
It also often makes smaller exe's, because your functions don't contain a bunch of code you don't need.

Share this post


Link to post
Share on other sites
The Quake 2 pak file format is an incredibly simple one to work with so you could add a few extra fields in the header to prevent existing software from reading the archive or alternatively encrypt the file data inside the pak, this will have the extra overhead of decrypting the data before you can load it so it's a tradeoff between the two.

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