| 79 | } |
| 80 | |
| 81 | Result DecryptCopyNax0ToNca(NcmContentStorage *cnt_storage, const NcmContentId cnt_id, const std::string &path, DecryptStartCallback dec_start_cb, DecryptProgressCallback dec_prog_cb) { |
| 82 | s64 cnt_size = 0; |
| 83 | GLEAF_RC_TRY(ncmContentStorageGetSizeFromContentId(cnt_storage, &cnt_size, &cnt_id)); |
| 84 | auto rem_size = static_cast<u64>(cnt_size); |
| 85 | auto exp = fs::GetExplorerForPath(path); |
| 86 | dec_start_cb((double)cnt_size); |
| 87 | |
| 88 | auto data_buf = new u8[g_Settings.json_settings.exports.value().decrypt_buffer_max_size.value()](); |
| 89 | ScopeGuard on_exit([&]() { |
| 90 | delete[] data_buf; |
| 91 | }); |
| 92 | |
| 93 | s64 off = 0; |
| 94 | exp->StartFile(path, fs::FileMode::Write); |
| 95 | while(rem_size) { |
| 96 | const auto read_size = std::min(g_Settings.json_settings.exports.value().decrypt_buffer_max_size.value(), rem_size); |
| 97 | GLEAF_RC_TRY(ncmContentStorageReadContentIdFile(cnt_storage, data_buf, read_size, &cnt_id, off)); |
| 98 | exp->WriteFile(path, data_buf, read_size); |
| 99 | rem_size -= read_size; |
| 100 | off += read_size; |
| 101 | dec_prog_cb((double)read_size); |
| 102 | } |
| 103 | exp->EndFile(); |
| 104 | |
| 105 | GLEAF_RC_SUCCEED; |
| 106 | } |
| 107 | |
| 108 | std::string ExportTicketCert(const u64 app_id, const bool export_cert) { |
| 109 | const auto tik_file = ReadTicket(app_id); |
no test coverage detected