citra-emu
/
citra
Archived
1
0
Fork 0

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:
Ben 2019-04-23 23:18:27 +02:00 committed by GitHub
parent d6d8c52c96
commit f4da2de99a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 4 deletions

View File

@ -21,6 +21,7 @@
#include "core/hle/service/cecd/cecd_ndm.h" #include "core/hle/service/cecd/cecd_ndm.h"
#include "core/hle/service/cecd/cecd_s.h" #include "core/hle/service/cecd/cecd_s.h"
#include "core/hle/service/cecd/cecd_u.h" #include "core/hle/service/cecd/cecd_u.h"
#include "core/hle/service/cfg/cfg.h"
#include "fmt/format.h" #include "fmt/format.h"
namespace Service::CECD { namespace Service::CECD {
@ -612,10 +613,12 @@ void Module::Interface::ReadData(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4); IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
std::vector<u8> buffer; std::vector<u8> buffer;
switch (info_type) { switch (info_type) {
case CecSystemInfoType::EulaVersion: // TODO: Read config Eula version case CecSystemInfoType::EulaVersion: {
buffer = {0xFF, 0xFF}; auto cfg = Service::CFG::GetModule(cecd->system);
dest_buffer.Write(buffer.data(), 0, buffer.size()); Service::CFG::EULAVersion version = cfg->GetEULAVersion();
dest_buffer.Write(&version, 0, sizeof(version));
break; break;
}
case CecSystemInfoType::Eula: case CecSystemInfoType::Eula:
buffer = {0x01}; // Eula agreed buffer = {0x01}; // Eula agreed
dest_buffer.Write(buffer.data(), 0, buffer.size()); dest_buffer.Write(buffer.data(), 0, buffer.size());

View File

@ -89,6 +89,7 @@ struct ConsoleCountryInfo {
static_assert(sizeof(ConsoleCountryInfo) == 4, "ConsoleCountryInfo must be exactly 4 bytes"); static_assert(sizeof(ConsoleCountryInfo) == 4, "ConsoleCountryInfo must be exactly 4 bytes");
} // namespace } // namespace
static const EULAVersion MAX_EULA_VERSION = {0x7F, 0x7F};
static const ConsoleModelInfo CONSOLE_MODEL = {NINTENDO_3DS_XL, {0, 0, 0}}; static const ConsoleModelInfo CONSOLE_MODEL = {NINTENDO_3DS_XL, {0, 0, 0}};
static const u8 CONSOLE_LANGUAGE = LANGUAGE_EN; static const u8 CONSOLE_LANGUAGE = LANGUAGE_EN;
static const UsernameBlock CONSOLE_USERNAME_BLOCK = {u"CITRA", 0, 0}; static const UsernameBlock CONSOLE_USERNAME_BLOCK = {u"CITRA", 0, 0};
@ -505,7 +506,8 @@ ResultCode Module::FormatConfig() {
return res; return res;
// 0x000D0000 - Accepted EULA version // 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()) if (!res.IsSuccess())
return res; return res;
@ -564,6 +566,15 @@ ResultCode Module::LoadConfigNANDSaveFile() {
Module::Module() { Module::Module() {
LoadConfigNANDSaveFile(); 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; Module::~Module() = default;
@ -718,6 +729,20 @@ u64 Module::GetConsoleUniqueId() {
return console_id_le; 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) { std::shared_ptr<Module> GetModule(Core::System& system) {
auto cfg = system.ServiceManager().GetService<Service::CFG::Module::Interface>("cfg:u"); auto cfg = system.ServiceManager().GetService<Service::CFG::Module::Interface>("cfg:u");
if (!cfg) if (!cfg)

View File

@ -47,6 +47,11 @@ enum SystemLanguage {
enum SoundOutputMode { SOUND_MONO = 0, SOUND_STEREO = 1, SOUND_SURROUND = 2 }; enum SoundOutputMode { SOUND_MONO = 0, SOUND_STEREO = 1, SOUND_SURROUND = 2 };
struct EULAVersion {
u8 minor;
u8 major;
};
/// Block header in the config savedata file /// Block header in the config savedata file
struct SaveConfigBlockEntry { struct SaveConfigBlockEntry {
u32 block_id; ///< The id of the current block u32 block_id; ///< The id of the current block
@ -398,6 +403,18 @@ public:
*/ */
u64 GetConsoleUniqueId(); 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 * 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 * @returns ResultCode indicating the result of the operation, 0 on success