mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 05:40:04 +00:00 
			
		
		
		
	Set accepted EULA version to max value (#4728)
* Set accepted EULA version to max value CFG: write the max value of 0x7F7F to the default cfg savegame and auto update on init CECD: Actually read the EULA version from CFG
This commit is contained in:
		
							parent
							
								
									d6d8c52c96
								
							
						
					
					
						commit
						f4da2de99a
					
				
					 3 changed files with 49 additions and 4 deletions
				
			
		|  | @ -21,6 +21,7 @@ | |||
| #include "core/hle/service/cecd/cecd_ndm.h" | ||||
| #include "core/hle/service/cecd/cecd_s.h" | ||||
| #include "core/hle/service/cecd/cecd_u.h" | ||||
| #include "core/hle/service/cfg/cfg.h" | ||||
| #include "fmt/format.h" | ||||
| 
 | ||||
| namespace Service::CECD { | ||||
|  | @ -612,10 +613,12 @@ void Module::Interface::ReadData(Kernel::HLERequestContext& ctx) { | |||
|     IPC::RequestBuilder rb = rp.MakeBuilder(1, 4); | ||||
|     std::vector<u8> buffer; | ||||
|     switch (info_type) { | ||||
|     case CecSystemInfoType::EulaVersion: // TODO: Read config Eula version
 | ||||
|         buffer = {0xFF, 0xFF}; | ||||
|         dest_buffer.Write(buffer.data(), 0, buffer.size()); | ||||
|     case CecSystemInfoType::EulaVersion: { | ||||
|         auto cfg = Service::CFG::GetModule(cecd->system); | ||||
|         Service::CFG::EULAVersion version = cfg->GetEULAVersion(); | ||||
|         dest_buffer.Write(&version, 0, sizeof(version)); | ||||
|         break; | ||||
|     } | ||||
|     case CecSystemInfoType::Eula: | ||||
|         buffer = {0x01}; // Eula agreed
 | ||||
|         dest_buffer.Write(buffer.data(), 0, buffer.size()); | ||||
|  |  | |||
|  | @ -89,6 +89,7 @@ struct ConsoleCountryInfo { | |||
| static_assert(sizeof(ConsoleCountryInfo) == 4, "ConsoleCountryInfo must be exactly 4 bytes"); | ||||
| } // namespace
 | ||||
| 
 | ||||
| static const EULAVersion MAX_EULA_VERSION = {0x7F, 0x7F}; | ||||
| static const ConsoleModelInfo CONSOLE_MODEL = {NINTENDO_3DS_XL, {0, 0, 0}}; | ||||
| static const u8 CONSOLE_LANGUAGE = LANGUAGE_EN; | ||||
| static const UsernameBlock CONSOLE_USERNAME_BLOCK = {u"CITRA", 0, 0}; | ||||
|  | @ -505,7 +506,8 @@ ResultCode Module::FormatConfig() { | |||
|         return res; | ||||
| 
 | ||||
|     // 0x000D0000 - Accepted EULA version
 | ||||
|     res = CreateConfigInfoBlk(EULAVersionBlockID, 0x4, 0xE, zero_buffer); | ||||
|     u32_le data = MAX_EULA_VERSION.minor + (MAX_EULA_VERSION.major << 8); | ||||
|     res = CreateConfigInfoBlk(EULAVersionBlockID, sizeof(data), 0xE, &data); | ||||
|     if (!res.IsSuccess()) | ||||
|         return res; | ||||
| 
 | ||||
|  | @ -564,6 +566,15 @@ ResultCode Module::LoadConfigNANDSaveFile() { | |||
| 
 | ||||
| Module::Module() { | ||||
|     LoadConfigNANDSaveFile(); | ||||
|     // Check the config savegame EULA Version and update it to 0x7F7F if necessary
 | ||||
|     // so users will never get a promt to accept EULA
 | ||||
|     EULAVersion version = GetEULAVersion(); | ||||
|     if (version.major != MAX_EULA_VERSION.major || version.minor != MAX_EULA_VERSION.minor) { | ||||
|         LOG_INFO(Service_CFG, "Updating accepted EULA version to {}.{}", MAX_EULA_VERSION.major, | ||||
|                  MAX_EULA_VERSION.minor); | ||||
|         SetEULAVersion(Service::CFG::MAX_EULA_VERSION); | ||||
|         UpdateConfigNANDSavegame(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| Module::~Module() = default; | ||||
|  | @ -718,6 +729,20 @@ u64 Module::GetConsoleUniqueId() { | |||
|     return console_id_le; | ||||
| } | ||||
| 
 | ||||
| EULAVersion Module::GetEULAVersion() { | ||||
|     u32_le data; | ||||
|     GetConfigInfoBlock(EULAVersionBlockID, sizeof(data), 0xE, &data); | ||||
|     EULAVersion version; | ||||
|     version.minor = data & 0xFF; | ||||
|     version.major = (data >> 8) & 0xFF; | ||||
|     return version; | ||||
| } | ||||
| 
 | ||||
| void Module::SetEULAVersion(const EULAVersion& version) { | ||||
|     u32_le data = version.minor + (version.major << 8); | ||||
|     SetConfigInfoBlock(EULAVersionBlockID, sizeof(data), 0xE, &data); | ||||
| } | ||||
| 
 | ||||
| std::shared_ptr<Module> GetModule(Core::System& system) { | ||||
|     auto cfg = system.ServiceManager().GetService<Service::CFG::Module::Interface>("cfg:u"); | ||||
|     if (!cfg) | ||||
|  |  | |||
|  | @ -47,6 +47,11 @@ enum SystemLanguage { | |||
| 
 | ||||
| enum SoundOutputMode { SOUND_MONO = 0, SOUND_STEREO = 1, SOUND_SURROUND = 2 }; | ||||
| 
 | ||||
| struct EULAVersion { | ||||
|     u8 minor; | ||||
|     u8 major; | ||||
| }; | ||||
| 
 | ||||
| /// Block header in the config savedata file
 | ||||
| struct SaveConfigBlockEntry { | ||||
|     u32 block_id;       ///< The id of the current block
 | ||||
|  | @ -398,6 +403,18 @@ public: | |||
|      */ | ||||
|     u64 GetConsoleUniqueId(); | ||||
| 
 | ||||
|     /**
 | ||||
|      * Sets the accepted EULA version in the config savegame. | ||||
|      * @param version the version to set | ||||
|      */ | ||||
|     void SetEULAVersion(const EULAVersion& version); | ||||
| 
 | ||||
|     /**
 | ||||
|      * Gets the accepted EULA version from config savegame. | ||||
|      * @returns the EULA version | ||||
|      */ | ||||
|     EULAVersion GetEULAVersion(); | ||||
| 
 | ||||
|     /**
 | ||||
|      * Writes the config savegame memory buffer to the config savegame file in the filesystem | ||||
|      * @returns ResultCode indicating the result of the operation, 0 on success | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue