예제 #1
0
파일: PKG.cpp 프로젝트: 0179cool/rpcs3
bool PKGLoader::Install(std::string dest)
{
	// Initial checks
	if (!pkg_f.IsOpened())
		return false;

	dest = rGetCwd() + dest;
	if (!dest.empty() && dest.back() != '/')
		dest += '/';

	// Fetch title ID from the header.
	char title_id[48];
	pkg_f.Seek(48);
	pkg_f.Read(title_id, 48);
	
	std::string titleID = std::string(title_id).substr(7, 9);

	if (rDirExists(dest+titleID)) {
		rMessageDialog d_overwrite(NULL, "Another installation was found. Do you want to overwrite it?", "PKG Decrypter / Installer", rYES_NO|rCENTRE);
		if (d_overwrite.ShowModal() != rID_YES) {
			ConLog.Error("PKG Loader: Another installation found in: %s", titleID.c_str());
			return false;
		}
		// TODO: Remove the following two lines and remove the folder dest+titleID
		ConLog.Error("PKG Loader: Another installation found in: %s", titleID.c_str());
		return false;
	}
	if (!rMkdir(dest+titleID)) {
		ConLog.Error("PKG Loader: Could not make the installation directory: %s", titleID.c_str());
		return false;
	}

	// Decrypt and unpack the PKG file.
	if (Unpack(pkg_f, titleID, dest) < 0)
	{
		ConLog.Error("PKG Loader: Failed to install package!");
		return false;
	}
	else
	{
		ConLog.Write("PKG Loader: Package successfully installed in: /dev_hdd0/game/%s", titleID.c_str());
		return true;
	}
}
예제 #2
0
int Unpack(rFile& pkg_f, std::string src, std::string dst)
{
	PKGHeader* m_header = (PKGHeader*) malloc (sizeof(PKGHeader));

	rFile dec_pkg_f;
	std::string decryptedFile = rGetCwd() + "/dev_hdd1/" + src + ".dec";

	dec_pkg_f.Create(decryptedFile, true);
	
	if (Decrypt(pkg_f, dec_pkg_f, m_header) < 0)
		return -1;
	
	dec_pkg_f.Close();

	rFile n_dec_pkg_f(decryptedFile, rFile::read);

	std::vector<PKGEntry> m_entries;
	m_entries.resize(m_header->file_count);

	PKGEntry *m_entries_ptr = &m_entries[0];
	if (!LoadEntries(n_dec_pkg_f, m_header, m_entries_ptr))
		return -1;

	wxProgressDialog pdlg("PKG Decrypter / Installer", "Please wait, unpacking...", m_entries.size(), 0, wxPD_AUTO_HIDE | wxPD_APP_MODAL);

	for (const PKGEntry& entry : m_entries)
	{
		UnpackEntry(n_dec_pkg_f, entry, dst + src + "/");
		pdlg.Update(pdlg.GetValue() + 1);
	}
	pdlg.Update(m_entries.size());

	n_dec_pkg_f.Close();
	wxRemoveFile(decryptedFile);

	return 0;
}
예제 #3
0
bool GLGSRender::LoadProgram()
{
	if(!m_cur_shader_prog)
	{
		ConLog.Warning("LoadProgram: m_cur_shader_prog == NULL");
		return false;
	}

	if(!m_cur_vertex_prog)
	{
		ConLog.Warning("LoadProgram: m_cur_vertex_prog == NULL");
		return false;
	}

	m_fp_buf_num = m_prog_buffer.SearchFp(*m_cur_shader_prog, m_shader_prog);
	m_vp_buf_num = m_prog_buffer.SearchVp(*m_cur_vertex_prog, m_vertex_prog);

	//ConLog.Write("Create program");

	if(m_fp_buf_num == -1)
	{
		ConLog.Warning("FP not found in buffer!");
		m_shader_prog.DecompileAsync(*m_cur_shader_prog);
		m_shader_prog.Wait();
		m_shader_prog.Compile();
		checkForGlError("m_shader_prog.Compile");

		rFile f(rGetCwd() + "/FragmentProgram.txt", rFile::write);
		f.Write(m_shader_prog.GetShaderText());
	}

	if(m_vp_buf_num == -1)
	{
		ConLog.Warning("VP not found in buffer!");
		m_vertex_prog.DecompileAsync(*m_cur_vertex_prog);
		m_vertex_prog.Wait();
		m_vertex_prog.Compile();
		checkForGlError("m_vertex_prog.Compile");

		rFile f(rGetCwd() + "/VertexProgram.txt", rFile::write);
		f.Write(m_vertex_prog.shader);
	}

	if(m_fp_buf_num != -1 && m_vp_buf_num != -1)
	{
		m_program.id = m_prog_buffer.GetProg(m_fp_buf_num, m_vp_buf_num);
	}

	if(m_program.id)
	{
		// RSX Debugger: Check if this program was modified and update it
		if (Ini.GSLogPrograms.GetValue())
		{
			for(auto& program : m_debug_programs)
			{
				if (program.id == m_program.id && program.modified)
				{
					// TODO: This isn't working perfectly. Is there any better/shorter way to update the program
					m_vertex_prog.shader = program.vp_shader;
					m_shader_prog.SetShaderText(program.fp_shader);
					m_vertex_prog.Wait();
					m_vertex_prog.Compile();
					checkForGlError("m_vertex_prog.Compile");
					m_shader_prog.Wait();
					m_shader_prog.Compile();
					checkForGlError("m_shader_prog.Compile");
					glAttachShader(m_program.id, m_vertex_prog.id);
					glAttachShader(m_program.id, m_shader_prog.GetId());
					glLinkProgram(m_program.id);
					checkForGlError("glLinkProgram");
					glDetachShader(m_program.id, m_vertex_prog.id);
					glDetachShader(m_program.id, m_shader_prog.GetId());
					program.vp_id = m_vertex_prog.id;
					program.fp_id = m_shader_prog.GetId();
					program.modified = false;
				}
			}
		}
		m_program.Use();
	}
	else
	{
		m_program.Create(m_vertex_prog.id, m_shader_prog.GetId());
		checkForGlError("m_program.Create");
		m_prog_buffer.Add(m_program, m_shader_prog, *m_cur_shader_prog, m_vertex_prog, *m_cur_vertex_prog);
		checkForGlError("m_prog_buffer.Add");
		m_program.Use();

		// RSX Debugger
		if (Ini.GSLogPrograms.GetValue())
		{
			RSXDebuggerProgram program;
			program.id = m_program.id;
			program.vp_id = m_vertex_prog.id;
			program.fp_id = m_shader_prog.GetId();
			program.vp_shader = m_vertex_prog.shader;
			program.fp_shader = m_shader_prog.GetShaderText();
			m_debug_programs.push_back(program);
		}
	}

	return true;
}