From 1ecb322daa0e2521fe0e179e87889db9aaaf63b0 Mon Sep 17 00:00:00 2001 From: TheKoopaKingdom Date: Wed, 8 Mar 2017 16:28:30 -0500 Subject: Added system for handling core errors in citra-qt. --- src/core/hle/service/apt/apt.cpp | 7 +++++-- src/core/hle/service/err_f.cpp | 2 ++ src/core/hle/service/fs/fs_user.cpp | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src/core/hle') diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index 366d1eacf..a92abb58f 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -5,6 +5,7 @@ #include "common/common_paths.h" #include "common/file_util.h" #include "common/logging/log.h" +#include "core/core.h" #include "core/hle/applets/applet.h" #include "core/hle/kernel/event.h" #include "core/hle/kernel/mutex.h" @@ -74,6 +75,7 @@ void GetSharedFont(Service::Interface* self) { LOG_ERROR(Service_APT, "shared font file missing - go dump it from your 3ds"); rb.Push(-1); // TODO: Find the right error code rb.Skip(1 + 2, true); + Core::System::GetInstance().SetStatus(Core::System::ResultStatus::ErrorSharedFont); return; } @@ -279,8 +281,9 @@ void CancelParameter(Service::Interface* self) { rb.Push(RESULT_SUCCESS); // No error rb.Push(true); // Set to Success - LOG_WARNING(Service_APT, "(STUBBED) called check_sender=0x%08X, sender_appid=0x%08X, " - "check_receiver=0x%08X, receiver_appid=0x%08X", + LOG_WARNING(Service_APT, + "(STUBBED) called check_sender=0x%08X, sender_appid=0x%08X, " + "check_receiver=0x%08X, receiver_appid=0x%08X", check_sender, sender_appid, check_receiver, receiver_appid); } diff --git a/src/core/hle/service/err_f.cpp b/src/core/hle/service/err_f.cpp index 9da55f328..4f4dc6dc7 100644 --- a/src/core/hle/service/err_f.cpp +++ b/src/core/hle/service/err_f.cpp @@ -10,6 +10,7 @@ #include "common/bit_field.h" #include "common/common_types.h" #include "common/logging/log.h" +#include "core/core.h" #include "core/hle/result.h" #include "core/hle/service/err_f.h" @@ -172,6 +173,7 @@ static void ThrowFatalError(Interface* self) { const ErrInfo* errinfo = reinterpret_cast(&cmd_buff[1]); LOG_CRITICAL(Service_ERR, "Fatal error type: %s", GetErrType(errinfo->errinfo_common.specifier).c_str()); + Core::System::GetInstance().SetStatus(Core::System::ResultStatus::ErrorUnknown); // Generic Info LogGenericInfo(errinfo->errinfo_common); diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index e53a970d3..5a4437123 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -8,6 +8,7 @@ #include "common/logging/log.h" #include "common/scope_exit.h" #include "common/string_util.h" +#include "core/core.h" #include "core/file_sys/errors.h" #include "core/hle/kernel/client_session.h" #include "core/hle/result.h" @@ -132,6 +133,10 @@ static void OpenFileDirectly(Service::Interface* self) { LOG_ERROR(Service_FS, "failed to get a handle for archive archive_id=0x%08X archive_path=%s", static_cast(archive_id), archive_path.DebugStr().c_str()); + if (static_cast(archive_id) == 0x2345678A) { + Core::System::GetInstance().SetStatus(Core::System::ResultStatus::ErrorSystemFiles); + return; + } cmd_buff[1] = archive_handle.Code().raw; cmd_buff[3] = 0; return; -- cgit v1.2.3 From 37bec598ea28662462dcaab65d5abd6db8372dbc Mon Sep 17 00:00:00 2001 From: TheKoopaKingdom Date: Wed, 8 Mar 2017 20:21:31 -0500 Subject: Made some changes from review comments: - Made LoadKernelSystemMode return a pair consisting of a system mode and a result code (Could use review). - Deleted ErrorOpenGL error code in favor of just having ErrorVideoCore. - Made dialog messages more clear. - Compared archive ID in fs_user.cpp to ArchiveIdCode::NCCH as opposed to hex magic. - Cleaned up some other stuff. --- src/core/hle/service/fs/archive.cpp | 8 +++----- src/core/hle/service/fs/fs_user.cpp | 7 +++---- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'src/core/hle') diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 632712f2c..6d1a49d92 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp @@ -257,11 +257,9 @@ ResultVal OpenArchive(ArchiveIdCode id_code, FileSys::Path& archi LOG_TRACE(Service_FS, "Opening archive with id code 0x%08X", id_code); auto itr = id_code_map.find(id_code); - if (itr == id_code_map.end()) { - // TODO: Verify error against hardware - return ResultCode(ErrorDescription::NotFound, ErrorModule::FS, ErrorSummary::NotFound, - ErrorLevel::Permanent); - } + if (itr == id_code_map.end()) + return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS, ErrorSummary::NotFound, + ErrorLevel::Status); CASCADE_RESULT(std::unique_ptr res, itr->second->Open(archive_path)); diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 5a4437123..0538ffc9c 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -133,12 +133,11 @@ static void OpenFileDirectly(Service::Interface* self) { LOG_ERROR(Service_FS, "failed to get a handle for archive archive_id=0x%08X archive_path=%s", static_cast(archive_id), archive_path.DebugStr().c_str()); - if (static_cast(archive_id) == 0x2345678A) { - Core::System::GetInstance().SetStatus(Core::System::ResultStatus::ErrorSystemFiles); - return; - } cmd_buff[1] = archive_handle.Code().raw; cmd_buff[3] = 0; + if (static_cast(archive_id) == ArchiveIdCode::NCCH) { + Core::System::GetInstance().SetStatus(Core::System::ResultStatus::ErrorSystemFiles); + } return; } SCOPE_EXIT({ CloseArchive(*archive_handle); }); -- cgit v1.2.3 From a8aef599e02e336f9ecb8d5cfc50aa856ea0a1c7 Mon Sep 17 00:00:00 2001 From: TheKoopaKingdom Date: Thu, 13 Apr 2017 01:18:54 -0400 Subject: Created a whitelist of system archives to prevent false positives creating dialogs. --- src/core/hle/service/apt/apt.cpp | 5 ++-- src/core/hle/service/fs/fs_user.cpp | 55 ++++++++++++++++++++++++++++++++++--- 2 files changed, 53 insertions(+), 7 deletions(-) (limited to 'src/core/hle') diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index a92abb58f..4c587e3c8 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -281,9 +281,8 @@ void CancelParameter(Service::Interface* self) { rb.Push(RESULT_SUCCESS); // No error rb.Push(true); // Set to Success - LOG_WARNING(Service_APT, - "(STUBBED) called check_sender=0x%08X, sender_appid=0x%08X, " - "check_receiver=0x%08X, receiver_appid=0x%08X", + LOG_WARNING(Service_APT, "(STUBBED) called check_sender=0x%08X, sender_appid=0x%08X, " + "check_receiver=0x%08X, receiver_appid=0x%08X", check_sender, sender_appid, check_receiver, receiver_appid); } diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 0538ffc9c..c65d46238 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -130,14 +130,61 @@ static void OpenFileDirectly(Service::Interface* self) { ResultVal archive_handle = OpenArchive(archive_id, archive_path); if (archive_handle.Failed()) { - LOG_ERROR(Service_FS, - "failed to get a handle for archive archive_id=0x%08X archive_path=%s", - static_cast(archive_id), archive_path.DebugStr().c_str()); cmd_buff[1] = archive_handle.Code().raw; cmd_buff[3] = 0; + if (static_cast(archive_id) == ArchiveIdCode::NCCH) { - Core::System::GetInstance().SetStatus(Core::System::ResultStatus::ErrorSystemFiles); + // High Title ID of the archive: The category (https://3dbrew.org/wiki/Title_list). + // (Note: The values there are big endian, these must be little endian.) + const std::vector shared_data_archive = {0x9B, 0x00, 0x04, 0x00}; + const std::vector system_data_archive = {0xDB, 0x00, 0x04, 0x00}; + + // Low Title IDs. + const std::vector mii_data = {0x02, 0x02, 0x01, 0x00}; + const std::vector region_manifest = {0x02, 0x04, 0x01, 0x00}; + const std::vector ng_word_list = {0x02, 0x03, 0x01, 0x00}; + + // Make a copy of the binary path because reusing AsBinary() for creating category + // results in bad_alloc being thrown. + std::vector binary_archive_path = archive_path.AsBinary(); + std::vector category(binary_archive_path.begin() + 4, + binary_archive_path.begin() + 8); + std::vector path(binary_archive_path.begin(), binary_archive_path.begin() + 4); + + if (category == shared_data_archive) { + if (path == mii_data) { + LOG_ERROR(Service_FS, + "Failed to get a handle for shared data archive: Mii data. " + "Archive ID=0x%08X Archive Path=%s", + static_cast(archive_id), archive_path.DebugStr().c_str()); + Core::System::GetInstance().SetStatus( + Core::System::ResultStatus::ErrorSystemFiles, "Mii data"); + return; + } else if (path == region_manifest) { + LOG_ERROR(Service_FS, + "Failed to get a handle for shared data archive: region manifest. " + "Archive ID=0x%08X Archive Path=%s", + static_cast(archive_id), archive_path.DebugStr().c_str()); + Core::System::GetInstance().SetStatus( + Core::System::ResultStatus::ErrorSystemFiles, "Region manifest"); + return; + } + } else if (category == system_data_archive) { + if (path == ng_word_list) { + LOG_ERROR(Service_FS, + "Failed to get a handle for system data archive: NG bad word list. " + "Archive ID=0x%08X Archive Path=%s", + static_cast(archive_id), archive_path.DebugStr().c_str()); + Core::System::GetInstance().SetStatus( + Core::System::ResultStatus::ErrorSystemFiles, "NG bad word list"); + return; + } + } } + + LOG_ERROR(Service_FS, + "Failed to get a handle for archive archive_id=0x%08X archive_path=%s", + static_cast(archive_id), archive_path.DebugStr().c_str()); return; } SCOPE_EXIT({ CloseArchive(*archive_handle); }); -- cgit v1.2.3 From cea19fd659496bcdf09a12b163ce490c1fa71ff7 Mon Sep 17 00:00:00 2001 From: TheKoopaKingdom Date: Tue, 23 May 2017 19:46:30 -0400 Subject: Moved whitelist checks from FS_User to the Archive_NCCH handler. --- src/core/hle/service/fs/fs_user.cpp | 54 ++----------------------------------- 1 file changed, 2 insertions(+), 52 deletions(-) (limited to 'src/core/hle') diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index c65d46238..c1825e9c8 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -130,61 +130,11 @@ static void OpenFileDirectly(Service::Interface* self) { ResultVal archive_handle = OpenArchive(archive_id, archive_path); if (archive_handle.Failed()) { - cmd_buff[1] = archive_handle.Code().raw; - cmd_buff[3] = 0; - - if (static_cast(archive_id) == ArchiveIdCode::NCCH) { - // High Title ID of the archive: The category (https://3dbrew.org/wiki/Title_list). - // (Note: The values there are big endian, these must be little endian.) - const std::vector shared_data_archive = {0x9B, 0x00, 0x04, 0x00}; - const std::vector system_data_archive = {0xDB, 0x00, 0x04, 0x00}; - - // Low Title IDs. - const std::vector mii_data = {0x02, 0x02, 0x01, 0x00}; - const std::vector region_manifest = {0x02, 0x04, 0x01, 0x00}; - const std::vector ng_word_list = {0x02, 0x03, 0x01, 0x00}; - - // Make a copy of the binary path because reusing AsBinary() for creating category - // results in bad_alloc being thrown. - std::vector binary_archive_path = archive_path.AsBinary(); - std::vector category(binary_archive_path.begin() + 4, - binary_archive_path.begin() + 8); - std::vector path(binary_archive_path.begin(), binary_archive_path.begin() + 4); - - if (category == shared_data_archive) { - if (path == mii_data) { - LOG_ERROR(Service_FS, - "Failed to get a handle for shared data archive: Mii data. " - "Archive ID=0x%08X Archive Path=%s", - static_cast(archive_id), archive_path.DebugStr().c_str()); - Core::System::GetInstance().SetStatus( - Core::System::ResultStatus::ErrorSystemFiles, "Mii data"); - return; - } else if (path == region_manifest) { - LOG_ERROR(Service_FS, - "Failed to get a handle for shared data archive: region manifest. " - "Archive ID=0x%08X Archive Path=%s", - static_cast(archive_id), archive_path.DebugStr().c_str()); - Core::System::GetInstance().SetStatus( - Core::System::ResultStatus::ErrorSystemFiles, "Region manifest"); - return; - } - } else if (category == system_data_archive) { - if (path == ng_word_list) { - LOG_ERROR(Service_FS, - "Failed to get a handle for system data archive: NG bad word list. " - "Archive ID=0x%08X Archive Path=%s", - static_cast(archive_id), archive_path.DebugStr().c_str()); - Core::System::GetInstance().SetStatus( - Core::System::ResultStatus::ErrorSystemFiles, "NG bad word list"); - return; - } - } - } - LOG_ERROR(Service_FS, "Failed to get a handle for archive archive_id=0x%08X archive_path=%s", static_cast(archive_id), archive_path.DebugStr().c_str()); + cmd_buff[1] = archive_handle.Code().raw; + cmd_buff[3] = 0; return; } SCOPE_EXIT({ CloseArchive(*archive_handle); }); -- cgit v1.2.3 From 59de38b96525d1230df07de3d6cda422421fd883 Mon Sep 17 00:00:00 2001 From: TheKoopaKingdom Date: Wed, 24 May 2017 19:51:31 -0400 Subject: Switched to the ERROR_NOT_FOUND constant from errors.h. --- src/core/hle/service/fs/archive.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/core/hle') diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 6d1a49d92..40d52f54b 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp @@ -258,8 +258,7 @@ ResultVal OpenArchive(ArchiveIdCode id_code, FileSys::Path& archi auto itr = id_code_map.find(id_code); if (itr == id_code_map.end()) - return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS, ErrorSummary::NotFound, - ErrorLevel::Status); + return FileSys::ERROR_NOT_FOUND; CASCADE_RESULT(std::unique_ptr res, itr->second->Open(archive_path)); -- cgit v1.2.3 From f008b22e3b2baa7720ea65c320fe49929a53bad7 Mon Sep 17 00:00:00 2001 From: TheKoopaKingdom Date: Fri, 2 Jun 2017 17:03:38 -0400 Subject: Addressed Bunnei's review comments, and made some other tweaks: - Deleted GetStatus() because it wasn't used anywhere outside of Core::System. - Fixed design flaw where the message bar status could be set despite the game being stopped. --- src/core/hle/service/fs/archive.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/core/hle') diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 40d52f54b..21929e966 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp @@ -257,8 +257,9 @@ ResultVal OpenArchive(ArchiveIdCode id_code, FileSys::Path& archi LOG_TRACE(Service_FS, "Opening archive with id code 0x%08X", id_code); auto itr = id_code_map.find(id_code); - if (itr == id_code_map.end()) + if (itr == id_code_map.end()) { return FileSys::ERROR_NOT_FOUND; + } CASCADE_RESULT(std::unique_ptr res, itr->second->Open(archive_path)); -- cgit v1.2.3