mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-26 19:10:06 +00:00
SystemIntegrityCheck: Moved the check for each Archive to a seperate function
This commit is contained in:
parent
69a36fbaec
commit
016a73127b
@ -207,52 +207,72 @@ void System::Shutdown() {
|
|||||||
LOG_DEBUG(Core, "Shutdown OK");
|
LOG_DEBUG(Core, "Shutdown OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
void System::SystemIntegrityCheck() {
|
static System::Integrity::Status GetArchiveStatus(const std::string& name, const u32 id_high,
|
||||||
// Shared Font JP/EUR/USA
|
const u32 id_low, std::string& settings_version,
|
||||||
|
const void* custom_data,
|
||||||
|
const size_t custom_data_length,
|
||||||
|
const std::string& legacy_path = "") {
|
||||||
std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX);
|
std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX);
|
||||||
const u32 shared_font_archive_id_low = 0x00014002;
|
std::string shared_font_path =
|
||||||
const u32 shared_font_archive_id_high = 0x0004009b;
|
Common::StringFromFormat("%s%s/title/%08x/%08x/content/00000000.app.romfs",
|
||||||
std::string shared_font_path = Common::StringFromFormat(
|
nand_directory.c_str(), SYSTEM_ID, id_high, id_low);
|
||||||
"%s%s/title/%08x/%08x/content/00000000.app.romfs", nand_directory.c_str(), SYSTEM_ID,
|
|
||||||
shared_font_archive_id_high, shared_font_archive_id_low);
|
|
||||||
if (FileUtil::Exists(shared_font_path)) {
|
if (FileUtil::Exists(shared_font_path)) {
|
||||||
std::string version = Settings::values.shared_font_jeu_version;
|
std::string version = Settings::values.shared_font_jeu_version;
|
||||||
if (version == "dumped") {
|
if (version == "dumped") {
|
||||||
system_integrity.shared_font_JEU = Integrity::Dumped;
|
LOG_INFO(Core, "SystemCheck: %s exists.", name.c_str());
|
||||||
LOG_INFO(Core, "SystemCheck: Shared Font exists.");
|
return System::Integrity::Dumped;
|
||||||
} else if (version == CUSTOM_ARCHIVES_VERSION) {
|
|
||||||
system_integrity.shared_font_JEU = Integrity::Custom;
|
|
||||||
LOG_WARNING(Core, "SystemCheck: Shared Font (custom) exists.");
|
|
||||||
#ifdef ENABLE_CUSTOM_SYSTEM_ARCHIVES
|
#ifdef ENABLE_CUSTOM_SYSTEM_ARCHIVES
|
||||||
|
} else if (settings_version == CUSTOM_ARCHIVES_VERSION) {
|
||||||
|
LOG_WARNING(Core, "SystemCheck: %s(custom) exists.", name.c_str());
|
||||||
|
return System::Integrity::Custom;
|
||||||
} else {
|
} else {
|
||||||
FileUtil::IOFile file(shared_font_path, "wb");
|
FileUtil::IOFile file(shared_font_path, "wb");
|
||||||
file.WriteBytes(SHARED_FONT_DATA, SHARED_FONT_DATA_len);
|
file.WriteBytes(custom_data, custom_data_length);
|
||||||
file.Close();
|
file.Close();
|
||||||
system_integrity.shared_font_JEU = Integrity::CreatedCustom;
|
settings_version = CUSTOM_ARCHIVES_VERSION;
|
||||||
Settings::values.shared_font_jeu_version = CUSTOM_ARCHIVES_VERSION;
|
LOG_WARNING(Core, "SystemCheck: Updated %s.", name.c_str());
|
||||||
LOG_WARNING(Core, "SystemCheck: Updated Shared Font.");
|
return System::Integrity::CreatedCustom;
|
||||||
}
|
#else
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
|
LOG_WARNING(Core, "SystemCheck: %s(custom) exists.", name.c_str());
|
||||||
|
return System::Integrity::Custom;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!legacy_path.empty() && FileUtil::Exists(legacy_path)) {
|
||||||
|
LOG_INFO(Core, "SystemCheck: %s(legacy) exists.", name.c_str());
|
||||||
|
return System::Integrity::DumpedLegacy;
|
||||||
|
} else {
|
||||||
|
LOG_ERROR(Core, "SystemCheck: %s missing.", name.c_str());
|
||||||
|
#ifdef ENABLE_CUSTOM_SYSTEM_ARCHIVES
|
||||||
|
FileUtil::IOFile file(shared_font_path, "wb");
|
||||||
|
file.WriteBytes(custom_data, custom_data_length);
|
||||||
|
file.Close();
|
||||||
|
settings_version = CUSTOM_ARCHIVES_VERSION;
|
||||||
|
LOG_WARNING(Core, "SystemCheck: Created %s.", name.c_str());
|
||||||
|
return System::Integrity::CreatedCustom;
|
||||||
|
#else
|
||||||
|
return System::Integrity::Missing;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void System::SystemIntegrityCheck() {
|
||||||
|
// TODO(B3N30): Check other required system archives
|
||||||
|
|
||||||
|
// Shared Font JP/EUR/USA
|
||||||
std::string shared_font_legacy_path = FileUtil::GetUserPath(D_SYSDATA_IDX) + SHARED_FONT;
|
std::string shared_font_legacy_path = FileUtil::GetUserPath(D_SYSDATA_IDX) + SHARED_FONT;
|
||||||
if (FileUtil::Exists(shared_font_legacy_path)) {
|
|
||||||
LOG_INFO(Core, "SystemCheck: Shared Font(legacy) exists.");
|
|
||||||
system_integrity.shared_font_JEU = Integrity::DumpedLegacy;
|
|
||||||
} else {
|
|
||||||
LOG_ERROR(Core, "SystemCheck: Shared Font missing.");
|
|
||||||
system_integrity.shared_font_JEU = Integrity::Missing;
|
|
||||||
#ifdef ENABLE_CUSTOM_SYSTEM_ARCHIVES
|
#ifdef ENABLE_CUSTOM_SYSTEM_ARCHIVES
|
||||||
FileUtil::IOFile file(shared_font_path, "wb");
|
system_integrity.shared_font_JEU = GetArchiveStatus(
|
||||||
file.WriteBytes(SHARED_FONT_DATA, SHARED_FONT_DATA_len);
|
"Shared Font JP/EUR/USA", 0x0004009b, 0x00014002, Settings::values.shared_font_jeu_version,
|
||||||
file.Close();
|
SHARED_FONT_DATA, SHARED_FONT_DATA_len, shared_font_legacy_path);
|
||||||
system_integrity.shared_font_JEU = Integrity::CreatedCustom;
|
#else
|
||||||
Settings::values.shared_font_jeu_version = CUSTOM_ARCHIVES_VERSION;
|
system_integrity.shared_font_JEU = GetArchiveStatus(
|
||||||
LOG_WARNING(Core, "SystemCheck: Created Shared Font.");
|
"Shared Font JP/EUR/USA", 0x0004009b, 0x00014002, Settings::values.shared_font_jeu_version,
|
||||||
|
nullptr, 0, shared_font_legacy_path);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(B3N30): Check if the other required system archives exists
|
} // namespace Core
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
Loading…
Reference in New Issue
Block a user