PayloadLoaderInstaller/source/InstallerService.h

93 lines
3.2 KiB
C
Raw Normal View History

2020-10-15 20:14:00 +02:00
#pragma once
#include "utils/pugixml.hpp"
#include "common/common.h"
#include <optional>
2020-11-30 17:49:32 +01:00
#include <coreinit/memorymap.h>
2020-10-15 20:14:00 +02:00
class InstallerService {
public:
enum eResults {
SUCCESS = 0,
NO_COMPATIBLE_APP_INSTALLED = -1,
FAILED_TO_COPY_FILES = -2,
FAILED_TO_CHECK_HASH_COPIED_FILES = -3,
SYSTEM_XML_INFORMATION_NOT_FOUND = -4,
SYSTEM_XML_PARSING_FAILED = -5,
SYSTEM_XML_HASH_MISMATCH_RESTORE_FAILED = -6,
SYSTEM_XML_HASH_MISMATCH = -7,
RPX_HASH_MISMATCH = -8,
RPX_HASH_MISMATCH_RESTORE_FAILED = -9,
COS_XML_PARSING_FAILED = -10,
COS_XML_HASH_MISMATCH = -11,
COS_XML_HASH_MISMATCH_RESTORE_FAILED = -12,
MALLOC_FAILED = -13,
FST_HASH_MISMATCH = -14,
FST_HASH_MISMATCH_RESTORE_FAILED = -15,
FST_HEADER_MISMATCH = -16,
FST_NO_USABLE_SECTION_FOUND = -17,
FAILED_TO_LOAD_FILE = -18,
};
2020-11-30 17:49:32 +01:00
static bool isColdBootAllowed(){
if (OSIsAddressValid(0x00FFFFF8)) {
uint64_t bootedFrom = *((uint64_t *) 0x00FFFFF8);
if (
2020-12-04 10:39:36 +01:00
bootedFrom == 0x000500101004E000L || // H&S JPN
2020-11-30 17:49:32 +01:00
bootedFrom == 0x000500101004E100L || // H&S USA
bootedFrom == 0x000500101004E200L // H&S EUR
) {
return true;
}
}
return false;
}
2020-12-01 02:05:24 +01:00
static bool isBackupAvailable(const std::string &path);
static eResults restoreAppFiles(const std::string &path);
static eResults backupAppFiles(const std::string &path);
2020-10-16 19:48:13 +02:00
static eResults patchCOS(const std::string &path, char *hash);
2020-10-15 20:14:00 +02:00
static eResults checkCOS(const std::string &path, char *hash);
static eResults checkSystemXML(const std::string &path, uint64_t titleId);
static eResults checkFST(const std::string &path, const char *fstHash);
static std::optional<appInformation> getInstalledAppInformation();
2020-12-01 02:05:24 +01:00
static std::optional<uint64_t> getSystemMenuTitleId();
2020-10-16 19:48:13 +02:00
static std::string ErrorMessage(eResults error);
2020-11-30 17:49:32 +01:00
2020-10-16 19:48:13 +02:00
static std::string ErrorDescription(eResults error);
static eResults patchFST(const std::string &path, const char *hash);
2020-10-16 22:51:14 +02:00
static eResults copyRPX(const std::string &path, const uint8_t *rpx_data, size_t size, const std::string &rpx_hash);
static eResults patchSystemXML(const std::string &path, uint64_t id);
2020-10-15 20:14:00 +02:00
2020-11-30 17:49:32 +01:00
static uint64_t getColdbootTitleId(const std::string &path);
static eResults checkFSTAlreadyValid(const std::string &path, const std::string &hash);
static eResults checkTMDValid(const std::string &path, const std::string &hash, const std::string &tmdWithCertHash);
2020-11-30 17:49:32 +01:00
static eResults checkCOSAlreadyValid(const std::string &path, const std::string &hash);
static eResults checkRPXAlreadyValid(const std::string &path, const std::string &hash);
2020-12-02 15:57:13 +01:00
static eResults setBootTitle(uint64_t titleId);
2020-10-15 20:14:00 +02:00
private:
2020-10-16 19:48:13 +02:00
static eResults patchFSTData(uint8_t *fstData, uint32_t size);
2020-10-15 20:14:00 +02:00
2020-10-16 19:48:13 +02:00
static bool patchCOSXMLData(pugi::xml_document *doc);
2020-11-30 17:49:32 +01:00
static eResults checkFileHash(const std::string &filePath, const std::string &hash);
};