2020-10-16 19:48:13 +02:00
|
|
|
#include "ApplicationState.h"
|
|
|
|
#include "WiiUScreen.h"
|
|
|
|
#include "ScreenUtils.h"
|
2020-12-02 15:57:13 +01:00
|
|
|
#include "StringTools.h"
|
2020-10-16 22:51:14 +02:00
|
|
|
#include "../build/safe_payload.h"
|
2020-10-16 19:48:13 +02:00
|
|
|
#include <sysapp/launch.h>
|
2020-10-16 22:51:14 +02:00
|
|
|
#include <iosuhax.h>
|
|
|
|
|
2020-11-30 17:49:32 +01:00
|
|
|
extern "C" void OSShutdown();
|
2020-10-16 19:48:13 +02:00
|
|
|
|
2020-12-02 15:57:13 +01:00
|
|
|
void ApplicationState::changeState(eGameState newState) {
|
|
|
|
this->state = newState;
|
2020-10-16 19:48:13 +02:00
|
|
|
|
2020-12-02 15:57:13 +01:00
|
|
|
menu.clear();
|
2020-10-16 19:48:13 +02:00
|
|
|
if (this->state == STATE_ERROR) {
|
2020-12-02 15:57:13 +01:00
|
|
|
menu.addText("The installation failed:");
|
|
|
|
menu.addText();
|
|
|
|
menu.addText("Error: " + ErrorMessage());
|
|
|
|
menu.addText("Description: " + ErrorDescription());
|
|
|
|
menu.addText();
|
|
|
|
menu.addText();
|
|
|
|
menu.addOption("Press A to return to the Wii U Menu.", STATE_EXIT_SYSMENU);
|
2020-10-16 19:48:13 +02:00
|
|
|
} else if (this->state == STATE_WELCOME_SCREEN) {
|
2020-12-02 15:57:13 +01:00
|
|
|
menu.addText("Welcome to the Aroma Installer!");
|
|
|
|
menu.addText("Do you want to check if an installation is possible?");
|
|
|
|
menu.addText();
|
|
|
|
menu.addOption("Check", STATE_GET_APP_INFORMATION);
|
|
|
|
menu.addOption("Exit", STATE_EXIT_SYSMENU);
|
2020-10-16 19:48:13 +02:00
|
|
|
} else if (this->state == STATE_GET_APP_INFORMATION) {
|
2020-12-02 15:57:13 +01:00
|
|
|
menu.addText("Getting app information");
|
2020-10-16 19:48:13 +02:00
|
|
|
} else if (this->state == STATE_CHECK_PATCH_POSSIBLE) {
|
2020-12-02 15:57:13 +01:00
|
|
|
menu.addText("Check if console can be patched.");
|
|
|
|
} else if (this->state == STATE_CHECK_COLDBOOT_STATUS) {
|
|
|
|
menu.addText("Check if coldboot can be enabled.");
|
2020-12-01 02:05:24 +01:00
|
|
|
} else if (this->state == STATE_CHECK_REMOVAL_POSSIBLE) {
|
2020-12-02 15:57:13 +01:00
|
|
|
menu.addText("Check if Aroma can be removed.");
|
|
|
|
} else if (this->state == STATE_APP_INCOMPATIBLE) {
|
|
|
|
menu.addText("Sorry, Aroma cannot be safely installed to:");
|
|
|
|
menu.addText(std::string(appInfo->appName));
|
|
|
|
menu.addText();
|
|
|
|
menu.addText("Additional informations:");
|
|
|
|
auto showCheckResult = [&] (const std::string &name, bool canPatch, bool patched) {
|
|
|
|
if (patched) {
|
2020-12-04 10:39:36 +01:00
|
|
|
menu.addText("[ X ] " + name + " is already patched!");
|
2020-12-02 15:57:13 +01:00
|
|
|
} else if (canPatch) {
|
2020-12-04 10:39:36 +01:00
|
|
|
menu.addText("[ X ] " + name + " can be patched!");
|
2020-12-01 02:05:24 +01:00
|
|
|
} else {
|
2020-12-04 10:39:36 +01:00
|
|
|
menu.addText("[ ] " + name + " can NOT be patched!");
|
2020-10-16 19:48:13 +02:00
|
|
|
}
|
2020-12-02 15:57:13 +01:00
|
|
|
};
|
2020-12-02 16:19:23 +01:00
|
|
|
if (this->tmdValid) {
|
|
|
|
menu.addText("[ X ] title.tmd is valid!");
|
|
|
|
} else {
|
|
|
|
menu.addText("[ ] title.tmd is NOT valid!");
|
|
|
|
}
|
2020-12-02 15:57:13 +01:00
|
|
|
showCheckResult("title.fst", this->fstPatchPossible, this->fstAlreadyPatched);
|
|
|
|
showCheckResult("cos.xml", this->cosPatchPossible, this->cosAlreadyPatched);
|
|
|
|
showCheckResult("safe.rpx", true, this->rpxAlreadyPatched);
|
|
|
|
menu.addText();
|
|
|
|
menu.addOption("Exit", STATE_EXIT_SYSMENU);
|
|
|
|
} else if (this->state == STATE_MAIN_MENU) {
|
|
|
|
menu.addText("Aroma " + std::string(alreadyInstalled ? "is" : "can be") + " installed to:");
|
|
|
|
menu.addText(std::string(appInfo->appName));
|
|
|
|
menu.addText();
|
|
|
|
menu.addOption("Install", STATE_INSTALL_CONFIRM_DIALOG);
|
|
|
|
menu.addOption("Boot options", STATE_BOOT_MENU);
|
|
|
|
if (this->removalPossible) {
|
|
|
|
menu.addOption("Remove", STATE_REMOVE_CONFIRM_DIALOG);
|
2020-10-16 19:48:13 +02:00
|
|
|
}
|
2020-12-02 15:57:13 +01:00
|
|
|
menu.addOption("Exit", STATE_EXIT_SYSMENU);
|
2020-10-16 19:48:13 +02:00
|
|
|
} else if (this->state == STATE_INSTALL_CONFIRM_DIALOG) {
|
2020-12-02 15:57:13 +01:00
|
|
|
menu.addText("Are you REALLY sure you want to install Aroma?");
|
|
|
|
menu.addText("Installing could permanently damage your console");
|
|
|
|
menu.addText();
|
|
|
|
menu.addText("After the installation you can NO longer use:");
|
|
|
|
menu.addText("- " + std::string(appInfo->appName));
|
|
|
|
menu.addText();
|
|
|
|
menu.addOption("Back", STATE_MAIN_MENU);
|
|
|
|
menu.addOption("Install", STATE_INSTALL_STARTED);
|
2020-10-16 19:48:13 +02:00
|
|
|
} else if (this->state == STATE_INSTALL_STARTED) {
|
2020-12-02 15:57:13 +01:00
|
|
|
menu.addText("Installing...");
|
2020-12-03 23:01:55 +01:00
|
|
|
} else if (this->state == STATE_INSTALL_BACKUP) {
|
|
|
|
menu.addText("... backing up files");
|
2020-10-16 19:48:13 +02:00
|
|
|
} else if (this->state == STATE_INSTALL_FST) {
|
2020-12-02 15:57:13 +01:00
|
|
|
menu.addText("... patching title.fst");
|
2020-10-16 19:48:13 +02:00
|
|
|
} else if (this->state == STATE_INSTALL_COS) {
|
2020-12-02 15:57:13 +01:00
|
|
|
menu.addText("... patching cos.xml");
|
2020-10-16 19:48:13 +02:00
|
|
|
} else if (this->state == STATE_INSTALL_RPX) {
|
2020-12-02 15:57:13 +01:00
|
|
|
menu.addText("... install safe.rpx");
|
2020-10-16 22:51:14 +02:00
|
|
|
} else if (this->state == STATE_INSTALL_SUCCESS) {
|
2020-12-02 15:57:13 +01:00
|
|
|
menu.addText("Aroma was successfully installed");
|
|
|
|
menu.addText();
|
|
|
|
menu.addOption("Press A to shutdown the console", STATE_EXIT_SHUTDOWN);
|
2020-12-01 02:05:24 +01:00
|
|
|
} else if (this->state == STATE_REMOVE_CONFIRM_DIALOG) {
|
2020-12-02 15:57:13 +01:00
|
|
|
menu.addText("Are you REALLY sure you want to remove Aroma?");
|
|
|
|
menu.addText("If you have modified some system apps such as the");
|
|
|
|
menu.addText("system menu this could make your console unusable");
|
|
|
|
menu.addText();
|
|
|
|
menu.addOption("Back", STATE_MAIN_MENU);
|
|
|
|
menu.addOption("Remove", STATE_REMOVE_STARTED);
|
2020-12-01 02:05:24 +01:00
|
|
|
} else if (this->state == STATE_REMOVE_STARTED) {
|
2020-12-02 15:57:13 +01:00
|
|
|
menu.addText("Removing...");
|
2020-12-01 02:05:24 +01:00
|
|
|
} else if (this->state == STATE_REMOVE_COLDBOOT) {
|
2020-12-02 15:57:13 +01:00
|
|
|
menu.addText("... remove system.xml coldboot patches");
|
2020-12-01 02:05:24 +01:00
|
|
|
} else if (this->state == STATE_REMOVE_AROMA) {
|
2020-12-02 15:57:13 +01:00
|
|
|
menu.addText("... remove Aroma application patches");
|
2020-12-01 02:05:24 +01:00
|
|
|
} else if (this->state == STATE_REMOVE_SUCCESS) {
|
2020-12-02 15:57:13 +01:00
|
|
|
menu.addText("Aroma was successfully removed");
|
|
|
|
menu.addText();
|
|
|
|
menu.addOption("Press A to shutdown the console", STATE_EXIT_SHUTDOWN);
|
|
|
|
} else if (this->state == STATE_BOOT_MENU) {
|
|
|
|
menu.addText("System is currently booting into: ");
|
|
|
|
std::string titleId = StringTools::strfmt("%ll016X", this->coldbootTitleId);
|
|
|
|
std::string titleName = this->coldbootTitle ?
|
|
|
|
std::string(this->coldbootTitle->name) : "Unknown title";
|
|
|
|
menu.addText(titleId + " (" + titleName + ")");
|
|
|
|
menu.addText();
|
|
|
|
|
|
|
|
if (this->systemXMLRestorePossible && this->systemXMLAlreadyPatched) {
|
|
|
|
menu.addOption("Switch back to System Menu", STATE_BOOT_SWITCH_SYSMENU);
|
|
|
|
} else if (this->systemXMLPatchAllowed) {
|
|
|
|
menu.addOption("Switch to Aroma", STATE_BOOT_SWITCH_AROMA);
|
|
|
|
} else if (this->systemXMLPatchPossible) {
|
|
|
|
menu.addText("To change the system boot title to Aroma, you need to");
|
|
|
|
menu.addText("launch this installer from an already running Aroma");
|
|
|
|
menu.addText("instance, in order to verify that the installation");
|
|
|
|
menu.addText("is working properly.");
|
|
|
|
menu.addText();
|
|
|
|
menu.addText("After installing Aroma, reboot the console, open the");
|
|
|
|
menu.addText("Health & Safety app and relaunch the Aroma installer.");
|
|
|
|
menu.addText();
|
|
|
|
} else {
|
|
|
|
menu.addText("Sorry, your system.xml file has not yet been tested");
|
|
|
|
menu.addText("with this tool. Boot options cannot be modified.");
|
|
|
|
menu.addText();
|
|
|
|
}
|
|
|
|
menu.addOption("Back", STATE_MAIN_MENU);
|
|
|
|
} else if (this->state == STATE_BOOT_SWITCH_AROMA) {
|
|
|
|
menu.addText("Changing system.xml to boot " + std::string(this->appInfo->appName) + " ...");
|
|
|
|
} else if (this->state == STATE_BOOT_SWITCH_SYSMENU) {
|
|
|
|
menu.addText("Changing system.xml to boot System Menu ...");
|
|
|
|
} else if (this->state == STATE_BOOT_SWITCH_SUCCESS) {
|
|
|
|
menu.addText("Boot title successfully updated!");
|
|
|
|
menu.addText();
|
|
|
|
menu.addOption("Press A to shutdown the console", STATE_EXIT_SHUTDOWN);
|
2020-10-16 19:48:13 +02:00
|
|
|
}
|
2020-12-02 15:57:13 +01:00
|
|
|
|
|
|
|
this->state = newState;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ApplicationState::render() {
|
|
|
|
menu.render();
|
2020-10-16 19:48:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ApplicationState::update(Input *input) {
|
|
|
|
if (this->state == STATE_ERROR) {
|
2020-10-16 22:51:14 +02:00
|
|
|
OSEnableHomeButtonMenu(true);
|
2020-10-16 19:48:13 +02:00
|
|
|
} else if (this->state == STATE_GET_APP_INFORMATION) {
|
|
|
|
getAppInformation();
|
|
|
|
} else if (this->state == STATE_CHECK_PATCH_POSSIBLE) {
|
|
|
|
checkPatchPossible();
|
2020-12-02 15:57:13 +01:00
|
|
|
} else if (this->state == STATE_CHECK_COLDBOOT_STATUS) {
|
|
|
|
checkColdbootStatus();
|
2020-12-01 02:05:24 +01:00
|
|
|
} else if (this->state == STATE_CHECK_REMOVAL_POSSIBLE) {
|
|
|
|
checkRemovalPossible();
|
2020-12-02 15:57:13 +01:00
|
|
|
} else if (this->state == STATE_COMPATIBILITY_RESULTS) {
|
|
|
|
if (this->installPossible) {
|
|
|
|
changeState(STATE_MAIN_MENU);
|
2020-10-16 19:48:13 +02:00
|
|
|
} else {
|
2020-12-02 15:57:13 +01:00
|
|
|
changeState(STATE_APP_INCOMPATIBLE);
|
2020-10-16 19:48:13 +02:00
|
|
|
}
|
|
|
|
} else if (this->state == STATE_INSTALL_STARTED) {
|
2020-12-02 15:57:13 +01:00
|
|
|
OSEnableHomeButtonMenu(false);
|
|
|
|
changeState(STATE_INSTALL_BACKUP);
|
2020-11-30 22:09:08 +01:00
|
|
|
} else if (this->state == STATE_INSTALL_BACKUP) {
|
|
|
|
auto result = InstallerService::backupAppFiles(this->appInfo->path);
|
|
|
|
if (result != InstallerService::SUCCESS) {
|
|
|
|
this->installerError = result;
|
2020-12-02 15:57:13 +01:00
|
|
|
setError(ERROR_INSTALLER_ERROR);
|
2020-11-30 22:09:08 +01:00
|
|
|
} else {
|
2020-12-02 15:57:13 +01:00
|
|
|
changeState(STATE_INSTALL_FST);
|
2020-11-30 22:09:08 +01:00
|
|
|
}
|
2020-10-16 19:48:13 +02:00
|
|
|
} else if (this->state == STATE_INSTALL_FST) {
|
2020-12-02 15:57:13 +01:00
|
|
|
auto result = (this->fstAlreadyPatched) ? InstallerService::SUCCESS :
|
|
|
|
InstallerService::patchFST(this->appInfo->path, this->appInfo->fstHash);
|
2020-10-16 19:48:13 +02:00
|
|
|
if (result != InstallerService::SUCCESS) {
|
|
|
|
this->installerError = result;
|
2020-12-02 15:57:13 +01:00
|
|
|
setError(ERROR_INSTALLER_ERROR);
|
2020-10-16 19:48:13 +02:00
|
|
|
} else {
|
2020-12-02 15:57:13 +01:00
|
|
|
changeState(STATE_INSTALL_COS);
|
2020-10-16 19:48:13 +02:00
|
|
|
}
|
|
|
|
} else if (this->state == STATE_INSTALL_COS) {
|
2020-12-02 15:57:13 +01:00
|
|
|
auto result = (this->cosAlreadyPatched) ? InstallerService::SUCCESS :
|
|
|
|
InstallerService::patchCOS(this->appInfo->path, this->appInfo->cosHash);
|
2020-10-16 19:48:13 +02:00
|
|
|
if (result != InstallerService::SUCCESS) {
|
|
|
|
this->installerError = result;
|
2020-12-02 15:57:13 +01:00
|
|
|
setError(ERROR_INSTALLER_ERROR);
|
2020-10-16 19:48:13 +02:00
|
|
|
} else {
|
2020-12-02 15:57:13 +01:00
|
|
|
changeState(STATE_INSTALL_RPX);
|
2020-10-16 19:48:13 +02:00
|
|
|
}
|
|
|
|
} else if (this->state == STATE_INSTALL_RPX) {
|
2020-10-17 00:55:14 +02:00
|
|
|
auto result = InstallerService::copyRPX(this->appInfo->path, root_rpx, root_rpx_size, RPX_HASH);
|
2020-10-16 22:51:14 +02:00
|
|
|
if (result != InstallerService::SUCCESS) {
|
|
|
|
this->installerError = result;
|
|
|
|
setError(ERROR_INSTALLER_ERROR);
|
|
|
|
} else {
|
2020-12-02 15:57:13 +01:00
|
|
|
changeState(STATE_INSTALL_SUCCESS);
|
2020-12-01 02:05:24 +01:00
|
|
|
}
|
|
|
|
} else if (this->state == STATE_REMOVE_STARTED) {
|
2020-12-02 15:57:13 +01:00
|
|
|
OSEnableHomeButtonMenu(false);
|
|
|
|
if (this->systemXMLAlreadyPatched) {
|
|
|
|
changeState(STATE_REMOVE_COLDBOOT);
|
|
|
|
} else {
|
|
|
|
changeState(STATE_REMOVE_AROMA);
|
|
|
|
}
|
2020-12-01 02:05:24 +01:00
|
|
|
} else if (this->state == STATE_REMOVE_COLDBOOT) {
|
2020-12-02 15:57:13 +01:00
|
|
|
auto result = InstallerService::setBootTitle(*this->systemMenuTitleId);
|
2020-12-01 02:05:24 +01:00
|
|
|
if (result != InstallerService::SUCCESS) {
|
|
|
|
this->installerError = result;
|
2020-12-02 15:57:13 +01:00
|
|
|
setError(ERROR_INSTALLER_ERROR);
|
2020-12-01 02:05:24 +01:00
|
|
|
} else {
|
2020-12-02 15:57:13 +01:00
|
|
|
changeState(STATE_REMOVE_AROMA);
|
2020-12-01 02:05:24 +01:00
|
|
|
}
|
|
|
|
} else if (this->state == STATE_REMOVE_AROMA) {
|
|
|
|
auto result = InstallerService::restoreAppFiles(this->appInfo->path);
|
|
|
|
if (result != InstallerService::SUCCESS) {
|
2020-12-02 15:57:13 +01:00
|
|
|
this->installerError = result;
|
2020-12-01 02:05:24 +01:00
|
|
|
setError(ERROR_INSTALLER_ERROR);
|
2020-12-02 15:57:13 +01:00
|
|
|
} else {
|
|
|
|
changeState(STATE_REMOVE_SUCCESS);
|
|
|
|
}
|
|
|
|
} else if (this->state == STATE_BOOT_SWITCH_SYSMENU) {
|
|
|
|
OSEnableHomeButtonMenu(false);
|
|
|
|
auto result = InstallerService::setBootTitle(*this->systemMenuTitleId);
|
|
|
|
if (result != InstallerService::SUCCESS) {
|
2020-12-01 02:05:24 +01:00
|
|
|
this->installerError = result;
|
2020-12-02 15:57:13 +01:00
|
|
|
setError(ERROR_INSTALLER_ERROR);
|
2020-12-01 02:05:24 +01:00
|
|
|
} else {
|
2020-12-02 15:57:13 +01:00
|
|
|
changeState(STATE_BOOT_SWITCH_SUCCESS);
|
2020-12-01 02:05:24 +01:00
|
|
|
}
|
2020-12-02 15:57:13 +01:00
|
|
|
} else if (this->state == STATE_BOOT_SWITCH_AROMA) {
|
|
|
|
OSEnableHomeButtonMenu(false);
|
|
|
|
auto result = InstallerService::setBootTitle(this->appInfo->titleId);
|
|
|
|
if (result != InstallerService::SUCCESS) {
|
|
|
|
this->installerError = result;
|
|
|
|
setError(ERROR_INSTALLER_ERROR);
|
|
|
|
} else {
|
|
|
|
changeState(STATE_BOOT_SWITCH_SUCCESS);
|
2020-12-01 02:05:24 +01:00
|
|
|
}
|
2020-12-02 15:57:13 +01:00
|
|
|
} else if (this->state == STATE_EXIT_SYSMENU) {
|
|
|
|
SYSLaunchMenu();
|
|
|
|
} else if (this->state == STATE_EXIT_SHUTDOWN) {
|
|
|
|
OSShutdown();
|
2020-10-16 19:48:13 +02:00
|
|
|
}
|
2020-12-02 15:57:13 +01:00
|
|
|
|
|
|
|
menu.update(input);
|
2020-10-16 19:48:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ApplicationState::ApplicationState() {
|
2020-12-02 15:57:13 +01:00
|
|
|
menu.setOptionsCallback(std::bind(&ApplicationState::changeState, this, std::placeholders::_1));
|
|
|
|
menu.setHeader("Aroma Installer");
|
|
|
|
menu.setFooter("By Maschell");
|
|
|
|
|
|
|
|
changeState(STATE_WELCOME_SCREEN);
|
2020-10-16 19:48:13 +02:00
|
|
|
DEBUG_FUNCTION_LINE("State has changed to \"STATE_WELCOME_SCREEN\"");
|
|
|
|
}
|
|
|
|
|
|
|
|
void ApplicationState::checkPatchPossible() {
|
|
|
|
DEBUG_FUNCTION_LINE("Check patch possible");
|
2020-11-30 17:49:32 +01:00
|
|
|
|
2020-12-04 10:45:13 +01:00
|
|
|
this->fstAlreadyPatched = (InstallerService::checkFSTAlreadyValid(this->appInfo->path, this->appInfo->fstHash) == InstallerService::SUCCESS);
|
|
|
|
this->rpxAlreadyPatched = (InstallerService::checkRPXAlreadyValid(this->appInfo->path, RPX_HASH) == InstallerService::SUCCESS);
|
|
|
|
this->cosAlreadyPatched = (InstallerService::checkCOSAlreadyValid(this->appInfo->path, this->appInfo->cosHash) == InstallerService::SUCCESS);
|
|
|
|
this->tmdValid = (InstallerService::checkTMDValid(this->appInfo->path, this->appInfo->tmdHash, this->appInfo->tmdWithCertHash) == InstallerService::SUCCESS);
|
2020-11-30 17:49:32 +01:00
|
|
|
|
2020-12-04 10:45:13 +01:00
|
|
|
InstallerService::eResults result;
|
2020-11-30 17:49:32 +01:00
|
|
|
|
2020-10-16 19:48:13 +02:00
|
|
|
this->fstPatchPossible = ((result = InstallerService::checkFST(this->appInfo->path, this->appInfo->fstHash)) == InstallerService::SUCCESS);
|
|
|
|
if (result != InstallerService::SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE("ERROR: %s", InstallerService::ErrorMessage(result).c_str());
|
|
|
|
}
|
|
|
|
this->cosPatchPossible = ((result = InstallerService::checkCOS(this->appInfo->path, this->appInfo->cosHash)) == InstallerService::SUCCESS);
|
|
|
|
if (result != InstallerService::SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE("ERROR: %s", InstallerService::ErrorMessage(result).c_str());
|
|
|
|
}
|
2020-12-02 15:57:13 +01:00
|
|
|
|
2020-12-02 16:19:23 +01:00
|
|
|
this->installPossible = this->fstPatchPossible && this->cosPatchPossible && this->tmdValid;
|
2020-12-02 15:57:13 +01:00
|
|
|
this->alreadyInstalled = this->fstAlreadyPatched && this->rpxAlreadyPatched && this->cosAlreadyPatched;
|
|
|
|
|
|
|
|
changeState(STATE_CHECK_COLDBOOT_STATUS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ApplicationState::checkColdbootStatus() {
|
|
|
|
DEBUG_FUNCTION_LINE("Check coldboot status");
|
|
|
|
|
|
|
|
this->coldbootTitleId = InstallerService::getColdbootTitleId("storage_slc_installer:/config");
|
|
|
|
this->coldbootTitle = nullptr;
|
|
|
|
for (int i = 0; GameList[i].tid != 0; i++) {
|
|
|
|
if (GameList[i].tid == this->coldbootTitleId) {
|
|
|
|
this->coldbootTitle = &GameList[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
InstallerService::eResults result;
|
|
|
|
|
|
|
|
this->systemMenuTitleId = InstallerService::getSystemMenuTitleId();
|
|
|
|
|
2020-10-16 19:48:13 +02:00
|
|
|
this->systemXMLPatchPossible = ((result = InstallerService::checkSystemXML("storage_slc_installer:/config", this->appInfo->titleId)) == InstallerService::SUCCESS);
|
|
|
|
if (result != InstallerService::SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE("ERROR: %s", InstallerService::ErrorMessage(result).c_str());
|
|
|
|
}
|
|
|
|
|
2020-12-02 15:57:13 +01:00
|
|
|
if (this->systemMenuTitleId) {
|
|
|
|
this->systemXMLRestorePossible = ((result = InstallerService::checkSystemXML("storage_slc_installer:/config", *this->systemMenuTitleId)) == InstallerService::SUCCESS);
|
|
|
|
if (result != InstallerService::SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE("ERROR: %s", InstallerService::ErrorMessage(result).c_str());
|
|
|
|
}
|
2020-12-01 02:05:24 +01:00
|
|
|
} else {
|
2020-12-02 15:57:13 +01:00
|
|
|
this->systemXMLRestorePossible = false;
|
2020-12-01 02:05:24 +01:00
|
|
|
}
|
2020-12-02 15:57:13 +01:00
|
|
|
|
|
|
|
this->systemXMLAlreadyPatched = (this->coldbootTitleId == this->appInfo->titleId);
|
|
|
|
|
|
|
|
this->systemXMLPatchAllowed = this->systemXMLPatchPossible && this->alreadyInstalled && InstallerService::isColdBootAllowed();
|
|
|
|
|
|
|
|
changeState(STATE_CHECK_REMOVAL_POSSIBLE);
|
2020-12-01 02:05:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ApplicationState::checkRemovalPossible() {
|
2020-12-02 15:57:13 +01:00
|
|
|
DEBUG_FUNCTION_LINE("Check removal possible");
|
2020-12-01 02:05:24 +01:00
|
|
|
|
2020-12-02 15:57:13 +01:00
|
|
|
this->removalPossible = this->alreadyInstalled;
|
|
|
|
if (this->removalPossible) {
|
|
|
|
this->removalPossible &= this->systemXMLRestorePossible || !this->systemXMLAlreadyPatched;
|
|
|
|
}
|
|
|
|
if (this->removalPossible) {
|
2020-12-01 02:05:24 +01:00
|
|
|
this->removalPossible &= InstallerService::isBackupAvailable(this->appInfo->path);
|
|
|
|
}
|
2020-12-02 15:57:13 +01:00
|
|
|
changeState(STATE_COMPATIBILITY_RESULTS);
|
2020-10-16 19:48:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ApplicationState::getAppInformation() {
|
|
|
|
DEBUG_FUNCTION_LINE("About to call getInstalledAppInformation");
|
|
|
|
this->appInfo = InstallerService::getInstalledAppInformation();
|
|
|
|
if (!this->appInfo) {
|
|
|
|
DEBUG_FUNCTION_LINE("ERROR =(");
|
2020-12-02 15:57:13 +01:00
|
|
|
setError(ERROR_NO_APP_INSTALLED);
|
2020-10-16 19:48:13 +02:00
|
|
|
} else {
|
|
|
|
DEBUG_FUNCTION_LINE("WORKED!");
|
2020-12-02 15:57:13 +01:00
|
|
|
changeState(STATE_CHECK_PATCH_POSSIBLE);
|
2020-10-16 19:48:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ApplicationState::ErrorMessage() {
|
|
|
|
if (this->error == ERROR_NONE) {
|
|
|
|
return "NONE";
|
|
|
|
} else if (this->error == ERROR_NO_APP_INSTALLED) {
|
|
|
|
return "ERROR_NO_APP_INSTALLED";
|
|
|
|
} else if (this->error == ERROR_IOSUHAX_FAILED) {
|
|
|
|
return "ERROR_IOSUHAX_FAILED";
|
|
|
|
} else if (this->error == ERROR_INSTALLER_ERROR) {
|
|
|
|
return InstallerService::ErrorMessage(this->installerError);
|
|
|
|
}
|
|
|
|
return "UNKNOWN_ERROR";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ApplicationState::ErrorDescription() {
|
|
|
|
if (this->error == ERROR_NONE) {
|
|
|
|
return "-";
|
|
|
|
} else if (this->error == ERROR_NO_APP_INSTALLED) {
|
|
|
|
return "No compatible application is installed. A safe installation is not possible.";
|
|
|
|
} else if (this->error == ERROR_INSTALLER_ERROR) {
|
|
|
|
return InstallerService::ErrorDescription(this->installerError);
|
|
|
|
} else if (this->error == ERROR_IOSUHAX_FAILED) {
|
|
|
|
return "Failed to init IOSUHAX.";
|
|
|
|
}
|
|
|
|
return "UNKNOWN_ERROR";
|
|
|
|
}
|
|
|
|
|
2020-10-16 22:51:14 +02:00
|
|
|
void ApplicationState::setError(eErrorState err) {
|
|
|
|
this->error = err;
|
|
|
|
OSEnableHomeButtonMenu(true);
|
2020-12-02 15:57:13 +01:00
|
|
|
changeState(STATE_ERROR);
|
2020-10-16 19:48:13 +02:00
|
|
|
}
|