| 26 | LOG_CHANNEL(sys_overlay); |
| 27 | |
| 28 | static error_code overlay_load_module(vm::ptr<u32> ovlmid, |
| 29 | const std::string &vpath, u64 /*flags*/, |
| 30 | vm::ptr<u32> entry, fs::file src = {}, |
| 31 | s64 file_offset = 0) { |
| 32 | if (!src) { |
| 33 | auto [fs_error, ppath, path, lv2_file, type] = lv2_file::open(vpath, 0, 0); |
| 34 | |
| 35 | if (fs_error) { |
| 36 | return {fs_error, vpath}; |
| 37 | } |
| 38 | |
| 39 | src = std::move(lv2_file); |
| 40 | } |
| 41 | |
| 42 | u128 klic = g_fxo->get<loaded_npdrm_keys>().last_key(); |
| 43 | |
| 44 | src = decrypt_self(std::move(src), reinterpret_cast<u8 *>(&klic)); |
| 45 | |
| 46 | if (!src) { |
| 47 | return {CELL_ENOEXEC, +"Failed to decrypt file"}; |
| 48 | } |
| 49 | |
| 50 | ppu_exec_object obj = std::move(src); |
| 51 | src.close(); |
| 52 | |
| 53 | if (obj != elf_error::ok) { |
| 54 | return {CELL_ENOEXEC, obj.operator elf_error()}; |
| 55 | } |
| 56 | |
| 57 | const auto [ovlm, error] = |
| 58 | ppu_load_overlay(obj, false, vfs::get(vpath), file_offset); |
| 59 | |
| 60 | obj.clear(); |
| 61 | |
| 62 | if (error) { |
| 63 | if (error == CELL_CANCEL + 0u) { |
| 64 | // Emulation stopped |
| 65 | return {}; |
| 66 | } |
| 67 | |
| 68 | return error; |
| 69 | } |
| 70 | |
| 71 | ppu_initialize(*ovlm); |
| 72 | |
| 73 | sys_overlay.success("Loaded overlay: \"%s\" (id=0x%x)", vpath, |
| 74 | idm::last_id()); |
| 75 | |
| 76 | *ovlmid = idm::last_id(); |
| 77 | *entry = ovlm->entry; |
| 78 | |
| 79 | return CELL_OK; |
| 80 | } |
| 81 | |
| 82 | fs::file make_file_view(fs::file &&file, u64 offset, u64 size); |
| 83 |
no test coverage detected