Format the code via clang-format

This commit is contained in:
Maschell 2022-07-24 17:07:42 +02:00
parent 0c8f5afbb1
commit d9f6b0a237
33 changed files with 341 additions and 242 deletions

67
.clang-format Normal file
View File

@ -0,0 +1,67 @@
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignOperands: Align
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 0
CompactNamespaces: false
ContinuationIndentWidth: 8
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Right
ReflowComments: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: Never

View File

@ -6,9 +6,16 @@ on:
- main - main
jobs: jobs:
clang-format:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source
build-binary: build-binary:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
needs: clang-format
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Checkout submodules using a PAT - name: Checkout submodules using a PAT
@ -63,4 +70,4 @@ jobs:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip asset_path: ./${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip
asset_name: ${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip asset_name: ${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip
asset_content_type: application/unknown asset_content_type: application/zip

View File

@ -3,8 +3,34 @@ name: CI-PR
on: [pull_request] on: [pull_request]
jobs: jobs:
clang-format:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source
check-build-with-logging:
runs-on: ubuntu-18.04
needs: clang-format
steps:
- uses: actions/checkout@v2
- name: Checkout submodules using a PAT
run: |
git config --file .gitmodules --get-regexp url | while read url; do
git config --file=.gitmodules $(echo "$url" | sed -E "s/git@github.com:|https:\/\/github.com\//https:\/\/${{ secrets.CI_PAT }}:${{ secrets.CI_PAT }}@github.com\//")
done
git submodule sync
git submodule update --init --recursive
- name: build binary with logging
run: |
docker build . -t builder
docker run --rm -v ${PWD}:/project builder make DEBUG=VERBOSE
docker run --rm -v ${PWD}:/project builder make clean
docker run --rm -v ${PWD}:/project builder make DEBUG=1
build-binary: build-binary:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
needs: clang-format
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Checkout submodules using a PAT - name: Checkout submodules using a PAT

View File

@ -1,10 +1,10 @@
#include "ApplicationState.h" #include "ApplicationState.h"
#include "utils/WiiUScreen.h" #include "../build/safe_payload.h"
#include "utils/ScreenUtils.h" #include "utils/ScreenUtils.h"
#include "utils/StringTools.h" #include "utils/StringTools.h"
#include "../build/safe_payload.h" #include "utils/WiiUScreen.h"
#include <sysapp/launch.h>
#include <iosuhax.h> #include <iosuhax.h>
#include <sysapp/launch.h>
extern "C" void OSShutdown(); extern "C" void OSShutdown();
@ -131,9 +131,8 @@ void ApplicationState::changeState(eGameState newState) {
menu.addOption("Press A to shutdown the console", STATE_EXIT_SHUTDOWN); menu.addOption("Press A to shutdown the console", STATE_EXIT_SHUTDOWN);
} else if (this->state == STATE_BOOT_MENU) { } else if (this->state == STATE_BOOT_MENU) {
menu.addText("System is currently booting into: "); menu.addText("System is currently booting into: ");
std::string titleId = StringTools::strfmt("%ll016X", this->coldbootTitleId); std::string titleId = StringTools::strfmt("%ll016X", this->coldbootTitleId);
std::string titleName = this->coldbootTitle ? std::string titleName = this->coldbootTitle ? std::string(this->coldbootTitle->name) : "Unknown title";
std::string(this->coldbootTitle->name) : "Unknown title";
menu.addText(titleId + " (" + titleName + ")"); menu.addText(titleId + " (" + titleName + ")");
menu.addText(); menu.addText();
if (this->systemXMLRestorePossible && this->systemXMLAlreadyPatched) { if (this->systemXMLRestorePossible && this->systemXMLAlreadyPatched) {
@ -209,8 +208,7 @@ void ApplicationState::update(Input *input) {
changeState(STATE_INSTALL_FST); changeState(STATE_INSTALL_FST);
} }
} else if (this->state == STATE_INSTALL_FST) { } else if (this->state == STATE_INSTALL_FST) {
auto result = (this->fstAlreadyPatched) ? InstallerService::SUCCESS : auto result = (this->fstAlreadyPatched) ? InstallerService::SUCCESS : InstallerService::patchFST(this->appInfo->path, this->appInfo->fstHash);
InstallerService::patchFST(this->appInfo->path, this->appInfo->fstHash);
if (result != InstallerService::SUCCESS) { if (result != InstallerService::SUCCESS) {
this->installerError = result; this->installerError = result;
setError(ERROR_INSTALLER_ERROR); setError(ERROR_INSTALLER_ERROR);
@ -218,8 +216,7 @@ void ApplicationState::update(Input *input) {
changeState(STATE_INSTALL_COS); changeState(STATE_INSTALL_COS);
} }
} else if (this->state == STATE_INSTALL_COS) { } else if (this->state == STATE_INSTALL_COS) {
auto result = (this->cosAlreadyPatched) ? InstallerService::SUCCESS : auto result = (this->cosAlreadyPatched) ? InstallerService::SUCCESS : InstallerService::patchCOS(this->appInfo->path, this->appInfo->cosHash);
InstallerService::patchCOS(this->appInfo->path, this->appInfo->cosHash);
if (result != InstallerService::SUCCESS) { if (result != InstallerService::SUCCESS) {
this->installerError = result; this->installerError = result;
setError(ERROR_INSTALLER_ERROR); setError(ERROR_INSTALLER_ERROR);
@ -302,7 +299,7 @@ void ApplicationState::checkPatchPossible() {
this->fstAlreadyPatched = (InstallerService::checkFSTAlreadyValid(this->appInfo->path, this->appInfo->fstHash) == InstallerService::SUCCESS); this->fstAlreadyPatched = (InstallerService::checkFSTAlreadyValid(this->appInfo->path, this->appInfo->fstHash) == InstallerService::SUCCESS);
this->rpxAlreadyPatched = (InstallerService::checkRPXAlreadyValid(this->appInfo->path, RPX_HASH) == 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->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); this->tmdValid = (InstallerService::checkTMDValid(this->appInfo->path, this->appInfo->tmdHash, this->appInfo->tmdWithCertHash) == InstallerService::SUCCESS);
InstallerService::eResults result; InstallerService::eResults result;
@ -315,7 +312,7 @@ void ApplicationState::checkPatchPossible() {
DEBUG_FUNCTION_LINE("ERROR: %s", InstallerService::ErrorMessage(result).c_str()); DEBUG_FUNCTION_LINE("ERROR: %s", InstallerService::ErrorMessage(result).c_str());
} }
this->installPossible = this->fstPatchPossible && this->cosPatchPossible && this->tmdValid; this->installPossible = this->fstPatchPossible && this->cosPatchPossible && this->tmdValid;
this->alreadyInstalledAndUpdated = this->fstAlreadyPatched && this->cosAlreadyPatched && this->tmdValid && this->rpxAlreadyPatched; this->alreadyInstalledAndUpdated = this->fstAlreadyPatched && this->cosAlreadyPatched && this->tmdValid && this->rpxAlreadyPatched;
changeState(STATE_CHECK_COLDBOOT_STATUS); changeState(STATE_CHECK_COLDBOOT_STATUS);
@ -365,7 +362,7 @@ void ApplicationState::checkColdbootStatus() {
this->systemXMLAlreadyPatched = (this->coldbootTitleId == this->appInfo->titleId); this->systemXMLAlreadyPatched = (this->coldbootTitleId == this->appInfo->titleId);
} }
this->systemXMLPatchAllowed = this->systemXMLPatchPossible && this->alreadyInstalledAndUpdated && InstallerService::isColdBootAllowed(); this->systemXMLPatchAllowed = this->systemXMLPatchPossible && this->alreadyInstalledAndUpdated && InstallerService::isColdBootAllowed();
this->systemXMLPatchAllowedButNoRPXCheck = this->systemXMLPatchPossible && this->fstAlreadyPatched && this->cosAlreadyPatched && this->tmdValid && InstallerService::isColdBootAllowed(); this->systemXMLPatchAllowedButNoRPXCheck = this->systemXMLPatchPossible && this->fstAlreadyPatched && this->cosAlreadyPatched && this->tmdValid && InstallerService::isColdBootAllowed();
changeState(STATE_CHECK_REMOVAL_POSSIBLE); changeState(STATE_CHECK_REMOVAL_POSSIBLE);

View File

@ -1,15 +1,14 @@
#pragma once #pragma once
#include <string>
#include <optional>
#include <input/Input.h>
#include "common/common.h"
#include "InstallerService.h" #include "InstallerService.h"
#include "Menu.h" #include "Menu.h"
#include "common/common.h"
#include <input/Input.h>
#include <optional>
#include <string>
class ApplicationState { class ApplicationState {
public: public:
enum eErrorState { enum eErrorState {
ERROR_NONE, ERROR_NONE,
ERROR_IOSUHAX_FAILED, ERROR_IOSUHAX_FAILED,
@ -80,23 +79,23 @@ private:
bool fstPatchPossible = false; bool fstPatchPossible = false;
bool cosPatchPossible = false; bool cosPatchPossible = false;
bool removalPossible = false; bool removalPossible = false;
bool installPossible = false; bool installPossible = false;
bool alreadyInstalledAndUpdated = false; bool alreadyInstalledAndUpdated = false;
bool systemXMLPatchPossible = false; bool systemXMLPatchPossible = false;
bool systemXMLPatchAllowed = false; bool systemXMLPatchAllowed = false;
bool systemXMLPatchAllowedButNoRPXCheck = false; bool systemXMLPatchAllowedButNoRPXCheck = false;
bool systemXMLAlreadyPatched = false; bool systemXMLAlreadyPatched = false;
bool systemXMLRestorePossible = false; bool systemXMLRestorePossible = false;
eGameState state = STATE_WELCOME_SCREEN; eGameState state = STATE_WELCOME_SCREEN;
eErrorState error = ERROR_NONE; eErrorState error = ERROR_NONE;
uint64_t coldbootTitleId = 0; uint64_t coldbootTitleId = 0;
_gList_t *coldbootTitle = nullptr; _gList_t *coldbootTitle = nullptr;
std::optional<uint64_t> systemMenuTitleId; std::optional<uint64_t> systemMenuTitleId;
bool fstAlreadyPatched = false; bool fstAlreadyPatched = false;
bool rpxAlreadyPatched = false; bool rpxAlreadyPatched = false;
bool cosAlreadyPatched = false; bool cosAlreadyPatched = false;
bool tmdValid = false; bool tmdValid = false;
}; };

View File

@ -1,19 +1,19 @@
#include "common/common.h"
#include "utils/logger.h"
#include "utils/WiiUScreen.h"
#include "utils/StringTools.h"
#include "fs/FSUtils.h"
#include "common/fst_structs.h"
#include "InstallerService.h" #include "InstallerService.h"
#include "utils/utils.h" #include "common/common.h"
#include "common/fst_structs.h"
#include "fs/FSUtils.h"
#include "utils/StringTools.h"
#include "utils/WiiUScreen.h"
#include "utils/logger.h"
#include "utils/pugixml.hpp" #include "utils/pugixml.hpp"
#include "utils/utils.h"
#include <coreinit/mcp.h> #include <coreinit/mcp.h>
#include <string>
#include <memory>
#include <cstdlib> #include <cstdlib>
#include <malloc.h>
#include <sstream>
#include <iosuhax.h> #include <iosuhax.h>
#include <malloc.h>
#include <memory>
#include <sstream>
#include <string>
InstallerService::eResults InstallerService::checkCOS(const std::string &path, char *hash) { InstallerService::eResults InstallerService::checkCOS(const std::string &path, char *hash) {
std::string cosFilePath = path + "/code/cos.xml"; std::string cosFilePath = path + "/code/cos.xml";
@ -100,7 +100,7 @@ InstallerService::eResults InstallerService::checkSystemXML(const std::string &p
InstallerService::eResults InstallerService::checkFST(const std::string &path, const char *fstHash) { InstallerService::eResults InstallerService::checkFST(const std::string &path, const char *fstHash) {
std::string fstFilePath = path + "/code/title.fst"; std::string fstFilePath = path + "/code/title.fst";
uint8_t *fstData = nullptr; uint8_t *fstData = nullptr;
uint32_t fstDataSize = 0; uint32_t fstDataSize = 0;
DEBUG_FUNCTION_LINE("Trying to load FST from %s", fstFilePath.c_str()); DEBUG_FUNCTION_LINE("Trying to load FST from %s", fstFilePath.c_str());
@ -137,7 +137,7 @@ bool InstallerService::patchCOSXMLData(pugi::xml_document *doc) {
appEntry.child("codegen_core").first_child().set_value("80000001"); appEntry.child("codegen_core").first_child().set_value("80000001");
appEntry.child("max_size").first_child().set_value("40000000"); appEntry.child("max_size").first_child().set_value("40000000");
appEntry.child("max_codesize").first_child().set_value("00800000"); appEntry.child("max_codesize").first_child().set_value("00800000");
for (pugi::xml_node permission: appEntry.child("permissions").children()) { for (pugi::xml_node permission : appEntry.child("permissions").children()) {
auto mask = permission.child("mask"); auto mask = permission.child("mask");
mask.first_child().set_value("FFFFFFFFFFFFFFFF"); mask.first_child().set_value("FFFFFFFFFFFFFFFF");
} }
@ -145,7 +145,7 @@ bool InstallerService::patchCOSXMLData(pugi::xml_document *doc) {
} }
std::optional<appInformation> InstallerService::getInstalledAppInformation() { std::optional<appInformation> InstallerService::getInstalledAppInformation() {
auto mcpHandle = (int32_t) MCP_Open(); auto mcpHandle = (int32_t) MCP_Open();
auto titleCount = (uint32_t) MCP_TitleCount(mcpHandle); auto titleCount = (uint32_t) MCP_TitleCount(mcpHandle);
auto *titleList = (MCPTitleListType *) memalign(32, sizeof(MCPTitleListType) * titleCount); auto *titleList = (MCPTitleListType *) memalign(32, sizeof(MCPTitleListType) * titleCount);
@ -188,7 +188,7 @@ std::optional<appInformation> InstallerService::getInstalledAppInformation() {
} }
std::optional<uint64_t> InstallerService::getSystemMenuTitleId() { std::optional<uint64_t> InstallerService::getSystemMenuTitleId() {
auto mcpHandle = (int32_t) MCP_Open(); auto mcpHandle = (int32_t) MCP_Open();
auto titleCount = (uint32_t) 1; auto titleCount = (uint32_t) 1;
auto *titleList = (MCPTitleListType *) memalign(32, sizeof(MCPTitleListType) * titleCount); auto *titleList = (MCPTitleListType *) memalign(32, sizeof(MCPTitleListType) * titleCount);
@ -241,7 +241,7 @@ InstallerService::eResults InstallerService::patchFSTData(uint8_t *fstData, uint
DEBUG_FUNCTION_LINE("Section %d can be used as a base", usableSectionIndex); DEBUG_FUNCTION_LINE("Section %d can be used as a base", usableSectionIndex);
} }
auto *rootEntry = (FSTNodeEntry *) (fstData + sizeof(FSTHeader) + numberOfSections * sizeof(FSTSectionEntry)); auto *rootEntry = (FSTNodeEntry *) (fstData + sizeof(FSTHeader) + numberOfSections * sizeof(FSTSectionEntry));
auto numberOfNodeEntries = rootEntry->directory.lastEntryNumber; auto numberOfNodeEntries = rootEntry->directory.lastEntryNumber;
char *stringTableOffset = (char *) ((uint32_t) rootEntry + (sizeof(FSTNodeEntry) * numberOfNodeEntries)); char *stringTableOffset = (char *) ((uint32_t) rootEntry + (sizeof(FSTNodeEntry) * numberOfNodeEntries));
@ -343,7 +343,6 @@ std::string InstallerService::ErrorMessage(InstallerService::eResults error) {
} else { } else {
return "UNKNOWN ERROR"; return "UNKNOWN ERROR";
} }
} }
bool InstallerService::isBackupAvailable(const std::string &path) { bool InstallerService::isBackupAvailable(const std::string &path) {
@ -353,7 +352,7 @@ bool InstallerService::isBackupAvailable(const std::string &path) {
{"/content/safe.rpx.bak"}, {"/content/safe.rpx.bak"},
}; };
for (auto &backupEntry: backupList) { for (auto &backupEntry : backupList) {
std::string backupFile = path + backupEntry; std::string backupFile = path + backupEntry;
std::string backupSha1 = backupFile + ".sha1"; std::string backupSha1 = backupFile + ".sha1";
@ -373,7 +372,7 @@ bool InstallerService::isBackupAvailable(const std::string &path) {
} }
std::string savedHash = std::string(sha1FileCont, sha1FileCont + sha1FileSize); std::string savedHash = std::string(sha1FileCont, sha1FileCont + sha1FileSize);
std::string fileHash = Utils::hashFile(backupFile); std::string fileHash = Utils::hashFile(backupFile);
if (fileHash != savedHash) { if (fileHash != savedHash) {
return false; return false;
} }
@ -385,12 +384,12 @@ bool InstallerService::isBackupAvailable(const std::string &path) {
InstallerService::eResults InstallerService::restoreAppFiles(const std::string &path) { InstallerService::eResults InstallerService::restoreAppFiles(const std::string &path) {
std::string backupList[][2] = { std::string backupList[][2] = {
{"/code/title.fst", "/content/title.fst.bak"}, {"/code/title.fst", "/content/title.fst.bak"},
{"/code/cos.xml", "/content/cos.xml.bak"}, {"/code/cos.xml", "/content/cos.xml.bak"},
{"/code/safe.rpx", "/content/safe.rpx.bak"}, {"/code/safe.rpx", "/content/safe.rpx.bak"},
}; };
for (auto &backupOp: backupList) { for (auto &backupOp : backupList) {
std::string destPath = path + backupOp[0]; std::string destPath = path + backupOp[0];
std::string backupPath = path + backupOp[1]; std::string backupPath = path + backupOp[1];
if (!FSUtils::copyFile(backupPath, destPath)) { if (!FSUtils::copyFile(backupPath, destPath)) {
@ -406,8 +405,8 @@ InstallerService::eResults InstallerService::restoreAppFiles(const std::string &
} }
} }
for (auto &backupOp: backupList) { for (auto &backupOp : backupList) {
std::string backupPath = path + backupOp[1]; std::string backupPath = path + backupOp[1];
std::string backupSha1Path = backupPath + ".sha1"; std::string backupSha1Path = backupPath + ".sha1";
::remove(backupPath.c_str()); ::remove(backupPath.c_str());
::remove(backupSha1Path.c_str()); ::remove(backupSha1Path.c_str());
@ -420,13 +419,13 @@ InstallerService::eResults InstallerService::restoreAppFiles(const std::string &
InstallerService::eResults InstallerService::backupAppFiles(const std::string &path) { InstallerService::eResults InstallerService::backupAppFiles(const std::string &path) {
std::string backupList[][2] = { std::string backupList[][2] = {
{"/code/title.fst", "/content/title.fst.bak"}, {"/code/title.fst", "/content/title.fst.bak"},
{"/code/cos.xml", "/content/cos.xml.bak"}, {"/code/cos.xml", "/content/cos.xml.bak"},
{"/code/safe.rpx", "/content/safe.rpx.bak"}, {"/code/safe.rpx", "/content/safe.rpx.bak"},
}; };
for (auto &backupOp: backupList) { for (auto &backupOp : backupList) {
std::string backupSrc = path + backupOp[0]; std::string backupSrc = path + backupOp[0];
std::string backupDst = path + backupOp[1]; std::string backupDst = path + backupOp[1];
std::string backupSha1 = backupDst + ".sha1"; std::string backupSha1 = backupDst + ".sha1";
if (FSUtils::CheckFile(backupDst.c_str())) { if (FSUtils::CheckFile(backupDst.c_str())) {
@ -456,7 +455,7 @@ InstallerService::eResults InstallerService::backupAppFiles(const std::string &p
} }
InstallerService::eResults InstallerService::patchFST(const std::string &path, const char *fstHash) { InstallerService::eResults InstallerService::patchFST(const std::string &path, const char *fstHash) {
std::string fstFilePath = path + "/code/title.fst"; std::string fstFilePath = path + "/code/title.fst";
std::string fstBackupFilePath = path + "/code/backup.fst"; std::string fstBackupFilePath = path + "/code/backup.fst";
std::string fstTargetFilePath = path + "/code/title.fst"; std::string fstTargetFilePath = path + "/code/title.fst";
@ -474,7 +473,7 @@ InstallerService::eResults InstallerService::patchFST(const std::string &path, c
return FAILED_TO_CHECK_HASH_COPIED_FILES; return FAILED_TO_CHECK_HASH_COPIED_FILES;
} }
uint8_t *fstData = nullptr; uint8_t *fstData = nullptr;
uint32_t fstDataSize = 0; uint32_t fstDataSize = 0;
DEBUG_FUNCTION_LINE("Trying to load FST from %s", fstFilePath.c_str()); DEBUG_FUNCTION_LINE("Trying to load FST from %s", fstFilePath.c_str());
@ -516,7 +515,7 @@ InstallerService::eResults InstallerService::patchFST(const std::string &path, c
} }
InstallerService::eResults InstallerService::patchCOS(const std::string &path, char *hash) { InstallerService::eResults InstallerService::patchCOS(const std::string &path, char *hash) {
std::string cosFilePath = path + "/code/cos.xml"; std::string cosFilePath = path + "/code/cos.xml";
std::string cosBackupFilePath = path + "/code/cback.xml"; std::string cosBackupFilePath = path + "/code/cback.xml";
std::string cosTargetFilePath = path + "/code/cos.xml"; std::string cosTargetFilePath = path + "/code/cos.xml";
@ -618,9 +617,9 @@ InstallerService::eResults InstallerService::copyRPX(const std::string &path, co
} }
InstallerService::eResults InstallerService::patchSystemXML(const std::string &path, uint64_t titleId) { InstallerService::eResults InstallerService::patchSystemXML(const std::string &path, uint64_t titleId) {
std::string inputFile = std::string(path + "/system.xml"); std::string inputFile = std::string(path + "/system.xml");
std::string backupFile = std::string(path + "/sbackup.xml"); std::string backupFile = std::string(path + "/sbackup.xml");
std::string finalFile = std::string(path + "/system.xml"); std::string finalFile = std::string(path + "/system.xml");
if (!FSUtils::copyFile(inputFile, backupFile)) { if (!FSUtils::copyFile(inputFile, backupFile)) {
DEBUG_CONSOLE_LOG("Failed to copy files"); DEBUG_CONSOLE_LOG("Failed to copy files");
@ -743,7 +742,7 @@ InstallerService::eResults InstallerService::checkRPXAlreadyValid(const std::str
} }
InstallerService::eResults InstallerService::checkFileHash(const std::string &filePath, const std::string &hash) { InstallerService::eResults InstallerService::checkFileHash(const std::string &filePath, const std::string &hash) {
uint8_t *fileData = nullptr; uint8_t *fileData = nullptr;
uint32_t fileDataSize = 0; uint32_t fileDataSize = 0;
if (FSUtils::LoadFileToMem(filePath.c_str(), &fileData, &fileDataSize) < 0) { if (FSUtils::LoadFileToMem(filePath.c_str(), &fileData, &fileDataSize) < 0) {
@ -789,4 +788,3 @@ InstallerService::eResults InstallerService::setBootTitle(uint64_t titleId) {
return SUCCESS; return SUCCESS;
} }

View File

@ -1,44 +1,44 @@
#pragma once #pragma once
#include "utils/pugixml.hpp"
#include "common/common.h" #include "common/common.h"
#include <optional> #include "utils/pugixml.hpp"
#include <coreinit/memorymap.h> #include <coreinit/memorymap.h>
#include <optional>
class InstallerService { class InstallerService {
public: public:
enum eResults { enum eResults {
SUCCESS = 0, SUCCESS = 0,
NO_COMPATIBLE_APP_INSTALLED = -1, NO_COMPATIBLE_APP_INSTALLED = -1,
FAILED_TO_COPY_FILES = -2, FAILED_TO_COPY_FILES = -2,
FAILED_TO_CHECK_HASH_COPIED_FILES = -3, FAILED_TO_CHECK_HASH_COPIED_FILES = -3,
SYSTEM_XML_INFORMATION_NOT_FOUND = -4, SYSTEM_XML_INFORMATION_NOT_FOUND = -4,
SYSTEM_XML_PARSING_FAILED = -5, SYSTEM_XML_PARSING_FAILED = -5,
SYSTEM_XML_HASH_MISMATCH_RESTORE_FAILED = -6, SYSTEM_XML_HASH_MISMATCH_RESTORE_FAILED = -6,
SYSTEM_XML_HASH_MISMATCH = -7, SYSTEM_XML_HASH_MISMATCH = -7,
RPX_HASH_MISMATCH = -8, RPX_HASH_MISMATCH = -8,
RPX_HASH_MISMATCH_RESTORE_FAILED = -9, RPX_HASH_MISMATCH_RESTORE_FAILED = -9,
COS_XML_PARSING_FAILED = -10, COS_XML_PARSING_FAILED = -10,
COS_XML_HASH_MISMATCH = -11, COS_XML_HASH_MISMATCH = -11,
COS_XML_HASH_MISMATCH_RESTORE_FAILED = -12, COS_XML_HASH_MISMATCH_RESTORE_FAILED = -12,
MALLOC_FAILED = -13, MALLOC_FAILED = -13,
FST_HASH_MISMATCH = -14, FST_HASH_MISMATCH = -14,
FST_HASH_MISMATCH_RESTORE_FAILED = -15, FST_HASH_MISMATCH_RESTORE_FAILED = -15,
FST_HEADER_MISMATCH = -16, FST_HEADER_MISMATCH = -16,
FST_NO_USABLE_SECTION_FOUND = -17, FST_NO_USABLE_SECTION_FOUND = -17,
FAILED_TO_LOAD_FILE = -18, FAILED_TO_LOAD_FILE = -18,
}; };
static bool isColdBootAllowed() { static bool isColdBootAllowed() {
/* if (OSIsAddressValid(0x00FFFFF8)) { */ /* if (OSIsAddressValid(0x00FFFFF8)) { */
uint64_t bootedFrom = *((uint64_t *) 0x00FFFFF8); uint64_t bootedFrom = *((uint64_t *) 0x00FFFFF8);
if ( if (
bootedFrom == 0x000500101004E000L || // H&S JPN bootedFrom == 0x000500101004E000L || // H&S JPN
bootedFrom == 0x000500101004E100L || // H&S USA bootedFrom == 0x000500101004E100L || // H&S USA
bootedFrom == 0x000500101004E200L // H&S EUR bootedFrom == 0x000500101004E200L // H&S EUR
) { ) {
return true; return true;
} }
// } // }
return false; return false;
} }

View File

@ -1,11 +1,12 @@
#pragma once #pragma once
#include <string> #include "input/Input.h"
#include <functional>
#include <utility>
#include <list>
#include "utils/WiiUScreen.h"
#include "utils/ScreenUtils.h" #include "utils/ScreenUtils.h"
#include "utils/WiiUScreen.h"
#include <functional>
#include <list>
#include <string>
#include <utility>
template<typename T> template<typename T>
class Menu { class Menu {
@ -45,7 +46,7 @@ public:
int selectedDist = selected; int selectedDist = selected;
WiiUScreen::clearScreen(); WiiUScreen::clearScreen();
printHeader(); printHeader();
for (auto &row: content) { for (auto &row : content) {
std::string cursor = ""; std::string cursor = "";
if (row.first) { if (row.first) {
cursor += (selectedDist--) ? " " : "> "; cursor += (selectedDist--) ? " " : "> ";

View File

@ -1,3 +1,4 @@
// clang-format off
#include "common.h" #include "common.h"
systemXMLInformation systemXMLHashInformation[] = { systemXMLInformation systemXMLHashInformation[] = {

View File

@ -1,13 +1,13 @@
#pragma once #pragma once
#include <cstdint>
#include <coreinit/mcp.h> #include <coreinit/mcp.h>
#include <cstdint>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#define VERSION "v0.1" #define VERSION "v0.1"
enum SYSTEM_XML_DEFAULT_TITLE_ID { enum SYSTEM_XML_DEFAULT_TITLE_ID {
WII_U_MENU_EUR, WII_U_MENU_EUR,

View File

@ -59,4 +59,3 @@ WUT_CHECK_OFFSET(FSTNodeEntry, 0x08, file.size);
WUT_CHECK_OFFSET(FSTNodeEntry, 0x0C, permission); WUT_CHECK_OFFSET(FSTNodeEntry, 0x0C, permission);
WUT_CHECK_OFFSET(FSTNodeEntry, 0x0E, sectionNumber); WUT_CHECK_OFFSET(FSTNodeEntry, 0x0E, sectionNumber);
WUT_CHECK_SIZE(FSTNodeEntry, 0x10); WUT_CHECK_SIZE(FSTNodeEntry, 0x10);

View File

@ -1,13 +1,13 @@
#include "CFile.hpp"
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <strings.h> #include <strings.h>
#include "CFile.hpp"
CFile::CFile() { CFile::CFile() {
iFd = -1; iFd = -1;
mem_file = NULL; mem_file = NULL;
filesize = 0; filesize = 0;
pos = 0; pos = 0;
} }
CFile::CFile(const std::string &filepath, eOpenTypes mode) { CFile::CFile(const std::string &filepath, eOpenTypes mode) {
@ -33,7 +33,7 @@ int32_t CFile::open(const std::string &filepath, eOpenTypes mode) {
switch (mode) { switch (mode) {
default: default:
case ReadOnly: // file must exist case ReadOnly: // file must exist
openMode = O_RDONLY; openMode = O_RDONLY;
break; break;
case WriteOnly: // file will be created / zerod case WriteOnly: // file will be created / zerod
@ -75,10 +75,10 @@ void CFile::close() {
if (iFd >= 0) if (iFd >= 0)
::close(iFd); ::close(iFd);
iFd = -1; iFd = -1;
mem_file = NULL; mem_file = NULL;
filesize = 0; filesize = 0;
pos = 0; pos = 0;
} }
int32_t CFile::read(uint8_t *ptr, size_t size) { int32_t CFile::read(uint8_t *ptr, size_t size) {
@ -125,7 +125,7 @@ int32_t CFile::write(const uint8_t *ptr, size_t size) {
} }
int32_t CFile::seek(long int offset, int32_t origin) { int32_t CFile::seek(long int offset, int32_t origin) {
int32_t ret = 0; int32_t ret = 0;
int64_t newPos = pos; int64_t newPos = pos;
if (origin == SEEK_SET) { if (origin == SEEK_SET) {
@ -156,7 +156,7 @@ int32_t CFile::seek(long int offset, int32_t origin) {
int32_t CFile::fwrite(const char *format, ...) { int32_t CFile::fwrite(const char *format, ...) {
char tmp[512]; char tmp[512];
tmp[0] = 0; tmp[0] = 0;
int32_t result = -1; int32_t result = -1;
va_list va; va_list va;
@ -169,5 +169,3 @@ int32_t CFile::fwrite(const char *format, ...) {
return result; return result;
} }

View File

@ -1,10 +1,10 @@
#ifndef CFILE_HPP_ #ifndef CFILE_HPP_
#define CFILE_HPP_ #define CFILE_HPP_
#include <stdio.h>
#include <string>
#include <string.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <unistd.h> #include <unistd.h>
#include <wut_types.h> #include <wut_types.h>

View File

@ -1,11 +1,11 @@
#include <malloc.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include "FSUtils.h" #include "FSUtils.h"
#include "CFile.hpp" #include "CFile.hpp"
#include "utils/logger.h" #include "utils/logger.h"
#include <fcntl.h>
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_t *size) { int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_t *size) {
//! always initialze input //! always initialze input
@ -27,8 +27,8 @@ int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_
} }
uint32_t blocksize = 0x4000; uint32_t blocksize = 0x4000;
uint32_t done = 0; uint32_t done = 0;
int32_t readBytes = 0; int32_t readBytes = 0;
while (done < filesize) { while (done < filesize) {
if (done + blocksize > filesize) { if (done + blocksize > filesize) {
@ -136,7 +136,7 @@ bool FSUtils::copyFile(const std::string &in, const std::string &out) {
size_t size; size_t size;
int source = open(in.c_str(), O_RDONLY, 0); int source = open(in.c_str(), O_RDONLY, 0);
int dest = open(out.c_str(), 0x602, 0644); int dest = open(out.c_str(), 0x602, 0644);
if (source < 0) { if (source < 0) {
return false; return false;
} }
@ -146,7 +146,7 @@ bool FSUtils::copyFile(const std::string &in, const std::string &out) {
} }
auto bufferSize = 1024 * 1024; auto bufferSize = 1024 * 1024;
char *buf = (char *) malloc(bufferSize); char *buf = (char *) malloc(bufferSize);
if (buf == NULL) { if (buf == NULL) {
return false; return false;
} }
@ -171,4 +171,3 @@ int32_t FSUtils::saveBufferToFile(const char *path, const void *buffer, uint32_t
file.close(); file.close();
return written; return written;
} }

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <wut_types.h>
#include <string> #include <string>
#include <wut_types.h>
class FSUtils { class FSUtils {
public: public:

View File

@ -1,4 +1,5 @@
#pragma once #pragma once
#include "Input.h"
class CombinedInput : public Input { class CombinedInput : public Input {
public: public:

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <cstring>
#include <cstdint> #include <cstdint>
#include <cstring>
class Input { class Input {
public: public:
@ -12,36 +12,36 @@ public:
virtual ~Input() = default; virtual ~Input() = default;
enum eButtons { enum eButtons {
BUTTON_NONE = 0x0000, BUTTON_NONE = 0x0000,
VPAD_TOUCH = 0x80000000, VPAD_TOUCH = 0x80000000,
BUTTON_Z = 0x20000, BUTTON_Z = 0x20000,
BUTTON_C = 0x10000, BUTTON_C = 0x10000,
BUTTON_A = 0x8000, BUTTON_A = 0x8000,
BUTTON_B = 0x4000, BUTTON_B = 0x4000,
BUTTON_X = 0x2000, BUTTON_X = 0x2000,
BUTTON_Y = 0x1000, BUTTON_Y = 0x1000,
BUTTON_1 = BUTTON_Y, BUTTON_1 = BUTTON_Y,
BUTTON_2 = BUTTON_X, BUTTON_2 = BUTTON_X,
BUTTON_LEFT = 0x0800, BUTTON_LEFT = 0x0800,
BUTTON_RIGHT = 0x0400, BUTTON_RIGHT = 0x0400,
BUTTON_UP = 0x0200, BUTTON_UP = 0x0200,
BUTTON_DOWN = 0x0100, BUTTON_DOWN = 0x0100,
BUTTON_ZL = 0x0080, BUTTON_ZL = 0x0080,
BUTTON_ZR = 0x0040, BUTTON_ZR = 0x0040,
BUTTON_L = 0x0020, BUTTON_L = 0x0020,
BUTTON_R = 0x0010, BUTTON_R = 0x0010,
BUTTON_PLUS = 0x0008, BUTTON_PLUS = 0x0008,
BUTTON_MINUS = 0x0004, BUTTON_MINUS = 0x0004,
BUTTON_HOME = 0x0002, BUTTON_HOME = 0x0002,
BUTTON_SYNC = 0x0001, BUTTON_SYNC = 0x0001,
STICK_R_LEFT = 0x04000000, STICK_R_LEFT = 0x04000000,
STICK_R_RIGHT = 0x02000000, STICK_R_RIGHT = 0x02000000,
STICK_R_UP = 0x01000000, STICK_R_UP = 0x01000000,
STICK_R_DOWN = 0x00800000, STICK_R_DOWN = 0x00800000,
STICK_L_LEFT = 0x40000000, STICK_L_LEFT = 0x40000000,
STICK_L_RIGHT = 0x20000000, STICK_L_RIGHT = 0x20000000,
STICK_L_UP = 0x10000000, STICK_L_UP = 0x10000000,
STICK_L_DOWN = 0x08000000 STICK_L_DOWN = 0x08000000
}; };
typedef struct { typedef struct {
@ -57,5 +57,4 @@ public:
PadData data{}; PadData data{};
PadData lastData{}; PadData lastData{};
}; };

View File

@ -16,8 +16,8 @@
* 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 <vpad/input.h>
#include "Input.h" #include "Input.h"
#include <vpad/input.h>
class VPadInput : public Input { class VPadInput : public Input {
public: public:
@ -36,11 +36,11 @@ public:
VPADRead(VPAD_CHAN_0, &vpad, 1, &vpadError); VPADRead(VPAD_CHAN_0, &vpad, 1, &vpadError);
if (vpadError == VPAD_READ_SUCCESS) { if (vpadError == VPAD_READ_SUCCESS) {
data.buttons_r = vpad.release; data.buttons_r = vpad.release;
data.buttons_h = vpad.hold; data.buttons_h = vpad.hold;
data.buttons_d = vpad.trigger; data.buttons_d = vpad.trigger;
data.validPointer = !vpad.tpNormal.validity; data.validPointer = !vpad.tpNormal.validity;
data.touched = vpad.tpNormal.touched; data.touched = vpad.tpNormal.touched;
VPADGetTPCalibratedPoint(VPAD_CHAN_0, &tpCalib, &vpad.tpFiltered1); VPADGetTPCalibratedPoint(VPAD_CHAN_0, &tpCalib, &vpad.tpFiltered1);

View File

@ -16,9 +16,9 @@
* 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 "Input.h"
#include <padscore/kpad.h> #include <padscore/kpad.h>
#include <padscore/wpad.h> #include <padscore/wpad.h>
#include "Input.h"
class WPADInput : public Input { class WPADInput : public Input {
public: public:

View File

@ -1,20 +1,20 @@
#include <coreinit/debug.h> #include <coreinit/debug.h>
#include <whb/proc.h>
#include <whb/log.h> #include <whb/log.h>
#include <whb/log_udp.h> #include <whb/log_udp.h>
#include <whb/proc.h>
#include "InstallerService.h"
#include "utils/WiiUScreen.h"
#include <input/CombinedInput.h>
#include <input/VPADInput.h>
#include <input/WPADInput.h>
#include <iosuhax.h> #include <iosuhax.h>
#include <iosuhax_devoptab.h> #include <iosuhax_devoptab.h>
#include <string_view> #include <string_view>
#include <input/WPADInput.h>
#include <input/VPADInput.h>
#include <input/CombinedInput.h>
#include "utils/WiiUScreen.h"
#include "InstallerService.h"
#include "ApplicationState.h"
#include "../build/safe_payload.h" #include "../build/safe_payload.h"
#include "ApplicationState.h"
constexpr bool strings_equal(char const *a, char const *b) { constexpr bool strings_equal(char const *a, char const *b) {
return std::string_view(a) == b; return std::string_view(a) == b;
@ -26,7 +26,7 @@ void initIOSUHax();
void deInitIOSUHax(); void deInitIOSUHax();
int sFSAFd = -1; int sFSAFd = -1;
bool sIosuhaxMount = false; bool sIosuhaxMount = false;
int main_loop() { int main_loop() {
@ -38,8 +38,7 @@ int main_loop() {
WPAD_CHAN_0, WPAD_CHAN_0,
WPAD_CHAN_1, WPAD_CHAN_1,
WPAD_CHAN_2, WPAD_CHAN_2,
WPAD_CHAN_3 WPAD_CHAN_3};
};
if (sFSAFd < 0 || !sIosuhaxMount) { if (sFSAFd < 0 || !sIosuhaxMount) {
state.setError(ApplicationState::eErrorState::ERROR_IOSUHAX_FAILED); state.setError(ApplicationState::eErrorState::ERROR_IOSUHAX_FAILED);
@ -51,7 +50,7 @@ int main_loop() {
if (vpadInput.update(1280, 720)) { if (vpadInput.update(1280, 720)) {
baseInput.combine(vpadInput); baseInput.combine(vpadInput);
} }
for (auto &wpadInput: wpadInputs) { for (auto &wpadInput : wpadInputs) {
if (wpadInput.update(1280, 720)) { if (wpadInput.update(1280, 720)) {
baseInput.combine(wpadInput); baseInput.combine(wpadInput);
} }
@ -88,13 +87,13 @@ int main(int argc, char **argv) {
void initIOSUHax() { void initIOSUHax() {
sIosuhaxMount = false; sIosuhaxMount = false;
int res = IOSUHAX_Open(nullptr); int res = IOSUHAX_Open(nullptr);
if (res < 0) { if (res < 0) {
DEBUG_FUNCTION_LINE("IOSUHAX_open failed"); DEBUG_FUNCTION_LINE("IOSUHAX_open failed");
OSFatal("IOSUHAX_open failed, please start this installer with an CFW"); OSFatal("IOSUHAX_open failed, please start this installer with an CFW");
} else { } else {
sIosuhaxMount = true; sIosuhaxMount = true;
sFSAFd = IOSUHAX_FSA_Open(); sFSAFd = IOSUHAX_FSA_Open();
if (sFSAFd < 0) { if (sFSAFd < 0) {
DEBUG_FUNCTION_LINE("IOSUHAX_FSA_Open failed"); DEBUG_FUNCTION_LINE("IOSUHAX_FSA_Open failed");
} else { } else {

View File

@ -14,8 +14,9 @@
* 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 <coreinit/screen.h>
#include "ScreenUtils.h" #include "ScreenUtils.h"
#include <coreinit/screen.h>
#include <stdint.h>
void ScreenUtils::printTextOnScreen(ConsoleScreenID screen, int x, int y, const char *msg) { void ScreenUtils::printTextOnScreen(ConsoleScreenID screen, int x, int y, const char *msg) {
if (!msg) { if (!msg) {

View File

@ -15,6 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <stdint.h>
//! Defines the ID of a display usable with OSScreen. //! Defines the ID of a display usable with OSScreen.
typedef enum ConsoleScreenID { typedef enum ConsoleScreenID {

View File

@ -23,17 +23,16 @@
* *
* for WiiXplorer 2010 * for WiiXplorer 2010
***************************************************************************/ ***************************************************************************/
#include <vector>
#include <string>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#include <strings.h>
#include <wut_types.h>
#include <stdio.h>
#include "StringTools.h" #include "StringTools.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <strings.h>
#include <vector>
#include <wchar.h>
#include <wut_types.h>
BOOL StringTools::EndsWith(const std::string &a, const std::string &b) { BOOL StringTools::EndsWith(const std::string &a, const std::string &b) {
@ -85,7 +84,7 @@ const wchar_t *StringTools::wfmt(const char *format, ...) {
static char tmp[512]; static char tmp[512];
static wchar_t strWChar[512]; static wchar_t strWChar[512];
strWChar[0] = 0; strWChar[0] = 0;
tmp[0] = 0; tmp[0] = 0;
if (!format) if (!format)
return (const wchar_t *) strWChar; return (const wchar_t *) strWChar;
@ -98,7 +97,7 @@ const wchar_t *StringTools::wfmt(const char *format, ...) {
if ((vsprintf(tmp, format, va) >= 0)) { if ((vsprintf(tmp, format, va) >= 0)) {
int32_t bt; int32_t bt;
int32_t strlength = strlen(tmp); int32_t strlength = strlen(tmp);
bt = mbstowcs(strWChar, tmp, (strlength < 512) ? strlength : 512); bt = mbstowcs(strWChar, tmp, (strlength < 512) ? strlength : 512);
if (bt > 0) { if (bt > 0) {
strWChar[bt] = 0; strWChar[bt] = 0;
@ -112,13 +111,13 @@ const wchar_t *StringTools::wfmt(const char *format, ...) {
int32_t StringTools::strprintf(std::string &str, const char *format, ...) { int32_t StringTools::strprintf(std::string &str, const char *format, ...) {
static char tmp[512]; static char tmp[512];
tmp[0] = 0; tmp[0] = 0;
int32_t result = 0; int32_t result = 0;
va_list va; va_list va;
va_start(va, format); va_start(va, format);
if ((vsprintf(tmp, format, va) >= 0)) { if ((vsprintf(tmp, format, va) >= 0)) {
str = tmp; str = tmp;
result = str.size(); result = str.size();
} }
va_end(va); va_end(va);
@ -214,8 +213,7 @@ bool StringTools::findStringIC(const std::string &strHaystack, const std::string
auto it = std::search( auto it = std::search(
strHaystack.begin(), strHaystack.end(), strHaystack.begin(), strHaystack.end(),
strNeedle.begin(), strNeedle.end(), strNeedle.begin(), strNeedle.end(),
[](char ch1, char ch2) { return std::toupper(ch1) == std::toupper(ch2); } [](char ch1, char ch2) { return std::toupper(ch1) == std::toupper(ch2); });
);
return (it != strHaystack.end()); return (it != strHaystack.end());
} }

View File

@ -25,11 +25,11 @@
***************************************************************************/ ***************************************************************************/
#pragma once #pragma once
#include <vector>
#include <string>
#include <wut_types.h>
#include <algorithm> #include <algorithm>
#include <cctype> #include <cctype>
#include <string>
#include <vector>
#include <wut_types.h>
class StringTools { class StringTools {
public: public:
@ -57,7 +57,7 @@ public:
if (!path) if (!path)
return path; return path;
const char *ptr = path; const char *ptr = path;
const char *Filename = ptr; const char *Filename = ptr;
while (*ptr != '\0') { while (*ptr != '\0') {

View File

@ -1,3 +1,4 @@
// clang-format off
/* /*
* *
* TinySHA1 - a header only implementation of the SHA1 algorithm in C++. Based * TinySHA1 - a header only implementation of the SHA1 algorithm in C++. Based

View File

@ -4,13 +4,13 @@
#include <cstdarg> #include <cstdarg>
#include <cstdio> #include <cstdio>
void *WiiUScreen::sBufferTV = nullptr; void *WiiUScreen::sBufferTV = nullptr;
void *WiiUScreen::sBufferDRC = nullptr; void *WiiUScreen::sBufferDRC = nullptr;
uint32_t WiiUScreen::sBufferSizeTV = 0; uint32_t WiiUScreen::sBufferSizeTV = 0;
uint32_t WiiUScreen::sBufferSizeDRC = 0; uint32_t WiiUScreen::sBufferSizeDRC = 0;
bool WiiUScreen::sConsoleHasForeground = true; bool WiiUScreen::sConsoleHasForeground = true;
uint32_t WiiUScreen::consoleColor = 0x041F60FF; uint32_t WiiUScreen::consoleColor = 0x041F60FF;
uint32_t WiiUScreen::consoleCursorY = 0; uint32_t WiiUScreen::consoleCursorY = 0;
uint32_t WiiUScreen::ProcCallbackAcquired(void *context) { uint32_t WiiUScreen::ProcCallbackAcquired(void *context) {
MEMHeapHandle heap = MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM1); MEMHeapHandle heap = MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM1);
@ -37,7 +37,7 @@ uint32_t WiiUScreen::ProcCallbackReleased(void *context) {
bool WiiUScreen::Init() { bool WiiUScreen::Init() {
OSScreenInit(); OSScreenInit();
sBufferSizeTV = OSScreenGetBufferSizeEx(SCREEN_TV); sBufferSizeTV = OSScreenGetBufferSizeEx(SCREEN_TV);
sBufferSizeDRC = OSScreenGetBufferSizeEx(SCREEN_DRC); sBufferSizeDRC = OSScreenGetBufferSizeEx(SCREEN_DRC);
WiiUScreen::ProcCallbackAcquired(nullptr); WiiUScreen::ProcCallbackAcquired(nullptr);

View File

@ -3,23 +3,24 @@
#include <whb/log.h> #include <whb/log.h>
#include <whb/log_console.h> #include <whb/log_console.h>
#include <coreinit/memheap.h> #include "logger.h"
#include <coreinit/cache.h> #include <coreinit/cache.h>
#include <coreinit/memfrmheap.h> #include <coreinit/memfrmheap.h>
#include <coreinit/memheap.h>
#include <coreinit/memory.h> #include <coreinit/memory.h>
#include <coreinit/screen.h> #include <coreinit/screen.h>
#include <proc_ui/procui.h>
#include <cstring> #include <cstring>
#include "logger.h" #include <proc_ui/procui.h>
#define NUM_LINES (16) #define NUM_LINES (16)
#define LINE_LENGTH (128) #define LINE_LENGTH (128)
#define CONSOLE_FRAME_HEAP_TAG (0x000DECAF) #define CONSOLE_FRAME_HEAP_TAG (0x000DECAF)
#define PRINTF_BUFFER_LENGTH 2048 #define PRINTF_BUFFER_LENGTH 2048
#define DEBUG_CONSOLE_LOG(FMT, ARGS...)do { \ #define DEBUG_CONSOLE_LOG(FMT, ARGS...) \
DEBUG_FUNCTION_LINE(FMT, ## ARGS); \ do { \
WiiUScreen::drawLinef(FMT, ## ARGS); \ DEBUG_FUNCTION_LINE(FMT, ##ARGS); \
WiiUScreen::drawLinef(FMT, ##ARGS); \
} while (0) } while (0)

View File

@ -8,14 +8,16 @@ extern "C" {
#include <whb/log.h> #include <whb/log.h>
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__) #define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__) #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \ #define DEBUG_FUNCTION_LINE(FMT, ARGS...) \
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \ do { \
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0); } while (0);
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \ #define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) \
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \ do { \
WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0); } while (0);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -1,3 +1,4 @@
// clang-format off
/** /**
* pugixml parser - version 1.10 * pugixml parser - version 1.10
* -------------------------------------------------------- * --------------------------------------------------------

View File

@ -1,3 +1,4 @@
// clang-format off
/** /**
* pugixml parser - version 1.10 * pugixml parser - version 1.10
* -------------------------------------------------------- * --------------------------------------------------------

View File

@ -1,3 +1,4 @@
// clang-format off
/** /**
* pugixml parser - version 1.10 * pugixml parser - version 1.10
* -------------------------------------------------------- * --------------------------------------------------------

View File

@ -1,10 +1,10 @@
#include <string.h>
#include <stddef.h>
#include <whb/log.h>
#include <fs/FSUtils.h>
#include "logger.h"
#include "utils.h" #include "utils.h"
#include "TinySHA1.hpp" #include "TinySHA1.hpp"
#include "logger.h"
#include <fs/FSUtils.h>
#include <stddef.h>
#include <string.h>
#include <whb/log.h>
// https://gist.github.com/ccbrown/9722406 // https://gist.github.com/ccbrown/9722406
void Utils::dumpHex(const void *data, size_t size) { void Utils::dumpHex(const void *data, size_t size) {

View File

@ -7,28 +7,29 @@
extern "C" { extern "C" {
#endif #endif
#define LIMIT(x, min, max) \ #define LIMIT(x, min, max) \
({ \ ({ \
typeof( x ) _x = x; \ typeof(x) _x = x; \
typeof( min ) _min = min; \ typeof(min) _min = min; \
typeof( max ) _max = max; \ typeof(max) _max = max; \
( ( ( _x ) < ( _min ) ) ? ( _min ) : ( ( _x ) > ( _max ) ) ? ( _max) : ( _x ) ); \ (((_x) < (_min)) ? (_min) : ((_x) > (_max)) ? (_max) \
}) : (_x)); \
})
#define DegToRad(a) ( (a) * 0.01745329252f ) #define DegToRad(a) ((a) *0.01745329252f)
#define RadToDeg(a) ( (a) * 57.29577951f ) #define RadToDeg(a) ((a) *57.29577951f)
#define ALIGN4(x) (((x) + 3) & ~3) #define ALIGN4(x) (((x) + 3) & ~3)
#define ALIGN32(x) (((x) + 31) & ~31) #define ALIGN32(x) (((x) + 31) & ~31)
// those work only in powers of 2 // those work only in powers of 2
#define ROUNDDOWN(val, align) ((val) & ~(align-1)) #define ROUNDDOWN(val, align) ((val) & ~(align - 1))
#define ROUNDUP(val, align) ROUNDDOWN(((val) + (align-1)), align) #define ROUNDUP(val, align) ROUNDDOWN(((val) + (align - 1)), align)
#define le16(i) ((((uint16_t) ((i) & 0xFF)) << 8) | ((uint16_t) (((i) & 0xFF00) >> 8))) #define le16(i) ((((uint16_t) ((i) &0xFF)) << 8) | ((uint16_t) (((i) &0xFF00) >> 8)))
#define le32(i) ((((uint32_t)le16((i) & 0xFFFF)) << 16) | ((uint32_t)le16(((i) & 0xFFFF0000) >> 16))) #define le32(i) ((((uint32_t) le16((i) &0xFFFF)) << 16) | ((uint32_t) le16(((i) &0xFFFF0000) >> 16)))
#define le64(i) ((((uint64_t)le32((i) & 0xFFFFFFFFLL)) << 32) | ((uint64_t)le32(((i) & 0xFFFFFFFF00000000LL) >> 32))) #define le64(i) ((((uint64_t) le32((i) &0xFFFFFFFFLL)) << 32) | ((uint64_t) le32(((i) &0xFFFFFFFF00000000LL) >> 32)))
#ifdef __cplusplus #ifdef __cplusplus
} }