diff --git a/Makefile b/Makefile index be5b313..da12d55 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ DATA := data INCLUDES := include lib/zipper/include /lib/borealis/library/include/borealis/extern/nlohmann APP_TITLE := All-in-One Switch Updater APP_AUTHOR := HamletDuFromage -APP_VERSION := 2.4.6 +APP_VERSION := 2.4.7 TARGET := $(notdir $(CURDIR)) ROMFS := resources diff --git a/include/current_cfw.hpp b/include/current_cfw.hpp index d6b916c..1e6d1de 100644 --- a/include/current_cfw.hpp +++ b/include/current_cfw.hpp @@ -7,6 +7,6 @@ namespace CurrentCfw { CFW getCFW(); std::string getAmsInfo(); - const extern CFW running_cfw; + extern CFW running_cfw; } \ No newline at end of file diff --git a/source/changelog_page.cpp b/source/changelog_page.cpp index 93ec70c..96ad3b9 100644 --- a/source/changelog_page.cpp +++ b/source/changelog_page.cpp @@ -136,6 +136,9 @@ ChangelogPage::ChangelogPage() : AppletFrame(true, true) verTitles.push_back("v2.4.6"); changes.push_back("\uE016 Added back support for SXOS. \uE016 Removed dialogue asking to update Hekate if downloading DeepSea.\uE016 Fixed incorrect description in inject payload menu."); + verTitles.push_back("v2.4.7"); + changes.push_back("\uE016 Fixed app only working on 0.19 AMS.\uE016 Proper replacement of stratosphere.romfs when updating."); + for(int i = verTitles.size() -1 ; i >= 0; i--){ listItem = new brls::ListItem(verTitles[i]); change = changes[i]; diff --git a/source/current_cfw.cpp b/source/current_cfw.cpp index ea1ea4d..1c1cfa9 100644 --- a/source/current_cfw.cpp +++ b/source/current_cfw.cpp @@ -16,22 +16,32 @@ namespace CurrentCfw { return running; } - Result smAtmosphereHasService(bool *out, SmServiceName name) { + Result smAtmosphereHasService(bool *out, SmServiceName name, bool v019) { u8 tmp = 0; - Result rc = tipcDispatchInOut(smGetServiceSessionTipc(), 65100, name, tmp); + Result rc = v019 ? tipcDispatchInOut(smGetServiceSessionTipc(), 65100, name, tmp) : serviceDispatchInOut(smGetServiceSession(), 65100, name, tmp); if (R_SUCCEEDED(rc) && out) *out = tmp; return rc; } + bool isPost019() { + u64 version; + if(R_SUCCEEDED(splGetConfig((SplConfigItem) 65000, &version))) { + if(((version >> 56) & ((1 << 8) - 1)) > 0 || ((version >> 48) & ((1 << 8) - 1)) >= 19) { + return true; + } + } + return false; + } } CFW getCFW(){ bool res = false; - if(R_SUCCEEDED(smAtmosphereHasService(&res, smEncodeName("rnx")))) { + bool v019 = isPost019(); //AMS v0.19 introduced sm changes, and as such old AMS versions have to be treated differently + if(R_SUCCEEDED(smAtmosphereHasService(&res, smEncodeName("rnx"), v019))) { if(res) return CFW::rnx; - smAtmosphereHasService(&res, smEncodeName("tx")); + smAtmosphereHasService(&res, smEncodeName("tx"), v019); if(res) return CFW::sxos; } @@ -43,18 +53,18 @@ namespace CurrentCfw { } std::string getAmsInfo() { - u64 version; - std::string res; - if(R_SUCCEEDED(splGetConfig((SplConfigItem) 65000, &version))){ - res += std::to_string((version >> 56) & ((1 << 8) - 1)) + "." + - std::to_string((version >> 48) & ((1 << 8) - 1)) + "." + - std::to_string((version >> 40) & ((1 << 8) - 1)); - if(R_SUCCEEDED(splGetConfig((SplConfigItem) 65007, &version))) - res += version ? "|E" : "|S"; - return res; - } - else - return "Couldn't retrieve AMS version"; + u64 version; + std::string res; + if(R_SUCCEEDED(splGetConfig((SplConfigItem) 65000, &version))) { + res += std::to_string((version >> 56) & ((1 << 8) - 1)) + "." + + std::to_string((version >> 48) & ((1 << 8) - 1)) + "." + + std::to_string((version >> 40) & ((1 << 8) - 1)); + if(R_SUCCEEDED(splGetConfig((SplConfigItem) 65007, &version))) + res += version ? "|E" : "|S"; + return res; + } + else + return "Couldn't retrieve AMS version"; } } \ No newline at end of file diff --git a/source/main.cpp b/source/main.cpp index 36ac225..abc9638 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -14,7 +14,7 @@ using namespace i18n::literals; //TimeServiceType __nx_time_service_type = TimeServiceType_System; -const CFW CurrentCfw::running_cfw = CurrentCfw::getCFW(); +CFW CurrentCfw::running_cfw; int main(int argc, char* argv[]) { @@ -44,6 +44,8 @@ int main(int argc, char* argv[]) nxlinkStdio(); splInitialize(); romfsInit(); + + CurrentCfw::running_cfw = CurrentCfw::getCFW(); fs::createTree(CONFIG_PATH); diff --git a/source/utils.cpp b/source/utils.cpp index e94e297..85fd4cf 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -241,10 +241,8 @@ std::string readVersion(const char* path){ } bool isErista() { - splInitialize(); u64 hwType; Result rc = splGetConfig(SplConfigItem_HardwareType, &hwType); - splExit(); if(R_FAILED(rc)) return true;