コード例 #1
0
Angle PseudoJet::Rap() const
{
    return rap() == fastjet::pseudojet_invalid_rap ? 0_rad : rap() * rad;
}
コード例 #2
0
ファイル: unedat.cpp プロジェクト: cornytrace/rpcs3
// Decrypts full file
fs::file DecryptEDAT(const fs::file& input, const std::string& input_file_name, int mode, const std::string& rap_file_name, u8 *custom_klic, bool verbose)
{
	// Prepare the files.
	input.seek(0);

	// Set keys (RIF and DEVKLIC).
	std::array<u8, 0x10> rifKey{ 0 };
	unsigned char devklic[0x10] = { 0 };
	
	// Select the EDAT key mode.
	switch (mode) 
	{
	case 0:
		break;
	case 1:
		memcpy(devklic, NP_KLIC_FREE, 0x10);
		break;
	case 2:
		memcpy(devklic, NP_OMAC_KEY_2, 0x10);
		break;
	case 3:
		memcpy(devklic, NP_OMAC_KEY_3, 0x10);
		break;
	case 4:
		memcpy(devklic, NP_KLIC_KEY, 0x10);
		break;
	case 5:
		memcpy(devklic, NP_PSX_KEY, 0x10);
		break;
	case 6:
		memcpy(devklic, NP_PSP_KEY_1, 0x10);
		break;
	case 7:
		memcpy(devklic, NP_PSP_KEY_2, 0x10);
		break;
	case 8: 
		{
			if (custom_klic != NULL)
				memcpy(devklic, custom_klic, 0x10);
			else
			{
				LOG_ERROR(LOADER, "EDAT: Invalid custom klic!");
				return fs::file{};
			}
			break;
		}
	default:
		LOG_ERROR(LOADER, "EDAT: Invalid mode!");
		return fs::file{};
	}

	// Read the RAP file, if provided.
	if (rap_file_name.size())
	{
		fs::file rap(rap_file_name);

		rifKey = GetEdatRifKeyFromRapFile(rap);
	}

	// Delete the bad output file if any errors arise.
	fs::file output = fs::make_stream<std::vector<u8>>();
	if (extract_all_data(&input, &output, input_file_name.c_str(), devklic, rifKey.data(), verbose))
	{
		output.release();
		return fs::file{};
	}
	
	output.seek(0);
	return output;
}