diff --git a/source/install/install.cpp b/source/install/install.cpp index 7b19558..eb6c3bd 100755 --- a/source/install/install.cpp +++ b/source/install/install.cpp @@ -61,7 +61,7 @@ namespace tin::install catch (std::runtime_error& e) { serviceClose(&contentMetaDatabase.s); - throw e; + THROW_FORMAT(e.what()); } serviceClose(&contentMetaDatabase.s); @@ -80,7 +80,7 @@ namespace tin::install // 0x410: The record doesn't already exist if (R_FAILED(rc = nsCountApplicationContentMeta(baseTitleId, &contentMetaCount)) && rc != 0x410) { - throw std::runtime_error("Failed to count application content meta"); + THROW_FORMAT("Failed to count application content meta"); } rc = 0; @@ -98,7 +98,7 @@ namespace tin::install if (entriesRead != contentMetaCount) { - throw std::runtime_error("Mismatch between entries read and content meta count"); + THROW_FORMAT("Mismatch between entries read and content meta count"); } memcpy(storageRecords.data(), contentStorageBuf.get(), contentStorageBufSize); diff --git a/source/install/install_nsp.cpp b/source/install/install_nsp.cpp index 1bee85d..c1677cf 100755 --- a/source/install/install_nsp.cpp +++ b/source/install/install_nsp.cpp @@ -102,7 +102,7 @@ namespace tin::install::nsp ncaName += ".cnmt.ncz"; else { - throw std::runtime_error(("Failed to find NCA file " + ncaName + ".nca/.cnmt.nca/.ncz/.cnmt.ncz").c_str()); + THROW_FORMAT(("Failed to find NCA file " + ncaName + ".nca/.cnmt.nca/.ncz/.cnmt.ncz").c_str()); } LOG_DEBUG("NcaId: %s\n", ncaName.c_str()); @@ -148,7 +148,7 @@ namespace tin::install::nsp auto readBuffer = std::make_unique(readSize); if (readBuffer == NULL) - throw std::runtime_error(("Failed to allocate read buffer for " + ncaName).c_str()); + THROW_FORMAT(("Failed to allocate read buffer for " + ncaName).c_str()); LOG_DEBUG("Size: 0x%lx\n", ncaSize); diff --git a/source/install/install_nsp_remote.cpp b/source/install/install_nsp_remote.cpp index 662f6b5..2f472d9 100755 --- a/source/install/install_nsp_remote.cpp +++ b/source/install/install_nsp_remote.cpp @@ -147,7 +147,7 @@ namespace tin::install::nsp if (tikFileEntry == nullptr) { LOG_DEBUG("Remote tik file is missing.\n"); - throw std::runtime_error("Remote tik file is not present!"); + THROW_FORMAT("Remote tik file is not present!"); } u64 tikSize = tikFileEntry->fileSize; @@ -161,7 +161,7 @@ namespace tin::install::nsp if (certFileEntry == nullptr) { LOG_DEBUG("Remote cert file is missing.\n"); - throw std::runtime_error("Remote cert file is not present!"); + THROW_FORMAT("Remote cert file is not present!"); } u64 certSize = certFileEntry->fileSize; diff --git a/source/install/install_xci.cpp b/source/install/install_xci.cpp index 8d065d9..139f7b7 100755 --- a/source/install/install_xci.cpp +++ b/source/install/install_xci.cpp @@ -153,7 +153,7 @@ namespace tin::install::xci if (tikFileEntries[i] == nullptr) { LOG_DEBUG("Remote tik file is missing.\n"); - throw std::runtime_error("Remote tik file is not present!"); + THROW_FORMAT("Remote tik file is not present!"); } u64 tikSize = tikFileEntries[i]->fileSize; @@ -164,7 +164,7 @@ namespace tin::install::xci if (certFileEntries[i] == nullptr) { LOG_DEBUG("Remote cert file is missing.\n"); - throw std::runtime_error("Remote cert file is not present!"); + THROW_FORMAT("Remote cert file is not present!"); } u64 certSize = certFileEntries[i]->fileSize; diff --git a/source/nx/content_meta.cpp b/source/nx/content_meta.cpp index c7ef706..0d0fd79 100755 --- a/source/nx/content_meta.cpp +++ b/source/nx/content_meta.cpp @@ -38,7 +38,7 @@ namespace nx::ncm m_bytes(size) { if (size < sizeof(PackagedContentMetaHeader)) - throw std::runtime_error("Content meta data size is too small!"); + THROW_FORMAT("Content meta data size is too small!"); m_bytes.Resize(size); memcpy(m_bytes.GetData(), data, size); diff --git a/source/nx/fs.cpp b/source/nx/fs.cpp index c014b6d..fa433c7 100755 --- a/source/nx/fs.cpp +++ b/source/nx/fs.cpp @@ -47,7 +47,7 @@ namespace nx::fs if (sizeRead != size) { std::string msg = "Size read " + std::string("" + sizeRead) + " doesn't match expected size " + std::string("" + size); - throw std::runtime_error(msg.c_str()); + THROW_FORMAT(msg.c_str()); } } @@ -78,7 +78,7 @@ namespace nx::fs /*if (entriesRead != numEntries) { std::string msg = "Entries read " + std::string("" + entriesRead) + " doesn't match expected number " + std::string("" + numEntries); - throw std::runtime_error(msg); + THROW_FORMAT(msg); }*/ } @@ -108,7 +108,7 @@ namespace nx::fs { Result rc = 0; if (path.length() >= FS_MAX_PATH) - throw std::runtime_error("Directory path is too long!"); + THROW_FORMAT("Directory path is too long!"); // libnx expects a FS_MAX_PATH-sized buffer path.reserve(FS_MAX_PATH); @@ -130,7 +130,7 @@ namespace nx::fs IFile IFileSystem::OpenFile(std::string path) { if (path.length() >= FS_MAX_PATH) - throw std::runtime_error("Directory path is too long!"); + THROW_FORMAT("Directory path is too long!"); // libnx expects a FS_MAX_PATH-sized buffer path.reserve(FS_MAX_PATH); @@ -144,7 +144,7 @@ namespace nx::fs { // Account for null at the end of c strings if (path.length() >= FS_MAX_PATH) - throw std::runtime_error("Directory path is too long!"); + THROW_FORMAT("Directory path is too long!"); // libnx expects a FS_MAX_PATH-sized buffer path.reserve(FS_MAX_PATH); diff --git a/source/nx/nca_writer.cpp b/source/nx/nca_writer.cpp index 1ce5484..d8d6b2d 100755 --- a/source/nx/nca_writer.cpp +++ b/source/nx/nca_writer.cpp @@ -428,7 +428,7 @@ u64 NcaWriter::write(const u8* ptr, u64 sz) } else { - throw std::runtime_error("not enough data to read ncz header"); + THROW_FORMAT("not enough data to read ncz header"); } } @@ -438,7 +438,7 @@ u64 NcaWriter::write(const u8* ptr, u64 sz) } else { - throw std::runtime_error("null writer"); + THROW_FORMAT("null writer"); } } @@ -462,7 +462,7 @@ void NcaWriter::flushHeader() } else { - throw std::runtime_error("Invalid NCA magic"); + THROW_FORMAT("Invalid NCA magic"); } if (header.distribution == 1) diff --git a/source/util/crypto.cpp b/source/util/crypto.cpp index da6b910..3e73a11 100755 --- a/source/util/crypto.cpp +++ b/source/util/crypto.cpp @@ -2,6 +2,7 @@ #include #include #include +#include "util/error.hpp" void Crypto::calculateMGF1andXOR(unsigned char* data, size_t data_size, const void* source, size_t source_size) { unsigned char h_buf[RSA_2048_BYTES] = {0}; @@ -45,7 +46,7 @@ bool Crypto::rsa2048PssVerify(const void *data, size_t len, const unsigned char mbedtls_mpi_exp_mod(&message_mpi, &signature_mpi, &e_mpi, &modulus_mpi, NULL); if (mbedtls_mpi_write_binary(&message_mpi, m_buf, RSA_2048_BYTES) != 0) { - throw std::runtime_error("Failed to export exponentiated RSA message!"); + THROW_FORMAT("Failed to export exponentiated RSA message!"); } mbedtls_mpi_free(&signature_mpi);