From 5c7c8a4a5a82624a4ba1501e749168aeade7598d Mon Sep 17 00:00:00 2001 From: Nomi Date: Tue, 26 Sep 2023 03:31:55 +0200 Subject: [PATCH] Add error code for unimplemented NCCH archives --- src/core/fs/archive_ncch.cpp | 9 ++++----- src/core/kernel/file_operations.cpp | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/fs/archive_ncch.cpp b/src/core/fs/archive_ncch.cpp index db6ee337..8c3bd5e6 100644 --- a/src/core/fs/archive_ncch.cpp +++ b/src/core/fs/archive_ncch.cpp @@ -75,7 +75,6 @@ std::optional NCCHArchive::readFile(FileSession* file, u64 offset, u32 size const u32 highProgramID = *(u32*)&archivePath[4]; // High Title ID of the archive (from Citra). https://3dbrew.org/wiki/Title_list. - constexpr u32 systemApplication = 0x00040010; constexpr u32 sharedDataArchive = 0x0004009B; constexpr u32 systemDataArchive = 0x000400DB; @@ -86,17 +85,17 @@ std::optional NCCHArchive::readFile(FileSession* file, u64 offset, u32 size constexpr u32 sharedFont = 0x00014002; std::vector fileData; - if (highProgramID == systemApplication) { - Helpers::panic("[NCCH archive] Read from system application. ID: %08X", lowProgramID); - } else if (highProgramID == sharedDataArchive) { + if (highProgramID == sharedDataArchive) { if (lowProgramID == miiData) fileData = std::vector(std::begin(MII_DATA), std::end(MII_DATA)); else if (lowProgramID == regionManifest) fileData = std::vector(std::begin(COUNTRY_LIST_DATA), std::end(COUNTRY_LIST_DATA)); else Helpers::panic("[NCCH archive] Read unimplemented NAND file. ID: %08X", lowProgramID); } else if (highProgramID == systemDataArchive && lowProgramID == badWordList) { fileData = std::vector(std::begin(BAD_WORD_LIST_DATA), std::end(BAD_WORD_LIST_DATA)); } else { - Helpers::panic("[NCCH archive] Read from unimplemented NCCH archive file. High program ID: %08X, low ID: %08X", + Helpers::warn("[NCCH archive] Read from unimplemented NCCH archive file. High program ID: %08X, low ID: %08X", highProgramID, lowProgramID); + + return std::nullopt; } if (offset >= fileData.size()) { diff --git a/src/core/kernel/file_operations.cpp b/src/core/kernel/file_operations.cpp index c7837100..ea243663 100644 --- a/src/core/kernel/file_operations.cpp +++ b/src/core/kernel/file_operations.cpp @@ -111,7 +111,8 @@ void Kernel::readFile(u32 messagePointer, Handle fileHandle) { auto archive = file->archive; std::optional bytesRead = archive->readFile(file, offset, size, dataPointer); if (!bytesRead.has_value()) { - Helpers::panic("Kernel::ReadFile failed"); + Helpers::warn("Kernel::ReadFile failed"); + mem.write32(messagePointer + 4, 0xC8804478); } else { mem.write32(messagePointer + 4, Result::Success); mem.write32(messagePointer + 8, bytesRead.value());