From c1e471f23afeba6a6cbc1dcd09bbb217bbc9b15e Mon Sep 17 00:00:00 2001 From: Tobi Date: Tue, 22 Nov 2022 23:00:01 +0100 Subject: [PATCH] The ResultDecoder Update --- Makefile | 2 +- include/renderd7/ResultDecoder.hpp | 27 ++ include/renderd7/renderd7.hpp | 8 +- source/ResultDecoder.cpp | 422 +++++++++++++++++++++++++++++ source/renderd7.cpp | 2 + 5 files changed, 458 insertions(+), 3 deletions(-) create mode 100644 include/renderd7/ResultDecoder.hpp create mode 100644 source/ResultDecoder.cpp diff --git a/Makefile b/Makefile index 7fc308d..b3a27d7 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ include $(DEVKITARM)/3ds_rules export renderd7_MAJOR := 0 export renderd7_MINOR := 8 -export renderd7_PATCH := 2 +export renderd7_PATCH := 3 VERSION := $(renderd7_MAJOR).$(renderd7_MINOR).$(renderd7_PATCH) diff --git a/include/renderd7/ResultDecoder.hpp b/include/renderd7/ResultDecoder.hpp new file mode 100644 index 0000000..dec2861 --- /dev/null +++ b/include/renderd7/ResultDecoder.hpp @@ -0,0 +1,27 @@ +#pragma once +#include +#include <3ds.h> + +namespace RenderD7 +{ + class ResultDecoder + { + public: + ResultDecoder(){} + ~ResultDecoder(){} + void Load(Result rescode); + void Load(std::string rescode); + std::string GetCode(); + std::string GetLevel(); + int GetLevelInt(); + std::string GetModule(); + int GetModuleInt(); + std::string GetDescription(); + int GetDescriptionInt(); + std::string GetSummary(); + int GetSummaryInt(); + + private: + Result m_rescode; + }; +} \ No newline at end of file diff --git a/include/renderd7/renderd7.hpp b/include/renderd7/renderd7.hpp index f1bc8e7..e8f9adb 100644 --- a/include/renderd7/renderd7.hpp +++ b/include/renderd7/renderd7.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -42,13 +43,16 @@ #include #include + extern "C" { #include } -#define RENDERD7VSTRING "0.8.2" +#define RENDERD7VSTRING "0.8.3" #define CHANGELOG \ - "0.8.2: Fix a lot of Stuff and add c++17 based filesystem class.\n0.8.1: " \ + "0.8.3: Addet Overlaycount to Info and Addet ResultDecoder for " \ + "errors.0.8.2: Fix a lot of Stuff and add c++17 based filesystem " \ + "class.\n0.8.1: " \ "Add abillity to Get Stdout as string to render it to the " \ "screen.\n0.8.0: Implement BitmapPrinter\n0.7.3: Implement Over Render " \ "Overlay " \ diff --git a/source/ResultDecoder.cpp b/source/ResultDecoder.cpp new file mode 100644 index 0000000..bb8a06b --- /dev/null +++ b/source/ResultDecoder.cpp @@ -0,0 +1,422 @@ +#include +#include +#include + +static std::map modules = { + {0, "common"}, + {1, "kernel"}, + {2, "util"}, + {3, "file server"}, + {4, "loader server"}, + {5, "tcb"}, + {6, "os"}, + {7, "dbg"}, + {8, "dmnt"}, + {9, "pdn"}, + {10, "gsp"}, + {11, "i2c"}, + {12, "gpio"}, + {13, "dd"}, + {14, "codec"}, + {15, "spi"}, + {16, "pxi"}, + {17, "fs"}, + {18, "di"}, + {19, "hid"}, + {20, "cam"}, + {21, "pi"}, + {22, "pm"}, + {23, "pm_low"}, + {24, "fsi"}, + {25, "srv"}, + {26, "ndm"}, + {27, "nwm"}, + {28, "soc"}, + {29, "ldr"}, + {30, "acc"}, + {31, "romfs"}, + {32, "am"}, + {33, "hio"}, + {34, "updater"}, + {35, "mic"}, + {36, "fnd"}, + {37, "mp"}, + {38, "mpwl"}, + {39, "ac"}, + {40, "http"}, + {41, "dsp"}, + {42, "snd"}, + {43, "dlp"}, + {44, "hio_low"}, + {45, "csnd"}, + {46, "ssl"}, + {47, "am_low"}, + {48, "nex"}, + {49, "friends"}, + {50, "rdt"}, + {51, "applet"}, + {52, "nim"}, + {53, "ptm"}, + {54, "midi"}, + {55, "mc"}, + {56, "swc"}, + {57, "fatfs"}, + {58, "ngc"}, + {59, "card"}, + {60, "cardnor"}, + {61, "sdmc"}, + {62, "boss"}, + {63, "dbm"}, + {64, "config"}, + {65, "ps"}, + {66, "cec"}, + {67, "ir"}, + {68, "uds"}, + {69, "pl"}, + {70, "cup"}, + {71, "gyroscope"}, + {72, "mcu"}, + {73, "ns"}, + {74, "news"}, + {75, "ro"}, + {76, "gd"}, + {77, "card spi"}, + {78, "ec"}, + {79, "web browser"}, + {80, "test"}, + {81, "enc"}, + {82, "pia"}, + {83, "act"}, + {84, "vctl"}, + {85, "olv"}, + {86, "neia"}, + {87, "npns"}, + {90, "avd"}, + {91, "l2b"}, + {92, "mvd"}, + {93, "nfc"}, + {94, "uart"}, + {95, "spm"}, + {96, "qtm"}, + {97, "nfp"}, + {254, "application"}, +}; + +static std::map levels = { + {0, "Success"}, {1, "Info"}, {25, "Status"}, + {26, "Temporary"}, {27, "Permanent"}, {28, "Usage"}, + {29, "Reinitialize"}, {30, "Reset"}, {31, "Fatal"}, +}; + +static std::map summaries = { + {0, "Success"}, + {1, "Nothing happened"}, + {2, "Would block"}, + {3, "Out of resource"}, + {4, "Not found"}, + {5, "Invalid state"}, + {6, "Not supported"}, + {7, "Invalid argument"}, + {8, "Wrong argument"}, + {9, "Canceled"}, + {10, "Status changed"}, + {11, "Internal"}, + {63, "Invalid result value"}, +}; + +static std::map desccommon = { + {0, "Success"}, + {1000, "Invalid selection"}, + {1001, "Too large"}, + {1002, "Not authorized"}, + {1003, "Already done"}, + {1004, "Invalid size"}, + {1005, "Invalid enum value"}, + {1006, "Invalid combination"}, + {1007, "No data"}, + {1008, "Busy"}, + {1009, "Misaligned address"}, + {1010, "Misaligned size"}, + {1011, "Out of memory"}, + {1012, "Not implemented"}, + {1013, "Invalid address"}, + {1014, "Invalid pointer"}, + {1015, "Invalid handle"}, + {1016, "Not initialized"}, + {1017, "Already initialized"}, + {1018, "Not found"}, + {1019, "Cancel requested"}, + {1020, "Already exists"}, + {1021, "Out of range"}, + {1022, "Timeout"}, + {1023, "Invalid result value"}, +}; + +static std::map desckernel = { + {2, "Invalid memory permissions."}, +}; + +static std::map descos = { + {10, "Not enough memory."}, + {26, "Session closed by remote."}, + {47, "Invalid command header."}, +}; + +//Need to Fix The Range based Values +static std::map descfs = { + {101, "Archive not mounted or mount-point not found."}, + {120, "Title or object not found."}, + {141, "Gamecard not inserted."}, + {230, "Invalid open flags or permissions."}, + {391, "NCCH hash check failed."}, + {302, "RSA or AES-MAC verification failed."}, + {395, "RomFS or Savedata hash check failed."}, + {630, "Command not allowed, or missing permissions."}, + {702, "Invalid path."}, + {761, "Incorrect ExeFS read size."}, + {100, "[Media] not found."}, + {180, "Exists already."}, + {200, "Not enough space."}, + {220, "Invalidated archive."}, + {230, "Unacceptable or write protected."}, + {340, "0x01"}, + {360, "Bad format."}, + {390, "Verification failure."}, + {400, "0x01"}, + {600, "Out of resources."}, + {630, "Access denied."}, + {661, "0x01"}, + {700, "Invalid argument."}, + {730, "Not initialized."}, + {750, "Already initialized."}, + {760, "Not supported."}, + {780, "0x01"}, +}; + +static std::map descsrv = { + {5, "Invalid string length (service name length is zero or longer than 8 " + "chars)."}, + {6, "Access to service denied (requested a service the application does " + "not have access to)."}, + {7, "String size does not match contents (service name contains unexpected " + "null byte)."}, +}; + +static std::map descnwm = { + {2, "This error usually indicates the wifi chipset in the console is dying " + "or dead."}, +}; + +static std::map descam = { + {4, "Invalid ticket version."}, + {32, "Empty CIA."}, + {37, "Invalid NCCH."}, + {39, "Invalid title version."}, + {43, "Database doesn\"t exist, or it failed to open."}, + {44, "Trying to uninstall system-app."}, + {106, "Invalid signature/CIA. Usually happens when developer UNITINFO is " + "enabled in Luma3DS."}, + {393, "Invalid database."}, +}; + +static std::map deschttp = { + {105, "Request timed out."}, +}; + +static std::map descnim = { + {1, "Invalid string IPC paramater (non null terminated at its indicated " + "length)."}, + {12, "Invalid country code returned by CFG module reading config save " + "0xB0000."}, + {13, "Zero string length console serial number or '000000000000000' " + "returned by CFG's SecureInfoGetSerialNo."}, + {18, "General data reading error of NIM's .dat files from its system save, " + "bad data or bad data lengths."}, + {22, "General invalid data or length of data returned from nintendo " + "servers. (Only applicable for some operations)"}, + {25, "IntegrityVerificationSeed is waiting on servers to be synced into " + "console. Can't processed with online services without sync being " + "completed first over IPC request."}, + {26, "Unavailable/unaccessable IntegrityVerificationSeed on Nintendo " + "servers. May happen if NIM is told to import " + "IntegrityVerificationSeed from servers at any time other than after " + "the successful System Transfer reboot."}, + {27, "Invalid country language code returned by CFG module reading config " + "save 0xA0002."}, + {37, "Service is in Standby Mode. (eShop ban? General service is down? " + "This caused by a server response flag on account information. " + "Account is not referring to NNID.)"}, + {39, "HTTP Status non 200. (Only applicable for some operations)"}, + {40, "General XML read/write error while processing Auto Delivery XMLs."}, + {41, "General XML read/write error while processing Auto Delivery XMLs. " + "(Stubbed virtual call was called)"}, + {58, + "Invalid NPNS token returned by CFG module reading config save 0xF0006."}, + {67, "HTTP Status 404 while trying to download a game's seed."}, + {68, "HTTP Status 503 while trying to download a game's seed."}, +}; + +static std::map descmvd = { + {271, "Invalid configuration."}, +}; + +static std::map descqtm = { + {8, "Camera is already in use or busy."}, +}; + +//Need to Fix The Range based Values +static std::map descapplication = { + {0, "The application raised an error. Please consult the application's " + "source code or ask the author for assistance with it."}, + {1024, "0x01"}, +}; + +namespace RenderD7 { +void ResultDecoder::Load(Result rescode) { this->m_rescode = rescode; } +void ResultDecoder::Load(std::string rescode) { + std::stringstream ss; + ss << rescode; + ss >> std::hex >> this->m_rescode; +} +std::string RenderD7::ResultDecoder::GetCode() { + std::stringstream ss; + ss << std::hex << m_rescode; + std::string reshex(ss.str()); + return reshex; +} +std::string ResultDecoder::GetLevel() { + std::string res = levels.at(this->GetLevelInt()) + " (" + + std::to_string(this->GetLevelInt()) + ")"; + return res; +} +int ResultDecoder::GetLevelInt() { return R_LEVEL(m_rescode); } +std::string ResultDecoder::GetModule() { + std::string res = modules.at(this->GetModuleInt()) + " (" + + std::to_string(this->GetModuleInt()) + ")"; + return res; +} +int ResultDecoder::GetModuleInt() { return R_MODULE(m_rescode); } +std::string ResultDecoder::GetDescription() { + std::string res = "Desc Not Implemented!"; + switch (this->GetModuleInt()) { + case 0: + res = desccommon.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + break; + case 1: + if ((desckernel.find(this->GetDescriptionInt()) == desckernel.end())) { + res = desccommon.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } else { + res = desckernel.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } + break; + case 6: + if ((descos.find(this->GetDescriptionInt()) == descos.end())) { + res = desccommon.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } else { + res = descos.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } + break; + case 17: + if ((descfs.find(this->GetDescriptionInt()) == descfs.end())) { + res = desccommon.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } else { + res = descfs.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } + break; + case 25: + if ((descsrv.find(this->GetDescriptionInt()) == descsrv.end())) { + res = desccommon.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } else { + res = descsrv.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } + break; + case 27: + if ((descnwm.find(this->GetDescriptionInt()) == descnwm.end())) { + res = desccommon.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } else { + res = descnwm.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } + break; + case 32: + if ((descam.find(this->GetDescriptionInt()) == descam.end())) { + res = desccommon.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } else { + res = descam.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } + break; + case 40: + if ((deschttp.find(this->GetDescriptionInt()) == deschttp.end())) { + res = desccommon.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } else { + res = deschttp.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } + break; + case 52: + if ((descnim.find(this->GetDescriptionInt()) == descnim.end())) { + res = desccommon.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } else { + res = descnim.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } + break; + case 92: + if ((descmvd.find(this->GetDescriptionInt()) == descmvd.end())) { + res = desccommon.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } else { + res = descmvd.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } + break; + case 96: + if ((descqtm.find(this->GetDescriptionInt()) == descqtm.end())) { + res = desccommon.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } else { + res = descqtm.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } + break; + case 254: + if ((descapplication.find(this->GetDescriptionInt()) == + descapplication.end())) { + res = desccommon.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } else { + res = descapplication.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + } + break; + + default: + res = desccommon.at(this->GetDescriptionInt()) + " (" + + std::to_string(this->GetDescriptionInt()) + ")"; + break; + } + return res; +} +int ResultDecoder::GetDescriptionInt() { return R_DESCRIPTION(m_rescode); } +std::string ResultDecoder::GetSummary() { + std::string res = summaries.at(this->GetSummaryInt()) + " (" + + std::to_string(this->GetSummaryInt()) + ")"; + return res; +} + +int ResultDecoder::GetSummaryInt() { return R_SUMMARY(m_rescode); } +} // namespace RenderD7 \ No newline at end of file diff --git a/source/renderd7.cpp b/source/renderd7.cpp index 227d7bc..1600798 100644 --- a/source/renderd7.cpp +++ b/source/renderd7.cpp @@ -877,6 +877,8 @@ void RenderD7::RSettings::Draw(void) const { "RenderD7-Build-Time: \n" + buildtime); RenderD7::Draw::Text(0, 150, 0.7f, DSEVENBLACK, "RenderD7-Commit: " + commit); + RenderD7::Draw::Text(0, 170, 0.7f, DSEVENBLACK, + "RenderD7-Overlays: " + std::to_string(overlays.size())); /*RenderD7::Draw::Text(0, 130, 0.7f, DSEVENBLACK, "Metrik Text RGB: " + mttxtcolstate); RenderD7::Draw::Text(0, 150, 0.7f, DSEVENBLACK, "Metrik Alpha: " + mtcola); RenderD7::Draw::Text(0, 170, 0.7f, DSEVENBLACK, "Metrik