mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 13:50:03 +00:00 
			
		
		
		
	Add console unique data (SecureInfo, LocalFriendCodeSeed, CTCert) (#6)
* Add console unique secure data * Add CTCert and DeviceID support * Fix AM_U::GetDeviceID Co-authored-by: Daniel López Guimaraes <112760654+DaniElectra@users.noreply.github.com> * Update to latest master changes. --------- Co-authored-by: Daniel López Guimaraes <112760654+DaniElectra@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									f112d975b9
								
							
						
					
					
						commit
						813d0c2a30
					
				
					 12 changed files with 597 additions and 14 deletions
				
			
		|  | @ -3,12 +3,14 @@ | |||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
| #include <cstring> | ||||
| #include <QFileDialog> | ||||
| #include <QFutureWatcher> | ||||
| #include <QMessageBox> | ||||
| #include <QProgressDialog> | ||||
| #include <QtConcurrent/QtConcurrentMap> | ||||
| #include "citra_qt/configuration/configuration_shared.h" | ||||
| #include "citra_qt/configuration/configure_system.h" | ||||
| #include "common/file_util.h" | ||||
| #include "common/settings.h" | ||||
| #include "core/core.h" | ||||
| #include "core/hle/service/am/am.h" | ||||
|  | @ -236,6 +238,32 @@ ConfigureSystem::ConfigureSystem(Core::System& system_, QWidget* parent) | |||
|             &ConfigureSystem::RefreshConsoleID); | ||||
|     connect(ui->button_start_download, &QPushButton::clicked, this, | ||||
|             &ConfigureSystem::DownloadFromNUS); | ||||
| 
 | ||||
|     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/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_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) { | ||||
|             ui->combo_country->addItem(tr(country_names.at(i)), i); | ||||
|  | @ -304,6 +332,7 @@ void ConfigureSystem::SetConfiguration() { | |||
|     ReadSystemSettings(); | ||||
| 
 | ||||
|     ui->group_system_settings->setEnabled(enabled); | ||||
|     ui->group_real_console_unique_data->setEnabled(enabled); | ||||
|     if (enabled) { | ||||
|         ui->label_disable_info->hide(); | ||||
|     } | ||||
|  | @ -354,6 +383,9 @@ void ConfigureSystem::ReadSystemSettings() { | |||
| 
 | ||||
|     // set firmware download region
 | ||||
|     ui->combo_download_region->setCurrentIndex(static_cast<int>(cfg->GetRegionValue())); | ||||
| 
 | ||||
|     // Refresh secure data status
 | ||||
|     RefreshSecureDataStatus(); | ||||
| } | ||||
| 
 | ||||
| void ConfigureSystem::ApplyConfiguration() { | ||||
|  | @ -522,6 +554,59 @@ void ConfigureSystem::RefreshConsoleID() { | |||
|         tr("Console ID: 0x%1").arg(QString::number(console_id, 16).toUpper())); | ||||
| } | ||||
| 
 | ||||
| void ConfigureSystem::InstallSecureData(const std::string& from_path, const std::string& to_path) { | ||||
|     std::string from = | ||||
|         FileUtil::SanitizePath(from_path, FileUtil::DirectorySeparator::PlatformDefault); | ||||
|     std::string to = FileUtil::SanitizePath(to_path, FileUtil::DirectorySeparator::PlatformDefault); | ||||
|     if (from.empty() || from == to) { | ||||
|         return; | ||||
|     } | ||||
|     FileUtil::CreateFullPath(to_path); | ||||
|     FileUtil::Copy(from, to); | ||||
|     cfg->InvalidateSecureData(); | ||||
|     RefreshSecureDataStatus(); | ||||
| } | ||||
| 
 | ||||
| void ConfigureSystem::InstallCTCert(const std::string& from_path) { | ||||
|     std::string from = | ||||
|         FileUtil::SanitizePath(from_path, 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); | ||||
|     RefreshSecureDataStatus(); | ||||
| } | ||||
| 
 | ||||
| void ConfigureSystem::RefreshSecureDataStatus() { | ||||
|     auto status_to_str = [](Service::CFG::SecureDataLoadStatus status) { | ||||
|         switch (status) { | ||||
|         case Service::CFG::SecureDataLoadStatus::Loaded: | ||||
|             return "Loaded"; | ||||
|         case Service::CFG::SecureDataLoadStatus::NotFound: | ||||
|             return "Not Found"; | ||||
|         case Service::CFG::SecureDataLoadStatus::Invalid: | ||||
|             return "Invalid"; | ||||
|         case Service::CFG::SecureDataLoadStatus::IOError: | ||||
|             return "IO Error"; | ||||
|         default: | ||||
|             return ""; | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     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<Service::CFG::SecureDataLoadStatus>( | ||||
|                                           Service::AM::Module::LoadCTCertFile(ct_cert)))) | ||||
|                .c_str())); | ||||
| } | ||||
| 
 | ||||
| void ConfigureSystem::RetranslateUI() { | ||||
|     ui->retranslateUi(this); | ||||
| } | ||||
|  |  | |||
|  | @ -20,6 +20,12 @@ namespace Core { | |||
| class System; | ||||
| } | ||||
| 
 | ||||
| namespace Service { | ||||
| namespace AM { | ||||
| class Module; | ||||
| } // namespace AM
 | ||||
| } // namespace Service
 | ||||
| 
 | ||||
| namespace Service { | ||||
| namespace CFG { | ||||
| class Module; | ||||
|  | @ -46,6 +52,10 @@ private: | |||
|     void UpdateInitTicks(int init_ticks_type); | ||||
|     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(); | ||||
| 
 | ||||
|     void DownloadFromNUS(); | ||||
|  |  | |||
|  | @ -506,6 +506,123 @@ | |||
|        </layout> | ||||
|       </widget> | ||||
|      </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> | ||||
|       <widget class="QLabel" name="label_disable_info"> | ||||
|        <property name="text"> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue