summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar TheKoopaKingdom2017-04-13 01:18:54 -0400
committerGravatar TheKoopaKingdom2017-06-02 18:28:14 -0400
commita8aef599e02e336f9ecb8d5cfc50aa856ea0a1c7 (patch)
tree37a7edc6a27eff75c96117203f48c9f1ec640b97
parentOptimized messages that were repetitive and added ability for core errors to ... (diff)
downloadyuzu-a8aef599e02e336f9ecb8d5cfc50aa856ea0a1c7.tar.gz
yuzu-a8aef599e02e336f9ecb8d5cfc50aa856ea0a1c7.tar.xz
yuzu-a8aef599e02e336f9ecb8d5cfc50aa856ea0a1c7.zip
Created a whitelist of system archives to prevent false positives creating dialogs.
-rw-r--r--src/citra_qt/bootmanager.h2
-rw-r--r--src/citra_qt/main.cpp16
-rw-r--r--src/citra_qt/main.h3
-rw-r--r--src/core/core.cpp6
-rw-r--r--src/core/core.h12
-rw-r--r--src/core/hle/service/apt/apt.cpp5
-rw-r--r--src/core/hle/service/fs/fs_user.cpp55
-rw-r--r--src/core/loader/loader.h4
-rw-r--r--src/core/loader/ncch.h2
9 files changed, 70 insertions, 35 deletions
diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h
index b12b37132..4b3a3b3cc 100644
--- a/src/citra_qt/bootmanager.h
+++ b/src/citra_qt/bootmanager.h
@@ -99,7 +99,7 @@ signals:
99 */ 99 */
100 void DebugModeLeft(); 100 void DebugModeLeft();
101 101
102 void ErrorThrown(Core::System::ResultStatus, boost::optional<std::string>); 102 void ErrorThrown(Core::System::ResultStatus, std::string);
103}; 103};
104 104
105class GRenderWindow : public QWidget, public EmuWindow { 105class GRenderWindow : public QWidget, public EmuWindow {
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index 1688e55cd..e3b296188 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -553,10 +553,9 @@ void GMainWindow::OnMenuRecentFile() {
553void GMainWindow::OnStartGame() { 553void GMainWindow::OnStartGame() {
554 emu_thread->SetRunning(true); 554 emu_thread->SetRunning(true);
555 qRegisterMetaType<Core::System::ResultStatus>("Core::System::ResultStatus"); 555 qRegisterMetaType<Core::System::ResultStatus>("Core::System::ResultStatus");
556 qRegisterMetaType<boost::optional<std::string>>("boost::optional<std::string>"); 556 qRegisterMetaType<std::string>("std::string");
557 connect(emu_thread.get(), 557 connect(emu_thread.get(), SIGNAL(ErrorThrown(Core::System::ResultStatus, std::string)), this,
558 SIGNAL(ErrorThrown(Core::System::ResultStatus, boost::optional<std::string>)), this, 558 SLOT(OnCoreError(Core::System::ResultStatus, std::string)));
559 SLOT(OnCoreError(Core::System::ResultStatus, boost::optional<std::string>)));
560 559
561 ui.action_Start->setEnabled(false); 560 ui.action_Start->setEnabled(false);
562 ui.action_Start->setText(tr("Continue")); 561 ui.action_Start->setText(tr("Continue"));
@@ -649,8 +648,7 @@ void GMainWindow::UpdateStatusBar() {
649 emu_frametime_label->setVisible(true); 648 emu_frametime_label->setVisible(true);
650} 649}
651 650
652void GMainWindow::OnCoreError(Core::System::ResultStatus result, 651void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string details) {
653 boost::optional<std::string> details) {
654 QMessageBox::StandardButton answer; 652 QMessageBox::StandardButton answer;
655 QString status_message; 653 QString status_message;
656 const QString common_message = 654 const QString common_message =
@@ -664,8 +662,8 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result,
664 switch (result) { 662 switch (result) {
665 case Core::System::ResultStatus::ErrorSystemFiles: { 663 case Core::System::ResultStatus::ErrorSystemFiles: {
666 QString message = "Citra was unable to locate a 3DS system archive"; 664 QString message = "Citra was unable to locate a 3DS system archive";
667 if (details) 665 if (details != std::string())
668 message.append(tr(": %1. ").arg(details.get().c_str())); 666 message.append(tr(": %1. ").arg(details.c_str()));
669 else 667 else
670 message.append(". "); 668 message.append(". ");
671 message.append(common_message); 669 message.append(common_message);
@@ -693,7 +691,7 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result,
693 "<a href='https://community.citra-emu.org/t/how-to-upload-the-log-file/296'>How to " 691 "<a href='https://community.citra-emu.org/t/how-to-upload-the-log-file/296'>How to "
694 "Upload the Log File</a>.<br/><br/>Would you like to quit back to the game list?"), 692 "Upload the Log File</a>.<br/><br/>Would you like to quit back to the game list?"),
695 QMessageBox::Yes | QMessageBox::No, QMessageBox::No); 693 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
696 status_message = "Fatal Error encountered."; 694 status_message = "Fatal Error encountered";
697 break; 695 break;
698 } 696 }
699 697
diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h
index eb2b055f6..952a50974 100644
--- a/src/citra_qt/main.h
+++ b/src/citra_qt/main.h
@@ -8,6 +8,7 @@
8#include <memory> 8#include <memory>
9#include <QMainWindow> 9#include <QMainWindow>
10#include <QTimer> 10#include <QTimer>
11#include "core/core.h"
11#include "ui_main.h" 12#include "ui_main.h"
12 13
13class Config; 14class Config;
@@ -125,7 +126,7 @@ private slots:
125 void OnDisplayTitleBars(bool); 126 void OnDisplayTitleBars(bool);
126 void ToggleWindowMode(); 127 void ToggleWindowMode();
127 void OnCreateGraphicsSurfaceViewer(); 128 void OnCreateGraphicsSurfaceViewer();
128 void OnCoreError(Core::System::ResultStatus, boost::optional<std::string>); 129 void OnCoreError(Core::System::ResultStatus, std::string);
129 130
130private: 131private:
131 void UpdateStatusBar(); 132 void UpdateStatusBar();
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 2a9664cb4..2456d8aa2 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -4,9 +4,6 @@
4 4
5#include <memory> 5#include <memory>
6#include <utility> 6#include <utility>
7
8#include <boost/optional.hpp>
9
10#include "audio_core/audio_core.h" 7#include "audio_core/audio_core.h"
11#include "common/logging/log.h" 8#include "common/logging/log.h"
12#include "core/arm/arm_interface.h" 9#include "core/arm/arm_interface.h"
@@ -81,7 +78,8 @@ System::ResultStatus System::Load(EmuWindow* emu_window, const std::string& file
81 app_loader->LoadKernelSystemMode(); 78 app_loader->LoadKernelSystemMode();
82 79
83 if (system_mode.second != Loader::ResultStatus::Success) { 80 if (system_mode.second != Loader::ResultStatus::Success) {
84 LOG_CRITICAL(Core, "Failed to determine system mode (Error %i)!", system_mode.second); 81 LOG_CRITICAL(Core, "Failed to determine system mode (Error %i)!",
82 static_cast<int>(system_mode.second));
85 System::Shutdown(); 83 System::Shutdown();
86 84
87 switch (system_mode.second) { 85 switch (system_mode.second) {
diff --git a/src/core/core.h b/src/core/core.h
index bc363ed97..6e555f954 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -6,9 +6,6 @@
6 6
7#include <memory> 7#include <memory>
8#include <string> 8#include <string>
9
10#include <boost/optional.hpp>
11
12#include "common/common_types.h" 9#include "common/common_types.h"
13#include "core/memory.h" 10#include "core/memory.h"
14#include "core/perf_stats.h" 11#include "core/perf_stats.h"
@@ -117,13 +114,10 @@ public:
117 114
118 void SetStatus(ResultStatus new_status, std::string details = std::string()) { 115 void SetStatus(ResultStatus new_status, std::string details = std::string()) {
119 status = new_status; 116 status = new_status;
120 if (details == std::string()) 117 status_details = details;
121 status_details = boost::none;
122 else
123 status_details = details;
124 } 118 }
125 119
126 boost::optional<std::string> GetStatusDetails() { 120 std::string GetStatusDetails() {
127 return status_details; 121 return status_details;
128 } 122 }
129 123
@@ -154,7 +148,7 @@ private:
154 static System s_instance; 148 static System s_instance;
155 149
156 ResultStatus status; 150 ResultStatus status;
157 boost::optional<std::string> status_details; 151 std::string status_details;
158}; 152};
159 153
160inline ARM_Interface& CPU() { 154inline ARM_Interface& CPU() {
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) {
281 rb.Push(RESULT_SUCCESS); // No error 281 rb.Push(RESULT_SUCCESS); // No error
282 rb.Push(true); // Set to Success 282 rb.Push(true); // Set to Success
283 283
284 LOG_WARNING(Service_APT, 284 LOG_WARNING(Service_APT, "(STUBBED) called check_sender=0x%08X, sender_appid=0x%08X, "
285 "(STUBBED) called check_sender=0x%08X, sender_appid=0x%08X, " 285 "check_receiver=0x%08X, receiver_appid=0x%08X",
286 "check_receiver=0x%08X, receiver_appid=0x%08X",
287 check_sender, sender_appid, check_receiver, receiver_appid); 286 check_sender, sender_appid, check_receiver, receiver_appid);
288} 287}
289 288
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) {
130 130
131 ResultVal<ArchiveHandle> archive_handle = OpenArchive(archive_id, archive_path); 131 ResultVal<ArchiveHandle> archive_handle = OpenArchive(archive_id, archive_path);
132 if (archive_handle.Failed()) { 132 if (archive_handle.Failed()) {
133 LOG_ERROR(Service_FS,
134 "failed to get a handle for archive archive_id=0x%08X archive_path=%s",
135 static_cast<u32>(archive_id), archive_path.DebugStr().c_str());
136 cmd_buff[1] = archive_handle.Code().raw; 133 cmd_buff[1] = archive_handle.Code().raw;
137 cmd_buff[3] = 0; 134 cmd_buff[3] = 0;
135
138 if (static_cast<FS::ArchiveIdCode>(archive_id) == ArchiveIdCode::NCCH) { 136 if (static_cast<FS::ArchiveIdCode>(archive_id) == ArchiveIdCode::NCCH) {
139 Core::System::GetInstance().SetStatus(Core::System::ResultStatus::ErrorSystemFiles); 137 // High Title ID of the archive: The category (https://3dbrew.org/wiki/Title_list).
138 // (Note: The values there are big endian, these must be little endian.)
139 const std::vector<u8> shared_data_archive = {0x9B, 0x00, 0x04, 0x00};
140 const std::vector<u8> system_data_archive = {0xDB, 0x00, 0x04, 0x00};
141
142 // Low Title IDs.
143 const std::vector<u8> mii_data = {0x02, 0x02, 0x01, 0x00};
144 const std::vector<u8> region_manifest = {0x02, 0x04, 0x01, 0x00};
145 const std::vector<u8> ng_word_list = {0x02, 0x03, 0x01, 0x00};
146
147 // Make a copy of the binary path because reusing AsBinary() for creating category
148 // results in bad_alloc being thrown.
149 std::vector<u8> binary_archive_path = archive_path.AsBinary();
150 std::vector<u8> category(binary_archive_path.begin() + 4,
151 binary_archive_path.begin() + 8);
152 std::vector<u8> path(binary_archive_path.begin(), binary_archive_path.begin() + 4);
153
154 if (category == shared_data_archive) {
155 if (path == mii_data) {
156 LOG_ERROR(Service_FS,
157 "Failed to get a handle for shared data archive: Mii data. "
158 "Archive ID=0x%08X Archive Path=%s",
159 static_cast<u32>(archive_id), archive_path.DebugStr().c_str());
160 Core::System::GetInstance().SetStatus(
161 Core::System::ResultStatus::ErrorSystemFiles, "Mii data");
162 return;
163 } else if (path == region_manifest) {
164 LOG_ERROR(Service_FS,
165 "Failed to get a handle for shared data archive: region manifest. "
166 "Archive ID=0x%08X Archive Path=%s",
167 static_cast<u32>(archive_id), archive_path.DebugStr().c_str());
168 Core::System::GetInstance().SetStatus(
169 Core::System::ResultStatus::ErrorSystemFiles, "Region manifest");
170 return;
171 }
172 } else if (category == system_data_archive) {
173 if (path == ng_word_list) {
174 LOG_ERROR(Service_FS,
175 "Failed to get a handle for system data archive: NG bad word list. "
176 "Archive ID=0x%08X Archive Path=%s",
177 static_cast<u32>(archive_id), archive_path.DebugStr().c_str());
178 Core::System::GetInstance().SetStatus(
179 Core::System::ResultStatus::ErrorSystemFiles, "NG bad word list");
180 return;
181 }
182 }
140 } 183 }
184
185 LOG_ERROR(Service_FS,
186 "Failed to get a handle for archive archive_id=0x%08X archive_path=%s",
187 static_cast<u32>(archive_id), archive_path.DebugStr().c_str());
141 return; 188 return;
142 } 189 }
143 SCOPE_EXIT({ CloseArchive(*archive_handle); }); 190 SCOPE_EXIT({ CloseArchive(*archive_handle); });
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h
index 0a2d4a10e..adb3ffdcf 100644
--- a/src/core/loader/loader.h
+++ b/src/core/loader/loader.h
@@ -10,9 +10,7 @@
10#include <string> 10#include <string>
11#include <utility> 11#include <utility>
12#include <vector> 12#include <vector>
13
14#include <boost/optional.hpp> 13#include <boost/optional.hpp>
15
16#include "common/common_types.h" 14#include "common/common_types.h"
17#include "common/file_util.h" 15#include "common/file_util.h"
18 16
@@ -103,7 +101,7 @@ public:
103 * Loads the system mode that this application needs. 101 * Loads the system mode that this application needs.
104 * This function defaults to 2 (96MB allocated to the application) if it can't read the 102 * This function defaults to 2 (96MB allocated to the application) if it can't read the
105 * information. 103 * information.
106 * @return A pair with the system mode (If found) and the result. 104 * @returns a pair of Optional with the kernel system mode and ResultStatus.
107 */ 105 */
108 virtual std::pair<boost::optional<u32>, ResultStatus> LoadKernelSystemMode() { 106 virtual std::pair<boost::optional<u32>, ResultStatus> LoadKernelSystemMode() {
109 // 96MB allocated to the application. 107 // 96MB allocated to the application.
diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h
index 712d496a4..507da7550 100644
--- a/src/core/loader/ncch.h
+++ b/src/core/loader/ncch.h
@@ -179,7 +179,7 @@ public:
179 179
180 /** 180 /**
181 * Loads the Exheader and returns the system mode for this application. 181 * Loads the Exheader and returns the system mode for this application.
182 * @return A pair with the system mode (If found) and the result. 182 * @returns a pair of Optional with the kernel system mode and ResultStatus
183 */ 183 */
184 std::pair<boost::optional<u32>, ResultStatus> LoadKernelSystemMode() override; 184 std::pair<boost::optional<u32>, ResultStatus> LoadKernelSystemMode() override;
185 185