From 6cf1a1c1f5a8f913c8de120cbd56e1f99f156148 Mon Sep 17 00:00:00 2001
From: PabloMK7
Date: Sun, 9 Mar 2025 13:26:18 +0100
Subject: [PATCH] Fix CIA installation and HLE module loading when no console
unique data provided.
---
src/citra_qt/citra_qt.cpp | 1 +
.../configuration/configure_system.cpp | 2 +-
src/common/settings.cpp | 1 -
src/core/hle/service/am/am.cpp | 25 ++++++++++++-------
src/core/hle/service/am/am.h | 6 ++---
src/core/hle/service/cfg/cfg.h | 2 +-
src/core/hle/service/service.cpp | 9 ++++++-
src/core/system_titles.h | 2 +-
8 files changed, 31 insertions(+), 17 deletions(-)
diff --git a/src/citra_qt/citra_qt.cpp b/src/citra_qt/citra_qt.cpp
index 56e0b8392..b0148ba27 100644
--- a/src/citra_qt/citra_qt.cpp
+++ b/src/citra_qt/citra_qt.cpp
@@ -2212,6 +2212,7 @@ void GMainWindow::OnMenuSetUpSystemFiles() {
"work.Both setup modes will work regardless of the model of the console "
"running the setup tool.
"),
&dialog);
+ label_description.setOpenExternalLinks(true);
layout.addWidget(&label_description);
QHBoxLayout layout_h(&dialog);
diff --git a/src/citra_qt/configuration/configure_system.cpp b/src/citra_qt/configuration/configure_system.cpp
index f17f79db6..920e1ce70 100644
--- a/src/citra_qt/configuration/configure_system.cpp
+++ b/src/citra_qt/configuration/configure_system.cpp
@@ -541,7 +541,7 @@ void ConfigureSystem::RefreshConsoleID() {
void ConfigureSystem::RefreshMAC() {
QMessageBox::StandardButton reply;
- QString warning_text = tr("This will replace your current MAC with a new one. "
+ QString warning_text = tr("This will replace your current MAC address with a new one. "
"It is not recommended to do this if you got the MAC address from "
"your real console using the setup tool. Continue?");
reply =
diff --git a/src/common/settings.cpp b/src/common/settings.cpp
index 7c0b5b692..c26771018 100644
--- a/src/common/settings.cpp
+++ b/src/common/settings.cpp
@@ -4,7 +4,6 @@
#include
#include
-#include
#include "audio_core/dsp_interface.h"
#include "common/file_util.h"
#include "common/settings.h"
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index 324d124af..fe693e7e9 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -94,12 +94,17 @@ public:
std::vector::Decryption> content;
};
-NCCHCryptoFile::NCCHCryptoFile(const std::string& out_file) {
- // A console unique crypto file is used to store the decrypted NCCH file. This is done
- // to prevent Azahar being used as a tool to download easy shareable decrypted contents
- // from the eshop.
- file = HW::UniqueData::OpenUniqueCryptoFile(out_file, "wb",
- HW::UniqueData::UniqueCryptoFileID::NCCH);
+NCCHCryptoFile::NCCHCryptoFile(const std::string& out_file, bool encrypted_content) {
+ if (encrypted_content) {
+ // A console unique crypto file is used to store the decrypted NCCH file. This is done
+ // to prevent Azahar being used as a tool to download easy shareable decrypted contents
+ // from the eshop.
+ file = HW::UniqueData::OpenUniqueCryptoFile(out_file, "wb",
+ HW::UniqueData::UniqueCryptoFileID::NCCH);
+ } else {
+ file = std::make_unique(out_file, "wb");
+ }
+
if (!file->IsOpen()) {
is_error = true;
}
@@ -573,7 +578,8 @@ ResultVal CIAFile::WriteContentData(u64 offset, std::size_t length,
const FileSys::TitleMetadata& tmd = container.GetTitleMetadata();
if (i != current_content_index) {
current_content_index = static_cast(i);
- current_content_file = std::make_unique(content_file_paths[i]);
+ current_content_file =
+ std::make_unique(content_file_paths[i], decryption_authorized);
current_content_file->decryption_authorized = decryption_authorized;
}
auto& file = *current_content_file;
@@ -709,7 +715,8 @@ ResultVal CIAFile::WriteContentDataIndexed(u16 content_index, u64 o
if (content_index != current_content_index) {
current_content_index = content_index;
- current_content_file = std::make_unique(content_file_paths[content_index]);
+ current_content_file = std::make_unique(content_file_paths[content_index],
+ decryption_authorized);
current_content_file->decryption_authorized = decryption_authorized;
}
auto& file = *current_content_file;
@@ -1771,7 +1778,7 @@ void Module::Interface::GetProgramInfosImpl(Kernel::HLERequestContext& ctx, bool
// found. However, since GetTitleInfoFromList does not care if the program was commited and
// only checks for the tmd, it will detect the title and return information while it
// shouldn't. To prevent this, we check if the importing context is present and not
- // committed If that's the case return not found
+ // committed. If that's the case, return not found
Result result = ResultSuccess;
for (auto tid : title_id_list) {
for (auto& import_ctx : am->import_title_contexts) {
diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h
index d45f621dd..e3fcbacf0 100644
--- a/src/core/hle/service/am/am.h
+++ b/src/core/hle/service/am/am.h
@@ -112,7 +112,7 @@ using ProgressCallback = void(std::size_t, std::size_t);
class NCCHCryptoFile final {
public:
- NCCHCryptoFile(const std::string& out_file);
+ NCCHCryptoFile(const std::string& out_file, bool encrypted_content);
void Write(const u8* buffer, std::size_t length);
bool IsError() {
@@ -128,7 +128,7 @@ private:
std::size_t written = 0;
- NCCH_Header ncch_header;
+ NCCH_Header ncch_header{};
std::size_t header_size = 0;
bool header_parsed = false;
@@ -156,7 +156,7 @@ private:
std::vector regions;
- ExeFs_Header exefs_header;
+ ExeFs_Header exefs_header{};
std::size_t exefs_header_written = 0;
bool exefs_header_processed = false;
};
diff --git a/src/core/hle/service/cfg/cfg.h b/src/core/hle/service/cfg/cfg.h
index c04ca58a5..32b1dd40c 100644
--- a/src/core/hle/service/cfg/cfg.h
+++ b/src/core/hle/service/cfg/cfg.h
@@ -628,7 +628,7 @@ public:
std::string& GetMacAddress();
/**
- *
+ * Saves the current MAC address to the filesystem
*/
void SaveMacAddress();
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 1931e7fef..68e1bfa47 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -207,7 +207,14 @@ static bool AttemptLLE(const ServiceModuleInfo& service_module) {
return false;
}
std::shared_ptr process;
- loader->Load(process);
+ Loader::ResultStatus load_result = loader->Load(process);
+ if (load_result != Loader::ResultStatus::Success) {
+ LOG_ERROR(Service,
+ "Service module \"{}\" could not be loaded (ResultStatus={}); Defaulting to HLE "
+ "implementation.",
+ service_module.name, static_cast(load_result));
+ return false;
+ }
LOG_DEBUG(Service, "Service module \"{}\" has been successfully loaded.", service_module.name);
return true;
}
diff --git a/src/core/system_titles.h b/src/core/system_titles.h
index 366fda928..9eb7caab8 100644
--- a/src/core/system_titles.h
+++ b/src/core/system_titles.h
@@ -5,7 +5,7 @@
#pragma once
#include
-#include
+#include
#include
#include "common/common_types.h"