Example #1
0
/// Decoding
///
/// Remarks: pvSrc is decoded first
///
/// @param pclArc     Archive
/// @param pvSrc      Compressed data
/// @param dwSrcSize  Compressed data size
/// @param pfnDecrypt Decoding function
///
BOOL CPB3B::Decode(CArcFile* pclArc, void* pvSrc, DWORD dwSrcSize, PB3B_DECRYPT pfnDecrypt)
{
	BYTE* pbtSrc = (BYTE*)pvSrc;

	// Decryption
	Decrypt(pbtSrc, dwSrcSize);

	// Get image information
	WORD wType = *(WORD*)&pbtSrc[28];
	long lWidth = *(WORD*)&pbtSrc[30];
	long lHeight = *(WORD*)&pbtSrc[32];
	WORD wBpp = *(WORD*)&pbtSrc[34];

	switch (wType)
	{
	case 1:
		Decode1(pclArc, pbtSrc, dwSrcSize, lWidth, lHeight, wBpp);
		break;

	case 2:
	case 3:
		Decode3(pclArc, pbtSrc, dwSrcSize, lWidth, lHeight, wBpp);
		break;

	case 4:
		Decode4(pclArc, pbtSrc, dwSrcSize, lWidth, lHeight, wBpp);
		break;

	case 5:
		Decode5(pclArc, pbtSrc, dwSrcSize, lWidth, lHeight, wBpp);
		break;

	case 6:
		Decode6(pclArc, pbtSrc, dwSrcSize, lWidth, lHeight, wBpp, pfnDecrypt);
		break;

	default: // Unknown
		pclArc->OpenFile();
		pclArc->WriteFile(pbtSrc, dwSrcSize);
		break;
	}

	return TRUE;
}
Example #2
0
/// Decode
///
/// Remark: pvSrc can be used to decrypt the first part
///
/// @param archive  Archive
/// @param src      Compressed data
/// @param src_size Compressed data size
///
bool CPB2A::Decode(CArcFile* archive, u8* src, size_t src_size)
{
	// Decrypt
	Decrypt(src, src_size);

	// Get image information
	const u16 type   = *reinterpret_cast<u16*>(&src[16]);
	const s32 width  = *reinterpret_cast<u16*>(&src[18]);
	const s32 height = *reinterpret_cast<u16*>(&src[20]);
	const u16 bpp    = *reinterpret_cast<u16*>(&src[22]);

	// Decompression
	switch (type)
	{
	case 1:
		Decode1(archive, src, src_size, width, height, bpp);
		break;

	case 2:
		Decode2(archive, src, src_size, width, height, bpp);
		break;

	case 3:
	case 4:
		Decode4(archive, src, src_size, width, height, bpp);
		break;

	case 5:
		Decode5(archive, src, src_size, width, height, bpp);
		break;

	case 6:
		Decode6(archive, src, src_size, width, height, bpp);
		break;

	default: // Unknown
		archive->OpenFile();
		archive->WriteFile(src, src_size);
		break;
	}

	return true;
}