Skip to content

Commit

Permalink
Formatting and minor clean ups
Browse files Browse the repository at this point in the history
  • Loading branch information
Maschell committed Oct 8, 2021
1 parent 648c0d0 commit 6919bdb
Show file tree
Hide file tree
Showing 30 changed files with 57 additions and 39 deletions.
2 changes: 1 addition & 1 deletion source/ApplicationState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions source/ApplicationState.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class ApplicationState {
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;

Expand All @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion source/WUD/DefaultNUSDataProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions source/WUD/DiscReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
class DiscReader {
public:
DiscReader();

virtual ~DiscReader();

virtual bool IsReady() = 0;
Expand Down
5 changes: 4 additions & 1 deletion source/WUD/DiscReaderDiscDrive.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion source/WUD/NUSDecryption.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
1 change: 1 addition & 0 deletions source/WUD/content/WiiUContentsInformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions source/WUD/content/WiiUDiscContentsHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Expand Down
5 changes: 3 additions & 2 deletions source/WUD/content/partitions/WiiUPartition.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class WiiUPartition {

public:
WiiUPartition();

explicit WiiUPartition(DiscReader *reader, uint32_t offset, const DiscBlockSize &blockSize);

virtual uint64_t getSectionOffsetOnDefaultPartition();
Expand All @@ -35,11 +36,11 @@ class WiiUPartition {
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;
}

Expand Down
4 changes: 2 additions & 2 deletions source/WUD/content/partitions/WiiUPartitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
8 changes: 4 additions & 4 deletions source/WUD/content/partitions/volumes/VolumeHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
}

Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions source/WUD/entities/FST/FST.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -35,5 +35,5 @@ class FST {
StringTable *stringTable;
NodeEntries *nodeEntries;

[[nodiscard]] RootEntry * getRootEntry() const;
[[nodiscard]] RootEntry *getRootEntry() const;
};
4 changes: 2 additions & 2 deletions source/WUD/entities/FST/header/FSTHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions source/WUD/entities/FST/nodeentry/NodeEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion source/WUD/entities/FST/nodeentry/NodeEntryParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion source/WUD/entities/FST/nodeentry/RootEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion source/WUD/entities/FST/sectionentry/SectionEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion source/WUD/entities/FST/stringtable/StringEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "StringEntry.h"
#include "StringTable.h"

std::string StringEntry::toString() const{
std::string StringEntry::toString() const {
return stringTable->getByAddress(offset);
}

Expand Down
4 changes: 2 additions & 2 deletions source/WUD/entities/TMD/TitleMetaData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/WUD/entities/TMD/TitleMetaData.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TitleMetaData {

std::vector<Content *> contentList;

Content* getContentByIndex(uint16_t index);
Content *getContentByIndex(uint16_t index);

private:
uint16_t contentCount;
Expand Down
4 changes: 4 additions & 0 deletions source/WUD/header/WiiUDiscHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ WiiUDiscHeader::~WiiUDiscHeader() {
delete discId;
delete wiiUContentsInformation;
}

WiiUDiscHeader::WiiUDiscHeader(DiscReaderDiscDrive *pDrive) : WiiUDiscHeader(pDrive, 0) {

}
7 changes: 5 additions & 2 deletions source/WUD/header/WiiUDiscHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
2 changes: 1 addition & 1 deletion source/WUD/header/WiiUManufactorDiscID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
2 changes: 1 addition & 1 deletion source/utils/FSTUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions source/utils/ScreenUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ class ScreenUtils {

private:
ScreenUtils() = default;

~ScreenUtils() = default;
};
2 changes: 1 addition & 1 deletion source/utils/StringTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
1 change: 1 addition & 0 deletions source/utils/blocksize/AddressInVolumeBlocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class AddressInVolumeBlocks : public AddressInBlocks {

public:
AddressInVolumeBlocks() = default;

AddressInVolumeBlocks(const VolumeBlockSize &pBlockSize, uint32_t pValue) : AddressInBlocks(pBlockSize, pValue) {
}
};
2 changes: 1 addition & 1 deletion source/utils/blocksize/BlockSize.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ class BlockSize {
this->blockSize = blockSize;
}

uint32_t blockSize {};
uint32_t blockSize{};
};
1 change: 1 addition & 0 deletions source/utils/blocksize/DiscBlockSize.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class DiscBlockSize : public BlockSize {

public:
DiscBlockSize() = default;

explicit DiscBlockSize(uint32_t blockSize) : BlockSize(blockSize) {

}
Expand Down
2 changes: 1 addition & 1 deletion source/utils/blocksize/SectionAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 6919bdb

Please sign in to comment.