View Single Post
Cpp

JCF Member

Joined: Mar 2001

Posts: 1,557

Cpp is doing well so far

Aug 15, 2006, 11:00 PM
Cpp is offline
Reply With Quote
Onag: I've done it with J2L format in C++ with zlib1.dll and it works like a charm. Decompiles the level into 4 streams allowing me to manually edit them and then recompile them into a modified J2L which runs fine. Don't know about the 4 bytes you're mentioning there as I only care for a working decompress/recompress. Might be CRC32?

EDIT: Here's the code I use to decompress:
Code:
// Uncompress the data pDataComp => pDataUncomp
bool CJ2FD::UncompressData() {
	
	int i;

	// Check if all compressed data pointers exist
	for (i = 0; i < 4; i++)
		if (pDataComp[i] == 0)
			return false;
	
	// Check the compressed data file sizes
	for (i = 0; i < 4; i++)
		if (!(Header.CData[i] > 0))
			return false;

	//Allocate memory for the uncompressed data
	for (i = 0; i < 4; i++) {
		if (pDataUncomp[i] != 0) delete[] pDataUncomp[i];
		pDataUncomp[i] = new unsigned char[Header.UData[i]];
	}

	// Finally uncompress the data
	for (i = 0; i < 4; i++)
		if (uncompress(pDataUncomp[i], &Header.UData[i], pDataComp[i], Header.CData[i]) != Z_OK)
			return false;

	return true;
}
The pDataComp[4] are pointers to 4 char arrays where each holds the compressed data of a single stream (CData). The function above will decompress the data into pDataUncomp[4], pointers to 4 arrays of uncompressed data.

Code:
unsigned char*	pDataComp[4];			// Pointer array for compressed data
unsigned char*	pDataUncomp[4];			// Pointer array for uncompressed data
__________________
<a href="http://nmap.org/"><img border="0" alt="Nmap Security Scanner" src="http://images.insecure.org/nmap/images/prop/nmap_bnr_matrix_pfos.gif"/></a>

Last edited by Cpp; Aug 15, 2006 at 11:34 PM.