diff --git a/source/ApplicationState.cpp b/source/ApplicationState.cpp index d3adcfc..352b839 100644 --- a/source/ApplicationState.cpp +++ b/source/ApplicationState.cpp @@ -719,7 +719,7 @@ void ApplicationState::dumpAppFiles() { return; } DEBUG_FUNCTION_LINE("Read DiscHeader"); - auto *discHeader = new WiiUDiscHeader(discReader, 0); + auto *discHeader = new WiiUDiscHeader(discReader); bool forceExit = false; for (auto &partition: discHeader->wiiUContentsInformation->partitions->partitions) { auto gmPartition = dynamic_cast(partition); diff --git a/source/ApplicationState.h b/source/ApplicationState.h index e4ecc3f..10ebc6c 100644 --- a/source/ApplicationState.h +++ b/source/ApplicationState.h @@ -104,7 +104,7 @@ class ApplicationState { std::vector skippedSectors; int readResult = 0; - [[nodiscard]] bool writeDataToFile(void* buffer, int numberOfSection); + [[nodiscard]] bool writeDataToFile(void *buffer, int numberOfSection); uint64_t totalSectorCount = 0; @@ -116,7 +116,8 @@ class ApplicationState { uint32_t writeBufferSize = 0; [[nodiscard]] bool writeCached(uint32_t addr, uint32_t writeSize); - void clearWriteCache(); + + void clearWriteCache(); [[nodiscard]] bool flushWriteCache(); diff --git a/source/WUD/DefaultNUSDataProcessor.h b/source/WUD/DefaultNUSDataProcessor.h index 2b43888..f2f8197 100644 --- a/source/WUD/DefaultNUSDataProcessor.h +++ b/source/WUD/DefaultNUSDataProcessor.h @@ -27,7 +27,7 @@ class DefaultNUSDataProcessor : public NUSDataProcessor { bool readPlainDecryptedContent(Content *pContent, uint8_t **data, uint32_t *length) override; - NUSDataProvider* getDataProvider() override; + NUSDataProvider *getDataProvider() override; private: NUSDataProvider *dataProvider; diff --git a/source/WUD/DiscReader.h b/source/WUD/DiscReader.h index 06c8fc9..adef411 100644 --- a/source/WUD/DiscReader.h +++ b/source/WUD/DiscReader.h @@ -21,6 +21,7 @@ class DiscReader { public: DiscReader(); + virtual ~DiscReader(); virtual bool IsReady() = 0; diff --git a/source/WUD/DiscReaderDiscDrive.h b/source/WUD/DiscReaderDiscDrive.h index 4e17703..02f1242 100644 --- a/source/WUD/DiscReaderDiscDrive.h +++ b/source/WUD/DiscReaderDiscDrive.h @@ -19,11 +19,14 @@ #include #include "DiscReader.h" -class DiscReaderDiscDrive : public DiscReader{ +class DiscReaderDiscDrive : public DiscReader { public: DiscReaderDiscDrive(); + ~DiscReaderDiscDrive() override; + bool readEncryptedSector(uint8_t *buffer, uint32_t block_cnt, uint64_t offset_in_sector) const override; + bool IsReady() override; bool readEncrypted(uint8_t *buf, uint64_t offset, uint32_t size) override; diff --git a/source/WUD/NUSDecryption.h b/source/WUD/NUSDecryption.h index 9148bba..b1354e9 100644 --- a/source/WUD/NUSDecryption.h +++ b/source/WUD/NUSDecryption.h @@ -22,7 +22,7 @@ class NUSDecryption { public: explicit NUSDecryption(Ticket *pTicket); - void decryptData(uint8_t *IV, uint8_t *inData, uint8_t *outData, uint32_t size) const ; + void decryptData(uint8_t *IV, uint8_t *inData, uint8_t *outData, uint32_t size) const; Ticket *ticket; }; diff --git a/source/WUD/content/WiiUContentsInformation.cpp b/source/WUD/content/WiiUContentsInformation.cpp index 663a91c..77108ff 100644 --- a/source/WUD/content/WiiUContentsInformation.cpp +++ b/source/WUD/content/WiiUContentsInformation.cpp @@ -18,6 +18,7 @@ #include "WiiUContentsInformation.h" uint32_t WiiUContentsInformation::LENGTH = 32768; + WiiUContentsInformation::WiiUContentsInformation(DiscReader *reader, uint32_t offset) { uint32_t curOffset = offset; discContentHeader = new WiiUDiscContentsHeader(reader, curOffset); diff --git a/source/WUD/content/WiiUDiscContentsHeader.cpp b/source/WUD/content/WiiUDiscContentsHeader.cpp index f1b3b6f..19d1c24 100644 --- a/source/WUD/content/WiiUDiscContentsHeader.cpp +++ b/source/WUD/content/WiiUDiscContentsHeader.cpp @@ -25,11 +25,11 @@ uint32_t WiiUDiscContentsHeader::MAGIC = 0xCCA6E67B; WiiUDiscContentsHeader::WiiUDiscContentsHeader(DiscReader *reader, uint32_t offset) { auto *buffer = (uint8_t *) malloc(LENGTH); if (!reader->hasDiscKey) { - if(!reader->readEncrypted(buffer, offset, LENGTH)){ + if (!reader->readEncrypted(buffer, offset, LENGTH)) { OSFatal("WiiUDiscContentsHeader: Failed to read encrypted"); } } else { - if(!reader->readDecrypted(buffer, offset, 0, LENGTH, reader->discKey, nullptr, true)){ + if (!reader->readDecrypted(buffer, offset, 0, LENGTH, reader->discKey, nullptr, true)) { OSFatal("WiiUDiscContentsHeader: Failed to read decrypted"); } } diff --git a/source/WUD/content/partitions/WiiUPartition.h b/source/WUD/content/partitions/WiiUPartition.h index 62a2b6a..686e3e0 100644 --- a/source/WUD/content/partitions/WiiUPartition.h +++ b/source/WUD/content/partitions/WiiUPartition.h @@ -25,6 +25,7 @@ class WiiUPartition { public: WiiUPartition(); + explicit WiiUPartition(DiscReader *reader, uint32_t offset, const DiscBlockSize &blockSize); virtual uint64_t getSectionOffsetOnDefaultPartition(); @@ -35,11 +36,11 @@ class WiiUPartition { return volumeId; } - [[nodiscard]] virtual std::map getVolumes() const&{ + [[nodiscard]] virtual std::map getVolumes() const &{ return volumes; } - [[nodiscard]] virtual uint16_t getFileSystemDescriptor() const{ + [[nodiscard]] virtual uint16_t getFileSystemDescriptor() const { return fileSystemDescriptor; } diff --git a/source/WUD/content/partitions/WiiUPartitions.h b/source/WUD/content/partitions/WiiUPartitions.h index fd02902..31badc1 100644 --- a/source/WUD/content/partitions/WiiUPartitions.h +++ b/source/WUD/content/partitions/WiiUPartitions.h @@ -30,9 +30,9 @@ class WiiUPartitions { public: - static bool getFSTEntryAsByte(uint8_t **buffer_out, uint32_t *outSize, std::string &filePath, FST *fst, const AddressInDiscBlocks& volumeAddress, DiscReader* discReader); + static bool getFSTEntryAsByte(uint8_t **buffer_out, uint32_t *outSize, std::string &filePath, FST *fst, const AddressInDiscBlocks &volumeAddress, DiscReader *discReader); - WiiUPartitions(DiscReader *reader, uint32_t offset, uint32_t numberOfPartitions, const DiscBlockSize& blockSize); + WiiUPartitions(DiscReader *reader, uint32_t offset, uint32_t numberOfPartitions, const DiscBlockSize &blockSize); ~WiiUPartitions(); diff --git a/source/WUD/content/partitions/volumes/VolumeHeader.cpp b/source/WUD/content/partitions/volumes/VolumeHeader.cpp index af4fdab..9286e43 100644 --- a/source/WUD/content/partitions/volumes/VolumeHeader.cpp +++ b/source/WUD/content/partitions/volumes/VolumeHeader.cpp @@ -21,7 +21,7 @@ uint32_t VolumeHeader::MAGIC = 0xCC93A4F5; -VolumeHeader::VolumeHeader(DiscReader *reader, uint64_t offset) { +VolumeHeader::VolumeHeader(DiscReader *reader, uint64_t offset) { auto buffer = (uint8_t *) malloc(64); if (buffer == nullptr) { OSFatal("VolumeHeader: failed to alloc buffer"); @@ -51,12 +51,12 @@ VolumeHeader::VolumeHeader(DiscReader *reader, uint64_t offset) { free(buffer); - auto bufferH3 = (uint8_t *) malloc(ROUNDUP(h3HashArrayListSize,16)); + auto bufferH3 = (uint8_t *) malloc(ROUNDUP(h3HashArrayListSize, 16)); if (bufferH3 == nullptr) { OSFatal("VolumeHeader: failed to alloc h3 buffer"); } - if (!reader->readEncrypted(bufferH3,offset + 64, ROUNDUP(h3HashArrayListSize,16))) { + if (!reader->readEncrypted(bufferH3, offset + 64, ROUNDUP(h3HashArrayListSize, 16))) { OSFatal("VolumeHeader: failed to read h3"); } @@ -67,7 +67,7 @@ VolumeHeader::VolumeHeader(DiscReader *reader, uint64_t offset) { std::vector VolumeHeader::getH3HashArray(uint8_t *h3Data, uint32_t pNumberOfH3HashArray, uint32_t pH3HashArrayListSize) { std::vector arrayList; - if(pNumberOfH3HashArray == 0){ + if (pNumberOfH3HashArray == 0) { return arrayList; } diff --git a/source/WUD/entities/FST/FST.h b/source/WUD/entities/FST/FST.h index ef25283..934ff4d 100644 --- a/source/WUD/entities/FST/FST.h +++ b/source/WUD/entities/FST/FST.h @@ -26,7 +26,7 @@ class FST { public: - FST(uint8_t *data, uint32_t fstSize, uint32_t offset, const VolumeBlockSize& blockSize); + FST(uint8_t *data, uint32_t fstSize, uint32_t offset, const VolumeBlockSize &blockSize); ~FST(); @@ -35,5 +35,5 @@ class FST { StringTable *stringTable; NodeEntries *nodeEntries; - [[nodiscard]] RootEntry * getRootEntry() const; + [[nodiscard]] RootEntry *getRootEntry() const; }; \ No newline at end of file diff --git a/source/WUD/entities/FST/header/FSTHeader.h b/source/WUD/entities/FST/header/FSTHeader.h index fc01711..f0e8d24 100644 --- a/source/WUD/entities/FST/header/FSTHeader.h +++ b/source/WUD/entities/FST/header/FSTHeader.h @@ -22,9 +22,9 @@ class FSTHeader { public: - explicit FSTHeader(uint8_t *data) ; + explicit FSTHeader(uint8_t *data); - ~FSTHeader()= default; + ~FSTHeader() = default; uint8_t FSTVersion; SectionBlockSize blockSize; diff --git a/source/WUD/entities/FST/nodeentry/NodeEntry.h b/source/WUD/entities/FST/nodeentry/NodeEntry.h index 7531644..e299793 100644 --- a/source/WUD/entities/FST/nodeentry/NodeEntry.h +++ b/source/WUD/entities/FST/nodeentry/NodeEntry.h @@ -41,19 +41,19 @@ class NodeEntry { uint32_t entryNumber{}; static NodeEntry *AutoDeserialize(uint8_t *data, uint32_t offset, DirectoryEntry *pParent, uint32_t eEntryNumber, SectionEntries *sectionEntries, - StringTable *stringTable, const SectionBlockSize& blockSize); + StringTable *stringTable, const SectionBlockSize &blockSize); - virtual ~NodeEntry()= default; + virtual ~NodeEntry() = default; virtual void printPathRecursive() { DEBUG_FUNCTION_LINE("%s", getFullPath().c_str()); } - [[nodiscard]] std::string getFullPath() const&; + [[nodiscard]] std::string getFullPath() const &; - [[nodiscard]] std::string getPath() const&; + [[nodiscard]] std::string getPath() const &; - [[nodiscard]] std::string getName() const&; + [[nodiscard]] std::string getName() const &; [[nodiscard]] bool isDirectory() const; diff --git a/source/WUD/entities/FST/nodeentry/NodeEntryParam.h b/source/WUD/entities/FST/nodeentry/NodeEntryParam.h index cdf1a9a..c61cccf 100644 --- a/source/WUD/entities/FST/nodeentry/NodeEntryParam.h +++ b/source/WUD/entities/FST/nodeentry/NodeEntryParam.h @@ -17,13 +17,14 @@ #pragma once #include + class DirectoryEntry; class NodeEntryParam { public: uint16_t sectionNumber; uint32_t entryNumber; - DirectoryEntry* parent; + DirectoryEntry *parent; uint16_t permission; uint8_t type; uint32_t uint24; diff --git a/source/WUD/entities/FST/nodeentry/RootEntry.cpp b/source/WUD/entities/FST/nodeentry/RootEntry.cpp index c46ee25..b935d5f 100644 --- a/source/WUD/entities/FST/nodeentry/RootEntry.cpp +++ b/source/WUD/entities/FST/nodeentry/RootEntry.cpp @@ -25,7 +25,7 @@ RootEntry::RootEntry(DirectoryEntry *input) { entryNumber = input->entryNumber; parent = input->parent; nameString = input->nameString; - if(nameString == nullptr){ + if (nameString == nullptr) { OSFatal("nameString was null"); } entryType = input->entryType; diff --git a/source/WUD/entities/FST/sectionentry/SectionEntry.cpp b/source/WUD/entities/FST/sectionentry/SectionEntry.cpp index 3e770dd..fe2018b 100644 --- a/source/WUD/entities/FST/sectionentry/SectionEntry.cpp +++ b/source/WUD/entities/FST/sectionentry/SectionEntry.cpp @@ -16,7 +16,7 @@ ****************************************************************************/ #include "SectionEntry.h" -SectionEntry::SectionEntry(uint8_t *data, uint32_t pSectionNumber, const VolumeBlockSize& pBlockSize) { +SectionEntry::SectionEntry(uint8_t *data, uint32_t pSectionNumber, const VolumeBlockSize &pBlockSize) { auto *dataAsUint = (uint32_t *) data; address = AddressInVolumeBlocks(pBlockSize, dataAsUint[0]); size = SizeInVolumeBlocks(pBlockSize, dataAsUint[1]); diff --git a/source/WUD/entities/FST/stringtable/StringEntry.cpp b/source/WUD/entities/FST/stringtable/StringEntry.cpp index cbce6e1..d54967c 100644 --- a/source/WUD/entities/FST/stringtable/StringEntry.cpp +++ b/source/WUD/entities/FST/stringtable/StringEntry.cpp @@ -17,7 +17,7 @@ #include "StringEntry.h" #include "StringTable.h" -std::string StringEntry::toString() const{ +std::string StringEntry::toString() const { return stringTable->getByAddress(offset); } diff --git a/source/WUD/entities/TMD/TitleMetaData.cpp b/source/WUD/entities/TMD/TitleMetaData.cpp index 1105770..9d94e8b 100644 --- a/source/WUD/entities/TMD/TitleMetaData.cpp +++ b/source/WUD/entities/TMD/TitleMetaData.cpp @@ -32,9 +32,9 @@ TitleMetaData::~TitleMetaData() { } } -Content* TitleMetaData::getContentByIndex(uint16_t i) { +Content *TitleMetaData::getContentByIndex(uint16_t i) { for (auto &content: contentList) { - if(content->index == i){ + if (content->index == i) { return content; } } diff --git a/source/WUD/entities/TMD/TitleMetaData.h b/source/WUD/entities/TMD/TitleMetaData.h index 7d8b542..c4667b5 100644 --- a/source/WUD/entities/TMD/TitleMetaData.h +++ b/source/WUD/entities/TMD/TitleMetaData.h @@ -28,7 +28,7 @@ class TitleMetaData { std::vector contentList; - Content* getContentByIndex(uint16_t index); + Content *getContentByIndex(uint16_t index); private: uint16_t contentCount; diff --git a/source/WUD/header/WiiUDiscHeader.cpp b/source/WUD/header/WiiUDiscHeader.cpp index 6625ce9..e0bd46d 100644 --- a/source/WUD/header/WiiUDiscHeader.cpp +++ b/source/WUD/header/WiiUDiscHeader.cpp @@ -38,3 +38,7 @@ WiiUDiscHeader::~WiiUDiscHeader() { delete discId; delete wiiUContentsInformation; } + +WiiUDiscHeader::WiiUDiscHeader(DiscReaderDiscDrive *pDrive) : WiiUDiscHeader(pDrive, 0) { + +} diff --git a/source/WUD/header/WiiUDiscHeader.h b/source/WUD/header/WiiUDiscHeader.h index 45b9429..f3ac758 100644 --- a/source/WUD/header/WiiUDiscHeader.h +++ b/source/WUD/header/WiiUDiscHeader.h @@ -19,19 +19,22 @@ #include #include #include +#include #include "WiiUManufactorDiscID.h" #include "WiiUDiscID.h" class WiiUDiscHeader { public: - static uint32_t LENGTH; + explicit WiiUDiscHeader(DiscReaderDiscDrive *pDrive); WiiUDiscHeader(DiscReader *reader, uint32_t offset); + ~WiiUDiscHeader(); + WiiUManufactorDiscID *manufactorDiscID = nullptr; WiiUDiscID *discId = nullptr; WiiUContentsInformation *wiiUContentsInformation = nullptr; - ~WiiUDiscHeader(); + static uint32_t LENGTH; }; \ No newline at end of file diff --git a/source/WUD/header/WiiUManufactorDiscID.cpp b/source/WUD/header/WiiUManufactorDiscID.cpp index ecda868..75500df 100644 --- a/source/WUD/header/WiiUManufactorDiscID.cpp +++ b/source/WUD/header/WiiUManufactorDiscID.cpp @@ -20,7 +20,7 @@ uint32_t WiiUManufactorDiscID::LENGTH = 65536; WiiUManufactorDiscID::WiiUManufactorDiscID(DiscReader *reader, uint32_t offset) { - if(!reader->readEncrypted(data, offset, LENGTH)){ + if (!reader->readEncrypted(data, offset, LENGTH)) { OSFatal("WiiUManufactorDiscID: read failed"); } } diff --git a/source/utils/FSTUtils.h b/source/utils/FSTUtils.h index ddf9e8c..6390c6b 100644 --- a/source/utils/FSTUtils.h +++ b/source/utils/FSTUtils.h @@ -5,7 +5,7 @@ #include #include -class FSTUtils{ +class FSTUtils { public: static NodeEntry *getFSTEntryByFullPath(DirectoryEntry *root, std::string &givenFullPath); diff --git a/source/utils/ScreenUtils.h b/source/utils/ScreenUtils.h index 1428049..ff6676f 100644 --- a/source/utils/ScreenUtils.h +++ b/source/utils/ScreenUtils.h @@ -51,5 +51,6 @@ class ScreenUtils { private: ScreenUtils() = default; + ~ScreenUtils() = default; }; \ No newline at end of file diff --git a/source/utils/StringTools.h b/source/utils/StringTools.h index 450d760..faf467a 100644 --- a/source/utils/StringTools.h +++ b/source/utils/StringTools.h @@ -89,7 +89,7 @@ class StringTools { static bool findStringIC(const std::string &strHaystack, const std::string &strNeedle); // https://stackoverflow.com/a/3418285 - static bool replace(std::string& str, const std::string& from, const std::string& to); + static bool replace(std::string &str, const std::string &from, const std::string &to); static bool strCompareIC(const std::string &str1, const std::string &str2); }; diff --git a/source/utils/blocksize/AddressInVolumeBlocks.h b/source/utils/blocksize/AddressInVolumeBlocks.h index 368331c..d5dae4e 100644 --- a/source/utils/blocksize/AddressInVolumeBlocks.h +++ b/source/utils/blocksize/AddressInVolumeBlocks.h @@ -23,6 +23,7 @@ class AddressInVolumeBlocks : public AddressInBlocks { public: AddressInVolumeBlocks() = default; + AddressInVolumeBlocks(const VolumeBlockSize &pBlockSize, uint32_t pValue) : AddressInBlocks(pBlockSize, pValue) { } }; \ No newline at end of file diff --git a/source/utils/blocksize/BlockSize.h b/source/utils/blocksize/BlockSize.h index 7692079..4327ca5 100644 --- a/source/utils/blocksize/BlockSize.h +++ b/source/utils/blocksize/BlockSize.h @@ -26,5 +26,5 @@ class BlockSize { this->blockSize = blockSize; } - uint32_t blockSize {}; + uint32_t blockSize{}; }; \ No newline at end of file diff --git a/source/utils/blocksize/DiscBlockSize.h b/source/utils/blocksize/DiscBlockSize.h index 4e8ef77..76f6dfe 100644 --- a/source/utils/blocksize/DiscBlockSize.h +++ b/source/utils/blocksize/DiscBlockSize.h @@ -23,6 +23,7 @@ class DiscBlockSize : public BlockSize { public: DiscBlockSize() = default; + explicit DiscBlockSize(uint32_t blockSize) : BlockSize(blockSize) { } diff --git a/source/utils/blocksize/SectionAddress.h b/source/utils/blocksize/SectionAddress.h index b76efda..55adfe6 100644 --- a/source/utils/blocksize/SectionAddress.h +++ b/source/utils/blocksize/SectionAddress.h @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . ****************************************************************************/ - #pragma once +#pragma once #include "AddressInBlocks.h" #include "SectionBlockSize.h"