diff --git a/config_templates/system_settings.ini b/config_templates/system_settings.ini index 32cebc036..5b6edd8ed 100644 --- a/config_templates/system_settings.ini +++ b/config_templates/system_settings.ini @@ -26,6 +26,9 @@ ; Enable reading the CAL0 partition for HBL. ; This is probably undesirable for normal usage. ; enable_hbl_cal_read = u8!0x0 +; Disable CAL0 write-protection +; This is almost certainly undesirable and dangerous for normal usage +; disable_cal_write = u8!0x0 WARRANTY VOID IF CHANGED - YOU HAVE BEEN WARNED ; Controls whether fs.mitm should redirect save files ; to directories on the sd card. ; 0 = Do not redirect, 1 = Redirect. diff --git a/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp b/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp index 8c13c3f70..ba0c64739 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp @@ -251,6 +251,7 @@ namespace ams::mitm::fs { const bool is_sysmodule = ncm::IsSystemProgramId(this->client_info.program_id); const bool is_hbl = this->client_info.override_status.IsHbl(); + const bool cal_write_protect = !GetSettingsItemBooleanValue("atmosphere", "disable_cal_write"); const bool can_write_bis = is_sysmodule || (is_hbl && GetSettingsItemBooleanValue("atmosphere", "enable_hbl_bis_write")); const bool can_read_cal = is_sysmodule || (is_hbl && GetSettingsItemBooleanValue("atmosphere", "enable_hbl_cal_read")); @@ -266,8 +267,11 @@ namespace ams::mitm::fs { out.SetValue(std::make_shared(new Boot0Storage(bis_storage, this->client_info)), target_object_id); } else if (bis_partition_id == FsBisPartitionId_CalibrationBinary) { /* PRODINFO should *never* be writable. */ + if (!cal_write_protect) { + /* unless the user explicitly disabled write-protection */ + out.SetValue(std::make_shared(new RemoteStorage(bis_storage)), target_object_id); /* If we have permissions, create a read only storage. */ - if (can_read_cal) { + } else if (can_read_cal) { out.SetValue(std::make_shared(new ReadOnlyStorageAdapter(new RemoteStorage(bis_storage))), target_object_id); } else { /* If we can't read cal, return permission denied. */ diff --git a/stratosphere/ams_mitm/source/set_mitm/settings_sd_kvs.cpp b/stratosphere/ams_mitm/source/set_mitm/settings_sd_kvs.cpp index 7e211a945..bd41a7b82 100644 --- a/stratosphere/ams_mitm/source/set_mitm/settings_sd_kvs.cpp +++ b/stratosphere/ams_mitm/source/set_mitm/settings_sd_kvs.cpp @@ -332,6 +332,10 @@ namespace ams::settings::fwdbg { /* This is probably undesirable for normal usage. */ R_ABORT_UNLESS(ParseSettingsItemValue("atmosphere", "enable_hbl_cal_read", "u8!0x0")); + /* Disable CAL0 write-protection */ + /* This is almost certainly undesirable and dangerous for normal usage. */ + R_ABORT_UNLESS(ParseSettingsItemValue("atmosphere", "disable_cal_write", "u8!0x0")); + /* Controls whether dmnt cheats should be toggled on or off by */ /* default. 1 = toggled on by default, 0 = toggled off by default. */ R_ABORT_UNLESS(ParseSettingsItemValue("atmosphere", "dmnt_cheats_enabled_by_default", "u8!0x1"));