예제 #1
0
bool EndlessISO::VerifySquashFS(const CString & image, const CString & signatureFilename, HashingCallback_t hashingCallback, LPVOID hashingContext)
{
    FUNCTION_ENTER;

    auto extractor = SevenZip::SevenZipExtractor(pImpl->sevenZip, image.GetString());
    extractor.SetCompressionFormat(SevenZip::CompressionFormat::SquashFS);

    UINT32 i = 0;
    auto size = extractor.GetOrigSizes()[i];
    std::unique_ptr<SevenZip::SevenZipExtractStream> stream(extractor.ExtractStream(i));

    auto reader = [&](void *buf, size_t bytes) {
        return stream->Read(buf, (UINT32)bytes);
    };
    return VerifyStream(reader, size, signatureFilename, hashingCallback, hashingContext);
}
예제 #2
0
//读取包进程
void *ReadAvData(void *arg)
{
	if(!arg)
		return NULL;

	AvManager *manager = (AvManager*)arg;

	int size = 0;
	double cur_pos = 0;
	void *data = NULL;
	long avsize = 0;

	for(;;)
	{
		//先处理命令,命令可以改变状态
		switch(manager->avCommand)
		{
		case PAUSE_CMD:
			manager->avState = PAUSE;
			break;
		case PLAY_CMD:
			manager->avState = PLAY;
			break;
		case STOP_CMD:
			manager->avState = STOP;
			break;
		}
		//命令已经修改完毕状态,使命已经完成,恢复默认
		manager->avCommand = NONE_CMD;

		//如果是停止状态,则表示人为停止
		if(manager->avState == STOP)
		{
			manager->autoEnd = FALSE;
			break;
		}

		if(manager->avSeek)
		{
			cur_pos = CrroectAvPos(manager,manager->avPos);
			manager->playerClock = cur_pos;
			manager->avSeek = SeekPositon(cur_pos,0) >= 0;
		}

		//如果是快进,清空所有

		if(manager->avSeek)
		{
			if(manager->playAudio)
				QueueBufferFlush(manager->MediaAudio);
			if(manager->playVideo)
			{
				QueueBufferFlush(manager->MediaVideo);
				QueueBufferFlush(manager->MediaPicture);
			}
		}

		if(QueueIsFull(manager))
		{
			usSleep(DEFAULT_AV_WAIT);
			continue;			
		}

		//如果队列没满,则开始读包
		data = ExtractStream();

		if(!data)
		{
			if(GetError())
			{
				manager->autoEnd = TRUE;
				break;				
			}
		}
		else
			SendDataToAvQueue(manager,data);

		if(!manager->avSeek && RenderOver(manager) == 0)
		{
			manager->autoEnd = TRUE;
			break;
		}

		if(manager->playAudio)
		{
			double diff = AV_DIFF_DURATION(manager->playerClock,manager->duration);

			if(diff <= 0.5 && diff >= -0.5)
			{
				manager->autoEnd = TRUE;
				break;
			}
		}

		//如果当前状态是SEEK,那么你到此必须还原SEEK的上一次状态
		if(manager->avSeek)
		{
			usSleep(DEFAULT_AV_WAIT*10);
			manager->avSeek = FALSE;
		}
	}

	Manager.already = FALSE;

	if(manager->autoEnd)
	{
		pthread_mutex_lock(&actionMutex);
		printf("av stop!\n");
		manager->avState = STOP;
		printf("clear queure\n");

		if(manager->playAudio)
		{
			if(ParseQueueBufferLength(manager->MediaAudio) > 0)
				UninitQueueBuffer(manager->MediaAudio);
			pthread_join(manager->renderAudio,NULL);
		}

		if(Manager.playVideo)
		{
			if(ParseQueueBufferLength(manager->MediaVideo) > 0)
				UninitQueueBuffer(manager->MediaVideo);
			pthread_join(manager->renderVideo,NULL);
			if(ParseQueueBufferLength(manager->MediaPicture) > 0)
				UninitQueueBuffer(manager->MediaPicture);
			pthread_join(manager->synProcess,NULL);
		}
		printf("unload waveengine\n");
		manager->managerEnd = TRUE;
		UnitWaveEngine();
		printf("unload scale\n");
		DeInitScaleEngine();
		printf("close file\n");
		CloseOcxByOCX();
		printf("render over!\n");
		pthread_mutex_unlock(&actionMutex);
	}

	printf("ready to quit player!\n");

	while(!manager->managerEnd)
		usSleep(DEFAULT_AV_WAIT);

	if(manager->autoEnd)
		manager->ManagerOver = TRUE;

	printf("quit player!\n");

	Manager.playerClock = 0;
	Manager.duration = 0;

	return NULL;
}
예제 #3
0
ComicBookRAR::ComicBookRAR(wxString file, wxUint32 cacheLen, COMICAL_ZOOM zoom, long zoomLevel, bool fitOnlyOversize, COMICAL_MODE mode, FREE_IMAGE_FILTER filter, COMICAL_DIRECTION direction, wxInt32 scrollbarThickness) : ComicBook(file, cacheLen, zoom, zoomLevel, fitOnlyOversize, mode, filter, direction, scrollbarThickness)
{
	HANDLE rarFile;
	int RHCode = 0, PFCode = 0;
	struct RARHeaderDataEx header;
	struct RAROpenArchiveDataEx flags;
	wxString path, new_password;
	wxInputStream *stream;
	ComicPage *page;
	int numEntries, progress=0;
	
	open_rar:
	
	rarFile = openRar(&flags, &header, RAR_OM_LIST);

	if (flags.Flags & 0x0080) { // if the headers are encrypted
		new_password = wxGetPasswordFromUser(
				wxT("This archive is password-protected.  Please enter the password."),
				wxT("Enter Password"));
		if (new_password.IsEmpty()) { // the dialog was cancelled, and the archive cannot be opened
			closeRar(rarFile, &flags);
			throw ArchiveException(filename, wxT("Comical could not open this file because it is password-protected."));
		}
		SetPassword(new_password.ToAscii());
	}
	if (password)
		RARSetPassword(rarFile, password);

	// skip through the entire archive to count the number of entries
	for (numEntries = 0; RARReadHeaderEx(rarFile, &header) == 0; numEntries++) {
		if ((PFCode = RARProcessFile(rarFile, RAR_SKIP, NULL, NULL)) != 0) {
			closeRar(rarFile, &flags);
			throw ArchiveException(filename, ProcessFileError(PFCode, header.FileNameW));
		}
	}

	wxProgressDialog progressDlg(wxString(wxT("Opening ")) + file, wxString(), numEntries);
	progressDlg.SetMinSize(wxSize(400, -1));

	// close and re-open the archive to restart at the first header
	closeRar(rarFile, &flags);
	rarFile = openRar(&flags, &header, RAR_OM_LIST);

	while ((RHCode = RARReadHeaderEx(rarFile, &header)) == 0) {
		path = header.FileNameW;

		progressDlg.Update(progress, wxString(wxT("Scanning: ")) + path);
		progressDlg.CentreOnParent(wxHORIZONTAL);

		stream = ExtractStream(path);
		page = new ComicPage(path, stream);
		if (page->GetBitmapType() == wxBITMAP_TYPE_INVALID)
			delete page;
		else
			Pages.push_back(page);

		wxDELETE(stream);

		if ((PFCode = RARProcessFileW(rarFile, RAR_SKIP, NULL, NULL)) != 0) {
			closeRar(rarFile, &flags);
			throw ArchiveException(filename, ProcessFileError(PFCode, path));
		}

		progressDlg.Update(++progress);
	}

	closeRar(rarFile, &flags);
	
	// Wrong return code + needs password = wrong password given
	if (RHCode != ERAR_END_ARCHIVE && flags.Flags & 0x0080) 
		goto open_rar;

	postCtor();
	Create(); // create the wxThread
}