From 1ca373cd71a11ac41b067538da21dc256105da35 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 14 Dec 2020 15:56:04 -0800 Subject: [PATCH] set.mitm: add setting for controlling DebugModeFlag for am --- config_templates/system_settings.ini | 4 ++++ .../ams_mitm/source/set_mitm/setsys_mitm_service.cpp | 12 ++++++++++++ .../ams_mitm/source/set_mitm/setsys_mitm_service.hpp | 4 +++- .../ams_mitm/source/set_mitm/settings_sd_kvs.cpp | 5 +++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/config_templates/system_settings.ini b/config_templates/system_settings.ini index 74027f711..600d03c5f 100644 --- a/config_templates/system_settings.ini +++ b/config_templates/system_settings.ini @@ -38,6 +38,10 @@ ; Please note this setting may be removed in a ; future release of Atmosphere. ; enable_deprecated_hid_mitm = u8!0x0 +; Controls whether am sees system settings "DebugModeFlag" as +; enabled or disabled. +; 0 = Disabled (not debug mode), 1 = Enabled (debug mode) +; enable_am_debug_mode = u8!0x0 [hbloader] ; Controls the size of the homebrew heap when running as applet. ; If set to zero, all available applet memory is used as heap. diff --git a/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp b/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp index b1b49fe91..769242f88 100644 --- a/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp @@ -122,4 +122,16 @@ namespace ams::mitm::settings { return ResultSuccess(); } + Result SetSysMitmService::GetDebugModeFlag(sf::Out out) { + /* If we're not processing for am, just return the real flag value. */ + R_UNLESS(this->client_info.program_id == ncm::SystemProgramId::Am, sm::mitm::ResultShouldForwardToSession()); + + /* Retrieve the user configuration. */ + u8 en = 0; + settings::fwdbg::GetSettingsItemValue(std::addressof(en), sizeof(en), "atmosphere", "enable_am_debug_mode"); + + out.SetValue(en != 0); + return ResultSuccess(); + } + } diff --git a/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.hpp b/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.hpp index 54bb22ecd..f91fbb183 100644 --- a/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.hpp +++ b/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.hpp @@ -24,7 +24,8 @@ namespace ams::mitm::settings { AMS_SF_METHOD_INFO(C, H, 3, Result, GetFirmwareVersion, (sf::Out out)) \ AMS_SF_METHOD_INFO(C, H, 4, Result, GetFirmwareVersion2, (sf::Out out)) \ AMS_SF_METHOD_INFO(C, H, 37, Result, GetSettingsItemValueSize, (sf::Out out_size, const ams::settings::fwdbg::SettingsName &name, const ams::settings::fwdbg::SettingsItemKey &key)) \ - AMS_SF_METHOD_INFO(C, H, 38, Result, GetSettingsItemValue, (sf::Out out_size, const sf::OutBuffer &out, const ams::settings::fwdbg::SettingsName &name, const ams::settings::fwdbg::SettingsItemKey &key)) + AMS_SF_METHOD_INFO(C, H, 38, Result, GetSettingsItemValue, (sf::Out out_size, const sf::OutBuffer &out, const ams::settings::fwdbg::SettingsName &name, const ams::settings::fwdbg::SettingsItemKey &key)) \ + AMS_SF_METHOD_INFO(C, H, 62, Result, GetDebugModeFlag, (sf::Out out)) AMS_SF_DEFINE_MITM_INTERFACE(ISetSysMitmInterface, AMS_SETTINGS_SYSTEM_MITM_INTERFACE_INFO) @@ -45,6 +46,7 @@ namespace ams::mitm::settings { Result GetFirmwareVersion2(sf::Out out); Result GetSettingsItemValueSize(sf::Out out_size, const ams::settings::fwdbg::SettingsName &name, const ams::settings::fwdbg::SettingsItemKey &key); Result GetSettingsItemValue(sf::Out out_size, const sf::OutBuffer &out, const ams::settings::fwdbg::SettingsName &name, const ams::settings::fwdbg::SettingsItemKey &key); + Result GetDebugModeFlag(sf::Out out); }; static_assert(IsISetSysMitmInterface); 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 597cc02dd..72228b2af 100644 --- a/stratosphere/ams_mitm/source/set_mitm/settings_sd_kvs.cpp +++ b/stratosphere/ams_mitm/source/set_mitm/settings_sd_kvs.cpp @@ -351,6 +351,11 @@ namespace ams::settings::fwdbg { /* Please note this setting may be removed in a future release of Atmosphere. */ R_ABORT_UNLESS(ParseSettingsItemValue("atmosphere", "enable_deprecated_hid_mitm", "u8!0x0")); + /* Controls whether am sees system settings "DebugModeFlag" as */ + /* enabled or disabled. */ + /* 0 = Disabled (not debug mode), 1 = Enabled (debug mode) */ + R_ABORT_UNLESS(ParseSettingsItemValue("atmosphere", "enable_am_debug_mode", "u8!0x0")); + /* Hbloader custom settings. */ /* Controls the size of the homebrew heap when running as applet. */