Fix CIA installation and HLE module loading when no console unique data provided.

This commit is contained in:
PabloMK7 2025-03-09 13:26:18 +01:00
parent 16519e055e
commit 6cf1a1c1f5
8 changed files with 31 additions and 17 deletions

View File

@ -2212,6 +2212,7 @@ void GMainWindow::OnMenuSetUpSystemFiles() {
"work.</li><li>Both setup modes will work regardless of the model of the console " "work.</li><li>Both setup modes will work regardless of the model of the console "
"running the setup tool.</li></ul><hr></p>"), "running the setup tool.</li></ul><hr></p>"),
&dialog); &dialog);
label_description.setOpenExternalLinks(true);
layout.addWidget(&label_description); layout.addWidget(&label_description);
QHBoxLayout layout_h(&dialog); QHBoxLayout layout_h(&dialog);

View File

@ -541,7 +541,7 @@ void ConfigureSystem::RefreshConsoleID() {
void ConfigureSystem::RefreshMAC() { void ConfigureSystem::RefreshMAC() {
QMessageBox::StandardButton reply; 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 " "It is not recommended to do this if you got the MAC address from "
"your real console using the setup tool. Continue?"); "your real console using the setup tool. Continue?");
reply = reply =

View File

@ -4,7 +4,6 @@
#include <string_view> #include <string_view>
#include <utility> #include <utility>
#include <cryptopp/osrng.h>
#include "audio_core/dsp_interface.h" #include "audio_core/dsp_interface.h"
#include "common/file_util.h" #include "common/file_util.h"
#include "common/settings.h" #include "common/settings.h"

View File

@ -94,12 +94,17 @@ public:
std::vector<CryptoPP::CBC_Mode<CryptoPP::AES>::Decryption> content; std::vector<CryptoPP::CBC_Mode<CryptoPP::AES>::Decryption> content;
}; };
NCCHCryptoFile::NCCHCryptoFile(const std::string& out_file) { NCCHCryptoFile::NCCHCryptoFile(const std::string& out_file, bool encrypted_content) {
// A console unique crypto file is used to store the decrypted NCCH file. This is done if (encrypted_content) {
// to prevent Azahar being used as a tool to download easy shareable decrypted contents // A console unique crypto file is used to store the decrypted NCCH file. This is done
// from the eshop. // to prevent Azahar being used as a tool to download easy shareable decrypted contents
file = HW::UniqueData::OpenUniqueCryptoFile(out_file, "wb", // from the eshop.
HW::UniqueData::UniqueCryptoFileID::NCCH); file = HW::UniqueData::OpenUniqueCryptoFile(out_file, "wb",
HW::UniqueData::UniqueCryptoFileID::NCCH);
} else {
file = std::make_unique<FileUtil::IOFile>(out_file, "wb");
}
if (!file->IsOpen()) { if (!file->IsOpen()) {
is_error = true; is_error = true;
} }
@ -573,7 +578,8 @@ ResultVal<std::size_t> CIAFile::WriteContentData(u64 offset, std::size_t length,
const FileSys::TitleMetadata& tmd = container.GetTitleMetadata(); const FileSys::TitleMetadata& tmd = container.GetTitleMetadata();
if (i != current_content_index) { if (i != current_content_index) {
current_content_index = static_cast<u16>(i); current_content_index = static_cast<u16>(i);
current_content_file = std::make_unique<NCCHCryptoFile>(content_file_paths[i]); current_content_file =
std::make_unique<NCCHCryptoFile>(content_file_paths[i], decryption_authorized);
current_content_file->decryption_authorized = decryption_authorized; current_content_file->decryption_authorized = decryption_authorized;
} }
auto& file = *current_content_file; auto& file = *current_content_file;
@ -709,7 +715,8 @@ ResultVal<std::size_t> CIAFile::WriteContentDataIndexed(u16 content_index, u64 o
if (content_index != current_content_index) { if (content_index != current_content_index) {
current_content_index = content_index; current_content_index = content_index;
current_content_file = std::make_unique<NCCHCryptoFile>(content_file_paths[content_index]); current_content_file = std::make_unique<NCCHCryptoFile>(content_file_paths[content_index],
decryption_authorized);
current_content_file->decryption_authorized = decryption_authorized; current_content_file->decryption_authorized = decryption_authorized;
} }
auto& file = *current_content_file; 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 // 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 // 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 // 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; Result result = ResultSuccess;
for (auto tid : title_id_list) { for (auto tid : title_id_list) {
for (auto& import_ctx : am->import_title_contexts) { for (auto& import_ctx : am->import_title_contexts) {

View File

@ -112,7 +112,7 @@ using ProgressCallback = void(std::size_t, std::size_t);
class NCCHCryptoFile final { class NCCHCryptoFile final {
public: 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); void Write(const u8* buffer, std::size_t length);
bool IsError() { bool IsError() {
@ -128,7 +128,7 @@ private:
std::size_t written = 0; std::size_t written = 0;
NCCH_Header ncch_header; NCCH_Header ncch_header{};
std::size_t header_size = 0; std::size_t header_size = 0;
bool header_parsed = false; bool header_parsed = false;
@ -156,7 +156,7 @@ private:
std::vector<CryptoRegion> regions; std::vector<CryptoRegion> regions;
ExeFs_Header exefs_header; ExeFs_Header exefs_header{};
std::size_t exefs_header_written = 0; std::size_t exefs_header_written = 0;
bool exefs_header_processed = false; bool exefs_header_processed = false;
}; };

View File

@ -628,7 +628,7 @@ public:
std::string& GetMacAddress(); std::string& GetMacAddress();
/** /**
* * Saves the current MAC address to the filesystem
*/ */
void SaveMacAddress(); void SaveMacAddress();

View File

@ -207,7 +207,14 @@ static bool AttemptLLE(const ServiceModuleInfo& service_module) {
return false; return false;
} }
std::shared_ptr<Kernel::Process> process; std::shared_ptr<Kernel::Process> 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<int>(load_result));
return false;
}
LOG_DEBUG(Service, "Service module \"{}\" has been successfully loaded.", service_module.name); LOG_DEBUG(Service, "Service module \"{}\" has been successfully loaded.", service_module.name);
return true; return true;
} }

View File

@ -5,7 +5,7 @@
#pragma once #pragma once
#include <optional> #include <optional>
#include <tuple> #include <utility>
#include <vector> #include <vector>
#include "common/common_types.h" #include "common/common_types.h"