mirror of
https://github.com/wiiu-env/wudd.git
synced 2024-12-24 00:51:54 +01:00
Formatting and minor clean ups
This commit is contained in:
parent
648c0d0fd7
commit
6919bdb44f
@ -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<WiiUGMPartition *>(partition);
|
||||
|
@ -104,7 +104,7 @@ private:
|
||||
std::vector<uint64_t> 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 @@ private:
|
||||
uint32_t writeBufferSize = 0;
|
||||
|
||||
[[nodiscard]] bool writeCached(uint32_t addr, uint32_t writeSize);
|
||||
void clearWriteCache();
|
||||
|
||||
void clearWriteCache();
|
||||
|
||||
[[nodiscard]] bool flushWriteCache();
|
||||
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
|
||||
bool readPlainDecryptedContent(Content *pContent, uint8_t **data, uint32_t *length) override;
|
||||
|
||||
NUSDataProvider* getDataProvider() override;
|
||||
NUSDataProvider *getDataProvider() override;
|
||||
|
||||
private:
|
||||
NUSDataProvider *dataProvider;
|
||||
|
@ -21,6 +21,7 @@
|
||||
class DiscReader {
|
||||
public:
|
||||
DiscReader();
|
||||
|
||||
virtual ~DiscReader();
|
||||
|
||||
virtual bool IsReady() = 0;
|
||||
|
@ -19,11 +19,14 @@
|
||||
#include <cstdint>
|
||||
#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;
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public:
|
||||
return volumeId;
|
||||
}
|
||||
|
||||
[[nodiscard]] virtual std::map<AddressInDiscBlocks, VolumeHeader *> getVolumes() const&{
|
||||
[[nodiscard]] virtual std::map<AddressInDiscBlocks, VolumeHeader *> getVolumes() const &{
|
||||
return volumes;
|
||||
}
|
||||
|
||||
[[nodiscard]] virtual uint16_t getFileSystemDescriptor() const{
|
||||
[[nodiscard]] virtual uint16_t getFileSystemDescriptor() const {
|
||||
return fileSystemDescriptor;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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<H3HashArray *> VolumeHeader::getH3HashArray(uint8_t *h3Data, uint32_t pNumberOfH3HashArray, uint32_t pH3HashArrayListSize) {
|
||||
std::vector<H3HashArray *> arrayList;
|
||||
if(pNumberOfH3HashArray == 0){
|
||||
if (pNumberOfH3HashArray == 0) {
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
|
@ -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 @@ public:
|
||||
StringTable *stringTable;
|
||||
NodeEntries *nodeEntries;
|
||||
|
||||
[[nodiscard]] RootEntry * getRootEntry() const;
|
||||
[[nodiscard]] RootEntry *getRootEntry() const;
|
||||
};
|
@ -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;
|
||||
|
@ -41,19 +41,19 @@ public:
|
||||
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;
|
||||
|
||||
|
@ -17,13 +17,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class DirectoryEntry;
|
||||
|
||||
class NodeEntryParam {
|
||||
public:
|
||||
uint16_t sectionNumber;
|
||||
uint32_t entryNumber;
|
||||
DirectoryEntry* parent;
|
||||
DirectoryEntry *parent;
|
||||
uint16_t permission;
|
||||
uint8_t type;
|
||||
uint32_t uint24;
|
||||
|
@ -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;
|
||||
|
@ -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]);
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "StringEntry.h"
|
||||
#include "StringTable.h"
|
||||
|
||||
std::string StringEntry::toString() const{
|
||||
std::string StringEntry::toString() const {
|
||||
return stringTable->getByAddress(offset);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
|
||||
std::vector<Content *> contentList;
|
||||
|
||||
Content* getContentByIndex(uint16_t index);
|
||||
Content *getContentByIndex(uint16_t index);
|
||||
|
||||
private:
|
||||
uint16_t contentCount;
|
||||
|
@ -38,3 +38,7 @@ WiiUDiscHeader::~WiiUDiscHeader() {
|
||||
delete discId;
|
||||
delete wiiUContentsInformation;
|
||||
}
|
||||
|
||||
WiiUDiscHeader::WiiUDiscHeader(DiscReaderDiscDrive *pDrive) : WiiUDiscHeader(pDrive, 0) {
|
||||
|
||||
}
|
||||
|
@ -19,19 +19,22 @@
|
||||
#include <cstdint>
|
||||
#include <WUD/DiscReader.h>
|
||||
#include <WUD/content/WiiUContentsInformation.h>
|
||||
#include <WUD/DiscReaderDiscDrive.h>
|
||||
#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;
|
||||
};
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <WUD/entities/FST/nodeentry/DirectoryEntry.h>
|
||||
#include <WUD/entities/FST/FST.h>
|
||||
|
||||
class FSTUtils{
|
||||
class FSTUtils {
|
||||
public:
|
||||
static NodeEntry *getFSTEntryByFullPath(DirectoryEntry *root, std::string &givenFullPath);
|
||||
|
||||
|
@ -51,5 +51,6 @@ public:
|
||||
|
||||
private:
|
||||
ScreenUtils() = default;
|
||||
|
||||
~ScreenUtils() = default;
|
||||
};
|
@ -89,7 +89,7 @@ public:
|
||||
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);
|
||||
};
|
||||
|
@ -23,6 +23,7 @@ class AddressInVolumeBlocks : public AddressInBlocks {
|
||||
|
||||
public:
|
||||
AddressInVolumeBlocks() = default;
|
||||
|
||||
AddressInVolumeBlocks(const VolumeBlockSize &pBlockSize, uint32_t pValue) : AddressInBlocks(pBlockSize, pValue) {
|
||||
}
|
||||
};
|
@ -26,5 +26,5 @@ public:
|
||||
this->blockSize = blockSize;
|
||||
}
|
||||
|
||||
uint32_t blockSize {};
|
||||
uint32_t blockSize{};
|
||||
};
|
@ -23,6 +23,7 @@ class DiscBlockSize : public BlockSize {
|
||||
|
||||
public:
|
||||
DiscBlockSize() = default;
|
||||
|
||||
explicit DiscBlockSize(uint32_t blockSize) : BlockSize(blockSize) {
|
||||
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include "AddressInBlocks.h"
|
||||
#include "SectionBlockSize.h"
|
||||
|
Loading…
Reference in New Issue
Block a user