mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
set_mitm: embed defaults in code, allow for missing ini
This commit is contained in:
parent
c10ba67973
commit
8d9c51f204
3 changed files with 84 additions and 26 deletions
|
@ -1,40 +1,37 @@
|
||||||
; Disable uploading error reports to Nintendo
|
; Disable uploading error reports to Nintendo
|
||||||
[eupld]
|
[eupld]
|
||||||
upload_enabled = u8!0x0
|
; upload_enabled = u8!0x0
|
||||||
; Enable USB 3.0 superspeed for homebrew
|
|
||||||
[usb]
|
|
||||||
usb30_force_enabled = u8!0x0
|
|
||||||
; Control whether RO should ease its validation of NROs.
|
; Control whether RO should ease its validation of NROs.
|
||||||
; (note: this is normally not necessary, and ips patches can be used.)
|
; (note: this is normally not necessary, and ips patches can be used.)
|
||||||
[ro]
|
[ro]
|
||||||
ease_nro_restriction = u8!0x0
|
; ease_nro_restriction = u8!0x0
|
||||||
; Atmosphere custom settings
|
; Atmosphere custom settings
|
||||||
[atmosphere]
|
[atmosphere]
|
||||||
; Reboot from fatal automatically after some number of milliseconds.
|
; Reboot from fatal automatically after some number of milliseconds.
|
||||||
; If field is not present or 0, fatal will wait indefinitely for user input.
|
; If field is not present or 0, fatal will wait indefinitely for user input.
|
||||||
fatal_auto_reboot_interval = u64!0x0
|
; fatal_auto_reboot_interval = u64!0x0
|
||||||
; Make the power menu's "reboot" button reboot to payload.
|
; Make the power menu's "reboot" button reboot to payload.
|
||||||
; Set to "normal" for normal reboot, "rcm" for rcm reboot.
|
; Set to "normal" for normal reboot, "rcm" for rcm reboot.
|
||||||
power_menu_reboot_function = str!payload
|
; power_menu_reboot_function = str!payload
|
||||||
; Controls whether dmnt cheats should be toggled on or off by
|
; Controls whether dmnt cheats should be toggled on or off by
|
||||||
; default. 1 = toggled on by default, 0 = toggled off by default.
|
; default. 1 = toggled on by default, 0 = toggled off by default.
|
||||||
dmnt_cheats_enabled_by_default = u8!0x1
|
; dmnt_cheats_enabled_by_default = u8!0x1
|
||||||
; Controls whether dmnt should always save cheat toggle state
|
; Controls whether dmnt should always save cheat toggle state
|
||||||
; for restoration on new game launch. 1 = always save toggles,
|
; for restoration on new game launch. 1 = always save toggles,
|
||||||
; 0 = only save toggles if toggle file exists.
|
; 0 = only save toggles if toggle file exists.
|
||||||
dmnt_always_save_cheat_toggles = u8!0x0
|
; dmnt_always_save_cheat_toggles = u8!0x0
|
||||||
; Controls whether fs.mitm should redirect save files
|
; Controls whether fs.mitm should redirect save files
|
||||||
; to directories on the sd card.
|
; to directories on the sd card.
|
||||||
; 0 = Do not redirect, 1 = Redirect.
|
; 0 = Do not redirect, 1 = Redirect.
|
||||||
; NOTE: EXPERIMENTAL
|
; NOTE: EXPERIMENTAL
|
||||||
; If you do not know what you are doing, do not touch this yet.
|
; If you do not know what you are doing, do not touch this yet.
|
||||||
fsmitm_redirect_saves_to_sd = u8!0x0
|
; fsmitm_redirect_saves_to_sd = u8!0x0
|
||||||
[hbloader]
|
[hbloader]
|
||||||
; Controls the size of the homebrew heap when running as applet.
|
; Controls the size of the homebrew heap when running as applet.
|
||||||
; If set to zero, all available applet memory is used as heap.
|
; If set to zero, all available applet memory is used as heap.
|
||||||
; The default is zero.
|
; The default is zero.
|
||||||
applet_heap_size = u64!0x0
|
; applet_heap_size = u64!0x0
|
||||||
; Controls the amount of memory to reserve when running as applet
|
; Controls the amount of memory to reserve when running as applet
|
||||||
; for usage by other applets. This setting has no effect if
|
; for usage by other applets. This setting has no effect if
|
||||||
; applet_heap_size is non-zero. The default is zero.
|
; applet_heap_size is non-zero. The default is 0x8000000.
|
||||||
applet_heap_reservation_size = u64!0x8000000
|
; applet_heap_reservation_size = u64!0x8000000
|
|
@ -13,6 +13,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
#include "../amsmitm_initialization.hpp"
|
||||||
#include "nsmitm_module.hpp"
|
#include "nsmitm_module.hpp"
|
||||||
#include "ns_am_mitm_service.hpp"
|
#include "ns_am_mitm_service.hpp"
|
||||||
#include "ns_web_mitm_service.hpp"
|
#include "ns_web_mitm_service.hpp"
|
||||||
|
@ -22,7 +23,7 @@ namespace ams::mitm::ns {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr sm::ServiceName NsAmMitmServiceName = sm::ServiceName::Encode("ns:am");
|
constexpr sm::ServiceName NsAmMitmServiceName = sm::ServiceName::Encode("ns:am");
|
||||||
constexpr sm::ServiceName NsWebMitmServiceName = sm::ServiceName::Encode("ns:am");
|
constexpr sm::ServiceName NsWebMitmServiceName = sm::ServiceName::Encode("ns:web");
|
||||||
|
|
||||||
constexpr size_t MaxServers = 1;
|
constexpr size_t MaxServers = 1;
|
||||||
constexpr size_t MaxSessions = 5;
|
constexpr size_t MaxSessions = 5;
|
||||||
|
@ -32,6 +33,9 @@ namespace ams::mitm::ns {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MitmModule::ThreadFunction(void *arg) {
|
void MitmModule::ThreadFunction(void *arg) {
|
||||||
|
/* Wait until initialization is complete. */
|
||||||
|
mitm::WaitInitialized();
|
||||||
|
|
||||||
/* Create mitm servers. */
|
/* Create mitm servers. */
|
||||||
if (hos::GetVersion() < hos::Version_300) {
|
if (hos::GetVersion() < hos::Version_300) {
|
||||||
R_ASSERT(g_server_manager.RegisterMitmServer<NsAmMitmService>(NsAmMitmServiceName));
|
R_ASSERT(g_server_manager.RegisterMitmServer<NsAmMitmService>(NsAmMitmServiceName));
|
||||||
|
|
|
@ -291,13 +291,80 @@ namespace ams::settings::fwdbg {
|
||||||
Result LoadSdCardKeyValueStore() {
|
Result LoadSdCardKeyValueStore() {
|
||||||
/* Open file. */
|
/* Open file. */
|
||||||
FsFile config_file;
|
FsFile config_file;
|
||||||
R_TRY(ams::mitm::fs::OpenAtmosphereSdFile(&config_file, "/system_settings.ini", FsOpenMode_Read));
|
if (R_FAILED(ams::mitm::fs::OpenAtmosphereSdFile(&config_file, "/system_settings.ini", FsOpenMode_Read))) {
|
||||||
|
/* It's okay if the file isn't readable/present, because we already loaded defaults. */
|
||||||
|
return ResultSuccess();
|
||||||
|
}
|
||||||
ON_SCOPE_EXIT { fsFileClose(&config_file); };
|
ON_SCOPE_EXIT { fsFileClose(&config_file); };
|
||||||
|
|
||||||
Result parse_result = ResultSuccess();
|
Result parse_result = ResultSuccess();
|
||||||
util::ini::ParseFile(&config_file, &parse_result, SystemSettingsIniHandler);
|
util::ini::ParseFile(&config_file, &parse_result, SystemSettingsIniHandler);
|
||||||
R_TRY(parse_result);
|
R_TRY(parse_result);
|
||||||
|
|
||||||
|
return ResultSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadDefaultCustomSettings() {
|
||||||
|
/* Disable uploading error reports to Nintendo. */
|
||||||
|
R_ASSERT(ParseSettingsItemValue("eupld", "upload_enabled", "u8!0x0"));
|
||||||
|
|
||||||
|
/* Control whether RO should ease its validation of NROs. */
|
||||||
|
/* (note: this is normally not necessary, and ips patches can be used.) */
|
||||||
|
R_ASSERT(ParseSettingsItemValue("ro", "ease_nro_restriction", "u8!0x0"));
|
||||||
|
|
||||||
|
/* Atmosphere custom settings. */
|
||||||
|
|
||||||
|
/* Reboot from fatal automatically after some number of milliseconds. */
|
||||||
|
/* If field is not present or 0, fatal will wait indefinitely for user input. */
|
||||||
|
R_ASSERT(ParseSettingsItemValue("atmosphere", "fatal_auto_reboot_interval", "u64!0x0"));
|
||||||
|
|
||||||
|
/* Make the power menu's "reboot" button reboot to payload. */
|
||||||
|
/* Set to "normal" for normal reboot, "rcm" for rcm reboot. */
|
||||||
|
R_ASSERT(ParseSettingsItemValue("atmosphere", "power_menu_reboot_function", "str!payload"));
|
||||||
|
|
||||||
|
/* Controls whether dmnt cheats should be toggled on or off by */
|
||||||
|
/* default. 1 = toggled on by default, 0 = toggled off by default. */
|
||||||
|
R_ASSERT(ParseSettingsItemValue("atmosphere", "dmnt_cheats_enabled_by_default", "u8!0x1"));
|
||||||
|
|
||||||
|
/* Controls whether dmnt should always save cheat toggle state */
|
||||||
|
/* for restoration on new game launch. 1 = always save toggles, */
|
||||||
|
/* 0 = only save toggles if toggle file exists. */
|
||||||
|
R_ASSERT(ParseSettingsItemValue("atmosphere", "dmnt_always_save_cheat_toggles", "u8!0x0"));
|
||||||
|
|
||||||
|
/* Controls whether fs.mitm should redirect save files */
|
||||||
|
/* to directories on the sd card. */
|
||||||
|
/* 0 = Do not redirect, 1 = Redirect. */
|
||||||
|
/* NOTE: EXPERIMENTAL */
|
||||||
|
/* If you do not know what you are doing, do not touch this yet. */
|
||||||
|
R_ASSERT(ParseSettingsItemValue("atmosphere", "fsmitm_redirect_saves_to_sd", "u8!0x0"));
|
||||||
|
|
||||||
|
/* Hbloader custom settings. */
|
||||||
|
|
||||||
|
/* Controls the size of the homebrew heap when running as applet. */
|
||||||
|
/* If set to zero, all available applet memory is used as heap. */
|
||||||
|
/* The default is zero. */
|
||||||
|
R_ASSERT(ParseSettingsItemValue("hbloader", "applet_heap_size", "u64!0x0"));
|
||||||
|
|
||||||
|
/* Controls the amount of memory to reserve when running as applet */
|
||||||
|
/* for usage by other applets. This setting has no effect if */
|
||||||
|
/* applet_heap_size is non-zero. The default is 0x8000000. */
|
||||||
|
R_ASSERT(ParseSettingsItemValue("hbloader", "applet_heap_reservation_size", "u64!0x8000000"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitializeSdCardKeyValueStore() {
|
||||||
|
/* Load in hardcoded defaults. */
|
||||||
|
/* These will be overwritten if present on the SD card. */
|
||||||
|
LoadDefaultCustomSettings();
|
||||||
|
|
||||||
|
/* Parse custom settings off the SD card. */
|
||||||
|
const Result parse_result = LoadSdCardKeyValueStore();
|
||||||
|
if (R_FAILED(parse_result)) {
|
||||||
|
ams::mitm::ThrowResultForDebug(parse_result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Determine how many custom settings are present. */
|
||||||
for (size_t i = 0; i < util::size(g_entries); i++) {
|
for (size_t i = 0; i < util::size(g_entries); i++) {
|
||||||
if (!g_entries[i].HasValue()) {
|
if (!g_entries[i].HasValue()) {
|
||||||
g_num_entries = i;
|
g_num_entries = i;
|
||||||
|
@ -305,20 +372,10 @@ namespace ams::settings::fwdbg {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ensure that the custom settings entries are sorted. */
|
||||||
if (g_num_entries) {
|
if (g_num_entries) {
|
||||||
std::sort(g_entries, g_entries + g_num_entries);
|
std::sort(g_entries, g_entries + g_num_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResultSuccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitializeSdCardKeyValueStore() {
|
|
||||||
const Result parse_result = LoadSdCardKeyValueStore();
|
|
||||||
if (R_FAILED(parse_result)) {
|
|
||||||
ams::mitm::ThrowResultForDebug(parse_result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result GetSdCardKeyValueStoreSettingsItemValueSize(size_t *out_size, const char *name, const char *key) {
|
Result GetSdCardKeyValueStoreSettingsItemValueSize(size_t *out_size, const char *name, const char *key) {
|
||||||
|
|
Loading…
Reference in a new issue