| 82 | fs::file make_file_view(fs::file &&file, u64 offset, u64 size); |
| 83 | |
| 84 | std::function<void(void *)> lv2_overlay::load(utils::serial &ar) { |
| 85 | const std::string vpath = ar.pop<std::string>(); |
| 86 | const std::string path = vfs::get(vpath); |
| 87 | const s64 offset = ar.pop<s64>(); |
| 88 | |
| 89 | sys_overlay.success("lv2_overlay::load(): vpath='%s', path='%s', offset=0x%x", |
| 90 | vpath, path, offset); |
| 91 | |
| 92 | shared_ptr<lv2_overlay> ovlm; |
| 93 | |
| 94 | fs::file file{path.substr( |
| 95 | 0, path.size() - (offset ? fmt::format("_x%x", offset).size() : 0))}; |
| 96 | |
| 97 | if (file) { |
| 98 | u128 klic = g_fxo->get<loaded_npdrm_keys>().last_key(); |
| 99 | file = make_file_view(std::move(file), offset, umax); |
| 100 | ovlm = |
| 101 | ppu_load_overlay(ppu_exec_object{decrypt_self( |
| 102 | std::move(file), reinterpret_cast<u8 *>(&klic))}, |
| 103 | false, path, 0, &ar) |
| 104 | .first; |
| 105 | |
| 106 | if (!ovlm) { |
| 107 | fmt::throw_exception("lv2_overlay::load(): ppu_load_overlay() failed. " |
| 108 | "(vpath='%s', offset=0x%x)", |
| 109 | vpath, offset); |
| 110 | } |
| 111 | } else if (!g_cfg.savestate.state_inspection_mode.get()) { |
| 112 | fmt::throw_exception( |
| 113 | "lv2_overlay::load(): Failed to find file. (vpath='%s', offset=0x%x)", |
| 114 | vpath, offset); |
| 115 | } else { |
| 116 | sys_overlay.error( |
| 117 | "lv2_overlay::load(): Failed to find file. (vpath='%s', offset=0x%x)", |
| 118 | vpath, offset); |
| 119 | } |
| 120 | |
| 121 | return [ovlm](void *storage) { |
| 122 | *static_cast<atomic_ptr<lv2_obj> *>(storage) = ovlm; |
| 123 | }; |
| 124 | } |
| 125 | |
| 126 | void lv2_overlay::save(utils::serial &ar) { |
| 127 | USING_SERIALIZATION_VERSION(lv2_prx_overlay); |
nothing calls this directly
no test coverage detected