cocos2d-x  3.3rc0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ZipUtils Class Reference

#include <ZipUtils.h>

Static Public Member Functions

static ssize_t ccInflateMemory (unsigned char *in, ssize_t inLength, unsigned char **out)
 Inflates either zlib or gzip deflated memory. More...
 
static ssize_t inflateMemory (unsigned char *in, ssize_t inLength, unsigned char **out)
static ssize_t ccInflateMemoryWithHint (unsigned char *in, ssize_t inLength, unsigned char **out, ssize_t outLengthHint)
 Inflates either zlib or gzip deflated memory. More...
 
static ssize_t inflateMemoryWithHint (unsigned char *in, ssize_t inLength, unsigned char **out, ssize_t outLengthHint)
static int ccInflateGZipFile (const char *filename, unsigned char **out)
 inflates a GZip file into memory More...
 
static int inflateGZipFile (const char *filename, unsigned char **out)
static bool ccIsGZipFile (const char *filename)
 test a file is a GZip format file or not More...
 
static bool isGZipFile (const char *filename)
static bool ccIsGZipBuffer (const unsigned char *buffer, ssize_t len)
 test the buffer is GZip format or not More...
 
static bool isGZipBuffer (const unsigned char *buffer, ssize_t len)
static int ccInflateCCZFile (const char *filename, unsigned char **out)
 inflates a CCZ file into memory More...
 
static int inflateCCZFile (const char *filename, unsigned char **out)
static int ccInflateCCZBuffer (const unsigned char *buffer, ssize_t len, unsigned char **out)
 inflates a buffer with CCZ format into memory More...
 
static int inflateCCZBuffer (const unsigned char *buffer, ssize_t len, unsigned char **out)
static bool ccIsCCZFile (const char *filename)
 test a file is a CCZ format file or not More...
 
static bool isCCZFile (const char *filename)
static bool ccIsCCZBuffer (const unsigned char *buffer, ssize_t len)
 test the buffer is CCZ format or not More...
 
static bool isCCZBuffer (const unsigned char *buffer, ssize_t len)
static void ccSetPvrEncryptionKeyPart (int index, unsigned int value)
 Sets the pvr.ccz encryption key parts separately for added security. More...
 
static void setPvrEncryptionKeyPart (int index, unsigned int value)
static void ccSetPvrEncryptionKey (unsigned int keyPart1, unsigned int keyPart2, unsigned int keyPart3, unsigned int keyPart4)
 Sets the pvr.ccz encryption key. More...
 
static void setPvrEncryptionKey (unsigned int keyPart1, unsigned int keyPart2, unsigned int keyPart3, unsigned int keyPart4)

Member Function Documentation

static int ccInflateCCZBuffer ( const unsigned char *  buffer,
ssize_t  len,
unsigned char **  out 
)
inlinestatic

inflates a buffer with CCZ format into memory

Returns
the length of the deflated buffer
Since
v3.0
static int ccInflateCCZFile ( const char *  filename,
unsigned char **  out 
)
inlinestatic

inflates a CCZ file into memory

Returns
the length of the deflated buffer
Since
v0.99.5
static int ccInflateGZipFile ( const char *  filename,
unsigned char **  out 
)
inlinestatic

inflates a GZip file into memory

Returns
the length of the deflated buffer
Since
v0.99.5
static ssize_t ccInflateMemory ( unsigned char *  in,
ssize_t  inLength,
unsigned char **  out 
)
inlinestatic

Inflates either zlib or gzip deflated memory.

The inflated memory is expected to be freed by the caller.

It will allocate 256k for the destination buffer. If it is not enough it will multiply the previous buffer size per 2, until there is enough memory.

Returns
the length of the deflated buffer
Since
v0.8.1
static ssize_t
ccInflateMemoryWithHint
( unsigned char *  in,
ssize_t  inLength,
unsigned char **  out,
ssize_t  outLengthHint 
)
inlinestatic

Inflates either zlib or gzip deflated memory.

The inflated memory is expected to be freed by the caller.

outLenghtHint is assumed to be the needed room to allocate the inflated buffer.

Returns
the length of the deflated buffer
Since
v1.0.0
static bool ccIsCCZBuffer ( const unsigned char *  buffer,
ssize_t  len 
)
inlinestatic

test the buffer is CCZ format or not

Returns
true is CCZ format. false is not
Since
v3.0
static bool ccIsCCZFile ( const char *  filename)
inlinestatic

test a file is a CCZ format file or not

Returns
true is a CCZ format file. false is not
Since
v3.0
static bool ccIsGZipBuffer ( const unsigned char *  buffer,
ssize_t  len 
)
inlinestatic

test the buffer is GZip format or not

Returns
true is GZip format. false is not
Since
v3.0
static bool ccIsGZipFile ( const char *  filename)
inlinestatic

test a file is a GZip format file or not

Returns
true is a GZip format file. false is not
Since
v3.0
static void ccSetPvrEncryptionKey ( unsigned int  keyPart1,
unsigned int  keyPart2,
unsigned int  keyPart3,
unsigned int  keyPart4 
)
inlinestatic

Sets the pvr.ccz encryption key.

Example: If the key used to encrypt the pvr.ccz file is 0xaaaaaaaabbbbbbbbccccccccdddddddd you will call this function with the key split into 4 parts as follows

ZipUtils::setPvrEncryptionKey(0xaaaaaaaa, 0xbbbbbbbb, 0xcccccccc, 0xdddddddd);

Note that using this function makes it easier to reverse engineer and discover the complete key because the key parts are present in one function call.

IMPORTANT: Be sure to call setPvrEncryptionKey or setPvrEncryptionKeyPart with all of the key parts before loading the spritesheet or decryption will fail and the spritesheet will fail to load.

Parameters
keyPart1the key value part 1.
keyPart2the key value part 2.
keyPart3the key value part 3.
keyPart4the key value part 4.
static void
ccSetPvrEncryptionKeyPart
( int  index,
unsigned int  value 
)
inlinestatic

Sets the pvr.ccz encryption key parts separately for added security.

Example: If the key used to encrypt the pvr.ccz file is 0xaaaaaaaabbbbbbbbccccccccdddddddd you will call this function 4 different times, preferably from 4 different source files, as follows

ZipUtils::setPvrEncryptionKeyPart(0, 0xaaaaaaaa); ZipUtils::setPvrEncryptionKeyPart(1, 0xbbbbbbbb); ZipUtils::setPvrEncryptionKeyPart(2, 0xcccccccc); ZipUtils::setPvrEncryptionKeyPart(3, 0xdddddddd);

Splitting the key into 4 parts and calling the function from 4 different source files increases the difficulty to reverse engineer the encryption key. Be aware that encrpytion is never 100% secure and the key code can be cracked by knowledgable persons.

IMPORTANT: Be sure to call setPvrEncryptionKey or setPvrEncryptionKeyPart with all of the key parts before loading the spritesheet or decryption will fail and the spritesheet will fail to load.

Parameters
indexpart of the key [0..3]
valuevalue of the key part
static int inflateCCZBuffer ( const unsigned char *  buffer,
ssize_t  len,
unsigned char **  out 
)
static
static int inflateCCZFile ( const char *  filename,
unsigned char **  out 
)
static
static int inflateGZipFile ( const char *  filename,
unsigned char **  out 
)
static
static ssize_t inflateMemory ( unsigned char *  in,
ssize_t  inLength,
unsigned char **  out 
)
static
static ssize_t
inflateMemoryWithHint
( unsigned char *  in,
ssize_t  inLength,
unsigned char **  out,
ssize_t  outLengthHint 
)
static
static bool isCCZBuffer ( const unsigned char *  buffer,
ssize_t  len 
)
static
static bool isCCZFile ( const char *  filename)
static
static bool isGZipBuffer ( const unsigned char *  buffer,
ssize_t  len 
)
static
static bool isGZipFile ( const char *  filename)
static
static void setPvrEncryptionKey ( unsigned int  keyPart1,
unsigned int  keyPart2,
unsigned int  keyPart3,
unsigned int  keyPart4 
)
static
static void setPvrEncryptionKeyPart ( int  index,
unsigned int  value 
)
static

The documentation for this class was generated from the following file: