Update to latest master changes.

This commit is contained in:
PabloMK7 2024-01-11 21:58:58 +01:00
parent f2a08854cd
commit 63e4e1dc43
6 changed files with 150 additions and 50 deletions

View File

@ -328,7 +328,6 @@ void ConfigureSystem::SetConfiguration() {
ui->edit_init_ticks_value->setText( ui->edit_init_ticks_value->setText(
QString::number(Settings::values.init_ticks_override.GetValue())); QString::number(Settings::values.init_ticks_override.GetValue()));
am = Service::AM::GetModule(system);
cfg = Service::CFG::GetModule(system); cfg = Service::CFG::GetModule(system);
ReadSystemSettings(); ReadSystemSettings();
@ -571,13 +570,12 @@ void ConfigureSystem::InstallSecureData(const std::string& from_path, const std:
void ConfigureSystem::InstallCTCert(const std::string& from_path) { void ConfigureSystem::InstallCTCert(const std::string& from_path) {
std::string from = std::string from =
FileUtil::SanitizePath(from_path, FileUtil::DirectorySeparator::PlatformDefault); FileUtil::SanitizePath(from_path, FileUtil::DirectorySeparator::PlatformDefault);
std::string to = std::string to = FileUtil::SanitizePath(Service::AM::Module::GetCTCertPath(),
FileUtil::SanitizePath(am->GetCTCertPath(), FileUtil::DirectorySeparator::PlatformDefault); FileUtil::DirectorySeparator::PlatformDefault);
if (from.empty() || from == to) { if (from.empty() || from == to) {
return; return;
} }
FileUtil::Copy(from, to); FileUtil::Copy(from, to);
am->InvalidateCTCertData();
RefreshSecureDataStatus(); RefreshSecureDataStatus();
} }
@ -597,13 +595,15 @@ void ConfigureSystem::RefreshSecureDataStatus() {
} }
}; };
Service::AM::CTCert ct_cert;
ui->label_secure_info_status->setText( ui->label_secure_info_status->setText(
tr((std::string("Status: ") + status_to_str(cfg->LoadSecureInfoAFile())).c_str())); tr((std::string("Status: ") + status_to_str(cfg->LoadSecureInfoAFile())).c_str()));
ui->label_friend_code_seed_status->setText( ui->label_friend_code_seed_status->setText(
tr((std::string("Status: ") + status_to_str(cfg->LoadLocalFriendCodeSeedBFile())).c_str())); tr((std::string("Status: ") + status_to_str(cfg->LoadLocalFriendCodeSeedBFile())).c_str()));
ui->label_ct_cert_status->setText( ui->label_ct_cert_status->setText(
tr((std::string("Status: ") + tr((std::string("Status: ") + status_to_str(static_cast<Service::CFG::SecureDataLoadStatus>(
status_to_str(static_cast<Service::CFG::SecureDataLoadStatus>(am->LoadCTCertFile()))) Service::AM::Module::LoadCTCertFile(ct_cert))))
.c_str())); .c_str()));
} }

View File

@ -67,7 +67,6 @@ private:
ConfigurationShared::CheckState lle_applets; ConfigurationShared::CheckState lle_applets;
bool enabled = false; bool enabled = false;
std::shared_ptr<Service::AM::Module> am;
std::shared_ptr<Service::CFG::Module> cfg; std::shared_ptr<Service::CFG::Module> cfg;
std::u16string username; std::u16string username;
int birthmonth = 0; int birthmonth = 0;

View File

@ -506,6 +506,123 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="group_real_console_unique_data">
<property name="title">
<string>Real Console Unique Data</string>
</property>
<layout class="QGridLayout" name="gridLayout1">
<item row="1" column="0">
<widget class="QLabel" name="label_secure_info">
<property name="text">
<string>SecureInfo_A/B</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QWidget" name="secure_info">
<layout class="QHBoxLayout" name="horizontalLayout_secure_info">
<item>
<widget class="QLabel" name="label_secure_info_status">
<property name="text">
<string></string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_secure_info">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Choose</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_friend_code_seed">
<property name="text">
<string>LocalFriendCodeSeed_A/B</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QWidget" name="friend_code_seed">
<layout class="QHBoxLayout" name="horizontalLayout_friend_code_seed">
<item>
<widget class="QLabel" name="label_friend_code_seed_status">
<property name="text">
<string></string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_friend_code_seed">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Choose</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_ct_cert">
<property name="text">
<string>CTCert</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QWidget" name="ct_cert">
<layout class="QHBoxLayout" name="horizontalLayout_ct_cert">
<item>
<widget class="QLabel" name="label_ct_cert_status">
<property name="text">
<string></string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_ct_cert">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Choose</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QLabel" name="label_disable_info"> <widget class="QLabel" name="label_disable_info">
<property name="text"> <property name="text">

View File

@ -1252,7 +1252,7 @@ void Module::Interface::GetDeviceID(Kernel::HLERequestContext& ctx) {
} }
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0); IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(0); rb.Push(0);
rb.Push(deviceID); 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())); buffer.Write(&am->ct_cert, 0, std::min(sizeof(CTCert), buffer.GetSize()));
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(0); rb.Push(0);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
} }
@ -1866,12 +1866,8 @@ std::string Module::GetCTCertPath() {
return FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir) + "CTCert.bin"; return FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir) + "CTCert.bin";
} }
void Module::InvalidateCTCertData() { CTCertLoadStatus Module::LoadCTCertFile(CTCert& output) {
ct_cert = CTCert(); if (output.IsValid()) {
}
CTCertLoadStatus Module::LoadCTCertFile() {
if (ct_cert.IsValid()) {
return CTCertLoadStatus::Loaded; return CTCertLoadStatus::Loaded;
} }
std::string file_path = GetCTCertPath(); std::string file_path = GetCTCertPath();
@ -1885,28 +1881,22 @@ CTCertLoadStatus Module::LoadCTCertFile() {
if (file.GetSize() != sizeof(CTCert)) { if (file.GetSize() != sizeof(CTCert)) {
return CTCertLoadStatus::Invalid; return CTCertLoadStatus::Invalid;
} }
if (file.ReadBytes(&ct_cert, sizeof(CTCert)) != sizeof(CTCert)) { if (file.ReadBytes(&output, sizeof(CTCert)) != sizeof(CTCert)) {
return CTCertLoadStatus::IOError; return CTCertLoadStatus::IOError;
} }
if (!ct_cert.IsValid()) { if (!output.IsValid()) {
ct_cert = CTCert(); output = CTCert();
return CTCertLoadStatus::Invalid; return CTCertLoadStatus::Invalid;
} }
return CTCertLoadStatus::Loaded; return CTCertLoadStatus::Loaded;
} }
Module::Module() { Module::Module(Core::System& _system) : system(_system) {
LoadCTCertFile();
}
Module::Module(Core::System& system) : kernel(&system.Kernel()) {
ScanForAllTitles(); ScanForAllTitles();
LoadCTCertFile(); LoadCTCertFile(ct_cert);
system_updater_mutex = system.Kernel().CreateMutex(false, "AM::SystemUpdaterMutex"); system_updater_mutex = system.Kernel().CreateMutex(false, "AM::SystemUpdaterMutex");
} }
Module::Module(Kernel::KernelSystem& kernel) : kernel(&kernel) {}
Module::~Module() = default; Module::~Module() = default;
std::shared_ptr<Module> GetModule(Core::System& system) { std::shared_ptr<Module> GetModule(Core::System& system) {

View File

@ -233,7 +233,6 @@ Result UninstallProgram(const FS::MediaType media_type, const u64 title_id);
class Module final { class Module final {
public: public:
Module();
explicit Module(Core::System& system); explicit Module(Core::System& system);
~Module(); ~Module();
@ -760,18 +759,13 @@ public:
* Gets the CTCert.bin path in the host filesystem * Gets the CTCert.bin path in the host filesystem
* @returns std::string CTCert.bin path in the host filesystem * @returns std::string CTCert.bin path in the host filesystem
*/ */
std::string GetCTCertPath(); static std::string GetCTCertPath();
/**
* Invalidates the CTCert data so that it is loaded again.
*/
void InvalidateCTCertData();
/** /**
* Loads the CTCert.bin file from the filesystem. * Loads the CTCert.bin file from the filesystem.
* @returns CTCertLoadStatus indicating the file load status. * @returns CTCertLoadStatus indicating the file load status.
*/ */
CTCertLoadStatus LoadCTCertFile(); static CTCertLoadStatus LoadCTCertFile(CTCert& output);
private: private:
/** /**

View File

@ -223,7 +223,7 @@ void Module::Interface::SecureInfoGetByte101(Kernel::HLERequestContext& ctx) {
} }
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u8>(ret); rb.Push<u8>(ret);
} }
@ -234,21 +234,21 @@ void Module::Interface::SecureInfoGetSerialNo(Kernel::HLERequestContext& ctx) {
if (out_buffer.GetSize() < sizeof(SecureInfoA::serial_number)) { if (out_buffer.GetSize() < sizeof(SecureInfoA::serial_number)) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::InvalidSize, ErrorModule::Config, rb.Push(Result(ErrorDescription::InvalidSize, ErrorModule::Config,
ErrorSummary::WrongArgument, ErrorLevel::Permanent)); ErrorSummary::WrongArgument, ErrorLevel::Permanent));
} }
// Never happens on real hardware, but may happen if user didn't supply a dump. // 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. // 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) { if (!cfg->secure_info_a_loaded || !cfg->local_friend_code_seed_b_loaded) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::Config, rb.Push(Result(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::InvalidState,
ErrorSummary::InvalidState, ErrorLevel::Permanent)); ErrorLevel::Permanent));
} }
out_buffer.Write(&cfg->secure_info_a.serial_number, 0, sizeof(SecureInfoA::serial_number)); out_buffer.Write(&cfg->secure_info_a.serial_number, 0, sizeof(SecureInfoA::serial_number));
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(out_buffer); rb.PushMappedBuffer(out_buffer);
} }
@ -399,18 +399,18 @@ void Module::Interface::GetLocalFriendCodeSeedData(Kernel::HLERequestContext& ct
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
if (out_buffer.GetSize() < sizeof(LocalFriendCodeSeedB)) { if (out_buffer.GetSize() < sizeof(LocalFriendCodeSeedB)) {
rb.Push(ResultCode(ErrorDescription::InvalidSize, ErrorModule::Config, rb.Push(Result(ErrorDescription::InvalidSize, ErrorModule::Config,
ErrorSummary::WrongArgument, ErrorLevel::Permanent)); ErrorSummary::WrongArgument, ErrorLevel::Permanent));
} }
// Never happens on real hardware, but may happen if user didn't supply a dump. // 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. // 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) { if (!cfg->secure_info_a_loaded || !cfg->local_friend_code_seed_b_loaded) {
rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::Config, rb.Push(Result(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::InvalidState,
ErrorSummary::InvalidState, ErrorLevel::Permanent)); ErrorLevel::Permanent));
} }
out_buffer.Write(&cfg->local_friend_code_seed_b, 0, sizeof(LocalFriendCodeSeedB)); 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) { 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. // 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) { if (!cfg->secure_info_a_loaded || !cfg->local_friend_code_seed_b_loaded) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::Config, rb.Push(Result(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::InvalidState,
ErrorSummary::InvalidState, ErrorLevel::Permanent)); ErrorLevel::Permanent));
} }
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0); IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u64>(cfg->local_friend_code_seed_b.friend_code_seed); rb.Push<u64>(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"; return FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + "rw/sys/SecureInfo_A";
} }
ResultCode Module::FormatConfig() { Result Module::FormatConfig() {
ResultCode res = DeleteConfigNANDSaveFile(); Result res = DeleteConfigNANDSaveFile();
// The delete command fails if the file doesn't exist, so we have to check that too // The delete command fails if the file doesn't exist, so we have to check that too
if (!res.IsSuccess() && res != FileSys::ResultFileNotFound) { if (!res.IsSuccess() && res != FileSys::ResultFileNotFound) {
return res; return res;