Skip to content

Commit 5e48e29

Browse files
committed
PXI: Return proper "not found" error for titles that may not be present
This allows us to drop the ugly placeholder title workaround.
1 parent 30f678e commit 5e48e29

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

source/gui-sdl/main.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -310,15 +310,6 @@ if (bootstrap_nand) // Experimental system bootstrapper
310310
std::filesystem::copy( settings.get<Settings::PathImmutableDataDir>() + "/nand/title", content_dir,
311311
std::filesystem::copy_options::skip_existing | std::filesystem::copy_options::recursive);
312312

313-
// Initial system setup requires title 0004001000022400 to be present.
314-
// Normally, this is the Camera app, which isn't bundled in game update
315-
// partitions. Since the setup only reads the ExeFS icon that aren't
316-
// specific to the Camera app (likely to perform general checks), we
317-
// use the Download Play app as a drop-in replacement if needed.
318-
if (!std::filesystem::exists(content_dir / "00040010/00022400")) {
319-
std::filesystem::copy(content_dir / "00040010/00022100", content_dir / "00040010/00022400", std::filesystem::copy_options::recursive);
320-
}
321-
322313
std::filesystem::create_directories(content_dir / "ro/sys");
323314
std::filesystem::create_directories(content_dir / "rw/sys");
324315
std::filesystem::create_directories(content_dir / "twlp");

source/processes/pxi_fs.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,25 @@ class ArchiveProgramDataFromTitleId : public Archive {
605605
throw Mikage::Exceptions::Invalid("Invalid sub file type {}", sub_file_type);
606606
}
607607

608-
auto sub_file = OpenNCCHSubFile(thread, program_info, content_id, sub_file_type, std::basic_string_view<uint8_t> { path.data() + 0xc, 8 }, gamecard);
609-
return std::make_pair(RESULT_OK, std::move(sub_file));
608+
try {
609+
auto sub_file = OpenNCCHSubFile(thread, program_info, content_id, sub_file_type, std::basic_string_view<uint8_t> { path.data() + 0xc, 8 }, gamecard);
610+
return std::make_pair(RESULT_OK, std::move(sub_file));
611+
} catch (const std::runtime_error& err) {
612+
if (std::string_view { err.what() }.starts_with("Tried to access non-existing title")) {
613+
// Report "not found" for some specific titles that may be
614+
// probed by system titles but which won't be present after
615+
// NAND bootstrap from gamecard update partitions.
616+
// 0x4001000022400: Camera app, probed during initial system setup
617+
// 0x4003000009d02: Internet Browser, probed by HOME Menu on system version 9.2.0
618+
// 0x400300000ba02: In-app Miiverse posting applet, probed by HOME Menu on system versions >= 10.5.0
619+
if (program_info.program_id == 0x4001000022400 ||
620+
program_info.program_id == 0x4003000009d02 ||
621+
program_info.program_id == 0x400300000ba02) {
622+
return std::make_pair(0xc8804478, std::unique_ptr<File> { });
623+
}
624+
}
625+
throw;
626+
}
610627
}
611628

612629
public:
@@ -676,8 +693,7 @@ static std::tuple<Result, uint64_t> OpenFile(FakeThread& thread, Context& contex
676693
std::unique_ptr<File> file;
677694
std::tie(result,file) = archive->OpenFile(thread, common_path);
678695
if (result != RESULT_OK) {
679-
thread.GetLogger()->error("Failed to get file open handler");
680-
thread.CallSVC(&OSImpl::SVCBreak, OSImpl::BreakReason::Panic);
696+
return std::make_tuple(result, 0);
681697
}
682698

683699
// TODO: Respect flags & ~0x4 ... in particular, write/read-only!

0 commit comments

Comments
 (0)