diff --git a/src/citra_qt/configuration/configure_system.cpp b/src/citra_qt/configuration/configure_system.cpp index dbc3766ff3..971f9f5206 100644 --- a/src/citra_qt/configuration/configure_system.cpp +++ b/src/citra_qt/configuration/configure_system.cpp @@ -328,7 +328,6 @@ void ConfigureSystem::SetConfiguration() { ui->edit_init_ticks_value->setText( QString::number(Settings::values.init_ticks_override.GetValue())); - am = Service::AM::GetModule(system); cfg = Service::CFG::GetModule(system); ReadSystemSettings(); @@ -571,13 +570,12 @@ void ConfigureSystem::InstallSecureData(const std::string& from_path, const std: void ConfigureSystem::InstallCTCert(const std::string& from_path) { std::string from = FileUtil::SanitizePath(from_path, FileUtil::DirectorySeparator::PlatformDefault); - std::string to = - FileUtil::SanitizePath(am->GetCTCertPath(), FileUtil::DirectorySeparator::PlatformDefault); + std::string to = FileUtil::SanitizePath(Service::AM::Module::GetCTCertPath(), + FileUtil::DirectorySeparator::PlatformDefault); if (from.empty() || from == to) { return; } FileUtil::Copy(from, to); - am->InvalidateCTCertData(); RefreshSecureDataStatus(); } @@ -597,13 +595,15 @@ void ConfigureSystem::RefreshSecureDataStatus() { } }; + Service::AM::CTCert ct_cert; + ui->label_secure_info_status->setText( tr((std::string("Status: ") + status_to_str(cfg->LoadSecureInfoAFile())).c_str())); ui->label_friend_code_seed_status->setText( tr((std::string("Status: ") + status_to_str(cfg->LoadLocalFriendCodeSeedBFile())).c_str())); ui->label_ct_cert_status->setText( - tr((std::string("Status: ") + - status_to_str(static_cast(am->LoadCTCertFile()))) + tr((std::string("Status: ") + status_to_str(static_cast( + Service::AM::Module::LoadCTCertFile(ct_cert)))) .c_str())); } diff --git a/src/citra_qt/configuration/configure_system.h b/src/citra_qt/configuration/configure_system.h index 772a9f995c..9db21ba1c8 100644 --- a/src/citra_qt/configuration/configure_system.h +++ b/src/citra_qt/configuration/configure_system.h @@ -67,7 +67,6 @@ private: ConfigurationShared::CheckState lle_applets; bool enabled = false; - std::shared_ptr am; std::shared_ptr cfg; std::u16string username; int birthmonth = 0; diff --git a/src/citra_qt/configuration/configure_system.ui b/src/citra_qt/configuration/configure_system.ui index 81f764b053..20f5856371 100644 --- a/src/citra_qt/configuration/configure_system.ui +++ b/src/citra_qt/configuration/configure_system.ui @@ -506,6 +506,123 @@ + + + + Real Console Unique Data + + + + + + SecureInfo_A/B + + + + + + + + + + + + + + + + + + 0 + 0 + + + + Qt::RightToLeft + + + Choose + + + + + + + + + + LocalFriendCodeSeed_A/B + + + + + + + + + + + + + + + + + + 0 + 0 + + + + Qt::RightToLeft + + + Choose + + + + + + + + + + CTCert + + + + + + + + + + + + + + + + + + 0 + 0 + + + + Qt::RightToLeft + + + Choose + + + + + + + + + diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index fac2408fb4..1807fc1853 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -1252,7 +1252,7 @@ void Module::Interface::GetDeviceID(Kernel::HLERequestContext& ctx) { } IPC::RequestBuilder rb = rp.MakeBuilder(3, 0); - rb.Push(RESULT_SUCCESS); + rb.Push(ResultSuccess); rb.Push(0); rb.Push(deviceID); } @@ -1857,7 +1857,7 @@ void Module::Interface::GetDeviceCert(Kernel::HLERequestContext& ctx) { buffer.Write(&am->ct_cert, 0, std::min(sizeof(CTCert), buffer.GetSize())); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); - rb.Push(RESULT_SUCCESS); + rb.Push(ResultSuccess); rb.Push(0); rb.PushMappedBuffer(buffer); } @@ -1866,12 +1866,8 @@ std::string Module::GetCTCertPath() { return FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir) + "CTCert.bin"; } -void Module::InvalidateCTCertData() { - ct_cert = CTCert(); -} - -CTCertLoadStatus Module::LoadCTCertFile() { - if (ct_cert.IsValid()) { +CTCertLoadStatus Module::LoadCTCertFile(CTCert& output) { + if (output.IsValid()) { return CTCertLoadStatus::Loaded; } std::string file_path = GetCTCertPath(); @@ -1885,28 +1881,22 @@ CTCertLoadStatus Module::LoadCTCertFile() { if (file.GetSize() != sizeof(CTCert)) { return CTCertLoadStatus::Invalid; } - if (file.ReadBytes(&ct_cert, sizeof(CTCert)) != sizeof(CTCert)) { + if (file.ReadBytes(&output, sizeof(CTCert)) != sizeof(CTCert)) { return CTCertLoadStatus::IOError; } - if (!ct_cert.IsValid()) { - ct_cert = CTCert(); + if (!output.IsValid()) { + output = CTCert(); return CTCertLoadStatus::Invalid; } return CTCertLoadStatus::Loaded; } -Module::Module() { - LoadCTCertFile(); -} - -Module::Module(Core::System& system) : kernel(&system.Kernel()) { +Module::Module(Core::System& _system) : system(_system) { ScanForAllTitles(); - LoadCTCertFile(); + LoadCTCertFile(ct_cert); system_updater_mutex = system.Kernel().CreateMutex(false, "AM::SystemUpdaterMutex"); } -Module::Module(Kernel::KernelSystem& kernel) : kernel(&kernel) {} - Module::~Module() = default; std::shared_ptr GetModule(Core::System& system) { diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 105375c8bc..26b9b1056c 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -233,7 +233,6 @@ Result UninstallProgram(const FS::MediaType media_type, const u64 title_id); class Module final { public: - Module(); explicit Module(Core::System& system); ~Module(); @@ -760,18 +759,13 @@ public: * Gets the CTCert.bin path in the host filesystem * @returns std::string CTCert.bin path in the host filesystem */ - std::string GetCTCertPath(); - - /** - * Invalidates the CTCert data so that it is loaded again. - */ - void InvalidateCTCertData(); + static std::string GetCTCertPath(); /** * Loads the CTCert.bin file from the filesystem. * @returns CTCertLoadStatus indicating the file load status. */ - CTCertLoadStatus LoadCTCertFile(); + static CTCertLoadStatus LoadCTCertFile(CTCert& output); private: /** diff --git a/src/core/hle/service/cfg/cfg.cpp b/src/core/hle/service/cfg/cfg.cpp index 50dc2d5bdc..d118250ba9 100644 --- a/src/core/hle/service/cfg/cfg.cpp +++ b/src/core/hle/service/cfg/cfg.cpp @@ -223,7 +223,7 @@ void Module::Interface::SecureInfoGetByte101(Kernel::HLERequestContext& ctx) { } IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); - rb.Push(RESULT_SUCCESS); + rb.Push(ResultSuccess); rb.Push(ret); } @@ -234,21 +234,21 @@ void Module::Interface::SecureInfoGetSerialNo(Kernel::HLERequestContext& ctx) { if (out_buffer.GetSize() < sizeof(SecureInfoA::serial_number)) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrorDescription::InvalidSize, ErrorModule::Config, - ErrorSummary::WrongArgument, ErrorLevel::Permanent)); + rb.Push(Result(ErrorDescription::InvalidSize, ErrorModule::Config, + ErrorSummary::WrongArgument, ErrorLevel::Permanent)); } // Never happens on real hardware, but may happen if user didn't supply a dump. // Always make sure to have available both secure data kinds or error otherwise. if (!cfg->secure_info_a_loaded || !cfg->local_friend_code_seed_b_loaded) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::Config, - ErrorSummary::InvalidState, ErrorLevel::Permanent)); + rb.Push(Result(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::InvalidState, + ErrorLevel::Permanent)); } out_buffer.Write(&cfg->secure_info_a.serial_number, 0, sizeof(SecureInfoA::serial_number)); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); - rb.Push(RESULT_SUCCESS); + rb.Push(ResultSuccess); rb.PushMappedBuffer(out_buffer); } @@ -399,18 +399,18 @@ void Module::Interface::GetLocalFriendCodeSeedData(Kernel::HLERequestContext& ct IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); if (out_buffer.GetSize() < sizeof(LocalFriendCodeSeedB)) { - rb.Push(ResultCode(ErrorDescription::InvalidSize, ErrorModule::Config, - ErrorSummary::WrongArgument, ErrorLevel::Permanent)); + rb.Push(Result(ErrorDescription::InvalidSize, ErrorModule::Config, + ErrorSummary::WrongArgument, ErrorLevel::Permanent)); } // Never happens on real hardware, but may happen if user didn't supply a dump. // Always make sure to have available both secure data kinds or error otherwise. if (!cfg->secure_info_a_loaded || !cfg->local_friend_code_seed_b_loaded) { - rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::Config, - ErrorSummary::InvalidState, ErrorLevel::Permanent)); + rb.Push(Result(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::InvalidState, + ErrorLevel::Permanent)); } out_buffer.Write(&cfg->local_friend_code_seed_b, 0, sizeof(LocalFriendCodeSeedB)); - rb.Push(RESULT_SUCCESS); + rb.Push(ResultSuccess); } void Module::Interface::GetLocalFriendCodeSeed(Kernel::HLERequestContext& ctx) { @@ -420,12 +420,12 @@ void Module::Interface::GetLocalFriendCodeSeed(Kernel::HLERequestContext& ctx) { // Always make sure to have available both secure data kinds or error otherwise. if (!cfg->secure_info_a_loaded || !cfg->local_friend_code_seed_b_loaded) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::Config, - ErrorSummary::InvalidState, ErrorLevel::Permanent)); + rb.Push(Result(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::InvalidState, + ErrorLevel::Permanent)); } IPC::RequestBuilder rb = rp.MakeBuilder(3, 0); - rb.Push(RESULT_SUCCESS); + rb.Push(ResultSuccess); rb.Push(cfg->local_friend_code_seed_b.friend_code_seed); } @@ -578,8 +578,8 @@ std::string Module::GetSecureInfoAPath() { return FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + "rw/sys/SecureInfo_A"; } -ResultCode Module::FormatConfig() { - ResultCode res = DeleteConfigNANDSaveFile(); +Result Module::FormatConfig() { + Result res = DeleteConfigNANDSaveFile(); // The delete command fails if the file doesn't exist, so we have to check that too if (!res.IsSuccess() && res != FileSys::ResultFileNotFound) { return res;