Example #1
0
int jpeg_decode(void)
{
    enable_mmu();
    dcache_enable();
    printf("mmu_enable\n");

    LoadJpegFile((void *)VIDEO_DATA_BASE);
    
    dcache_disable();
    stop_mmu();

    return 0;
}
Example #2
0
BOOL CJpegFile::DecryptJPEG(std::string csJpeg)
{
	char szTempName[MAX_PATH] = "";
	std::string szDstpath;
	HANDLE hSrc, hDst;
	BYTE *dst_data, *src_data;
	DWORD dst_len, src_len, src_hlen;
	DWORD result_len, i, j;

	int rfv = csJpeg.rfind('\\');
	szDstpath = csJpeg;
	szDstpath.resize(rfv);
	if(szDstpath.size()== 2) szDstpath += '\\';//_T('\\');

	if(GetTempFileName((LPCTSTR)szDstpath.c_str(), "ksc", 0, szTempName) == 0)
	{
//		AfxMessageBox("임시 파일을 생성할 수가 없습니다.", MB_ICONSTOP|MB_OK);
		return FALSE;
	}

	hSrc = CreateFile((LPCTSTR)csJpeg.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	if(hSrc == INVALID_HANDLE_VALUE)
	{
//		AfxMessageBox("소스 파일이 존재하지 않습니다. 다른 파일을 선택해주세요.", MB_ICONSTOP|MB_OK);
		return FALSE;
	}

	hDst = CreateFile((LPCTSTR)szTempName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
	if(hDst == INVALID_HANDLE_VALUE)
	{
		CloseHandle(hSrc);
		return FALSE;
	}

	src_len = GetFileSize(hSrc, &src_hlen);
	if(src_hlen > 0)
	{
		CloseHandle(hSrc);
		CloseHandle(hDst);
	}
	dst_len = src_len - 8;

	src_data = new BYTE[src_len];
	dst_data = new BYTE[dst_len];

	ReadFile(hSrc, (LPVOID)src_data, src_len, &result_len, NULL);

	m_r = 1124;
	for(i = 0; i < 4; i++)
	{
		Decrypt(src_data[i]);
	}

	BYTE magic[4];
	for(i = 4; i < 8; i++)
	{
		magic[i-4] = Decrypt(src_data[i]);
	}

	if(magic[0] == 'K' && magic[1] == 'S' && magic[2] == 'C' && magic[3] == 1)
	{
		//버전 1번
	}
	else
	{
		CloseHandle(hSrc);
		CloseHandle(hDst);
		delete[] dst_data;
		delete[] src_data;
		return FALSE;
	}

	for(j = 0; i < src_len; i++, j++)
	{
		dst_data[j] = Decrypt(src_data[i]);
	}

	WriteFile(hDst, (LPCVOID)dst_data, dst_len, &result_len, NULL);
	
	CloseHandle(hSrc);
	CloseHandle(hDst);

	delete[] dst_data;
	delete[] src_data;

	LoadJpegFile(szTempName);
	DeleteFile((LPCTSTR)szTempName);

	return TRUE;
}