| 2255 | } |
| 2256 | |
| 2257 | static bool installRap(JNIEnv *env, fs::file &&file, jlong progressId, |
| 2258 | std::string_view rootPath) { |
| 2259 | Progress progress(env, progressId); |
| 2260 | |
| 2261 | auto ebootPath = locateEbootPath(rootPath); |
| 2262 | |
| 2263 | std::vector<std::uint8_t> bytes; |
| 2264 | if (!file.read(bytes, 16)) { |
| 2265 | progress.failure("Failed to read key"); |
| 2266 | return false; |
| 2267 | } |
| 2268 | |
| 2269 | SelfAdditionalInfo info; |
| 2270 | decrypt_self(fs::file(ebootPath), nullptr, &info); |
| 2271 | |
| 2272 | auto npd = [&]() -> NPD_HEADER * { |
| 2273 | for (auto &supplemental : info.supplemental_hdr) { |
| 2274 | if (supplemental.type == 3) { |
| 2275 | return &supplemental.PS3_npdrm_header.npd; |
| 2276 | } |
| 2277 | } |
| 2278 | |
| 2279 | return nullptr; |
| 2280 | }(); |
| 2281 | |
| 2282 | if (npd == nullptr) { |
| 2283 | progress.failure("Failed to fetch NPDRM of SELF"); |
| 2284 | return false; |
| 2285 | } |
| 2286 | |
| 2287 | const auto licenseFile = |
| 2288 | fmt::format("%shome/%s/exdata/%s.rap", rpcs3::utils::get_hdd0_dir(), |
| 2289 | Emu.GetUsr(), npd->content_id); |
| 2290 | |
| 2291 | if (!fs::write_file(licenseFile, fs::open_mode::create + fs::open_mode::trunc, |
| 2292 | bytes)) { |
| 2293 | progress.failure(fmt::format("Failed to write key to %s", licenseFile)); |
| 2294 | return false; |
| 2295 | } |
| 2296 | |
| 2297 | if (!decrypt_self(fs::file(ebootPath))) { |
| 2298 | progress.failure("Provided key is invalid for selected game"); |
| 2299 | fs::remove_file(licenseFile); |
| 2300 | return false; |
| 2301 | } |
| 2302 | |
| 2303 | collectGameInfo(env, -1, {std::string(rootPath)}); |
| 2304 | g_compilationQueue.push(progress, std::move(ebootPath)); |
| 2305 | return true; |
| 2306 | } |
| 2307 | |
| 2308 | static bool installIso(JNIEnv *env, fs::file &&file, jlong progressId) { |
| 2309 | auto optIso = iso_dev::open(std::make_unique<file_view_block_dev>(file)); |
no test coverage detected