示例#1
0
BOOL CYkc::Mount(CArcFile* pclArc)
{
	if (memcmp(pclArc->GetHed(), "YKC001", 6) != 0)
		return FALSE;

	// Get the index size and the offset to the index
	DWORD dwIndexOffset;
	DWORD dwIndexSize;
	pclArc->SeekHed(0x10);
	pclArc->Read(&dwIndexOffset, 4);
	pclArc->Read(&dwIndexSize, 4);

	// Get the index
	YCMemory<BYTE> clmbtIndex(dwIndexSize);
	pclArc->SeekHed(dwIndexOffset);
	pclArc->Read(&clmbtIndex[0], dwIndexSize);

	// Get the offset of the filename, and the offset to the index file name
	DWORD dwFileNameIndexOffset = *(LPDWORD)&clmbtIndex[0];
	DWORD dwFileNameIndexSize = dwIndexOffset - dwFileNameIndexOffset;

	// Get the filename index
	YCMemory<BYTE> clmbtFileNameIndex(dwFileNameIndexSize);
	pclArc->SeekHed(dwFileNameIndexOffset);
	pclArc->Read(&clmbtFileNameIndex[0], dwFileNameIndexSize);

	// Get file information
	for (DWORD i = 0, j = 0; i < dwIndexSize; i += 20)
	{
		// Get the length of the filename
		DWORD dwFileNameLen = *(LPDWORD)&clmbtIndex[i + 4];

		// Get the filename
		TCHAR szFileName[_MAX_FNAME];
		lstrcpy(szFileName, (LPCTSTR)&clmbtFileNameIndex[j]);
		j += dwFileNameLen;

		// Get file information
		SFileInfo stfiWork;
		stfiWork.name = szFileName;
		stfiWork.start = *(LPDWORD)&clmbtIndex[i + 8];
		stfiWork.sizeCmp = *(LPDWORD)&clmbtIndex[i + 12];
		stfiWork.sizeOrg = stfiWork.sizeCmp;
		stfiWork.end = stfiWork.start + stfiWork.sizeCmp;

		pclArc->AddFileInfo(stfiWork);
	}

	return TRUE;
}
示例#2
0
/// Mount
///
/// @param pclArc Archive
///
BOOL CCmv::Mount(CArcFile* pclArc)
{
	if (pclArc->GetArcExten() != _T(".cmv"))
	{
		return FALSE;
	}

	if (memcmp(pclArc->GetHed(), "CMV", 3) != 0)
	{
		return FALSE;
	}

	// Read Header
	BYTE abtHeader[44];
	pclArc->Read(abtHeader, sizeof(abtHeader));

	// Get offset
	DWORD dwOffset = *(DWORD*)&abtHeader[4];

	// Get index size
	DWORD dwIndexSize = *(DWORD*)&abtHeader[4] - 44;

	// Get file count
	DWORD dwFiles = *(DWORD*)&abtHeader[16] + 1;

	// Get index
	YCMemory<BYTE> clmbtIndex(dwIndexSize);
	DWORD          dwIndexPtr = 0;
	pclArc->Read(&clmbtIndex[0], dwIndexSize);

	// Get archive name
	TCHAR szArcName[_MAX_FNAME];
	lstrcpy(szArcName, pclArc->GetArcName());
	PathRenameExtension(szArcName, _T("_"));

	// Get file info
	for (DWORD i = 0; i < dwFiles; i++)
	{
		TCHAR szFileExt[_MAX_EXT];
		DWORD dwType = *(DWORD*)&clmbtIndex[12];

		switch (dwType)
		{
		case 0: // Ogg Vorbis
			lstrcpy(szFileExt, _T(".ogg"));
			break;

		case 2: // JBP
			lstrcpy(szFileExt, _T(".jbp"));
			break;
		}

		// Create the file name serial number
		TCHAR szFileName[_MAX_FNAME];
		_stprintf(szFileName, _T("%s%06u%s"), szArcName, i, szFileExt);

		// Add to list view
		SFileInfo stFileInfo;
		stFileInfo.name = szFileName;
		stFileInfo.sizeCmp = *(DWORD*)&clmbtIndex[dwIndexPtr + 4];
		stFileInfo.sizeOrg = *(DWORD*)&clmbtIndex[dwIndexPtr + 8];
		stFileInfo.start = *(DWORD*)&clmbtIndex[dwIndexPtr + 16] + dwOffset;
		stFileInfo.end = stFileInfo.start + stFileInfo.sizeCmp;
		pclArc->AddFileInfo(stFileInfo);
		dwIndexPtr += 20;
	}

	return TRUE;
}
示例#3
0
BOOL CKatakoi::MountWar(CArcFile* pclArc)
{
	if (pclArc->GetArcExten() != _T(".war"))
		return FALSE;

	if (memcmp(pclArc->GetHed(), "war ", 4) != 0)
		return FALSE;

	// Version check
	DWORD dwVersion = *(LPDWORD)&pclArc->GetHed()[4];
	DWORD dwFileEntrySize = 0;

	if (dwVersion == 8)
	{
		dwFileEntrySize = 24;
	}
	else
	{
		return FALSE;
	}

	pclArc->SeekHed(0x08);

	// Get the number of files
	DWORD dwFiles;
	pclArc->Read(&dwFiles, 4);

	// Get index size
	DWORD dwIndexSize = dwFiles * dwFileEntrySize;

	// Get index
	YCMemory<BYTE> clmbtIndex(dwIndexSize);
	pclArc->SeekCur(0x04);
	pclArc->Read(&clmbtIndex[0], dwIndexSize);

	// Get the filename index
	YCMemory<BYTE> clmbtSec;
	DWORD dwNameIndex;

	BOOL bSec = GetNameIndex(pclArc, clmbtSec, dwNameIndex);

	// Set index for each archive filename to see if it is correct(Used in delta synthesis/decoding)
	pclArc->SetFlag(bSec);

	// Getting file info

	TCHAR szFileName[_MAX_FNAME];
	TCHAR szWork[_MAX_FNAME];

	if (!bSec)
	{
		// Failed to get the filename index
		lstrcpy(szWork, pclArc->GetArcName());
		PathRemoveExtension(szWork);
	}

	for (DWORD i = 0; i < dwFiles; i++)
	{
		if (!bSec)
		{
			// Create a sequential filename
			_stprintf(szFileName, _T("%s_%06u"), szWork, i);
		}
		else
		{
			// Get filename from the filename index
			lstrcpy(szFileName, (LPCTSTR)&clmbtSec[dwNameIndex]);

			dwNameIndex += strlen((char*)&clmbtSec[dwNameIndex]) + 1; // File name
			dwNameIndex += strlen((char*)&clmbtSec[dwNameIndex]) + 1; // File type
			dwNameIndex += strlen((char*)&clmbtSec[dwNameIndex]) + 1; // Archive type
			dwNameIndex += 4 + *(LPDWORD)&clmbtSec[dwNameIndex];      // Archive name length + Archive name + File number
		}

		SFileInfo stfiWork;
		stfiWork.name = szFileName;
		stfiWork.start = *(LPDWORD)&clmbtIndex[i * dwFileEntrySize];
		stfiWork.sizeCmp = *(LPDWORD)&clmbtIndex[i * dwFileEntrySize + 4];
		stfiWork.sizeOrg = stfiWork.sizeCmp;
		stfiWork.end = stfiWork.start + stfiWork.sizeCmp;
		pclArc->AddFileInfo(stfiWork);
	}

	return TRUE;
}
示例#4
0
BOOL CKatakoi::MountIar(CArcFile* pclArc)
{
	if (pclArc->GetArcExten() != _T(".iar"))
		return FALSE;

	if (memcmp(pclArc->GetHed(), "iar ", 4) != 0)
		return FALSE;

	// Version check
	DWORD dwVersion = *(LPDWORD)&pclArc->GetHed()[4];
	DWORD dwFileEntrySize = 0;

	if (dwVersion == 2)
	{
		dwFileEntrySize = 4;
	}
	else if (dwVersion == 3)
	{
		dwFileEntrySize = 8;
	}
	else
	{
		return FALSE;
	}

	pclArc->SeekHed(0x1C);

	// Get number of files
	DWORD dwFiles;
	pclArc->Read(&dwFiles, 4);

	// Get index size
	DWORD dwIndexSize = dwFiles * dwFileEntrySize;

	// Get index
	YCMemory<BYTE> clmbtIndex(dwIndexSize);
	pclArc->Read(&clmbtIndex[0], dwIndexSize);

	// Get index filename
	YCMemory<BYTE> clmbtSec;
	DWORD dwNameIndex;

	BOOL bSec = GetNameIndex(pclArc, clmbtSec, dwNameIndex);

	// File information retrieval
	TCHAR szFileName[_MAX_FNAME];
	TCHAR szWork[_MAX_FNAME];

	if (!bSec)
	{
		// Failed to get the filename index
		lstrcpy(szWork, pclArc->GetArcName());
		PathRemoveExtension(szWork);
	}

	for (DWORD i = 0; i < dwFiles; i++)
	{
		if (!bSec)
		{
			// Create a sequential filename
			_stprintf(szFileName, _T("%s_%06u"), szWork, i);
		}
		else
		{
			// Get the name of the file from the filename index
			lstrcpy(szFileName, (LPCTSTR)&clmbtSec[dwNameIndex]);

			dwNameIndex += strlen((char*)&clmbtSec[dwNameIndex]) + 1; // Filename
			dwNameIndex += strlen((char*)&clmbtSec[dwNameIndex]) + 1; // File type
			dwNameIndex += strlen((char*)&clmbtSec[dwNameIndex]) + 1; // Archive type
			dwNameIndex += 4 + *(LPDWORD)&clmbtSec[dwNameIndex];      // Archive name length + Archive name + File number
		}

		SFileInfo stfiWork;

		stfiWork.name = szFileName;
		stfiWork.start = *(LPDWORD)&clmbtIndex[i * dwFileEntrySize];
		stfiWork.end = ((i + 1) < dwFiles) ? *(LPDWORD)&clmbtIndex[(i+1) * dwFileEntrySize] : pclArc->GetArcSize();
		stfiWork.sizeCmp = stfiWork.end - stfiWork.start;
		stfiWork.sizeOrg = stfiWork.sizeCmp;

		pclArc->AddFileInfo(stfiWork);
	}

	return TRUE;
}
示例#5
0
/// Mount
///
/// @param pclArc Archive
///
BOOL CPaz::Mount(CArcFile* pclArc)
{
    if (pclArc->GetArcExten() != _T(".paz"))
        return FALSE;

    // Initialize Mount Key
    InitMountKey(pclArc);

    // Initialize Table
    InitTable();

    // Decode Table
    DecodeTable1();
    DecodeTable2();

    // Get index size
    DWORD dwIndexSize;
    pclArc->Read(&dwIndexSize, 4);
    Decrypt(&dwIndexSize, 4);

    // Get index
    DWORD dwIndexPtr = 0;
    YCMemory<BYTE> clmbtIndex(dwIndexSize);
    pclArc->Read(&clmbtIndex[0], dwIndexSize);

    // Decode Index
    Decrypt(&clmbtIndex[0], dwIndexSize);
    DecodeData(&clmbtIndex[0], dwIndexSize);

    // Get file count
    DWORD dwFiles = *(DWORD*)&clmbtIndex[0];
    dwIndexPtr += 4;

    // Initialization table for decoding movies
    if (pclArc->GetArcName() == _T("mov.paz"))
    {
        dwIndexPtr += InitMovieTable(&clmbtIndex[dwIndexPtr]);
    }

    // Get file info
    for (DWORD i = 0; i < dwFiles; i++)
    {
        // Get file name
        TCHAR szFileName[_MAX_FNAME];
        lstrcpy(szFileName, (LPCTSTR)&clmbtIndex[dwIndexPtr]);
        dwIndexPtr += lstrlen(szFileName) + 1;

        // Add .ogg extension if voice.paz (Don't know why they don't have extensions)

        if (pclArc->GetArcName().Left(5) == _T("voice"))
        {
            if (lstrcmp(PathFindExtension(szFileName), _T("")) == 0)
            {
                lstrcat(szFileName, _T(".ogg"));
            }
        }

        DWORD dwType = *(DWORD*)&clmbtIndex[dwIndexPtr + 20];

        // Add to list view
        SFileInfo stFileInfo;
        stFileInfo.name = szFileName;
        stFileInfo.sizeOrg = (dwType == 1) ? *(DWORD*)&clmbtIndex[dwIndexPtr + 8] : *(DWORD*)&clmbtIndex[dwIndexPtr + 12];
        stFileInfo.dwSizeOrg2 = *(DWORD*)&clmbtIndex[dwIndexPtr + 16];
        stFileInfo.sizeCmp = (dwType == 1) ? *(DWORD*)&clmbtIndex[dwIndexPtr + 16] : stFileInfo.sizeOrg;
        stFileInfo.start = *(DWORD*)&clmbtIndex[dwIndexPtr + 0];
        stFileInfo.end = stFileInfo.start + stFileInfo.sizeCmp;

        if (dwType == 1)
        {
            stFileInfo.format = _T("zlib");
        }

        pclArc->AddFileInfo(stFileInfo);

        dwIndexPtr += 24;
    }

    return TRUE;
}