Add CTCert and DeviceID support

This commit is contained in:
PabloMK7
2024-02-02 10:20:06 +01:00
parent e39501556c
commit dedd48c7da
7 changed files with 222 additions and 11 deletions
@@ -241,20 +241,28 @@ ConfigureSystem::ConfigureSystem(Core::System& system_, QWidget* parent)
connect(ui->button_secure_info, &QPushButton::clicked, this, [this] {
ui->button_secure_info->setEnabled(false);
const QString file_path_qtstr =
QFileDialog::getOpenFileName(this, tr("Select SecureInfo_A"), QString(),
tr("SecureInfo_A (SecureInfo_A);;All Files (*.*)"));
const QString file_path_qtstr = QFileDialog::getOpenFileName(
this, tr("Select SecureInfo_A/B"), QString(),
tr("SecureInfo_A/B (SecureInfo_A SecureInfo_B);;All Files (*.*)"));
ui->button_secure_info->setEnabled(true);
InstallSecureData(file_path_qtstr.toStdString(), cfg->GetSecureInfoAPath());
});
connect(ui->button_friend_code_seed, &QPushButton::clicked, this, [this] {
ui->button_friend_code_seed->setEnabled(false);
const QString file_path_qtstr = QFileDialog::getOpenFileName(
this, tr("Select LocalFriendCodeSeed_B"), QString(),
tr("LocalFriendCodeSeed_B (LocalFriendCodeSeed_B);;All Files (*.*)"));
const QString file_path_qtstr =
QFileDialog::getOpenFileName(this, tr("Select LocalFriendCodeSeed_A/B"), QString(),
tr("LocalFriendCodeSeed_A/B (LocalFriendCodeSeed_A "
"LocalFriendCodeSeed_B);;All Files (*.*)"));
ui->button_friend_code_seed->setEnabled(true);
InstallSecureData(file_path_qtstr.toStdString(), cfg->GetLocalFriendCodeSeedBPath());
});
connect(ui->button_ct_cert, &QPushButton::clicked, this, [this] {
ui->button_ct_cert->setEnabled(false);
const QString file_path_qtstr = QFileDialog::getOpenFileName(
this, tr("Select CTCert"), QString(), tr("CTCert.bin (*.bin);;All Files (*.*)"));
ui->button_ct_cert->setEnabled(true);
InstallCTCert(file_path_qtstr.toStdString());
});
for (u8 i = 0; i < country_names.size(); i++) {
if (std::strcmp(country_names.at(i), "") != 0) {
@@ -320,6 +328,7 @@ 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();
@@ -559,6 +568,19 @@ void ConfigureSystem::InstallSecureData(const std::string& from_path, const std:
RefreshSecureDataStatus();
}
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);
if (from.empty() || from == to) {
return;
}
FileUtil::Copy(from, to);
am->InvalidateCTCertData();
RefreshSecureDataStatus();
}
void ConfigureSystem::RefreshSecureDataStatus() {
auto status_to_str = [](Service::CFG::SecureDataLoadStatus status) {
switch (status) {
@@ -579,6 +601,10 @@ void ConfigureSystem::RefreshSecureDataStatus() {
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<Service::CFG::SecureDataLoadStatus>(am->LoadCTCertFile())))
.c_str()));
}
void ConfigureSystem::RetranslateUI() {
@@ -20,6 +20,12 @@ namespace Core {
class System;
}
namespace Service {
namespace AM {
class Module;
} // namespace AM
} // namespace Service
namespace Service {
namespace CFG {
class Module;
@@ -47,6 +53,7 @@ private:
void RefreshConsoleID();
void InstallSecureData(const std::string& from_path, const std::string& to_path);
void InstallCTCert(const std::string& from_path);
void RefreshSecureDataStatus();
void SetupPerGameUI();
@@ -60,6 +67,7 @@ private:
ConfigurationShared::CheckState lle_applets;
bool enabled = false;
std::shared_ptr<Service::AM::Module> am;
std::shared_ptr<Service::CFG::Module> cfg;
std::u16string username;
int birthmonth = 0;