diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..56cc685 --- /dev/null +++ b/.clang-format @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7b85a3..3080603 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,9 +6,16 @@ on: - main 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: runs-on: ubuntu-18.04 + needs: clang-format steps: - uses: actions/checkout@v2 - 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 asset_path: ./${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip asset_name: ${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip - asset_content_type: application/unknown \ No newline at end of file + asset_content_type: application/zip \ No newline at end of file diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d987c9b..fdef0da 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -3,8 +3,34 @@ name: CI-PR on: [pull_request] 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: runs-on: ubuntu-18.04 + needs: clang-format steps: - uses: actions/checkout@v2 - name: Checkout submodules using a PAT diff --git a/source/ApplicationState.cpp b/source/ApplicationState.cpp index 051e1fe..4b0833f 100644 --- a/source/ApplicationState.cpp +++ b/source/ApplicationState.cpp @@ -1,10 +1,10 @@ #include "ApplicationState.h" -#include "utils/WiiUScreen.h" +#include "../build/safe_payload.h" #include "utils/ScreenUtils.h" #include "utils/StringTools.h" -#include "../build/safe_payload.h" -#include +#include "utils/WiiUScreen.h" #include +#include extern "C" void OSShutdown(); @@ -131,9 +131,8 @@ void ApplicationState::changeState(eGameState newState) { 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"; + 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) { @@ -209,8 +208,7 @@ void ApplicationState::update(Input *input) { changeState(STATE_INSTALL_FST); } } else if (this->state == STATE_INSTALL_FST) { - auto result = (this->fstAlreadyPatched) ? InstallerService::SUCCESS : - InstallerService::patchFST(this->appInfo->path, this->appInfo->fstHash); + auto result = (this->fstAlreadyPatched) ? InstallerService::SUCCESS : InstallerService::patchFST(this->appInfo->path, this->appInfo->fstHash); if (result != InstallerService::SUCCESS) { this->installerError = result; setError(ERROR_INSTALLER_ERROR); @@ -218,8 +216,7 @@ void ApplicationState::update(Input *input) { changeState(STATE_INSTALL_COS); } } else if (this->state == STATE_INSTALL_COS) { - auto result = (this->cosAlreadyPatched) ? InstallerService::SUCCESS : - InstallerService::patchCOS(this->appInfo->path, this->appInfo->cosHash); + auto result = (this->cosAlreadyPatched) ? InstallerService::SUCCESS : InstallerService::patchCOS(this->appInfo->path, this->appInfo->cosHash); if (result != InstallerService::SUCCESS) { this->installerError = result; setError(ERROR_INSTALLER_ERROR); @@ -302,7 +299,7 @@ void ApplicationState::checkPatchPossible() { 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); + this->tmdValid = (InstallerService::checkTMDValid(this->appInfo->path, this->appInfo->tmdHash, this->appInfo->tmdWithCertHash) == InstallerService::SUCCESS); InstallerService::eResults result; @@ -315,7 +312,7 @@ void ApplicationState::checkPatchPossible() { 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; changeState(STATE_CHECK_COLDBOOT_STATUS); @@ -365,7 +362,7 @@ void ApplicationState::checkColdbootStatus() { 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(); changeState(STATE_CHECK_REMOVAL_POSSIBLE); diff --git a/source/ApplicationState.h b/source/ApplicationState.h index 2f5c694..ae3b35d 100644 --- a/source/ApplicationState.h +++ b/source/ApplicationState.h @@ -1,15 +1,14 @@ #pragma once -#include -#include -#include -#include "common/common.h" #include "InstallerService.h" #include "Menu.h" +#include "common/common.h" +#include +#include +#include class ApplicationState { public: - enum eErrorState { ERROR_NONE, ERROR_IOSUHAX_FAILED, @@ -80,23 +79,23 @@ private: bool fstPatchPossible = false; bool cosPatchPossible = false; - bool removalPossible = false; - bool installPossible = false; + bool removalPossible = false; + bool installPossible = false; bool alreadyInstalledAndUpdated = false; - bool systemXMLPatchPossible = false; - bool systemXMLPatchAllowed = false; + bool systemXMLPatchPossible = false; + bool systemXMLPatchAllowed = false; bool systemXMLPatchAllowedButNoRPXCheck = false; - bool systemXMLAlreadyPatched = false; - bool systemXMLRestorePossible = false; + bool systemXMLAlreadyPatched = false; + bool systemXMLRestorePossible = false; - eGameState state = STATE_WELCOME_SCREEN; - eErrorState error = ERROR_NONE; + eGameState state = STATE_WELCOME_SCREEN; + eErrorState error = ERROR_NONE; uint64_t coldbootTitleId = 0; - _gList_t *coldbootTitle = nullptr; + _gList_t *coldbootTitle = nullptr; std::optional systemMenuTitleId; bool fstAlreadyPatched = false; bool rpxAlreadyPatched = false; bool cosAlreadyPatched = false; - bool tmdValid = false; + bool tmdValid = false; }; diff --git a/source/InstallerService.cpp b/source/InstallerService.cpp index 42059bb..e66ab12 100644 --- a/source/InstallerService.cpp +++ b/source/InstallerService.cpp @@ -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 "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/utils.h" #include -#include -#include #include -#include -#include #include +#include +#include +#include +#include InstallerService::eResults InstallerService::checkCOS(const std::string &path, char *hash) { 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) { std::string fstFilePath = path + "/code/title.fst"; - uint8_t *fstData = nullptr; + uint8_t *fstData = nullptr; uint32_t fstDataSize = 0; 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("max_size").first_child().set_value("40000000"); 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"); mask.first_child().set_value("FFFFFFFFFFFFFFFF"); } @@ -145,7 +145,7 @@ bool InstallerService::patchCOSXMLData(pugi::xml_document *doc) { } std::optional InstallerService::getInstalledAppInformation() { - auto mcpHandle = (int32_t) MCP_Open(); + auto mcpHandle = (int32_t) MCP_Open(); auto titleCount = (uint32_t) MCP_TitleCount(mcpHandle); auto *titleList = (MCPTitleListType *) memalign(32, sizeof(MCPTitleListType) * titleCount); @@ -188,7 +188,7 @@ std::optional InstallerService::getInstalledAppInformation() { } std::optional InstallerService::getSystemMenuTitleId() { - auto mcpHandle = (int32_t) MCP_Open(); + auto mcpHandle = (int32_t) MCP_Open(); auto titleCount = (uint32_t) 1; 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); } - auto *rootEntry = (FSTNodeEntry *) (fstData + sizeof(FSTHeader) + numberOfSections * sizeof(FSTSectionEntry)); + auto *rootEntry = (FSTNodeEntry *) (fstData + sizeof(FSTHeader) + numberOfSections * sizeof(FSTSectionEntry)); auto numberOfNodeEntries = rootEntry->directory.lastEntryNumber; char *stringTableOffset = (char *) ((uint32_t) rootEntry + (sizeof(FSTNodeEntry) * numberOfNodeEntries)); @@ -343,7 +343,6 @@ std::string InstallerService::ErrorMessage(InstallerService::eResults error) { } else { return "UNKNOWN ERROR"; } - } bool InstallerService::isBackupAvailable(const std::string &path) { @@ -353,7 +352,7 @@ bool InstallerService::isBackupAvailable(const std::string &path) { {"/content/safe.rpx.bak"}, }; - for (auto &backupEntry: backupList) { + for (auto &backupEntry : backupList) { std::string backupFile = path + backupEntry; 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 fileHash = Utils::hashFile(backupFile); + std::string fileHash = Utils::hashFile(backupFile); if (fileHash != savedHash) { return false; } @@ -385,12 +384,12 @@ 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) { - std::string destPath = path + backupOp[0]; + for (auto &backupOp : backupList) { + std::string destPath = path + backupOp[0]; std::string backupPath = path + backupOp[1]; if (!FSUtils::copyFile(backupPath, destPath)) { @@ -406,8 +405,8 @@ InstallerService::eResults InstallerService::restoreAppFiles(const std::string & } } - for (auto &backupOp: backupList) { - std::string backupPath = path + backupOp[1]; + for (auto &backupOp : backupList) { + std::string backupPath = path + backupOp[1]; std::string backupSha1Path = backupPath + ".sha1"; ::remove(backupPath.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) { 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) { - std::string backupSrc = path + backupOp[0]; - std::string backupDst = path + backupOp[1]; + for (auto &backupOp : backupList) { + std::string backupSrc = path + backupOp[0]; + std::string backupDst = path + backupOp[1]; std::string backupSha1 = backupDst + ".sha1"; 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) { - std::string fstFilePath = path + "/code/title.fst"; + std::string fstFilePath = path + "/code/title.fst"; std::string fstBackupFilePath = path + "/code/backup.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; } - uint8_t *fstData = nullptr; + uint8_t *fstData = nullptr; uint32_t fstDataSize = 0; 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) { - std::string cosFilePath = path + "/code/cos.xml"; + std::string cosFilePath = path + "/code/cos.xml"; std::string cosBackupFilePath = path + "/code/cback.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) { - 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 finalFile = std::string(path + "/system.xml"); + std::string finalFile = std::string(path + "/system.xml"); if (!FSUtils::copyFile(inputFile, backupFile)) { 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) { - uint8_t *fileData = nullptr; + uint8_t *fileData = nullptr; uint32_t fileDataSize = 0; if (FSUtils::LoadFileToMem(filePath.c_str(), &fileData, &fileDataSize) < 0) { @@ -789,4 +788,3 @@ InstallerService::eResults InstallerService::setBootTitle(uint64_t titleId) { return SUCCESS; } - diff --git a/source/InstallerService.h b/source/InstallerService.h index e231d6b..09c0a4e 100644 --- a/source/InstallerService.h +++ b/source/InstallerService.h @@ -1,44 +1,44 @@ #pragma once -#include "utils/pugixml.hpp" #include "common/common.h" -#include +#include "utils/pugixml.hpp" #include +#include 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, + 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, + 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, }; static bool isColdBootAllowed() { /* if (OSIsAddressValid(0x00FFFFF8)) { */ - uint64_t bootedFrom = *((uint64_t *) 0x00FFFFF8); - if ( - bootedFrom == 0x000500101004E000L || // H&S JPN - bootedFrom == 0x000500101004E100L || // H&S USA - bootedFrom == 0x000500101004E200L // H&S EUR - ) { - return true; - } + uint64_t bootedFrom = *((uint64_t *) 0x00FFFFF8); + if ( + bootedFrom == 0x000500101004E000L || // H&S JPN + bootedFrom == 0x000500101004E100L || // H&S USA + bootedFrom == 0x000500101004E200L // H&S EUR + ) { + return true; + } // } return false; } diff --git a/source/Menu.h b/source/Menu.h index e640036..9fe8512 100644 --- a/source/Menu.h +++ b/source/Menu.h @@ -1,11 +1,12 @@ #pragma once -#include -#include -#include -#include -#include "utils/WiiUScreen.h" +#include "input/Input.h" #include "utils/ScreenUtils.h" +#include "utils/WiiUScreen.h" +#include +#include +#include +#include template class Menu { @@ -45,7 +46,7 @@ public: int selectedDist = selected; WiiUScreen::clearScreen(); printHeader(); - for (auto &row: content) { + for (auto &row : content) { std::string cursor = ""; if (row.first) { cursor += (selectedDist--) ? " " : "> "; diff --git a/source/common/common.cpp b/source/common/common.cpp index bf521ee..1e4380a 100644 --- a/source/common/common.cpp +++ b/source/common/common.cpp @@ -1,3 +1,4 @@ +// clang-format off #include "common.h" systemXMLInformation systemXMLHashInformation[] = { diff --git a/source/common/common.h b/source/common/common.h index 6520ea5..def22ff 100644 --- a/source/common/common.h +++ b/source/common/common.h @@ -1,13 +1,13 @@ #pragma once -#include #include +#include #ifdef __cplusplus extern "C" { #endif -#define VERSION "v0.1" +#define VERSION "v0.1" enum SYSTEM_XML_DEFAULT_TITLE_ID { WII_U_MENU_EUR, diff --git a/source/common/fst_structs.h b/source/common/fst_structs.h index 2da9f1e..eaf17e1 100644 --- a/source/common/fst_structs.h +++ b/source/common/fst_structs.h @@ -59,4 +59,3 @@ WUT_CHECK_OFFSET(FSTNodeEntry, 0x08, file.size); WUT_CHECK_OFFSET(FSTNodeEntry, 0x0C, permission); WUT_CHECK_OFFSET(FSTNodeEntry, 0x0E, sectionNumber); WUT_CHECK_SIZE(FSTNodeEntry, 0x10); - diff --git a/source/fs/CFile.cpp b/source/fs/CFile.cpp index 17a6c5e..12ba550 100644 --- a/source/fs/CFile.cpp +++ b/source/fs/CFile.cpp @@ -1,13 +1,13 @@ +#include "CFile.hpp" #include #include #include -#include "CFile.hpp" CFile::CFile() { - iFd = -1; + iFd = -1; mem_file = NULL; filesize = 0; - pos = 0; + pos = 0; } CFile::CFile(const std::string &filepath, eOpenTypes mode) { @@ -33,7 +33,7 @@ int32_t CFile::open(const std::string &filepath, eOpenTypes mode) { switch (mode) { default: - case ReadOnly: // file must exist + case ReadOnly: // file must exist openMode = O_RDONLY; break; case WriteOnly: // file will be created / zerod @@ -75,10 +75,10 @@ void CFile::close() { if (iFd >= 0) ::close(iFd); - iFd = -1; + iFd = -1; mem_file = NULL; filesize = 0; - pos = 0; + pos = 0; } 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 ret = 0; + int32_t ret = 0; int64_t newPos = pos; 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, ...) { char tmp[512]; - tmp[0] = 0; + tmp[0] = 0; int32_t result = -1; va_list va; @@ -169,5 +169,3 @@ int32_t CFile::fwrite(const char *format, ...) { return result; } - - diff --git a/source/fs/CFile.hpp b/source/fs/CFile.hpp index 8192fab..103f5f7 100644 --- a/source/fs/CFile.hpp +++ b/source/fs/CFile.hpp @@ -1,10 +1,10 @@ #ifndef CFILE_HPP_ #define CFILE_HPP_ -#include -#include -#include #include +#include +#include +#include #include #include diff --git a/source/fs/FSUtils.cpp b/source/fs/FSUtils.cpp index 76fa2d4..9eec0a3 100644 --- a/source/fs/FSUtils.cpp +++ b/source/fs/FSUtils.cpp @@ -1,11 +1,11 @@ -#include -#include -#include -#include -#include #include "FSUtils.h" #include "CFile.hpp" #include "utils/logger.h" +#include +#include +#include +#include +#include int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_t *size) { //! always initialze input @@ -27,8 +27,8 @@ int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_ } uint32_t blocksize = 0x4000; - uint32_t done = 0; - int32_t readBytes = 0; + uint32_t done = 0; + int32_t readBytes = 0; while (done < filesize) { if (done + blocksize > filesize) { @@ -136,7 +136,7 @@ bool FSUtils::copyFile(const std::string &in, const std::string &out) { size_t size; 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) { return false; } @@ -146,7 +146,7 @@ bool FSUtils::copyFile(const std::string &in, const std::string &out) { } auto bufferSize = 1024 * 1024; - char *buf = (char *) malloc(bufferSize); + char *buf = (char *) malloc(bufferSize); if (buf == NULL) { return false; } @@ -171,4 +171,3 @@ int32_t FSUtils::saveBufferToFile(const char *path, const void *buffer, uint32_t file.close(); return written; } - diff --git a/source/fs/FSUtils.h b/source/fs/FSUtils.h index b38a999..47a1f94 100644 --- a/source/fs/FSUtils.h +++ b/source/fs/FSUtils.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include class FSUtils { public: diff --git a/source/input/CombinedInput.h b/source/input/CombinedInput.h index d06350b..3f83c8b 100644 --- a/source/input/CombinedInput.h +++ b/source/input/CombinedInput.h @@ -1,4 +1,5 @@ #pragma once +#include "Input.h" class CombinedInput : public Input { public: diff --git a/source/input/Input.h b/source/input/Input.h index f5fc51e..2c6d88f 100644 --- a/source/input/Input.h +++ b/source/input/Input.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include class Input { public: @@ -12,36 +12,36 @@ public: virtual ~Input() = default; enum eButtons { - BUTTON_NONE = 0x0000, - VPAD_TOUCH = 0x80000000, - BUTTON_Z = 0x20000, - BUTTON_C = 0x10000, - BUTTON_A = 0x8000, - BUTTON_B = 0x4000, - BUTTON_X = 0x2000, - BUTTON_Y = 0x1000, - BUTTON_1 = BUTTON_Y, - BUTTON_2 = BUTTON_X, - BUTTON_LEFT = 0x0800, - BUTTON_RIGHT = 0x0400, - BUTTON_UP = 0x0200, - BUTTON_DOWN = 0x0100, - BUTTON_ZL = 0x0080, - BUTTON_ZR = 0x0040, - BUTTON_L = 0x0020, - BUTTON_R = 0x0010, - BUTTON_PLUS = 0x0008, - BUTTON_MINUS = 0x0004, - BUTTON_HOME = 0x0002, - BUTTON_SYNC = 0x0001, - STICK_R_LEFT = 0x04000000, - STICK_R_RIGHT = 0x02000000, - STICK_R_UP = 0x01000000, - STICK_R_DOWN = 0x00800000, - STICK_L_LEFT = 0x40000000, - STICK_L_RIGHT = 0x20000000, - STICK_L_UP = 0x10000000, - STICK_L_DOWN = 0x08000000 + BUTTON_NONE = 0x0000, + VPAD_TOUCH = 0x80000000, + BUTTON_Z = 0x20000, + BUTTON_C = 0x10000, + BUTTON_A = 0x8000, + BUTTON_B = 0x4000, + BUTTON_X = 0x2000, + BUTTON_Y = 0x1000, + BUTTON_1 = BUTTON_Y, + BUTTON_2 = BUTTON_X, + BUTTON_LEFT = 0x0800, + BUTTON_RIGHT = 0x0400, + BUTTON_UP = 0x0200, + BUTTON_DOWN = 0x0100, + BUTTON_ZL = 0x0080, + BUTTON_ZR = 0x0040, + BUTTON_L = 0x0020, + BUTTON_R = 0x0010, + BUTTON_PLUS = 0x0008, + BUTTON_MINUS = 0x0004, + BUTTON_HOME = 0x0002, + BUTTON_SYNC = 0x0001, + STICK_R_LEFT = 0x04000000, + STICK_R_RIGHT = 0x02000000, + STICK_R_UP = 0x01000000, + STICK_R_DOWN = 0x00800000, + STICK_L_LEFT = 0x40000000, + STICK_L_RIGHT = 0x20000000, + STICK_L_UP = 0x10000000, + STICK_L_DOWN = 0x08000000 }; typedef struct { @@ -57,5 +57,4 @@ public: PadData data{}; PadData lastData{}; - }; diff --git a/source/input/VPADInput.h b/source/input/VPADInput.h index c4c538f..663f7b0 100644 --- a/source/input/VPADInput.h +++ b/source/input/VPADInput.h @@ -16,8 +16,8 @@ * along with this program. If not, see . ****************************************************************************/ -#include #include "Input.h" +#include class VPadInput : public Input { public: @@ -36,11 +36,11 @@ public: VPADRead(VPAD_CHAN_0, &vpad, 1, &vpadError); if (vpadError == VPAD_READ_SUCCESS) { - data.buttons_r = vpad.release; - data.buttons_h = vpad.hold; - data.buttons_d = vpad.trigger; + data.buttons_r = vpad.release; + data.buttons_h = vpad.hold; + data.buttons_d = vpad.trigger; data.validPointer = !vpad.tpNormal.validity; - data.touched = vpad.tpNormal.touched; + data.touched = vpad.tpNormal.touched; VPADGetTPCalibratedPoint(VPAD_CHAN_0, &tpCalib, &vpad.tpFiltered1); diff --git a/source/input/WPADInput.h b/source/input/WPADInput.h index 5d10091..1594ba6 100644 --- a/source/input/WPADInput.h +++ b/source/input/WPADInput.h @@ -16,9 +16,9 @@ * along with this program. If not, see . ****************************************************************************/ +#include "Input.h" #include #include -#include "Input.h" class WPADInput : public Input { public: diff --git a/source/main.cpp b/source/main.cpp index bba1996..b68c141 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -1,20 +1,20 @@ #include -#include #include #include +#include +#include "InstallerService.h" +#include "utils/WiiUScreen.h" +#include +#include +#include #include #include #include -#include -#include -#include -#include "utils/WiiUScreen.h" -#include "InstallerService.h" -#include "ApplicationState.h" #include "../build/safe_payload.h" +#include "ApplicationState.h" constexpr bool strings_equal(char const *a, char const *b) { return std::string_view(a) == b; @@ -26,7 +26,7 @@ void initIOSUHax(); void deInitIOSUHax(); -int sFSAFd = -1; +int sFSAFd = -1; bool sIosuhaxMount = false; int main_loop() { @@ -38,8 +38,7 @@ int main_loop() { WPAD_CHAN_0, WPAD_CHAN_1, WPAD_CHAN_2, - WPAD_CHAN_3 - }; + WPAD_CHAN_3}; if (sFSAFd < 0 || !sIosuhaxMount) { state.setError(ApplicationState::eErrorState::ERROR_IOSUHAX_FAILED); @@ -51,7 +50,7 @@ int main_loop() { if (vpadInput.update(1280, 720)) { baseInput.combine(vpadInput); } - for (auto &wpadInput: wpadInputs) { + for (auto &wpadInput : wpadInputs) { if (wpadInput.update(1280, 720)) { baseInput.combine(wpadInput); } @@ -88,13 +87,13 @@ int main(int argc, char **argv) { void initIOSUHax() { sIosuhaxMount = false; - int res = IOSUHAX_Open(nullptr); + int res = IOSUHAX_Open(nullptr); if (res < 0) { DEBUG_FUNCTION_LINE("IOSUHAX_open failed"); OSFatal("IOSUHAX_open failed, please start this installer with an CFW"); } else { sIosuhaxMount = true; - sFSAFd = IOSUHAX_FSA_Open(); + sFSAFd = IOSUHAX_FSA_Open(); if (sFSAFd < 0) { DEBUG_FUNCTION_LINE("IOSUHAX_FSA_Open failed"); } else { diff --git a/source/utils/ScreenUtils.cpp b/source/utils/ScreenUtils.cpp index 3fe9090..7131034 100644 --- a/source/utils/ScreenUtils.cpp +++ b/source/utils/ScreenUtils.cpp @@ -14,8 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . ****************************************************************************/ -#include #include "ScreenUtils.h" +#include +#include void ScreenUtils::printTextOnScreen(ConsoleScreenID screen, int x, int y, const char *msg) { if (!msg) { diff --git a/source/utils/ScreenUtils.h b/source/utils/ScreenUtils.h index ff6676f..30af8ad 100644 --- a/source/utils/ScreenUtils.h +++ b/source/utils/ScreenUtils.h @@ -15,6 +15,7 @@ * along with this program. If not, see . ****************************************************************************/ #pragma once +#include //! Defines the ID of a display usable with OSScreen. typedef enum ConsoleScreenID { diff --git a/source/utils/StringTools.cpp b/source/utils/StringTools.cpp index f313e3e..14ffcfa 100644 --- a/source/utils/StringTools.cpp +++ b/source/utils/StringTools.cpp @@ -23,17 +23,16 @@ * * for WiiXplorer 2010 ***************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "StringTools.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include 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 wchar_t strWChar[512]; strWChar[0] = 0; - tmp[0] = 0; + tmp[0] = 0; if (!format) return (const wchar_t *) strWChar; @@ -98,7 +97,7 @@ const wchar_t *StringTools::wfmt(const char *format, ...) { if ((vsprintf(tmp, format, va) >= 0)) { int32_t bt; int32_t strlength = strlen(tmp); - bt = mbstowcs(strWChar, tmp, (strlength < 512) ? strlength : 512); + bt = mbstowcs(strWChar, tmp, (strlength < 512) ? strlength : 512); if (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, ...) { static char tmp[512]; - tmp[0] = 0; + tmp[0] = 0; int32_t result = 0; va_list va; va_start(va, format); if ((vsprintf(tmp, format, va) >= 0)) { - str = tmp; + str = tmp; result = str.size(); } va_end(va); @@ -214,8 +213,7 @@ bool StringTools::findStringIC(const std::string &strHaystack, const std::string auto it = std::search( strHaystack.begin(), strHaystack.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()); } diff --git a/source/utils/StringTools.h b/source/utils/StringTools.h index faf467a..d84f4ef 100644 --- a/source/utils/StringTools.h +++ b/source/utils/StringTools.h @@ -25,11 +25,11 @@ ***************************************************************************/ #pragma once -#include -#include -#include #include #include +#include +#include +#include class StringTools { public: @@ -57,7 +57,7 @@ public: if (!path) return path; - const char *ptr = path; + const char *ptr = path; const char *Filename = ptr; while (*ptr != '\0') { diff --git a/source/utils/TinySHA1.hpp b/source/utils/TinySHA1.hpp index 82b1ea4..749aa48 100644 --- a/source/utils/TinySHA1.hpp +++ b/source/utils/TinySHA1.hpp @@ -1,3 +1,4 @@ +// clang-format off /* * * TinySHA1 - a header only implementation of the SHA1 algorithm in C++. Based diff --git a/source/utils/WiiUScreen.cpp b/source/utils/WiiUScreen.cpp index 6c3c2bc..038ed9f 100644 --- a/source/utils/WiiUScreen.cpp +++ b/source/utils/WiiUScreen.cpp @@ -4,13 +4,13 @@ #include #include -void *WiiUScreen::sBufferTV = nullptr; -void *WiiUScreen::sBufferDRC = nullptr; -uint32_t WiiUScreen::sBufferSizeTV = 0; -uint32_t WiiUScreen::sBufferSizeDRC = 0; +void *WiiUScreen::sBufferTV = nullptr; +void *WiiUScreen::sBufferDRC = nullptr; +uint32_t WiiUScreen::sBufferSizeTV = 0; +uint32_t WiiUScreen::sBufferSizeDRC = 0; bool WiiUScreen::sConsoleHasForeground = true; -uint32_t WiiUScreen::consoleColor = 0x041F60FF; -uint32_t WiiUScreen::consoleCursorY = 0; +uint32_t WiiUScreen::consoleColor = 0x041F60FF; +uint32_t WiiUScreen::consoleCursorY = 0; uint32_t WiiUScreen::ProcCallbackAcquired(void *context) { MEMHeapHandle heap = MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM1); @@ -37,7 +37,7 @@ uint32_t WiiUScreen::ProcCallbackReleased(void *context) { bool WiiUScreen::Init() { OSScreenInit(); - sBufferSizeTV = OSScreenGetBufferSizeEx(SCREEN_TV); + sBufferSizeTV = OSScreenGetBufferSizeEx(SCREEN_TV); sBufferSizeDRC = OSScreenGetBufferSizeEx(SCREEN_DRC); WiiUScreen::ProcCallbackAcquired(nullptr); diff --git a/source/utils/WiiUScreen.h b/source/utils/WiiUScreen.h index 30a33c6..352b64b 100644 --- a/source/utils/WiiUScreen.h +++ b/source/utils/WiiUScreen.h @@ -3,23 +3,24 @@ #include #include -#include +#include "logger.h" #include #include +#include #include #include -#include #include -#include "logger.h" +#include -#define NUM_LINES (16) -#define LINE_LENGTH (128) +#define NUM_LINES (16) +#define LINE_LENGTH (128) #define CONSOLE_FRAME_HEAP_TAG (0x000DECAF) -#define PRINTF_BUFFER_LENGTH 2048 +#define PRINTF_BUFFER_LENGTH 2048 -#define DEBUG_CONSOLE_LOG(FMT, ARGS...)do { \ - DEBUG_FUNCTION_LINE(FMT, ## ARGS); \ - WiiUScreen::drawLinef(FMT, ## ARGS); \ +#define DEBUG_CONSOLE_LOG(FMT, ARGS...) \ + do { \ + DEBUG_FUNCTION_LINE(FMT, ##ARGS); \ + WiiUScreen::drawLinef(FMT, ##ARGS); \ } while (0) diff --git a/source/utils/logger.h b/source/utils/logger.h index 7a56ddf..3445883 100644 --- a/source/utils/logger.h +++ b/source/utils/logger.h @@ -8,14 +8,16 @@ extern "C" { #include #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 { \ - WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \ +#define DEBUG_FUNCTION_LINE(FMT, ARGS...) \ + do { \ + WHBLogPrintf("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \ } while (0); -#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \ - WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \ +#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) \ + do { \ + WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \ } while (0); #ifdef __cplusplus diff --git a/source/utils/pugiconfig.hpp b/source/utils/pugiconfig.hpp index ac3ce7f..af54dee 100644 --- a/source/utils/pugiconfig.hpp +++ b/source/utils/pugiconfig.hpp @@ -1,3 +1,4 @@ +// clang-format off /** * pugixml parser - version 1.10 * -------------------------------------------------------- diff --git a/source/utils/pugixml.cpp b/source/utils/pugixml.cpp index f92fdef..9a6a64d 100644 --- a/source/utils/pugixml.cpp +++ b/source/utils/pugixml.cpp @@ -1,3 +1,4 @@ +// clang-format off /** * pugixml parser - version 1.10 * -------------------------------------------------------- diff --git a/source/utils/pugixml.hpp b/source/utils/pugixml.hpp index 64e735e..5a4dea6 100644 --- a/source/utils/pugixml.hpp +++ b/source/utils/pugixml.hpp @@ -1,3 +1,4 @@ +// clang-format off /** * pugixml parser - version 1.10 * -------------------------------------------------------- diff --git a/source/utils/utils.cpp b/source/utils/utils.cpp index 5db2604..d99711d 100644 --- a/source/utils/utils.cpp +++ b/source/utils/utils.cpp @@ -1,10 +1,10 @@ -#include -#include -#include -#include -#include "logger.h" #include "utils.h" #include "TinySHA1.hpp" +#include "logger.h" +#include +#include +#include +#include // https://gist.github.com/ccbrown/9722406 void Utils::dumpHex(const void *data, size_t size) { diff --git a/source/utils/utils.h b/source/utils/utils.h index d4223be..598c943 100644 --- a/source/utils/utils.h +++ b/source/utils/utils.h @@ -7,28 +7,29 @@ extern "C" { #endif -#define LIMIT(x, min, max) \ - ({ \ - typeof( x ) _x = x; \ - typeof( min ) _min = min; \ - typeof( max ) _max = max; \ - ( ( ( _x ) < ( _min ) ) ? ( _min ) : ( ( _x ) > ( _max ) ) ? ( _max) : ( _x ) ); \ -}) +#define LIMIT(x, min, max) \ + ({ \ + typeof(x) _x = x; \ + typeof(min) _min = min; \ + typeof(max) _max = max; \ + (((_x) < (_min)) ? (_min) : ((_x) > (_max)) ? (_max) \ + : (_x)); \ + }) -#define DegToRad(a) ( (a) * 0.01745329252f ) -#define RadToDeg(a) ( (a) * 57.29577951f ) +#define DegToRad(a) ((a) *0.01745329252f) +#define RadToDeg(a) ((a) *57.29577951f) -#define ALIGN4(x) (((x) + 3) & ~3) -#define ALIGN32(x) (((x) + 31) & ~31) +#define ALIGN4(x) (((x) + 3) & ~3) +#define ALIGN32(x) (((x) + 31) & ~31) // those work only in powers of 2 -#define ROUNDDOWN(val, align) ((val) & ~(align-1)) -#define ROUNDUP(val, align) ROUNDDOWN(((val) + (align-1)), align) +#define ROUNDDOWN(val, align) ((val) & ~(align - 1)) +#define ROUNDUP(val, align) ROUNDDOWN(((val) + (align - 1)), align) -#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 le64(i) ((((uint64_t)le32((i) & 0xFFFFFFFFLL)) << 32) | ((uint64_t)le32(((i) & 0xFFFFFFFF00000000LL) >> 32))) +#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 le64(i) ((((uint64_t) le32((i) &0xFFFFFFFFLL)) << 32) | ((uint64_t) le32(((i) &0xFFFFFFFF00000000LL) >> 32))) #ifdef __cplusplus }