mirror of
https://github.com/wiiu-env/PayloadLoaderInstaller.git
synced 2024-11-23 18:29:20 +01:00
Formatting
This commit is contained in:
parent
80110c3f4c
commit
f972091f50
@ -39,7 +39,7 @@ void ApplicationState::changeState(eGameState newState) {
|
||||
menu.addText(std::string(appInfo->appName));
|
||||
menu.addText();
|
||||
menu.addText("Additional informations:");
|
||||
auto showCheckResult = [&] (const std::string &name, bool canPatch, bool patched) {
|
||||
auto showCheckResult = [&](const std::string &name, bool canPatch, bool patched) {
|
||||
if (patched) {
|
||||
menu.addText("[ X ] " + name + " is already patched!");
|
||||
} else if (canPatch) {
|
||||
|
@ -37,7 +37,7 @@ InstallerService::eResults InstallerService::checkCOS(const std::string &path, c
|
||||
DEBUG_FUNCTION_LINE("Success! cos.xml is compatible");
|
||||
return SUCCESS;
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("Hash mismatch! cos.xml is NOT compatible. Expected hash: %s actual hash: %s",hash, newHash.c_str());
|
||||
DEBUG_FUNCTION_LINE("Hash mismatch! cos.xml is NOT compatible. Expected hash: %s actual hash: %s", hash, newHash.c_str());
|
||||
}
|
||||
|
||||
return COS_XML_HASH_MISMATCH;
|
||||
@ -203,8 +203,7 @@ std::optional<uint64_t> InstallerService::getSystemMenuTitleId() {
|
||||
|
||||
if ((titleList->titleId != 0x0005001010040000L) &&
|
||||
(titleList->titleId != 0x0005001010040100L) &&
|
||||
(titleList->titleId != 0x0005001010040200L))
|
||||
{
|
||||
(titleList->titleId != 0x0005001010040200L)) {
|
||||
DEBUG_FUNCTION_LINE("Unrecognized System Menu title");
|
||||
return {};
|
||||
}
|
||||
@ -350,11 +349,11 @@ std::string InstallerService::ErrorMessage(InstallerService::eResults error) {
|
||||
bool InstallerService::isBackupAvailable(const std::string &path) {
|
||||
std::string backupList[] = {
|
||||
{"/content/title.fst.bak"},
|
||||
{"/content/cos.xml.bak" },
|
||||
{"/content/safe.rpx.bak" },
|
||||
{"/content/cos.xml.bak"},
|
||||
{"/content/safe.rpx.bak"},
|
||||
};
|
||||
|
||||
for (auto &backupEntry : backupList) {
|
||||
for (auto &backupEntry: backupList) {
|
||||
std::string backupFile = path + backupEntry;
|
||||
std::string backupSha1 = backupFile + ".sha1";
|
||||
|
||||
@ -386,11 +385,11 @@ bool InstallerService::isBackupAvailable(const std::string &path) {
|
||||
InstallerService::eResults InstallerService::restoreAppFiles(const std::string &path) {
|
||||
std::string backupList[][2] = {
|
||||
{"/code/title.fst", "/content/title.fst.bak"},
|
||||
{"/code/cos.xml", "/content/cos.xml.bak" },
|
||||
{"/code/safe.rpx", "/content/safe.rpx.bak" },
|
||||
{"/code/cos.xml", "/content/cos.xml.bak"},
|
||||
{"/code/safe.rpx", "/content/safe.rpx.bak"},
|
||||
};
|
||||
|
||||
for (auto &backupOp : backupList) {
|
||||
for (auto &backupOp: backupList) {
|
||||
std::string destPath = path + backupOp[0];
|
||||
std::string backupPath = path + backupOp[1];
|
||||
|
||||
@ -407,7 +406,7 @@ InstallerService::eResults InstallerService::restoreAppFiles(const std::string &
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &backupOp : backupList) {
|
||||
for (auto &backupOp: backupList) {
|
||||
std::string backupPath = path + backupOp[1];
|
||||
std::string backupSha1Path = backupPath + ".sha1";
|
||||
::remove(backupPath.c_str());
|
||||
@ -421,11 +420,11 @@ InstallerService::eResults InstallerService::restoreAppFiles(const std::string &
|
||||
InstallerService::eResults InstallerService::backupAppFiles(const std::string &path) {
|
||||
std::string backupList[][2] = {
|
||||
{"/code/title.fst", "/content/title.fst.bak"},
|
||||
{"/code/cos.xml", "/content/cos.xml.bak" },
|
||||
{"/code/safe.rpx", "/content/safe.rpx.bak" },
|
||||
{"/code/cos.xml", "/content/cos.xml.bak"},
|
||||
{"/code/safe.rpx", "/content/safe.rpx.bak"},
|
||||
};
|
||||
|
||||
for (auto &backupOp : backupList) {
|
||||
for (auto &backupOp: backupList) {
|
||||
std::string backupSrc = path + backupOp[0];
|
||||
std::string backupDst = path + backupOp[1];
|
||||
std::string backupSha1 = backupDst + ".sha1";
|
||||
@ -726,7 +725,7 @@ InstallerService::eResults InstallerService::checkTMDValid(const std::string &pa
|
||||
|
||||
InstallerService::eResults result = checkFileHash(filePath, hash);
|
||||
|
||||
if(result != SUCCESS){
|
||||
if (result != SUCCESS) {
|
||||
// In some cases the tmd seems to have cert appended
|
||||
return checkFileHash(filePath, tmdWithCertHash);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
FAILED_TO_LOAD_FILE = -18,
|
||||
};
|
||||
|
||||
static bool isColdBootAllowed(){
|
||||
static bool isColdBootAllowed() {
|
||||
if (OSIsAddressValid(0x00FFFFF8)) {
|
||||
uint64_t bootedFrom = *((uint64_t *) 0x00FFFFF8);
|
||||
if (
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "utils/WiiUScreen.h"
|
||||
#include "utils/ScreenUtils.h"
|
||||
|
||||
template <typename T>
|
||||
template<typename T>
|
||||
class Menu {
|
||||
public:
|
||||
Menu() {
|
||||
@ -45,7 +45,7 @@ public:
|
||||
int selectedDist = selected;
|
||||
WiiUScreen::clearScreen();
|
||||
printHeader();
|
||||
for (auto &row : content) {
|
||||
for (auto &row: content) {
|
||||
std::string cursor = "";
|
||||
if (row.first) {
|
||||
cursor += (selectedDist--) ? " " : "> ";
|
||||
|
@ -51,5 +51,6 @@ public:
|
||||
|
||||
private:
|
||||
ScreenUtils() = default;
|
||||
|
||||
~ScreenUtils() = default;
|
||||
};
|
@ -89,7 +89,7 @@ public:
|
||||
static bool findStringIC(const std::string &strHaystack, const std::string &strNeedle);
|
||||
|
||||
// https://stackoverflow.com/a/3418285
|
||||
static bool replace(std::string& str, const std::string& from, const std::string& to);
|
||||
static bool replace(std::string &str, const std::string &from, const std::string &to);
|
||||
|
||||
static bool strCompareIC(const std::string &str1, const std::string &str2);
|
||||
};
|
||||
|
@ -21,31 +21,37 @@
|
||||
*/
|
||||
#ifndef _TINY_SHA1_HPP_
|
||||
#define _TINY_SHA1_HPP_
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <stdint.h>
|
||||
namespace sha1
|
||||
{
|
||||
class SHA1
|
||||
{
|
||||
|
||||
namespace sha1 {
|
||||
class SHA1 {
|
||||
public:
|
||||
typedef uint32_t digest32_t[5];
|
||||
typedef uint8_t digest8_t[20];
|
||||
|
||||
inline static uint32_t LeftRotate(uint32_t value, size_t count) {
|
||||
return (value << count) ^ (value >> (32-count));
|
||||
return (value << count) ^ (value >> (32 - count));
|
||||
}
|
||||
SHA1(){ reset(); }
|
||||
|
||||
SHA1() { reset(); }
|
||||
|
||||
virtual ~SHA1() {}
|
||||
SHA1(const SHA1& s) { *this = s; }
|
||||
const SHA1& operator = (const SHA1& s) {
|
||||
|
||||
SHA1(const SHA1 &s) { *this = s; }
|
||||
|
||||
const SHA1 &operator=(const SHA1 &s) {
|
||||
memcpy(m_digest, s.m_digest, 5 * sizeof(uint32_t));
|
||||
memcpy(m_block, s.m_block, 64);
|
||||
m_blockByteIndex = s.m_blockByteIndex;
|
||||
m_byteCount = s.m_byteCount;
|
||||
return *this;
|
||||
}
|
||||
SHA1& reset() {
|
||||
|
||||
SHA1 &reset() {
|
||||
m_digest[0] = 0x67452301;
|
||||
m_digest[1] = 0xEFCDAB89;
|
||||
m_digest[2] = 0x98BADCFE;
|
||||
@ -55,30 +61,34 @@ namespace sha1
|
||||
m_byteCount = 0;
|
||||
return *this;
|
||||
}
|
||||
SHA1& processByte(uint8_t octet) {
|
||||
|
||||
SHA1 &processByte(uint8_t octet) {
|
||||
this->m_block[this->m_blockByteIndex++] = octet;
|
||||
++this->m_byteCount;
|
||||
if(m_blockByteIndex == 64) {
|
||||
if (m_blockByteIndex == 64) {
|
||||
this->m_blockByteIndex = 0;
|
||||
processBlock();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
SHA1& processBlock(const void* const start, const void* const end) {
|
||||
const uint8_t* begin = static_cast<const uint8_t*>(start);
|
||||
const uint8_t* finish = static_cast<const uint8_t*>(end);
|
||||
while(begin != finish) {
|
||||
|
||||
SHA1 &processBlock(const void *const start, const void *const end) {
|
||||
const uint8_t *begin = static_cast<const uint8_t *>(start);
|
||||
const uint8_t *finish = static_cast<const uint8_t *>(end);
|
||||
while (begin != finish) {
|
||||
processByte(*begin);
|
||||
begin++;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
SHA1& processBytes(const void* const data, size_t len) {
|
||||
const uint8_t* block = static_cast<const uint8_t*>(data);
|
||||
|
||||
SHA1 &processBytes(const void *const data, size_t len) {
|
||||
const uint8_t *block = static_cast<const uint8_t *>(data);
|
||||
processBlock(block, block + len);
|
||||
return *this;
|
||||
}
|
||||
const uint32_t* getDigest(digest32_t digest) {
|
||||
|
||||
const uint32_t *getDigest(digest32_t digest) {
|
||||
size_t bitCount = this->m_byteCount * 8;
|
||||
processByte(0x80);
|
||||
if (this->m_blockByteIndex > 56) {
|
||||
@ -97,15 +107,16 @@ namespace sha1
|
||||
processByte(0);
|
||||
processByte(0);
|
||||
processByte(0);
|
||||
processByte( static_cast<unsigned char>((bitCount>>24) & 0xFF));
|
||||
processByte( static_cast<unsigned char>((bitCount>>16) & 0xFF));
|
||||
processByte( static_cast<unsigned char>((bitCount>>8 ) & 0xFF));
|
||||
processByte( static_cast<unsigned char>((bitCount) & 0xFF));
|
||||
processByte(static_cast<unsigned char>((bitCount >> 24) & 0xFF));
|
||||
processByte(static_cast<unsigned char>((bitCount >> 16) & 0xFF));
|
||||
processByte(static_cast<unsigned char>((bitCount >> 8) & 0xFF));
|
||||
processByte(static_cast<unsigned char>((bitCount) & 0xFF));
|
||||
|
||||
memcpy(digest, m_digest, 5 * sizeof(uint32_t));
|
||||
return digest;
|
||||
}
|
||||
const uint8_t* getDigestBytes(digest8_t digest) {
|
||||
|
||||
const uint8_t *getDigestBytes(digest8_t digest) {
|
||||
digest32_t d32;
|
||||
getDigest(d32);
|
||||
size_t di = 0;
|
||||
@ -140,13 +151,13 @@ namespace sha1
|
||||
void processBlock() {
|
||||
uint32_t w[80];
|
||||
for (size_t i = 0; i < 16; i++) {
|
||||
w[i] = (m_block[i*4 + 0] << 24);
|
||||
w[i] |= (m_block[i*4 + 1] << 16);
|
||||
w[i] |= (m_block[i*4 + 2] << 8);
|
||||
w[i] |= (m_block[i*4 + 3]);
|
||||
w[i] = (m_block[i * 4 + 0] << 24);
|
||||
w[i] |= (m_block[i * 4 + 1] << 16);
|
||||
w[i] |= (m_block[i * 4 + 2] << 8);
|
||||
w[i] |= (m_block[i * 4 + 3]);
|
||||
}
|
||||
for (size_t i = 16; i < 80; i++) {
|
||||
w[i] = LeftRotate((w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16]), 1);
|
||||
w[i] = LeftRotate((w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16]), 1);
|
||||
}
|
||||
|
||||
uint32_t a = m_digest[0];
|
||||
@ -155,17 +166,17 @@ namespace sha1
|
||||
uint32_t d = m_digest[3];
|
||||
uint32_t e = m_digest[4];
|
||||
|
||||
for (std::size_t i=0; i<80; ++i) {
|
||||
for (std::size_t i = 0; i < 80; ++i) {
|
||||
uint32_t f = 0;
|
||||
uint32_t k = 0;
|
||||
|
||||
if (i<20) {
|
||||
if (i < 20) {
|
||||
f = (b & c) | (~b & d);
|
||||
k = 0x5A827999;
|
||||
} else if (i<40) {
|
||||
} else if (i < 40) {
|
||||
f = b ^ c ^ d;
|
||||
k = 0x6ED9EBA1;
|
||||
} else if (i<60) {
|
||||
} else if (i < 60) {
|
||||
f = (b & c) | (b & d) | (c & d);
|
||||
k = 0x8F1BBCDC;
|
||||
} else {
|
||||
@ -186,6 +197,7 @@ namespace sha1
|
||||
m_digest[3] += d;
|
||||
m_digest[4] += e;
|
||||
}
|
||||
|
||||
private:
|
||||
digest32_t m_digest;
|
||||
uint8_t m_block[64];
|
||||
|
@ -24,7 +24,7 @@ void Utils::dumpHex(const void *data, size_t size) {
|
||||
if ((i + 1) % 16 == 0) {
|
||||
WHBLogPrintf("| %s ", ascii);
|
||||
if (i + 1 < size) {
|
||||
DEBUG_FUNCTION_LINE("0x%08X (0x%04X); ", ((uint32_t)data) + i + 1, i + 1);
|
||||
DEBUG_FUNCTION_LINE("0x%08X (0x%04X); ", ((uint32_t) data) + i + 1, i + 1);
|
||||
}
|
||||
} else if (i + 1 == size) {
|
||||
ascii[(i + 1) % 16] = '\0';
|
||||
|
Loading…
Reference in New Issue
Block a user